his_api_controller.go 718KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504250525062507250825092510251125122513251425152516251725182519252025212522252325242525252625272528252925302531253225332534253525362537253825392540254125422543254425452546254725482549255025512552255325542555255625572558255925602561256225632564256525662567256825692570257125722573257425752576257725782579258025812582258325842585258625872588258925902591259225932594259525962597259825992600260126022603260426052606260726082609261026112612261326142615261626172618261926202621262226232624262526262627262826292630263126322633263426352636263726382639264026412642264326442645264626472648264926502651265226532654265526562657265826592660266126622663266426652666266726682669267026712672267326742675267626772678267926802681268226832684268526862687268826892690269126922693269426952696269726982699270027012702270327042705270627072708270927102711271227132714271527162717271827192720272127222723272427252726272727282729273027312732273327342735273627372738273927402741274227432744274527462747274827492750275127522753275427552756275727582759276027612762276327642765276627672768276927702771277227732774277527762777277827792780278127822783278427852786278727882789279027912792279327942795279627972798279928002801280228032804280528062807280828092810281128122813281428152816281728182819282028212822282328242825282628272828282928302831283228332834283528362837283828392840284128422843284428452846284728482849285028512852285328542855285628572858285928602861286228632864286528662867286828692870287128722873287428752876287728782879288028812882288328842885288628872888288928902891289228932894289528962897289828992900290129022903290429052906290729082909291029112912291329142915291629172918291929202921292229232924292529262927292829292930293129322933293429352936293729382939294029412942294329442945294629472948294929502951295229532954295529562957295829592960296129622963296429652966296729682969297029712972297329742975297629772978297929802981298229832984298529862987298829892990299129922993299429952996299729982999300030013002300330043005300630073008300930103011301230133014301530163017301830193020302130223023302430253026302730283029303030313032303330343035303630373038303930403041304230433044304530463047304830493050305130523053305430553056305730583059306030613062306330643065306630673068306930703071307230733074307530763077307830793080308130823083308430853086308730883089309030913092309330943095309630973098309931003101310231033104310531063107310831093110311131123113311431153116311731183119312031213122312331243125312631273128312931303131313231333134313531363137313831393140314131423143314431453146314731483149315031513152315331543155315631573158315931603161316231633164316531663167316831693170317131723173317431753176317731783179318031813182318331843185318631873188318931903191319231933194319531963197319831993200320132023203320432053206320732083209321032113212321332143215321632173218321932203221322232233224322532263227322832293230323132323233323432353236323732383239324032413242324332443245324632473248324932503251325232533254325532563257325832593260326132623263326432653266326732683269327032713272327332743275327632773278327932803281328232833284328532863287328832893290329132923293329432953296329732983299330033013302330333043305330633073308330933103311331233133314331533163317331833193320332133223323332433253326332733283329333033313332333333343335333633373338333933403341334233433344334533463347334833493350335133523353335433553356335733583359336033613362336333643365336633673368336933703371337233733374337533763377337833793380338133823383338433853386338733883389339033913392339333943395339633973398339934003401340234033404340534063407340834093410341134123413341434153416341734183419342034213422342334243425342634273428342934303431343234333434343534363437343834393440344134423443344434453446344734483449345034513452345334543455345634573458345934603461346234633464346534663467346834693470347134723473347434753476347734783479348034813482348334843485348634873488348934903491349234933494349534963497349834993500350135023503350435053506350735083509351035113512351335143515351635173518351935203521352235233524352535263527352835293530353135323533353435353536353735383539354035413542354335443545354635473548354935503551355235533554355535563557355835593560356135623563356435653566356735683569357035713572357335743575357635773578357935803581358235833584358535863587358835893590359135923593359435953596359735983599360036013602360336043605360636073608360936103611361236133614361536163617361836193620362136223623362436253626362736283629363036313632363336343635363636373638363936403641364236433644364536463647364836493650365136523653365436553656365736583659366036613662366336643665366636673668366936703671367236733674367536763677367836793680368136823683368436853686368736883689369036913692369336943695369636973698369937003701370237033704370537063707370837093710371137123713371437153716371737183719372037213722372337243725372637273728372937303731373237333734373537363737373837393740374137423743374437453746374737483749375037513752375337543755375637573758375937603761376237633764376537663767376837693770377137723773377437753776377737783779378037813782378337843785378637873788378937903791379237933794379537963797379837993800380138023803380438053806380738083809381038113812381338143815381638173818381938203821382238233824382538263827382838293830383138323833383438353836383738383839384038413842384338443845384638473848384938503851385238533854385538563857385838593860386138623863386438653866386738683869387038713872387338743875387638773878387938803881388238833884388538863887388838893890389138923893389438953896389738983899390039013902390339043905390639073908390939103911391239133914391539163917391839193920392139223923392439253926392739283929393039313932393339343935393639373938393939403941394239433944394539463947394839493950395139523953395439553956395739583959396039613962396339643965396639673968396939703971397239733974397539763977397839793980398139823983398439853986398739883989399039913992399339943995399639973998399940004001400240034004400540064007400840094010401140124013401440154016401740184019402040214022402340244025402640274028402940304031403240334034403540364037403840394040404140424043404440454046404740484049405040514052405340544055405640574058405940604061406240634064406540664067406840694070407140724073407440754076407740784079408040814082408340844085408640874088408940904091409240934094409540964097409840994100410141024103410441054106410741084109411041114112411341144115411641174118411941204121412241234124412541264127412841294130413141324133413441354136413741384139414041414142414341444145414641474148414941504151415241534154415541564157415841594160416141624163416441654166416741684169417041714172417341744175417641774178417941804181418241834184418541864187418841894190419141924193419441954196419741984199420042014202420342044205420642074208420942104211421242134214421542164217421842194220422142224223422442254226422742284229423042314232423342344235423642374238423942404241424242434244424542464247424842494250425142524253425442554256425742584259426042614262426342644265426642674268426942704271427242734274427542764277427842794280428142824283428442854286428742884289429042914292429342944295429642974298429943004301430243034304430543064307430843094310431143124313431443154316431743184319432043214322432343244325432643274328432943304331433243334334433543364337433843394340434143424343434443454346434743484349435043514352435343544355435643574358435943604361436243634364436543664367436843694370437143724373437443754376437743784379438043814382438343844385438643874388438943904391439243934394439543964397439843994400440144024403440444054406440744084409441044114412441344144415441644174418441944204421442244234424442544264427442844294430443144324433443444354436443744384439444044414442444344444445444644474448444944504451445244534454445544564457445844594460446144624463446444654466446744684469447044714472447344744475447644774478447944804481448244834484448544864487448844894490449144924493449444954496449744984499450045014502450345044505450645074508450945104511451245134514451545164517451845194520452145224523452445254526452745284529453045314532453345344535453645374538453945404541454245434544454545464547454845494550455145524553455445554556455745584559456045614562456345644565456645674568456945704571457245734574457545764577457845794580458145824583458445854586458745884589459045914592459345944595459645974598459946004601460246034604460546064607460846094610461146124613461446154616461746184619462046214622462346244625462646274628462946304631463246334634463546364637463846394640464146424643464446454646464746484649465046514652465346544655465646574658465946604661466246634664466546664667466846694670467146724673467446754676467746784679468046814682468346844685468646874688468946904691469246934694469546964697469846994700470147024703470447054706470747084709471047114712471347144715471647174718471947204721472247234724472547264727472847294730473147324733473447354736473747384739474047414742474347444745474647474748474947504751475247534754475547564757475847594760476147624763476447654766476747684769477047714772477347744775477647774778477947804781478247834784478547864787478847894790479147924793479447954796479747984799480048014802480348044805480648074808480948104811481248134814481548164817481848194820482148224823482448254826482748284829483048314832483348344835483648374838483948404841484248434844484548464847484848494850485148524853485448554856485748584859486048614862486348644865486648674868486948704871487248734874487548764877487848794880488148824883488448854886488748884889489048914892489348944895489648974898489949004901490249034904490549064907490849094910491149124913491449154916491749184919492049214922492349244925492649274928492949304931493249334934493549364937493849394940494149424943494449454946494749484949495049514952495349544955495649574958495949604961496249634964496549664967496849694970497149724973497449754976497749784979498049814982498349844985498649874988498949904991499249934994499549964997499849995000500150025003500450055006500750085009501050115012501350145015501650175018501950205021502250235024502550265027502850295030503150325033503450355036503750385039504050415042504350445045504650475048504950505051505250535054505550565057505850595060506150625063506450655066506750685069507050715072507350745075507650775078507950805081508250835084508550865087508850895090509150925093509450955096509750985099510051015102510351045105510651075108510951105111511251135114511551165117511851195120512151225123512451255126512751285129513051315132513351345135513651375138513951405141514251435144514551465147514851495150515151525153515451555156515751585159516051615162516351645165516651675168516951705171517251735174517551765177517851795180518151825183518451855186518751885189519051915192519351945195519651975198519952005201520252035204520552065207520852095210521152125213521452155216521752185219522052215222522352245225522652275228522952305231523252335234523552365237523852395240524152425243524452455246524752485249525052515252525352545255525652575258525952605261526252635264526552665267526852695270527152725273527452755276527752785279528052815282528352845285528652875288528952905291529252935294529552965297529852995300530153025303530453055306530753085309531053115312531353145315531653175318531953205321532253235324532553265327532853295330533153325333533453355336533753385339534053415342534353445345534653475348534953505351535253535354535553565357535853595360536153625363536453655366536753685369537053715372537353745375537653775378537953805381538253835384538553865387538853895390539153925393539453955396539753985399540054015402540354045405540654075408540954105411541254135414541554165417541854195420542154225423542454255426542754285429543054315432543354345435543654375438543954405441544254435444544554465447544854495450545154525453545454555456545754585459546054615462546354645465546654675468546954705471547254735474547554765477547854795480548154825483548454855486548754885489549054915492549354945495549654975498549955005501550255035504550555065507550855095510551155125513551455155516551755185519552055215522552355245525552655275528552955305531553255335534553555365537553855395540554155425543554455455546554755485549555055515552555355545555555655575558555955605561556255635564556555665567556855695570557155725573557455755576557755785579558055815582558355845585558655875588558955905591559255935594559555965597559855995600560156025603560456055606560756085609561056115612561356145615561656175618561956205621562256235624562556265627562856295630563156325633563456355636563756385639564056415642564356445645564656475648564956505651565256535654565556565657565856595660566156625663566456655666566756685669567056715672567356745675567656775678567956805681568256835684568556865687568856895690569156925693569456955696569756985699570057015702570357045705570657075708570957105711571257135714571557165717571857195720572157225723572457255726572757285729573057315732573357345735573657375738573957405741574257435744574557465747574857495750575157525753575457555756575757585759576057615762576357645765576657675768576957705771577257735774577557765777577857795780578157825783578457855786578757885789579057915792579357945795579657975798579958005801580258035804580558065807580858095810581158125813581458155816581758185819582058215822582358245825582658275828582958305831583258335834583558365837583858395840584158425843584458455846584758485849585058515852585358545855585658575858585958605861586258635864586558665867586858695870587158725873587458755876587758785879588058815882588358845885588658875888588958905891589258935894589558965897589858995900590159025903590459055906590759085909591059115912591359145915591659175918591959205921592259235924592559265927592859295930593159325933593459355936593759385939594059415942594359445945594659475948594959505951595259535954595559565957595859595960596159625963596459655966596759685969597059715972597359745975597659775978597959805981598259835984598559865987598859895990599159925993599459955996599759985999600060016002600360046005600660076008600960106011601260136014601560166017601860196020602160226023602460256026602760286029603060316032603360346035603660376038603960406041604260436044604560466047604860496050605160526053605460556056605760586059606060616062606360646065606660676068606960706071607260736074607560766077607860796080608160826083608460856086608760886089609060916092609360946095609660976098609961006101610261036104610561066107610861096110611161126113611461156116611761186119612061216122612361246125612661276128612961306131613261336134613561366137613861396140614161426143614461456146614761486149615061516152615361546155615661576158615961606161616261636164616561666167616861696170617161726173617461756176617761786179618061816182618361846185618661876188618961906191619261936194619561966197619861996200620162026203620462056206620762086209621062116212621362146215621662176218621962206221622262236224622562266227622862296230623162326233623462356236623762386239624062416242624362446245624662476248624962506251625262536254625562566257625862596260626162626263626462656266626762686269627062716272627362746275627662776278627962806281628262836284628562866287628862896290629162926293629462956296629762986299630063016302630363046305630663076308630963106311631263136314631563166317631863196320632163226323632463256326632763286329633063316332633363346335633663376338633963406341634263436344634563466347634863496350635163526353635463556356635763586359636063616362636363646365636663676368636963706371637263736374637563766377637863796380638163826383638463856386638763886389639063916392639363946395639663976398639964006401640264036404640564066407640864096410641164126413641464156416641764186419642064216422642364246425642664276428642964306431643264336434643564366437643864396440644164426443644464456446644764486449645064516452645364546455645664576458645964606461646264636464646564666467646864696470647164726473647464756476647764786479648064816482648364846485648664876488648964906491649264936494649564966497649864996500650165026503650465056506650765086509651065116512651365146515651665176518651965206521652265236524652565266527652865296530653165326533653465356536653765386539654065416542654365446545654665476548654965506551655265536554655565566557655865596560656165626563656465656566656765686569657065716572657365746575657665776578657965806581658265836584658565866587658865896590659165926593659465956596659765986599660066016602660366046605660666076608660966106611661266136614661566166617661866196620662166226623662466256626662766286629663066316632663366346635663666376638663966406641664266436644664566466647664866496650665166526653665466556656665766586659666066616662666366646665666666676668666966706671667266736674667566766677667866796680668166826683668466856686668766886689669066916692669366946695669666976698669967006701670267036704670567066707670867096710671167126713671467156716671767186719672067216722672367246725672667276728672967306731673267336734673567366737673867396740674167426743674467456746674767486749675067516752675367546755675667576758675967606761676267636764676567666767676867696770677167726773677467756776677767786779678067816782678367846785678667876788678967906791679267936794679567966797679867996800680168026803680468056806680768086809681068116812681368146815681668176818681968206821682268236824682568266827682868296830683168326833683468356836683768386839684068416842684368446845684668476848684968506851685268536854685568566857685868596860686168626863686468656866686768686869687068716872687368746875687668776878687968806881688268836884688568866887688868896890689168926893689468956896689768986899690069016902690369046905690669076908690969106911691269136914691569166917691869196920692169226923692469256926692769286929693069316932693369346935693669376938693969406941694269436944694569466947694869496950695169526953695469556956695769586959696069616962696369646965696669676968696969706971697269736974697569766977697869796980698169826983698469856986698769886989699069916992699369946995699669976998699970007001700270037004700570067007700870097010701170127013701470157016701770187019702070217022702370247025702670277028702970307031703270337034703570367037703870397040704170427043704470457046704770487049705070517052705370547055705670577058705970607061706270637064706570667067706870697070707170727073707470757076707770787079708070817082708370847085708670877088708970907091709270937094709570967097709870997100710171027103710471057106710771087109711071117112711371147115711671177118711971207121712271237124712571267127712871297130713171327133713471357136713771387139714071417142714371447145714671477148714971507151715271537154715571567157715871597160716171627163716471657166716771687169717071717172717371747175717671777178717971807181718271837184718571867187718871897190719171927193719471957196719771987199720072017202720372047205720672077208720972107211721272137214721572167217721872197220722172227223722472257226722772287229723072317232723372347235723672377238723972407241724272437244724572467247724872497250725172527253725472557256725772587259726072617262726372647265726672677268726972707271727272737274727572767277727872797280728172827283728472857286728772887289729072917292729372947295729672977298729973007301730273037304730573067307730873097310731173127313731473157316731773187319732073217322732373247325732673277328732973307331733273337334733573367337733873397340734173427343734473457346734773487349735073517352735373547355735673577358735973607361736273637364736573667367736873697370737173727373737473757376737773787379738073817382738373847385738673877388738973907391739273937394739573967397739873997400740174027403740474057406740774087409741074117412741374147415741674177418741974207421742274237424742574267427742874297430743174327433743474357436743774387439744074417442744374447445744674477448744974507451745274537454745574567457745874597460746174627463746474657466746774687469747074717472747374747475747674777478747974807481748274837484748574867487748874897490749174927493749474957496749774987499750075017502750375047505750675077508750975107511751275137514751575167517751875197520752175227523752475257526752775287529753075317532753375347535753675377538753975407541754275437544754575467547754875497550755175527553755475557556755775587559756075617562756375647565756675677568756975707571757275737574757575767577757875797580758175827583758475857586758775887589759075917592759375947595759675977598759976007601760276037604760576067607760876097610761176127613761476157616761776187619762076217622762376247625762676277628762976307631763276337634763576367637763876397640764176427643764476457646764776487649765076517652765376547655765676577658765976607661766276637664766576667667766876697670767176727673767476757676767776787679768076817682768376847685768676877688768976907691769276937694769576967697769876997700770177027703770477057706770777087709771077117712771377147715771677177718771977207721772277237724772577267727772877297730773177327733773477357736773777387739774077417742774377447745774677477748774977507751775277537754775577567757775877597760776177627763776477657766776777687769777077717772777377747775777677777778777977807781778277837784778577867787778877897790779177927793779477957796779777987799780078017802780378047805780678077808780978107811781278137814781578167817781878197820782178227823782478257826782778287829783078317832783378347835783678377838783978407841784278437844784578467847784878497850785178527853785478557856785778587859786078617862786378647865786678677868786978707871787278737874787578767877787878797880788178827883788478857886788778887889789078917892789378947895789678977898789979007901790279037904790579067907790879097910791179127913791479157916791779187919792079217922792379247925792679277928792979307931793279337934793579367937793879397940794179427943794479457946794779487949795079517952795379547955795679577958795979607961796279637964796579667967796879697970797179727973797479757976797779787979798079817982798379847985798679877988798979907991799279937994799579967997799879998000800180028003800480058006800780088009801080118012801380148015801680178018801980208021802280238024802580268027802880298030803180328033803480358036803780388039804080418042804380448045804680478048804980508051805280538054805580568057805880598060806180628063806480658066806780688069807080718072807380748075807680778078807980808081808280838084808580868087808880898090809180928093809480958096809780988099810081018102810381048105810681078108810981108111811281138114811581168117811881198120812181228123812481258126812781288129813081318132813381348135813681378138813981408141814281438144814581468147814881498150815181528153815481558156815781588159816081618162816381648165816681678168816981708171817281738174817581768177817881798180818181828183818481858186818781888189819081918192819381948195819681978198819982008201820282038204820582068207820882098210821182128213821482158216821782188219822082218222822382248225822682278228822982308231823282338234823582368237823882398240824182428243824482458246824782488249825082518252825382548255825682578258825982608261826282638264826582668267826882698270827182728273827482758276827782788279828082818282828382848285828682878288828982908291829282938294829582968297829882998300830183028303830483058306830783088309831083118312831383148315831683178318831983208321832283238324832583268327832883298330833183328333833483358336833783388339834083418342834383448345834683478348834983508351835283538354835583568357835883598360836183628363836483658366836783688369837083718372837383748375837683778378837983808381838283838384838583868387838883898390839183928393839483958396839783988399840084018402840384048405840684078408840984108411841284138414841584168417841884198420842184228423842484258426842784288429843084318432843384348435843684378438843984408441844284438444844584468447844884498450845184528453845484558456845784588459846084618462846384648465846684678468846984708471847284738474847584768477847884798480848184828483848484858486848784888489849084918492849384948495849684978498849985008501850285038504850585068507850885098510851185128513851485158516851785188519852085218522852385248525852685278528852985308531853285338534853585368537853885398540854185428543854485458546854785488549855085518552855385548555855685578558855985608561856285638564856585668567856885698570857185728573857485758576857785788579858085818582858385848585858685878588858985908591859285938594859585968597859885998600860186028603860486058606860786088609861086118612861386148615861686178618861986208621862286238624862586268627862886298630863186328633863486358636863786388639864086418642864386448645864686478648864986508651865286538654865586568657865886598660866186628663866486658666866786688669867086718672867386748675867686778678867986808681868286838684868586868687868886898690869186928693869486958696869786988699870087018702870387048705870687078708870987108711871287138714871587168717871887198720872187228723872487258726872787288729873087318732873387348735873687378738873987408741874287438744874587468747874887498750875187528753875487558756875787588759876087618762876387648765876687678768876987708771877287738774877587768777877887798780878187828783878487858786878787888789879087918792879387948795879687978798879988008801880288038804880588068807880888098810881188128813881488158816881788188819882088218822882388248825882688278828882988308831883288338834883588368837883888398840884188428843884488458846884788488849885088518852885388548855885688578858885988608861886288638864886588668867886888698870887188728873887488758876887788788879888088818882888388848885888688878888888988908891889288938894889588968897889888998900890189028903890489058906890789088909891089118912891389148915891689178918891989208921892289238924892589268927892889298930893189328933893489358936893789388939894089418942894389448945894689478948894989508951895289538954895589568957895889598960896189628963896489658966896789688969897089718972897389748975897689778978897989808981898289838984898589868987898889898990899189928993899489958996899789988999900090019002900390049005900690079008900990109011901290139014901590169017901890199020902190229023902490259026902790289029903090319032903390349035903690379038903990409041904290439044904590469047904890499050905190529053905490559056905790589059906090619062906390649065906690679068906990709071907290739074907590769077907890799080908190829083908490859086908790889089909090919092909390949095909690979098909991009101910291039104910591069107910891099110911191129113911491159116911791189119912091219122912391249125912691279128912991309131913291339134913591369137913891399140914191429143914491459146914791489149915091519152915391549155915691579158915991609161916291639164916591669167916891699170917191729173917491759176917791789179918091819182918391849185918691879188918991909191919291939194919591969197919891999200920192029203920492059206920792089209921092119212921392149215921692179218921992209221922292239224922592269227922892299230923192329233923492359236923792389239924092419242924392449245924692479248924992509251925292539254925592569257925892599260926192629263926492659266926792689269927092719272927392749275927692779278927992809281928292839284928592869287928892899290929192929293929492959296929792989299930093019302930393049305930693079308930993109311931293139314931593169317931893199320932193229323932493259326932793289329933093319332933393349335933693379338933993409341934293439344934593469347934893499350935193529353935493559356935793589359936093619362936393649365936693679368936993709371937293739374937593769377937893799380938193829383938493859386938793889389939093919392939393949395939693979398939994009401940294039404940594069407940894099410941194129413941494159416941794189419942094219422942394249425942694279428942994309431943294339434943594369437943894399440944194429443944494459446944794489449945094519452945394549455945694579458945994609461946294639464946594669467946894699470947194729473947494759476947794789479948094819482948394849485948694879488948994909491949294939494949594969497949894999500950195029503950495059506950795089509951095119512951395149515951695179518951995209521952295239524952595269527952895299530953195329533953495359536953795389539954095419542954395449545954695479548954995509551955295539554955595569557955895599560956195629563956495659566956795689569957095719572957395749575957695779578957995809581958295839584958595869587958895899590959195929593959495959596959795989599960096019602960396049605960696079608960996109611961296139614961596169617961896199620962196229623962496259626962796289629963096319632963396349635963696379638963996409641964296439644964596469647964896499650965196529653965496559656965796589659966096619662966396649665966696679668966996709671967296739674967596769677967896799680968196829683968496859686968796889689969096919692969396949695969696979698969997009701970297039704970597069707970897099710971197129713971497159716971797189719972097219722972397249725972697279728972997309731973297339734973597369737973897399740974197429743974497459746974797489749975097519752975397549755975697579758975997609761976297639764976597669767976897699770977197729773977497759776977797789779978097819782978397849785978697879788978997909791979297939794979597969797979897999800980198029803980498059806980798089809981098119812981398149815981698179818981998209821982298239824982598269827982898299830983198329833983498359836983798389839984098419842984398449845984698479848984998509851985298539854985598569857985898599860986198629863986498659866986798689869987098719872987398749875987698779878987998809881988298839884988598869887988898899890989198929893989498959896989798989899990099019902990399049905990699079908990999109911991299139914991599169917991899199920992199229923992499259926992799289929993099319932993399349935993699379938993999409941994299439944994599469947994899499950995199529953995499559956995799589959996099619962996399649965996699679968996999709971997299739974997599769977997899799980998199829983998499859986998799889989999099919992999399949995999699979998999910000100011000210003100041000510006100071000810009100101001110012100131001410015100161001710018100191002010021100221002310024100251002610027100281002910030100311003210033100341003510036100371003810039100401004110042100431004410045100461004710048100491005010051100521005310054100551005610057100581005910060100611006210063100641006510066100671006810069100701007110072100731007410075100761007710078100791008010081100821008310084100851008610087100881008910090100911009210093100941009510096100971009810099101001010110102101031010410105101061010710108101091011010111101121011310114101151011610117101181011910120101211012210123101241012510126101271012810129101301013110132101331013410135101361013710138101391014010141101421014310144101451014610147101481014910150101511015210153101541015510156101571015810159101601016110162101631016410165101661016710168101691017010171101721017310174101751017610177101781017910180101811018210183101841018510186101871018810189101901019110192101931019410195101961019710198101991020010201102021020310204102051020610207102081020910210102111021210213102141021510216102171021810219102201022110222102231022410225102261022710228102291023010231102321023310234102351023610237102381023910240102411024210243102441024510246102471024810249102501025110252102531025410255102561025710258102591026010261102621026310264102651026610267102681026910270102711027210273102741027510276102771027810279102801028110282102831028410285102861028710288102891029010291102921029310294102951029610297102981029910300103011030210303103041030510306103071030810309103101031110312103131031410315103161031710318103191032010321103221032310324103251032610327103281032910330103311033210333103341033510336103371033810339103401034110342103431034410345103461034710348103491035010351103521035310354103551035610357103581035910360103611036210363103641036510366103671036810369103701037110372103731037410375103761037710378103791038010381103821038310384103851038610387103881038910390103911039210393103941039510396103971039810399104001040110402104031040410405104061040710408104091041010411104121041310414104151041610417104181041910420104211042210423104241042510426104271042810429104301043110432104331043410435104361043710438104391044010441104421044310444104451044610447104481044910450104511045210453104541045510456104571045810459104601046110462104631046410465104661046710468104691047010471104721047310474104751047610477104781047910480104811048210483104841048510486104871048810489104901049110492104931049410495104961049710498104991050010501105021050310504105051050610507105081050910510105111051210513105141051510516105171051810519105201052110522105231052410525105261052710528105291053010531105321053310534105351053610537105381053910540105411054210543105441054510546105471054810549105501055110552105531055410555105561055710558105591056010561105621056310564105651056610567105681056910570105711057210573105741057510576105771057810579105801058110582105831058410585105861058710588105891059010591105921059310594105951059610597105981059910600106011060210603106041060510606106071060810609106101061110612106131061410615106161061710618106191062010621106221062310624106251062610627106281062910630106311063210633106341063510636106371063810639106401064110642106431064410645106461064710648106491065010651106521065310654106551065610657106581065910660106611066210663106641066510666106671066810669106701067110672106731067410675106761067710678106791068010681106821068310684106851068610687106881068910690106911069210693106941069510696106971069810699107001070110702107031070410705107061070710708107091071010711107121071310714107151071610717107181071910720107211072210723107241072510726107271072810729107301073110732107331073410735107361073710738107391074010741107421074310744107451074610747107481074910750107511075210753107541075510756107571075810759107601076110762107631076410765107661076710768107691077010771107721077310774107751077610777107781077910780107811078210783107841078510786107871078810789107901079110792107931079410795107961079710798107991080010801108021080310804108051080610807108081080910810108111081210813108141081510816108171081810819108201082110822108231082410825108261082710828108291083010831108321083310834108351083610837108381083910840108411084210843108441084510846108471084810849108501085110852108531085410855108561085710858108591086010861108621086310864108651086610867108681086910870108711087210873108741087510876108771087810879108801088110882108831088410885108861088710888108891089010891108921089310894108951089610897108981089910900109011090210903109041090510906109071090810909109101091110912109131091410915109161091710918109191092010921109221092310924109251092610927109281092910930109311093210933109341093510936109371093810939109401094110942109431094410945109461094710948109491095010951109521095310954109551095610957109581095910960109611096210963109641096510966109671096810969109701097110972109731097410975109761097710978109791098010981109821098310984109851098610987109881098910990109911099210993109941099510996109971099810999110001100111002110031100411005110061100711008110091101011011110121101311014110151101611017110181101911020110211102211023110241102511026110271102811029110301103111032110331103411035110361103711038110391104011041110421104311044110451104611047110481104911050110511105211053110541105511056110571105811059110601106111062110631106411065110661106711068110691107011071110721107311074110751107611077110781107911080110811108211083110841108511086110871108811089110901109111092110931109411095110961109711098110991110011101111021110311104111051110611107111081110911110111111111211113111141111511116111171111811119111201112111122111231112411125111261112711128111291113011131111321113311134111351113611137111381113911140111411114211143111441114511146111471114811149111501115111152111531115411155111561115711158111591116011161111621116311164111651116611167111681116911170111711117211173111741117511176111771117811179111801118111182111831118411185111861118711188111891119011191111921119311194111951119611197111981119911200112011120211203112041120511206112071120811209112101121111212112131121411215112161121711218112191122011221112221122311224112251122611227112281122911230112311123211233112341123511236112371123811239112401124111242112431124411245112461124711248112491125011251112521125311254112551125611257112581125911260112611126211263112641126511266112671126811269112701127111272112731127411275112761127711278112791128011281112821128311284112851128611287112881128911290112911129211293112941129511296112971129811299113001130111302113031130411305113061130711308113091131011311113121131311314113151131611317113181131911320113211132211323113241132511326113271132811329113301133111332113331133411335113361133711338113391134011341113421134311344113451134611347113481134911350113511135211353113541135511356113571135811359113601136111362113631136411365113661136711368113691137011371113721137311374113751137611377113781137911380113811138211383113841138511386113871138811389113901139111392113931139411395113961139711398113991140011401114021140311404114051140611407114081140911410114111141211413114141141511416114171141811419114201142111422114231142411425114261142711428114291143011431114321143311434114351143611437114381143911440114411144211443114441144511446114471144811449114501145111452114531145411455114561145711458114591146011461114621146311464114651146611467114681146911470114711147211473114741147511476114771147811479114801148111482114831148411485114861148711488114891149011491114921149311494114951149611497114981149911500115011150211503115041150511506115071150811509115101151111512115131151411515115161151711518115191152011521115221152311524115251152611527115281152911530115311153211533115341153511536115371153811539115401154111542115431154411545115461154711548115491155011551115521155311554115551155611557115581155911560115611156211563115641156511566115671156811569115701157111572115731157411575115761157711578115791158011581115821158311584115851158611587115881158911590115911159211593115941159511596115971159811599116001160111602116031160411605116061160711608116091161011611116121161311614116151161611617116181161911620116211162211623116241162511626116271162811629116301163111632116331163411635116361163711638116391164011641116421164311644116451164611647116481164911650116511165211653116541165511656116571165811659116601166111662116631166411665116661166711668116691167011671116721167311674116751167611677116781167911680116811168211683116841168511686116871168811689116901169111692116931169411695116961169711698116991170011701117021170311704117051170611707117081170911710117111171211713117141171511716117171171811719117201172111722117231172411725117261172711728117291173011731117321173311734117351173611737117381173911740117411174211743117441174511746117471174811749117501175111752117531175411755117561175711758117591176011761117621176311764117651176611767117681176911770117711177211773117741177511776117771177811779117801178111782117831178411785117861178711788117891179011791117921179311794117951179611797117981179911800118011180211803118041180511806118071180811809118101181111812118131181411815118161181711818118191182011821118221182311824118251182611827118281182911830118311183211833118341183511836118371183811839118401184111842118431184411845118461184711848118491185011851118521185311854118551185611857118581185911860118611186211863118641186511866118671186811869118701187111872118731187411875118761187711878118791188011881118821188311884118851188611887118881188911890118911189211893118941189511896118971189811899119001190111902119031190411905119061190711908119091191011911119121191311914119151191611917119181191911920119211192211923119241192511926119271192811929119301193111932119331193411935119361193711938119391194011941119421194311944119451194611947119481194911950119511195211953119541195511956119571195811959119601196111962119631196411965119661196711968119691197011971119721197311974119751197611977119781197911980119811198211983119841198511986119871198811989119901199111992119931199411995119961199711998119991200012001120021200312004120051200612007120081200912010120111201212013120141201512016120171201812019120201202112022120231202412025120261202712028120291203012031120321203312034120351203612037120381203912040120411204212043120441204512046120471204812049120501205112052120531205412055120561205712058120591206012061120621206312064120651206612067120681206912070120711207212073120741207512076120771207812079120801208112082120831208412085120861208712088120891209012091120921209312094120951209612097120981209912100121011210212103121041210512106121071210812109121101211112112121131211412115121161211712118121191212012121121221212312124121251212612127121281212912130121311213212133121341213512136121371213812139121401214112142121431214412145121461214712148121491215012151121521215312154121551215612157121581215912160121611216212163121641216512166121671216812169121701217112172121731217412175121761217712178121791218012181121821218312184121851218612187121881218912190121911219212193121941219512196121971219812199122001220112202122031220412205122061220712208122091221012211122121221312214122151221612217122181221912220122211222212223122241222512226122271222812229122301223112232122331223412235122361223712238122391224012241122421224312244122451224612247122481224912250122511225212253122541225512256122571225812259122601226112262122631226412265122661226712268122691227012271122721227312274122751227612277122781227912280122811228212283122841228512286122871228812289122901229112292122931229412295122961229712298122991230012301123021230312304123051230612307123081230912310123111231212313123141231512316123171231812319123201232112322123231232412325123261232712328123291233012331123321233312334123351233612337123381233912340123411234212343123441234512346123471234812349123501235112352123531235412355123561235712358123591236012361123621236312364123651236612367123681236912370123711237212373123741237512376123771237812379123801238112382123831238412385123861238712388123891239012391123921239312394123951239612397123981239912400124011240212403124041240512406124071240812409124101241112412124131241412415124161241712418124191242012421124221242312424124251242612427124281242912430124311243212433124341243512436124371243812439124401244112442124431244412445124461244712448124491245012451124521245312454124551245612457124581245912460124611246212463124641246512466124671246812469124701247112472124731247412475124761247712478124791248012481124821248312484124851248612487124881248912490124911249212493124941249512496124971249812499125001250112502125031250412505125061250712508125091251012511125121251312514125151251612517125181251912520125211252212523125241252512526125271252812529125301253112532125331253412535125361253712538125391254012541125421254312544125451254612547125481254912550125511255212553125541255512556125571255812559125601256112562125631256412565125661256712568125691257012571125721257312574125751257612577125781257912580125811258212583125841258512586125871258812589125901259112592125931259412595125961259712598125991260012601126021260312604126051260612607126081260912610126111261212613126141261512616126171261812619126201262112622126231262412625126261262712628126291263012631126321263312634126351263612637126381263912640126411264212643126441264512646126471264812649126501265112652126531265412655126561265712658126591266012661126621266312664126651266612667126681266912670126711267212673126741267512676126771267812679126801268112682126831268412685126861268712688126891269012691126921269312694126951269612697126981269912700127011270212703127041270512706127071270812709127101271112712127131271412715127161271712718127191272012721127221272312724127251272612727127281272912730127311273212733127341273512736127371273812739127401274112742127431274412745127461274712748127491275012751127521275312754127551275612757127581275912760127611276212763127641276512766127671276812769127701277112772127731277412775127761277712778127791278012781127821278312784127851278612787127881278912790127911279212793127941279512796127971279812799128001280112802128031280412805128061280712808128091281012811128121281312814128151281612817128181281912820128211282212823128241282512826128271282812829128301283112832128331283412835128361283712838128391284012841128421284312844128451284612847128481284912850128511285212853128541285512856128571285812859128601286112862128631286412865128661286712868128691287012871128721287312874128751287612877128781287912880128811288212883128841288512886128871288812889128901289112892128931289412895128961289712898128991290012901129021290312904129051290612907129081290912910129111291212913129141291512916129171291812919129201292112922129231292412925129261292712928129291293012931129321293312934129351293612937129381293912940129411294212943129441294512946129471294812949129501295112952129531295412955129561295712958129591296012961129621296312964129651296612967129681296912970129711297212973129741297512976129771297812979129801298112982129831298412985129861298712988129891299012991129921299312994129951299612997129981299913000130011300213003130041300513006130071300813009130101301113012130131301413015130161301713018130191302013021130221302313024130251302613027130281302913030130311303213033130341303513036130371303813039130401304113042130431304413045130461304713048130491305013051130521305313054130551305613057130581305913060130611306213063130641306513066130671306813069130701307113072130731307413075130761307713078130791308013081130821308313084130851308613087130881308913090130911309213093130941309513096130971309813099131001310113102131031310413105131061310713108131091311013111131121311313114131151311613117131181311913120131211312213123131241312513126131271312813129131301313113132131331313413135131361313713138131391314013141131421314313144131451314613147131481314913150131511315213153131541315513156131571315813159131601316113162131631316413165131661316713168131691317013171131721317313174131751317613177131781317913180131811318213183131841318513186131871318813189131901319113192131931319413195131961319713198131991320013201132021320313204132051320613207132081320913210132111321213213132141321513216132171321813219132201322113222132231322413225132261322713228132291323013231132321323313234132351323613237132381323913240132411324213243132441324513246132471324813249132501325113252132531325413255132561325713258132591326013261132621326313264132651326613267132681326913270132711327213273132741327513276132771327813279132801328113282132831328413285132861328713288132891329013291132921329313294132951329613297132981329913300133011330213303133041330513306133071330813309133101331113312133131331413315133161331713318133191332013321133221332313324133251332613327133281332913330133311333213333133341333513336133371333813339133401334113342133431334413345133461334713348133491335013351133521335313354133551335613357133581335913360133611336213363133641336513366133671336813369133701337113372133731337413375133761337713378133791338013381133821338313384133851338613387133881338913390133911339213393133941339513396133971339813399134001340113402134031340413405134061340713408134091341013411134121341313414134151341613417134181341913420134211342213423134241342513426134271342813429134301343113432134331343413435134361343713438134391344013441134421344313444134451344613447134481344913450134511345213453134541345513456134571345813459134601346113462134631346413465134661346713468134691347013471134721347313474134751347613477134781347913480134811348213483134841348513486134871348813489134901349113492134931349413495134961349713498134991350013501135021350313504135051350613507135081350913510135111351213513135141351513516135171351813519135201352113522135231352413525135261352713528135291353013531135321353313534135351353613537135381353913540135411354213543135441354513546135471354813549135501355113552135531355413555135561355713558135591356013561135621356313564135651356613567135681356913570135711357213573135741357513576135771357813579135801358113582135831358413585135861358713588135891359013591135921359313594135951359613597135981359913600136011360213603136041360513606136071360813609136101361113612136131361413615136161361713618136191362013621136221362313624136251362613627136281362913630136311363213633136341363513636136371363813639136401364113642136431364413645136461364713648136491365013651136521365313654136551365613657136581365913660136611366213663136641366513666136671366813669136701367113672136731367413675136761367713678136791368013681136821368313684136851368613687136881368913690136911369213693136941369513696136971369813699137001370113702137031370413705137061370713708137091371013711137121371313714137151371613717137181371913720137211372213723137241372513726137271372813729137301373113732137331373413735137361373713738137391374013741137421374313744137451374613747137481374913750137511375213753137541375513756137571375813759137601376113762137631376413765137661376713768137691377013771137721377313774137751377613777137781377913780137811378213783137841378513786137871378813789137901379113792137931379413795137961379713798137991380013801138021380313804138051380613807138081380913810138111381213813138141381513816138171381813819138201382113822138231382413825138261382713828138291383013831138321383313834138351383613837138381383913840138411384213843138441384513846138471384813849138501385113852138531385413855138561385713858138591386013861138621386313864138651386613867138681386913870138711387213873138741387513876138771387813879138801388113882138831388413885138861388713888138891389013891138921389313894138951389613897138981389913900139011390213903139041390513906139071390813909139101391113912139131391413915139161391713918139191392013921139221392313924139251392613927139281392913930139311393213933139341393513936139371393813939139401394113942139431394413945139461394713948139491395013951139521395313954139551395613957139581395913960139611396213963139641396513966139671396813969139701397113972139731397413975139761397713978139791398013981139821398313984139851398613987139881398913990139911399213993139941399513996139971399813999140001400114002140031400414005140061400714008140091401014011140121401314014140151401614017140181401914020140211402214023140241402514026140271402814029140301403114032140331403414035140361403714038140391404014041140421404314044140451404614047140481404914050140511405214053140541405514056140571405814059140601406114062140631406414065140661406714068140691407014071140721407314074140751407614077140781407914080140811408214083140841408514086140871408814089140901409114092140931409414095140961409714098140991410014101141021410314104141051410614107141081410914110141111411214113141141411514116141171411814119141201412114122141231412414125141261412714128141291413014131141321413314134141351413614137141381413914140141411414214143141441414514146141471414814149141501415114152141531415414155141561415714158141591416014161141621416314164141651416614167141681416914170141711417214173141741417514176141771417814179141801418114182141831418414185141861418714188141891419014191141921419314194141951419614197141981419914200142011420214203142041420514206142071420814209142101421114212142131421414215142161421714218142191422014221142221422314224142251422614227142281422914230142311423214233142341423514236142371423814239142401424114242142431424414245142461424714248142491425014251142521425314254142551425614257142581425914260142611426214263142641426514266142671426814269142701427114272142731427414275142761427714278142791428014281142821428314284142851428614287142881428914290142911429214293142941429514296142971429814299143001430114302143031430414305143061430714308143091431014311143121431314314143151431614317143181431914320143211432214323143241432514326143271432814329143301433114332143331433414335143361433714338143391434014341143421434314344143451434614347143481434914350143511435214353143541435514356143571435814359143601436114362143631436414365143661436714368143691437014371143721437314374143751437614377143781437914380143811438214383143841438514386143871438814389143901439114392143931439414395143961439714398143991440014401144021440314404144051440614407144081440914410144111441214413144141441514416144171441814419144201442114422144231442414425144261442714428144291443014431144321443314434144351443614437144381443914440144411444214443144441444514446144471444814449144501445114452144531445414455144561445714458144591446014461144621446314464144651446614467144681446914470144711447214473144741447514476144771447814479144801448114482144831448414485144861448714488144891449014491144921449314494144951449614497144981449914500145011450214503145041450514506145071450814509145101451114512145131451414515145161451714518145191452014521145221452314524145251452614527145281452914530145311453214533145341453514536145371453814539145401454114542145431454414545145461454714548145491455014551145521455314554145551455614557145581455914560145611456214563145641456514566145671456814569145701457114572145731457414575145761457714578145791458014581145821458314584145851458614587145881458914590145911459214593145941459514596145971459814599146001460114602146031460414605146061460714608146091461014611146121461314614146151461614617146181461914620146211462214623146241462514626146271462814629146301463114632146331463414635146361463714638146391464014641146421464314644146451464614647146481464914650146511465214653146541465514656146571465814659146601466114662146631466414665146661466714668146691467014671146721467314674146751467614677146781467914680146811468214683146841468514686146871468814689146901469114692146931469414695146961469714698146991470014701147021470314704147051470614707147081470914710147111471214713147141471514716147171471814719147201472114722147231472414725147261472714728147291473014731147321473314734147351473614737147381473914740147411474214743147441474514746147471474814749147501475114752147531475414755147561475714758147591476014761147621476314764147651476614767147681476914770147711477214773147741477514776147771477814779147801478114782147831478414785147861478714788147891479014791147921479314794147951479614797147981479914800148011480214803148041480514806148071480814809148101481114812148131481414815148161481714818148191482014821148221482314824148251482614827148281482914830148311483214833148341483514836148371483814839148401484114842148431484414845148461484714848148491485014851148521485314854148551485614857148581485914860148611486214863148641486514866148671486814869148701487114872148731487414875148761487714878148791488014881148821488314884148851488614887148881488914890148911489214893148941489514896148971489814899149001490114902149031490414905149061490714908149091491014911149121491314914149151491614917149181491914920149211492214923149241492514926149271492814929149301493114932149331493414935149361493714938149391494014941149421494314944149451494614947149481494914950149511495214953149541495514956149571495814959149601496114962149631496414965149661496714968149691497014971149721497314974149751497614977149781497914980149811498214983149841498514986149871498814989149901499114992149931499414995149961499714998149991500015001150021500315004150051500615007150081500915010150111501215013150141501515016150171501815019150201502115022150231502415025150261502715028150291503015031150321503315034150351503615037150381503915040150411504215043150441504515046150471504815049150501505115052150531505415055150561505715058150591506015061150621506315064150651506615067150681506915070150711507215073150741507515076150771507815079150801508115082150831508415085150861508715088150891509015091150921509315094150951509615097150981509915100151011510215103151041510515106151071510815109151101511115112151131511415115151161511715118151191512015121151221512315124151251512615127151281512915130151311513215133151341513515136151371513815139151401514115142151431514415145151461514715148151491515015151151521515315154151551515615157151581515915160151611516215163151641516515166151671516815169151701517115172151731517415175151761517715178151791518015181151821518315184151851518615187151881518915190151911519215193151941519515196151971519815199152001520115202152031520415205152061520715208152091521015211152121521315214152151521615217152181521915220152211522215223152241522515226152271522815229152301523115232152331523415235152361523715238152391524015241152421524315244152451524615247152481524915250152511525215253152541525515256152571525815259152601526115262152631526415265152661526715268152691527015271152721527315274152751527615277152781527915280152811528215283152841528515286152871528815289152901529115292152931529415295152961529715298152991530015301153021530315304153051530615307153081530915310153111531215313153141531515316153171531815319153201532115322153231532415325153261532715328153291533015331153321533315334153351533615337153381533915340153411534215343153441534515346153471534815349153501535115352153531535415355153561535715358153591536015361153621536315364153651536615367153681536915370153711537215373153741537515376153771537815379153801538115382153831538415385153861538715388153891539015391153921539315394153951539615397153981539915400154011540215403154041540515406154071540815409154101541115412154131541415415154161541715418154191542015421154221542315424154251542615427154281542915430154311543215433154341543515436154371543815439154401544115442154431544415445154461544715448154491545015451154521545315454154551545615457154581545915460154611546215463154641546515466154671546815469154701547115472154731547415475154761547715478154791548015481154821548315484154851548615487154881548915490154911549215493154941549515496154971549815499155001550115502155031550415505155061550715508155091551015511155121551315514155151551615517155181551915520155211552215523155241552515526155271552815529155301553115532155331553415535155361553715538155391554015541155421554315544155451554615547155481554915550155511555215553155541555515556155571555815559155601556115562155631556415565155661556715568155691557015571155721557315574155751557615577155781557915580155811558215583155841558515586155871558815589155901559115592155931559415595155961559715598155991560015601156021560315604156051560615607156081560915610156111561215613156141561515616156171561815619156201562115622156231562415625156261562715628156291563015631156321563315634156351563615637156381563915640156411564215643156441564515646156471564815649156501565115652156531565415655156561565715658156591566015661156621566315664156651566615667156681566915670156711567215673156741567515676156771567815679156801568115682156831568415685156861568715688156891569015691156921569315694156951569615697156981569915700157011570215703157041570515706157071570815709157101571115712157131571415715157161571715718157191572015721157221572315724157251572615727157281572915730157311573215733157341573515736157371573815739157401574115742157431574415745157461574715748157491575015751157521575315754157551575615757157581575915760157611576215763157641576515766157671576815769157701577115772157731577415775157761577715778157791578015781157821578315784157851578615787157881578915790157911579215793157941579515796157971579815799158001580115802158031580415805158061580715808158091581015811158121581315814158151581615817158181581915820158211582215823158241582515826158271582815829158301583115832158331583415835158361583715838158391584015841158421584315844158451584615847158481584915850158511585215853158541585515856158571585815859158601586115862158631586415865158661586715868158691587015871158721587315874158751587615877158781587915880158811588215883158841588515886158871588815889158901589115892158931589415895158961589715898158991590015901159021590315904159051590615907159081590915910159111591215913159141591515916159171591815919159201592115922159231592415925159261592715928159291593015931159321593315934159351593615937159381593915940159411594215943159441594515946159471594815949159501595115952159531595415955159561595715958159591596015961159621596315964159651596615967159681596915970159711597215973159741597515976159771597815979159801598115982159831598415985159861598715988159891599015991159921599315994159951599615997159981599916000160011600216003160041600516006160071600816009160101601116012160131601416015160161601716018160191602016021160221602316024160251602616027160281602916030160311603216033160341603516036160371603816039160401604116042160431604416045160461604716048160491605016051160521605316054160551605616057160581605916060160611606216063160641606516066160671606816069160701607116072160731607416075160761607716078160791608016081160821608316084160851608616087160881608916090160911609216093160941609516096160971609816099161001610116102161031610416105161061610716108161091611016111161121611316114161151611616117161181611916120161211612216123161241612516126161271612816129161301613116132161331613416135161361613716138161391614016141161421614316144161451614616147161481614916150161511615216153161541615516156161571615816159161601616116162161631616416165161661616716168161691617016171161721617316174161751617616177161781617916180161811618216183161841618516186161871618816189161901619116192161931619416195161961619716198161991620016201162021620316204162051620616207162081620916210162111621216213162141621516216162171621816219162201622116222162231622416225162261622716228162291623016231162321623316234162351623616237162381623916240162411624216243162441624516246162471624816249162501625116252162531625416255162561625716258162591626016261162621626316264162651626616267162681626916270162711627216273162741627516276162771627816279162801628116282162831628416285162861628716288162891629016291162921629316294162951629616297162981629916300163011630216303163041630516306163071630816309163101631116312163131631416315163161631716318163191632016321163221632316324163251632616327163281632916330163311633216333163341633516336163371633816339163401634116342163431634416345163461634716348163491635016351163521635316354163551635616357163581635916360163611636216363163641636516366163671636816369163701637116372163731637416375163761637716378163791638016381163821638316384163851638616387163881638916390163911639216393163941639516396163971639816399164001640116402164031640416405164061640716408164091641016411164121641316414164151641616417164181641916420164211642216423164241642516426164271642816429164301643116432164331643416435164361643716438164391644016441164421644316444164451644616447164481644916450164511645216453164541645516456164571645816459164601646116462164631646416465164661646716468164691647016471164721647316474164751647616477164781647916480164811648216483164841648516486164871648816489164901649116492164931649416495164961649716498164991650016501165021650316504165051650616507165081650916510165111651216513165141651516516165171651816519165201652116522165231652416525165261652716528165291653016531165321653316534165351653616537165381653916540165411654216543165441654516546165471654816549165501655116552165531655416555165561655716558165591656016561165621656316564165651656616567165681656916570165711657216573165741657516576165771657816579165801658116582165831658416585165861658716588165891659016591165921659316594165951659616597165981659916600166011660216603166041660516606166071660816609166101661116612166131661416615166161661716618166191662016621166221662316624166251662616627166281662916630166311663216633166341663516636166371663816639166401664116642166431664416645166461664716648166491665016651166521665316654166551665616657166581665916660166611666216663166641666516666166671666816669166701667116672166731667416675166761667716678166791668016681166821668316684166851668616687166881668916690166911669216693166941669516696166971669816699167001670116702167031670416705167061670716708167091671016711167121671316714167151671616717167181671916720167211672216723167241672516726167271672816729167301673116732167331673416735167361673716738167391674016741167421674316744167451674616747167481674916750167511675216753167541675516756167571675816759167601676116762167631676416765167661676716768167691677016771167721677316774167751677616777167781677916780167811678216783167841678516786167871678816789167901679116792167931679416795167961679716798167991680016801168021680316804168051680616807168081680916810168111681216813168141681516816168171681816819168201682116822168231682416825168261682716828168291683016831168321683316834168351683616837168381683916840168411684216843168441684516846168471684816849168501685116852168531685416855168561685716858168591686016861168621686316864168651686616867168681686916870168711687216873168741687516876168771687816879168801688116882168831688416885168861688716888168891689016891168921689316894168951689616897168981689916900169011690216903169041690516906169071690816909169101691116912169131691416915169161691716918169191692016921169221692316924169251692616927169281692916930169311693216933169341693516936169371693816939169401694116942169431694416945169461694716948169491695016951169521695316954169551695616957169581695916960169611696216963169641696516966169671696816969169701697116972169731697416975169761697716978169791698016981169821698316984169851698616987169881698916990169911699216993169941699516996169971699816999170001700117002170031700417005170061700717008170091701017011170121701317014170151701617017170181701917020170211702217023170241702517026170271702817029170301703117032170331703417035170361703717038170391704017041170421704317044170451704617047170481704917050170511705217053170541705517056170571705817059170601706117062170631706417065170661706717068170691707017071170721707317074170751707617077170781707917080170811708217083170841708517086170871708817089170901709117092170931709417095170961709717098170991710017101171021710317104171051710617107171081710917110171111711217113171141711517116171171711817119171201712117122171231712417125171261712717128171291713017131171321713317134171351713617137171381713917140171411714217143171441714517146171471714817149171501715117152171531715417155171561715717158171591716017161171621716317164171651716617167171681716917170171711717217173171741717517176171771717817179171801718117182171831718417185171861718717188171891719017191171921719317194171951719617197171981719917200172011720217203172041720517206172071720817209172101721117212172131721417215172161721717218172191722017221172221722317224172251722617227172281722917230172311723217233172341723517236172371723817239172401724117242172431724417245172461724717248172491725017251172521725317254172551725617257172581725917260172611726217263172641726517266172671726817269172701727117272172731727417275172761727717278172791728017281172821728317284172851728617287172881728917290172911729217293172941729517296172971729817299173001730117302173031730417305173061730717308173091731017311173121731317314173151731617317173181731917320173211732217323173241732517326173271732817329173301733117332173331733417335173361733717338173391734017341173421734317344173451734617347173481734917350173511735217353173541735517356173571735817359173601736117362173631736417365173661736717368173691737017371173721737317374173751737617377173781737917380173811738217383173841738517386173871738817389173901739117392173931739417395173961739717398173991740017401174021740317404174051740617407174081740917410174111741217413174141741517416174171741817419174201742117422174231742417425174261742717428174291743017431174321743317434174351743617437174381743917440174411744217443174441744517446174471744817449174501745117452174531745417455174561745717458174591746017461174621746317464174651746617467174681746917470174711747217473174741747517476174771747817479174801748117482174831748417485174861748717488174891749017491174921749317494174951749617497174981749917500175011750217503175041750517506175071750817509175101751117512175131751417515175161751717518175191752017521175221752317524175251752617527175281752917530175311753217533175341753517536175371753817539175401754117542175431754417545175461754717548175491755017551175521755317554175551755617557175581755917560175611756217563175641756517566175671756817569175701757117572175731757417575175761757717578175791758017581175821758317584175851758617587175881758917590175911759217593175941759517596175971759817599176001760117602176031760417605176061760717608176091761017611176121761317614176151761617617176181761917620176211762217623176241762517626176271762817629176301763117632176331763417635176361763717638176391764017641176421764317644176451764617647176481764917650176511765217653176541765517656176571765817659176601766117662176631766417665176661766717668176691767017671176721767317674176751767617677176781767917680176811768217683176841768517686176871768817689176901769117692176931769417695176961769717698176991770017701177021770317704177051770617707177081770917710177111771217713177141771517716177171771817719177201772117722177231772417725177261772717728177291773017731177321773317734177351773617737177381773917740177411774217743177441774517746177471774817749177501775117752177531775417755177561775717758177591776017761177621776317764177651776617767177681776917770177711777217773177741777517776177771777817779177801778117782177831778417785177861778717788177891779017791177921779317794177951779617797177981779917800178011780217803178041780517806178071780817809178101781117812178131781417815178161781717818178191782017821178221782317824178251782617827178281782917830178311783217833178341783517836178371783817839178401784117842178431784417845178461784717848178491785017851178521785317854178551785617857178581785917860178611786217863178641786517866178671786817869178701787117872178731787417875178761787717878178791788017881178821788317884178851788617887178881788917890178911789217893178941789517896178971789817899179001790117902179031790417905179061790717908179091791017911179121791317914179151791617917179181791917920179211792217923179241792517926179271792817929179301793117932179331793417935179361793717938179391794017941179421794317944179451794617947179481794917950179511795217953179541795517956179571795817959179601796117962179631796417965179661796717968179691797017971179721797317974179751797617977179781797917980179811798217983179841798517986179871798817989179901799117992179931799417995179961799717998179991800018001180021800318004180051800618007180081800918010180111801218013180141801518016180171801818019180201802118022180231802418025180261802718028180291803018031180321803318034180351803618037180381803918040180411804218043180441804518046180471804818049180501805118052180531805418055180561805718058180591806018061180621806318064180651806618067180681806918070180711807218073180741807518076180771807818079180801808118082180831808418085180861808718088180891809018091180921809318094180951809618097180981809918100181011810218103181041810518106181071810818109181101811118112181131811418115181161811718118181191812018121181221812318124181251812618127181281812918130181311813218133181341813518136181371813818139181401814118142181431814418145181461814718148181491815018151181521815318154181551815618157181581815918160181611816218163181641816518166181671816818169181701817118172181731817418175181761817718178181791818018181181821818318184181851818618187181881818918190181911819218193181941819518196181971819818199182001820118202182031820418205182061820718208182091821018211182121821318214182151821618217182181821918220182211822218223182241822518226182271822818229182301823118232182331823418235182361823718238182391824018241182421824318244182451824618247182481824918250182511825218253182541825518256182571825818259182601826118262182631826418265182661826718268182691827018271182721827318274182751827618277182781827918280182811828218283182841828518286182871828818289182901829118292182931829418295182961829718298182991830018301183021830318304183051830618307183081830918310183111831218313183141831518316183171831818319183201832118322183231832418325183261832718328183291833018331183321833318334183351833618337183381833918340183411834218343183441834518346183471834818349183501835118352183531835418355183561835718358183591836018361183621836318364183651836618367183681836918370183711837218373183741837518376183771837818379183801838118382183831838418385183861838718388183891839018391183921839318394183951839618397183981839918400184011840218403184041840518406184071840818409184101841118412184131841418415184161841718418184191842018421184221842318424184251842618427184281842918430184311843218433184341843518436184371843818439184401844118442184431844418445184461844718448184491845018451184521845318454184551845618457184581845918460184611846218463184641846518466184671846818469184701847118472184731847418475184761847718478184791848018481184821848318484184851848618487184881848918490184911849218493184941849518496184971849818499185001850118502185031850418505185061850718508185091851018511185121851318514185151851618517185181851918520185211852218523185241852518526185271852818529185301853118532185331853418535185361853718538185391854018541185421854318544185451854618547185481854918550185511855218553185541855518556185571855818559185601856118562185631856418565185661856718568185691857018571185721857318574185751857618577185781857918580185811858218583185841858518586185871858818589185901859118592185931859418595185961859718598185991860018601186021860318604186051860618607186081860918610186111861218613186141861518616186171861818619186201862118622186231862418625186261862718628186291863018631186321863318634186351863618637186381863918640186411864218643186441864518646186471864818649186501865118652186531865418655186561865718658186591866018661186621866318664186651866618667186681866918670186711867218673186741867518676186771867818679186801868118682186831868418685186861868718688186891869018691186921869318694186951869618697186981869918700187011870218703187041870518706187071870818709187101871118712187131871418715187161871718718187191872018721187221872318724187251872618727187281872918730187311873218733187341873518736187371873818739187401874118742187431874418745187461874718748187491875018751187521875318754187551875618757187581875918760187611876218763187641876518766187671876818769187701877118772187731877418775187761877718778187791878018781187821878318784187851878618787187881878918790187911879218793187941879518796187971879818799188001880118802188031880418805188061880718808188091881018811188121881318814188151881618817188181881918820188211882218823188241882518826188271882818829188301883118832188331883418835188361883718838188391884018841188421884318844188451884618847188481884918850188511885218853188541885518856188571885818859188601886118862188631886418865188661886718868188691887018871188721887318874188751887618877188781887918880188811888218883188841888518886188871888818889188901889118892188931889418895188961889718898188991890018901189021890318904189051890618907189081890918910189111891218913189141891518916189171891818919189201892118922189231892418925189261892718928189291893018931189321893318934189351893618937189381893918940189411894218943189441894518946189471894818949189501895118952189531895418955189561895718958189591896018961189621896318964189651896618967189681896918970189711897218973189741897518976189771897818979189801898118982189831898418985189861898718988189891899018991189921899318994189951899618997189981899919000190011900219003190041900519006190071900819009190101901119012190131901419015190161901719018190191902019021190221902319024190251902619027190281902919030190311903219033190341903519036190371903819039190401904119042190431904419045190461904719048190491905019051190521905319054190551905619057190581905919060190611906219063190641906519066190671906819069190701907119072190731907419075190761907719078190791908019081190821908319084190851908619087190881908919090190911909219093190941909519096190971909819099191001910119102191031910419105191061910719108191091911019111191121911319114191151911619117191181911919120191211912219123191241912519126191271912819129191301913119132191331913419135191361913719138191391914019141191421914319144191451914619147191481914919150191511915219153191541915519156191571915819159191601916119162191631916419165191661916719168191691917019171191721917319174191751917619177191781917919180191811918219183191841918519186191871918819189191901919119192191931919419195191961919719198
  1. package sg
  2. import (
  3. "archive/zip"
  4. "bytes"
  5. //"crypto/x509/pkix"
  6. "encoding/json"
  7. "fmt"
  8. //"github.com/tjfoc/gmsm/sm2"
  9. //"github.com/tjfoc/gmsm/sm3"
  10. "gdyb/controllers"
  11. "gdyb/enums"
  12. "gdyb/models"
  13. "gdyb/service"
  14. "gdyb/utils"
  15. "github.com/astaxie/beego"
  16. "github.com/axgle/mahonia"
  17. "github.com/gorilla/websocket"
  18. "github.com/jinzhu/gorm"
  19. "github.com/shopspring/decimal"
  20. "io"
  21. "io/ioutil"
  22. "math"
  23. "math/rand"
  24. "net/http"
  25. "net/url"
  26. "os"
  27. "path/filepath"
  28. "regexp"
  29. "strconv"
  30. "strings"
  31. "syscall"
  32. "time"
  33. "unsafe"
  34. )
  35. type HisApiController struct {
  36. controllers.BaseAuthAPIController
  37. }
  38. func HisManagerApiRegistRouters() {
  39. //挂号
  40. beego.Router("/api/register/get", &HisApiController{}, "get:GetRegisterInfo")
  41. //上传就诊信息-上传明细-结算
  42. beego.Router("/api/upload/get", &HisApiController{}, "get:GetUploadInfo")
  43. //查询
  44. beego.Router("/api/settle/query", &HisApiController{}, "get:GetSettleAccounts")
  45. //对总账
  46. beego.Router("/api/checkaccount/get", &HisApiController{}, "get:GetCheckAccount")
  47. //对明细
  48. beego.Router("/api/checkdetailaccount/get", &HisApiController{}, "get:GetCheckDetailAccount")
  49. //退费,退明细
  50. beego.Router("/api/refund/post", &HisApiController{}, "get:Refund")
  51. //退号
  52. beego.Router("/api/refundnumber/post", &HisApiController{}, "get:RefundNumber")
  53. //退明细
  54. beego.Router("/api/refunddetail/post", &HisApiController{}, "get:RefundDetail")
  55. //上传就诊信息-上传明细-预结算
  56. beego.Router("/api/presettle/get", &HisApiController{}, "get:GetPreUploadInfo")
  57. beego.Router("/api/treatment/check", &HisApiController{}, "get:CheckTreatment")
  58. beego.Router("/api/org/info", &HisApiController{}, "get:GetOrgInfo")
  59. beego.Router("/api/readcard", &HisApiController{}, "get:ReadCard")
  60. beego.Router("/api/310", &HisApiController{}, "get:Check310")
  61. beego.Router("/api/390", &HisApiController{}, "get:Check390")
  62. beego.Router("/api/patient/info", &HisApiController{}, "get:GetPatientInfo")
  63. beego.Router("/api/checkcode/get", &HisApiController{}, "get:GetCheckCode")
  64. beego.Router("/api/uncheckcode/get", &HisApiController{}, "get:UnCheckCode")
  65. beego.Router("/api/psn/putonrecord", &HisApiController{}, "get:PsnPutOnRecord")
  66. beego.Router("/api/psn/unputonrecord", &HisApiController{}, "get:PsnUnPutOnRecord")
  67. beego.Router("/api/psn/ncds/putonrecord", &HisApiController{}, "get:PsnPutNCDSOnRecord")
  68. beego.Router("/api/psn/ncds/unputonrecord", &HisApiController{}, "get:PsnPutUnNCDSOnRecord")
  69. beego.Router("/api/reversal", &HisApiController{}, "get:ReversalData")
  70. beego.Router("/api/reversal/other", &HisApiController{}, "get:ReversalOtherData")
  71. beego.Router("/api/settlelist/get", &HisApiController{}, "get:GetSettleList")
  72. beego.Router("/api/settlelisthosptial/get", &HisApiController{}, "get:GetSettleListHospital")
  73. beego.Router("/api/pwd/check", &HisApiController{}, "get:CheckCardPWD")
  74. beego.Router("/api/insutype/check", &HisApiController{}, "get:CheckInsutype")
  75. //beego.Router("/api/batchsettlelist/get", &HisApiController{}, "get:GetBatchSettleList")
  76. beego.Router("/api/psn/info", &HisApiController{}, "get:GetPsnNcdsInfo")
  77. beego.Router("/api/allopatry/refund", &HisApiController{}, "post:RefundAllopatry")
  78. beego.Router("/api/check", &HisApiController{}, "get:Check")
  79. //beego.Router("/api/check3101", &HisApiController{}, "get:Check3101")
  80. //beego.Router("/api/check3102", &HisApiController{}, "get:Check3102")
  81. beego.Router("/90990", &HisApiController{}, "get:CheckCardPWDTwo")
  82. beego.Router("/9001", &HisApiController{}, "get:Get9001")
  83. //beego.Router("/api/readelecard", &HisApiController{}, "get:ReadEleCard")
  84. beego.Router("/api/3202", &HisApiController{}, "get:Post3202")
  85. beego.Router("/api/3501", &HisApiController{}, "post:Post3501")
  86. beego.Router("/api/readele", &HisApiController{}, "get:ReadEleToken")
  87. beego.Router("/api/2505", &HisApiController{}, "get:Get2505")
  88. beego.Router("/api/4201A", &HisApiController{}, "get:Get4201A")
  89. beego.Router("/api/4202", &HisApiController{}, "get:Get4202")
  90. beego.Router("/api/4203", &HisApiController{}, "get:Get4203")
  91. beego.Router("/api/4205", &HisApiController{}, "get:Get4205")
  92. beego.Router("/api/4207", &HisApiController{}, "get:Get4207")
  93. beego.Router("/api/4208", &HisApiController{}, "get:Get4208")
  94. beego.Router("/api/4209", &HisApiController{}, "get:Get4209")
  95. beego.Router("/api/allopatry/get", &HisApiController{}, "get:GetAllopatry")
  96. beego.Router("/api/comfirmallopatry/post", &HisApiController{}, "post:ComfirmAllopatry")
  97. beego.Router("/api/allopatry/refund", &HisApiController{}, "get:RefundAllopatry")
  98. beego.Router("/api/settle/query/batch", &HisApiController{}, "get:GetBatchSettleAccounts")
  99. beego.Router("/api/bl4201A", &HisApiController{}, "get:GetBL4201A")
  100. beego.Router("/api/bl4201A", &HisApiController{}, "get:GetBL4201A")
  101. beego.Router("/api/CFYLJG001", &HisApiController{}, "get:GetCFYLJG001")
  102. beego.Router("/api/CFYLJG002", &HisApiController{}, "get:GetCFYLJG002")
  103. beego.Router("/api/CFYLJG003", &HisApiController{}, "get:GetCFYLJG003")
  104. beego.Router("/api/CFYLJG004", &HisApiController{}, "get:GetCFYLJG004")
  105. beego.Router("/api/CFYLJG005", &HisApiController{}, "get:GetCFYLJG005")
  106. beego.Router("/api/CFYLJG006", &HisApiController{}, "get:GetCFYLJG006")
  107. beego.Router("/api/CFYLJG007", &HisApiController{}, "get:GetCFYLJG007")
  108. //beego.Router("/api/CFYLJG008", &HisApiController{}, "get:GetCFYLJG008")
  109. //beego.Router("/api/CFYLJG009", &HisApiController{}, "get:GetCFYLJG009")
  110. //beego.Router("/api/2205", &HisApiController{}, "get:Get2205")
  111. beego.Router("/jsyb/3260", &HisApiController{}, "get:Get3260")
  112. beego.Router("/jsyb/3261", &HisApiController{}, "get:Get3261")
  113. beego.Router("/jsyb/3262", &HisApiController{}, "get:Get3262")
  114. beego.Router("/jsyb/3263", &HisApiController{}, "get:Get3263")
  115. beego.Router("/jsyb/3264", &HisApiController{}, "get:Get3264")
  116. beego.Router("/jsyb/3265", &HisApiController{}, "get:Get3265")
  117. beego.Router("/jsyb/3266", &HisApiController{}, "get:Get3266")
  118. beego.Router("/jsyb/3267", &HisApiController{}, "get:Get3267")
  119. beego.Router("/jsyb/3268", &HisApiController{}, "get:Get3268")
  120. beego.Router("/jsyb/3269", &HisApiController{}, "get:Get3269")
  121. beego.Router("/jsyb/3270", &HisApiController{}, "get:Get3270")
  122. beego.Router("/jsyb/3271", &HisApiController{}, "get:Get3271")
  123. beego.Router("/jsyb/3272", &HisApiController{}, "get:Get3272")
  124. beego.Router("/jsyb/3273", &HisApiController{}, "get:Get3273")
  125. beego.Router("/jsyb/3274", &HisApiController{}, "get:Get3274")
  126. beego.Router("/jsyb/3275", &HisApiController{}, "get:Get3275")
  127. beego.Router("/jsyb/3276", &HisApiController{}, "get:Get3276")
  128. beego.Router("/jsyb/3277", &HisApiController{}, "get:Get3277")
  129. }
  130. func (c *HisApiController) Get3260() {
  131. admin_user_id, _ := c.GetInt64("admin_user_id")
  132. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  133. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  134. var api string
  135. if miConfig.MdtrtareaAdmvs == "320921" {
  136. api = "http://192.168.2.3:9532/" + "jsyb/3260?" + "org_name=" + miConfig.OrgName + "&doctor=" + curRoles.UserName + "&doctor_name=" + curRoles.UserName + "&fixmedins_code=" + miConfig.Code +
  137. "&insuplc_admdvs=" + miConfig.MdtrtareaAdmvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  138. } else {
  139. api = "http://192.168.5.251:9532/" + "jsyb/3260?" + "org_name=" + miConfig.OrgName + "&doctor=" + curRoles.UserName + "&doctor_name=" + curRoles.UserName + "&fixmedins_code=" + miConfig.Code +
  140. "&insuplc_admdvs=" + miConfig.MdtrtareaAdmvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  141. }
  142. }
  143. func (c *HisApiController) Get3261() {
  144. admin_user_id, _ := c.GetInt64("admin_user_id")
  145. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  146. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  147. var api string
  148. if miConfig.MdtrtareaAdmvs == "320921" {
  149. api = "http://192.168.2.3:9532/" + "jsyb/3260?" + "org_name=" + miConfig.OrgName + "&doctor=" + curRoles.UserName + "&doctor_name=" + curRoles.UserName + "&fixmedins_code=" + miConfig.Code +
  150. "&insuplc_admdvs=" + miConfig.MdtrtareaAdmvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  151. } else {
  152. api = "http://192.168.5.251:9532/" + "jsyb/3260?" + "org_name=" + miConfig.OrgName + "&doctor=" + curRoles.UserName + "&doctor_name=" + curRoles.UserName + "&fixmedins_code=" + miConfig.Code +
  153. "&insuplc_admdvs=" + miConfig.MdtrtareaAdmvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  154. }
  155. }
  156. func (c *HisApiController) Get3262() {
  157. admin_user_id, _ := c.GetInt64("admin_user_id")
  158. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  159. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  160. var api string
  161. if miConfig.MdtrtareaAdmvs == "320921" {
  162. api = "http://192.168.2.3:9532/" + "jsyb/3260?" + "org_name=" + miConfig.OrgName + "&doctor=" + curRoles.UserName + "&doctor_name=" + curRoles.UserName + "&fixmedins_code=" + miConfig.Code +
  163. "&insuplc_admdvs=" + miConfig.MdtrtareaAdmvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  164. } else {
  165. api = "http://192.168.5.251:9532/" + "jsyb/3260?" + "org_name=" + miConfig.OrgName + "&doctor=" + curRoles.UserName + "&doctor_name=" + curRoles.UserName + "&fixmedins_code=" + miConfig.Code +
  166. "&insuplc_admdvs=" + miConfig.MdtrtareaAdmvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  167. }
  168. }
  169. func (c *HisApiController) Get3263() {
  170. admin_user_id, _ := c.GetInt64("admin_user_id")
  171. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  172. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  173. var api string
  174. if miConfig.MdtrtareaAdmvs == "320921" {
  175. api = "http://192.168.2.3:9532/" + "jsyb/3260?" + "org_name=" + miConfig.OrgName + "&doctor=" + curRoles.UserName + "&doctor_name=" + curRoles.UserName + "&fixmedins_code=" + miConfig.Code +
  176. "&insuplc_admdvs=" + miConfig.MdtrtareaAdmvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  177. } else {
  178. api = "http://192.168.5.251:9532/" + "jsyb/3260?" + "org_name=" + miConfig.OrgName + "&doctor=" + curRoles.UserName + "&doctor_name=" + curRoles.UserName + "&fixmedins_code=" + miConfig.Code +
  179. "&insuplc_admdvs=" + miConfig.MdtrtareaAdmvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  180. }
  181. }
  182. func (c *HisApiController) Get3264() {
  183. if miConfig.MdtrtareaAdmvs == "320921" {
  184. api = "http://192.168.2.3:9532/" + "jsyb/3264?psn_no=" + PsnNo + "&insutype=" + insutype + "&cert_no=" + cert_no + "&ipt_otp_no=" + ipt_otp_no +
  185. "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&doctor_name=" + doctor_info.UserName + "&fixmedins_code=" + miConfig.Code +
  186. "&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
  187. } else {
  188. api = "http://192.168.5.251:9532/" + "jsyb/3264?psn_no=" + PsnNo + "&insutype=" + insutype + "&cert_no=" + cert_no + "&ipt_otp_no=" + ipt_otp_no +
  189. "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&doctor_name=" + doctor_info.UserName + "&fixmedins_code=" + miConfig.Code +
  190. "&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
  191. }
  192. }
  193. func (c *HisApiController) Get3265() {
  194. if miConfig.MdtrtareaAdmvs == "320921" {
  195. api = "http://192.168.2.3:9532/" + "jsyb/3265?psn_no=" + PsnNo + "&insutype=" + insutype + "&cert_no=" + cert_no + "&ipt_otp_no=" + ipt_otp_no +
  196. "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&doctor_name=" + doctor_info.UserName + "&fixmedins_code=" + miConfig.Code +
  197. "&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
  198. } else {
  199. api = "http://192.168.5.251:9532/" + "jsyb/3265?psn_no=" + PsnNo + "&insutype=" + insutype + "&cert_no=" + cert_no + "&ipt_otp_no=" + ipt_otp_no +
  200. "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&doctor_name=" + doctor_info.UserName + "&fixmedins_code=" + miConfig.Code +
  201. "&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
  202. }
  203. }
  204. func (c *HisApiController) Get3266() {
  205. if miConfig.MdtrtareaAdmvs == "320921" {
  206. api = "http://192.168.2.3:9532/" + "jsyb/3266?psn_no=" + PsnNo + "&insutype=" + insutype + "&cert_no=" + cert_no + "&ipt_otp_no=" + ipt_otp_no +
  207. "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&doctor_name=" + doctor_info.UserName + "&fixmedins_code=" + miConfig.Code +
  208. "&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
  209. } else {
  210. api = "http://192.168.5.251:9532/" + "jsyb/3266?psn_no=" + PsnNo + "&insutype=" + insutype + "&cert_no=" + cert_no + "&ipt_otp_no=" + ipt_otp_no +
  211. "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&doctor_name=" + doctor_info.UserName + "&fixmedins_code=" + miConfig.Code +
  212. "&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
  213. }
  214. }
  215. func (c *HisApiController) Get3267() {
  216. if miConfig.MdtrtareaAdmvs == "320921" {
  217. api = "http://192.168.2.3:9532/" + "jsyb/3267?psn_no=" + PsnNo + "&insutype=" + insutype + "&cert_no=" + cert_no + "&ipt_otp_no=" + ipt_otp_no +
  218. "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&doctor_name=" + doctor_info.UserName + "&fixmedins_code=" + miConfig.Code +
  219. "&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
  220. } else {
  221. api = "http://192.168.5.251:9532/" + "jsyb/3267?psn_no=" + PsnNo + "&insutype=" + insutype + "&cert_no=" + cert_no + "&ipt_otp_no=" + ipt_otp_no +
  222. "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&doctor_name=" + doctor_info.UserName + "&fixmedins_code=" + miConfig.Code +
  223. "&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
  224. }
  225. }
  226. func (c *HisApiController) Get3268() {
  227. if miConfig.MdtrtareaAdmvs == "320921" {
  228. api = "http://192.168.2.3:9532/" + "jsyb/3268?psn_no=" + PsnNo + "&insutype=" + insutype + "&cert_no=" + cert_no + "&ipt_otp_no=" + ipt_otp_no +
  229. "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&doctor_name=" + doctor_info.UserName + "&fixmedins_code=" + miConfig.Code +
  230. "&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
  231. } else {
  232. api = "http://192.168.5.251:9532/" + "jsyb/3268?psn_no=" + PsnNo + "&insutype=" + insutype + "&cert_no=" + cert_no + "&ipt_otp_no=" + ipt_otp_no +
  233. "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&doctor_name=" + doctor_info.UserName + "&fixmedins_code=" + miConfig.Code +
  234. "&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
  235. }
  236. }
  237. func (c *HisApiController) Get3269() {
  238. if miConfig.MdtrtareaAdmvs == "320921" {
  239. api = "http://192.168.2.3:9532/" + "jsyb/3269?psn_no=" + PsnNo + "&insutype=" + insutype + "&cert_no=" + cert_no + "&ipt_otp_no=" + ipt_otp_no +
  240. "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&doctor_name=" + doctor_info.UserName + "&fixmedins_code=" + miConfig.Code +
  241. "&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
  242. } else {
  243. api = "http://192.168.5.251:9532/" + "jsyb/3269?psn_no=" + PsnNo + "&insutype=" + insutype + "&cert_no=" + cert_no + "&ipt_otp_no=" + ipt_otp_no +
  244. "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&doctor_name=" + doctor_info.UserName + "&fixmedins_code=" + miConfig.Code +
  245. "&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
  246. }
  247. }
  248. func (c *HisApiController) Get3270() {
  249. if miConfig.MdtrtareaAdmvs == "320921" {
  250. api = "http://192.168.2.3:9532/" + "jsyb/3270?psn_no=" + PsnNo + "&insutype=" + insutype + "&cert_no=" + cert_no + "&ipt_otp_no=" + ipt_otp_no +
  251. "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&doctor_name=" + doctor_info.UserName + "&fixmedins_code=" + miConfig.Code +
  252. "&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
  253. } else {
  254. api = "http://192.168.5.251:9532/" + "jsyb/3270?psn_no=" + PsnNo + "&insutype=" + insutype + "&cert_no=" + cert_no + "&ipt_otp_no=" + ipt_otp_no +
  255. "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&doctor_name=" + doctor_info.UserName + "&fixmedins_code=" + miConfig.Code +
  256. "&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
  257. }
  258. }
  259. func (c *HisApiController) Get3271() {
  260. if miConfig.MdtrtareaAdmvs == "320921" {
  261. api = "http://192.168.2.3:9532/" + "jsyb/3271?psn_no=" + PsnNo + "&insutype=" + insutype + "&cert_no=" + cert_no + "&ipt_otp_no=" + ipt_otp_no +
  262. "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&doctor_name=" + doctor_info.UserName + "&fixmedins_code=" + miConfig.Code +
  263. "&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
  264. } else {
  265. api = "http://192.168.5.251:9532/" + "jsyb/3271?psn_no=" + PsnNo + "&insutype=" + insutype + "&cert_no=" + cert_no + "&ipt_otp_no=" + ipt_otp_no +
  266. "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&doctor_name=" + doctor_info.UserName + "&fixmedins_code=" + miConfig.Code +
  267. "&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
  268. }
  269. }
  270. func (c *HisApiController) Get3272() {
  271. if miConfig.MdtrtareaAdmvs == "320921" {
  272. api = "http://192.168.2.3:9532/" + "jsyb/3272?psn_no=" + PsnNo + "&insutype=" + insutype + "&cert_no=" + cert_no + "&ipt_otp_no=" + ipt_otp_no +
  273. "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&doctor_name=" + doctor_info.UserName + "&fixmedins_code=" + miConfig.Code +
  274. "&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
  275. } else {
  276. api = "http://192.168.5.251:9532/" + "jsyb/3272?psn_no=" + PsnNo + "&insutype=" + insutype + "&cert_no=" + cert_no + "&ipt_otp_no=" + ipt_otp_no +
  277. "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&doctor_name=" + doctor_info.UserName + "&fixmedins_code=" + miConfig.Code +
  278. "&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
  279. }
  280. }
  281. func (c *HisApiController) Get3273() {
  282. if miConfig.MdtrtareaAdmvs == "320921" {
  283. api = "http://192.168.2.3:9532/" + "jsyb/3273?psn_no=" + PsnNo + "&insutype=" + insutype + "&cert_no=" + cert_no + "&ipt_otp_no=" + ipt_otp_no +
  284. "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&doctor_name=" + doctor_info.UserName + "&fixmedins_code=" + miConfig.Code +
  285. "&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
  286. } else {
  287. api = "http://192.168.5.251:9532/" + "jsyb/3273?psn_no=" + PsnNo + "&insutype=" + insutype + "&cert_no=" + cert_no + "&ipt_otp_no=" + ipt_otp_no +
  288. "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&doctor_name=" + doctor_info.UserName + "&fixmedins_code=" + miConfig.Code +
  289. "&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
  290. }
  291. }
  292. func (c *HisApiController) Get3274() {
  293. if miConfig.MdtrtareaAdmvs == "320921" {
  294. api = "http://192.168.2.3:9532/" + "jsyb/3274?psn_no=" + PsnNo + "&insutype=" + insutype + "&cert_no=" + cert_no + "&ipt_otp_no=" + ipt_otp_no +
  295. "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&doctor_name=" + doctor_info.UserName + "&fixmedins_code=" + miConfig.Code +
  296. "&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
  297. } else {
  298. api = "http://192.168.5.251:9532/" + "jsyb/3274?psn_no=" + PsnNo + "&insutype=" + insutype + "&cert_no=" + cert_no + "&ipt_otp_no=" + ipt_otp_no +
  299. "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&doctor_name=" + doctor_info.UserName + "&fixmedins_code=" + miConfig.Code +
  300. "&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
  301. }
  302. }
  303. func (c *HisApiController) Get3275() {
  304. if miConfig.MdtrtareaAdmvs == "320921" {
  305. api = "http://192.168.2.3:9532/" + "jsyb/3275?psn_no=" + PsnNo + "&insutype=" + insutype + "&cert_no=" + cert_no + "&ipt_otp_no=" + ipt_otp_no +
  306. "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&doctor_name=" + doctor_info.UserName + "&fixmedins_code=" + miConfig.Code +
  307. "&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
  308. } else {
  309. api = "http://192.168.5.251:9532/" + "jsyb/3275?psn_no=" + PsnNo + "&insutype=" + insutype + "&cert_no=" + cert_no + "&ipt_otp_no=" + ipt_otp_no +
  310. "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&doctor_name=" + doctor_info.UserName + "&fixmedins_code=" + miConfig.Code +
  311. "&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
  312. }
  313. }
  314. func (c *HisApiController) Get3276() {
  315. if miConfig.MdtrtareaAdmvs == "320921" {
  316. api = "http://192.168.2.3:9532/" + "jsyb/3276?psn_no=" + PsnNo + "&insutype=" + insutype + "&cert_no=" + cert_no + "&ipt_otp_no=" + ipt_otp_no +
  317. "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&doctor_name=" + doctor_info.UserName + "&fixmedins_code=" + miConfig.Code +
  318. "&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
  319. } else {
  320. api = "http://192.168.5.251:9532/" + "jsyb/3276?psn_no=" + PsnNo + "&insutype=" + insutype + "&cert_no=" + cert_no + "&ipt_otp_no=" + ipt_otp_no +
  321. "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&doctor_name=" + doctor_info.UserName + "&fixmedins_code=" + miConfig.Code +
  322. "&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
  323. }
  324. }
  325. func (c *HisApiController) Get3277() {
  326. if miConfig.MdtrtareaAdmvs == "320921" {
  327. api = "http://192.168.2.3:9532/" + "jsyb/3277?psn_no=" + PsnNo + "&insutype=" + insutype + "&cert_no=" + cert_no + "&ipt_otp_no=" + ipt_otp_no +
  328. "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&doctor_name=" + doctor_info.UserName + "&fixmedins_code=" + miConfig.Code +
  329. "&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
  330. } else {
  331. api = "http://192.168.5.251:9532/" + "jsyb/3277?psn_no=" + PsnNo + "&insutype=" + insutype + "&cert_no=" + cert_no + "&ipt_otp_no=" + ipt_otp_no +
  332. "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&doctor_name=" + doctor_info.UserName + "&fixmedins_code=" + miConfig.Code +
  333. "&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
  334. }
  335. }
  336. func (c *HisApiController) GetCFYLJG001() {
  337. admin_user_id, _ := c.GetInt64("admin_user_id")
  338. patient_id, _ := c.GetInt64("patient_id")
  339. his_patient_id, _ := c.GetInt64("his_patient_id")
  340. record_time := c.GetString("record_time")
  341. admin_user_id = 3626
  342. patient_id = 19424
  343. his_patient_id = 238932
  344. record_time = "2023-07-03"
  345. his, _ := service.GetHisPatientRecord(c.GetAdminUserInfo().CurrentOrgId, his_patient_id)
  346. psn, _ := service.GetPsnByPatientId(patient_id)
  347. //patient, _ := service.GetPatientByID(c.GetAdminUserInfo().CurrentOrgId,patient_id)
  348. //patient, _ := service.GetPatientByID(c.GetAdminUserInfo().CurrentOrgId,patient_id)
  349. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  350. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  351. var cFYLJG001 models.CFYLJG001
  352. timeLayout := "2006-01-02"
  353. loc, _ := time.LoadLocation("Local")
  354. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  355. if err != nil {
  356. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  357. return
  358. }
  359. recordDateTime := theTime.Unix()
  360. prescriptions, _ := service.GetHisPrescriptionForMedType(c.GetAdminUserInfo().CurrentOrgId, patient_id, recordDateTime)
  361. info, _ := service.FindLastPatientPrescriptionInfoTwo(c.GetAdminUserInfo().CurrentOrgId, patient_id, recordDateTime)
  362. for _, item := range prescriptions {
  363. doctor, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, item.Creator)
  364. if his.IdCardType == 1 {
  365. bas := strings.Split(psn.CardInfo, "|")
  366. basNumber := bas[1]
  367. fmt.Println(basNumber)
  368. card_sn := bas[3]
  369. card_no := bas[2]
  370. cFYLJG001.MdtrtCertType = "03"
  371. cFYLJG001.CardSn = card_sn
  372. cFYLJG001.MdtrtCertNo = card_no
  373. cFYLJG001.EcToken = ""
  374. cFYLJG001.AuthNo = ""
  375. } else if his.IdCardType == 2 {
  376. cFYLJG001.MdtrtCertType = "02"
  377. cFYLJG001.CardSn = ""
  378. cFYLJG001.MdtrtCertNo = his.IdCardNo
  379. cFYLJG001.EcToken = ""
  380. cFYLJG001.AuthNo = ""
  381. } else if his.IdCardType == 4 {
  382. cFYLJG001.MdtrtCertType = "01"
  383. cFYLJG001.CardSn = ""
  384. cFYLJG001.MdtrtCertNo = psn.VerifyNumber
  385. cFYLJG001.EcToken = psn.VerifyNumber
  386. cFYLJG001.AuthNo = ""
  387. }
  388. cFYLJG001.BizTypeCode = "01"
  389. cFYLJG001.InsuAdmdvs = psn.InsuplcAdmdvs
  390. cFYLJG001.HospRxno = strconv.FormatInt(item.ID, 10)
  391. cFYLJG001.RxTypeCode = "1"
  392. tempTime := time.Unix(item.PreTime, 0)
  393. timeFormatOne := tempTime.Format("2006-01-02 15:04:05")
  394. cFYLJG001.PrscTime = timeFormatOne
  395. var count float64
  396. if item.Type == 1 {
  397. for _, sumItem := range item.HisDoctorAdviceInfo {
  398. count = count + sumItem.PrescribingNumber
  399. }
  400. }
  401. cFYLJG001.RxDrugCnt = count
  402. cFYLJG001.ValiDays = "5"
  403. ts := time.Unix(item.PreTime, 0)
  404. record_time2 := ts.AddDate(0, 0, int(5)).Unix()
  405. tempTime3 := time.Unix(record_time2, 0)
  406. timeFormat3 := tempTime3.Format("2006-01-02 15:04:05")
  407. cFYLJG001.ValiEndTime = timeFormat3
  408. cFYLJG001.RxCotnFlag = "0"
  409. for _, subItem := range item.HisDoctorAdviceInfo {
  410. var drug models.RxDrug
  411. drug.MedListCodg = subItem.BaseDrugLib.MedicalInsuranceNumber
  412. drug.MedinsListCodg = subItem.BaseDrugLib.MedicalInsuranceNumber
  413. drug.RxItemTypeCode = "11"
  414. drug.DrugDosform = "乳膏剂" //TODO
  415. if subItem.BaseDrugLib.MinUnit != subItem.BaseDrugLib.DoseUnit {
  416. drug.DrugSpec = subItem.BaseDrugLib.Dose + subItem.BaseDrugLib.DoseUnit + "*" + strconv.FormatInt(subItem.BaseDrugLib.MinNumber, 10) + subItem.BaseDrugLib.MinUnit + "/" + subItem.BaseDrugLib.MaxUnit
  417. }
  418. drug.MedcWayDscr = subItem.DeliveryWay
  419. tempTime2 := time.Unix(subItem.StartTime, 0)
  420. timeFormatTwo := tempTime2.Format("2006-01-02 15:04:05")
  421. drug.MedcBegntime = timeFormatTwo
  422. if subItem.Day > 0 {
  423. ts := time.Unix(subItem.StartTime, 0)
  424. record_time := ts.AddDate(0, 0, int(subItem.Day)).Unix()
  425. tempTime4 := time.Unix(record_time, 0)
  426. timeFormat5 := tempTime4.Format("2006-01-02") + " 23:59:00"
  427. drug.MedcEndtime = timeFormat5
  428. } else {
  429. tempTime2 := time.Unix(subItem.StartTime, 0)
  430. timeFormatTwo := tempTime2.Format("2006-01-02") + " 23:59:00"
  431. drug.MedcEndtime = timeFormatTwo
  432. }
  433. drug.MedcDays = strconv.FormatInt(subItem.Day, 10)
  434. drug.DrugPric = fmt.Sprintf("%.2f", subItem.Price)
  435. drug.DrugSumamt = fmt.Sprintf("%.2f", subItem.Price*subItem.PrescribingNumber)
  436. drug.DrugCnt = subItem.PrescribingNumber
  437. drug.DrugDosunt = subItem.PrescribingNumberUnit
  438. drug.DrugGenname = subItem.AdviceName
  439. drug.MedcWayCodg = subItem.DeliveryWay
  440. //drug.DrugTotlcnt = subItem.PrescribingNumber
  441. drug.SinDoscnt = subItem.SingleDose
  442. drug.SinDosunt = subItem.SingleDoseUnit
  443. drug.UsedFrquCodg = strconv.FormatInt(subItem.ID, 10)
  444. drug.UsedFrquName = subItem.ExecutionFrequency
  445. drug.DrugTotlcnt = fmt.Sprintf("%.2f", subItem.PrescribingNumber)
  446. drug.DrugTotlcntEmp = subItem.PrescribingNumberUnit
  447. drug.HospApprFlag = "1"
  448. cFYLJG001.List = append(cFYLJG001.List, drug)
  449. }
  450. cFYLJG001.Mdtrtinfo.FixmedinsCode = miConfig.Code
  451. cFYLJG001.Mdtrtinfo.FixmedinsName = miConfig.Code
  452. cFYLJG001.Mdtrtinfo.MdtrtID = his.Number
  453. cFYLJG001.Mdtrtinfo.MedType = item.MedType
  454. cFYLJG001.Mdtrtinfo.IptOtpNo = his.IptOtpNo
  455. cFYLJG001.Mdtrtinfo.OtpIptFlag = "1"
  456. cFYLJG001.Mdtrtinfo.PsnNo = his.PsnNo
  457. cFYLJG001.Mdtrtinfo.PatnName = his.PsnName
  458. cFYLJG001.Mdtrtinfo.Certno = his.IdCardNo
  459. cFYLJG001.Mdtrtinfo.PsnCertType = "01"
  460. cFYLJG001.Mdtrtinfo.PatnAge = fmt.Sprintf("%.1f", his.Age)
  461. cFYLJG001.Mdtrtinfo.PatnHgt = "160" //todo
  462. cFYLJG001.Mdtrtinfo.PatnWt = "58" //todo
  463. cFYLJG001.Mdtrtinfo.Gend = his.Gend
  464. cFYLJG001.Mdtrtinfo.PatnAge = fmt.Sprintf("%.1f", his.Age)
  465. cFYLJG001.Mdtrtinfo.PrscDeptName = "肾内科"
  466. cFYLJG001.Mdtrtinfo.PrscDeptCode = "A03.06"
  467. cFYLJG001.Mdtrtinfo.DrCode = doctor.DoctorNumber
  468. cFYLJG001.Mdtrtinfo.PrscDrName = doctor.UserName
  469. cFYLJG001.Mdtrtinfo.DrProfttlCodg = "234"
  470. cFYLJG001.Mdtrtinfo.DrProfttlName = "医师"
  471. cFYLJG001.Mdtrtinfo.DrDeptCode = "A03.06"
  472. cFYLJG001.Mdtrtinfo.DrDeptName = "肾内科"
  473. cFYLJG001.Mdtrtinfo.Caty = "A03.06"
  474. tempTime2 := time.Now().Unix()
  475. tempTime6 := time.Unix(tempTime2, 0)
  476. timeFormatTwo := tempTime6.Format("2006-01-02 15:04:05")
  477. cFYLJG001.Mdtrtinfo.MdtrtTime = timeFormatTwo
  478. cFYLJG001.Mdtrtinfo.DiseCodg = "M07803"
  479. cFYLJG001.Mdtrtinfo.SpDiseFlag = "1"
  480. cFYLJG001.Mdtrtinfo.MaindiagCode = "N18.500"
  481. cFYLJG001.Mdtrtinfo.MaindiagName = "慢性肾脏病5期"
  482. memo := make(map[string]interface{})
  483. memo["insutype"] = his.Insutype
  484. bytesData, _ := json.Marshal(memo)
  485. cFYLJG001.Mdtrtinfo.Extras = string(bytesData)
  486. diagnosis_ids := strings.Split(info.Diagnosis, ",")
  487. var config []*models.HisXtDiagnoseConfig
  488. for _, item := range diagnosis_ids {
  489. id, _ := strconv.ParseInt(item, 10, 64)
  490. diagnosisConfig, _ := service.FindDiagnoseById(id)
  491. config = append(config, &diagnosisConfig)
  492. }
  493. for index, subitem := range config {
  494. if index == 0 {
  495. var dia models.DiseInfo
  496. dia.DiagType = "1"
  497. dia.MaindiagFlag = "1"
  498. dia.DiagSrtNo = strconv.FormatInt(int64(index+1), 10)
  499. dia.DiagCode = subitem.CountryCode
  500. dia.DiagName = subitem.ClassName
  501. dia.DiagDept = "肾内科"
  502. dia.DiagDrNo = doctor.DoctorNumber
  503. dia.DiagDrName = doctor.UserName
  504. tempTime3 := time.Unix(item.PreTime, 0)
  505. timeFormatTwo := tempTime3.Format("2006-01-02 15:04:05")
  506. dia.DiagTime = timeFormatTwo
  507. cFYLJG001.Diseinfo = append(cFYLJG001.Diseinfo, dia)
  508. } else {
  509. var dia models.DiseInfo
  510. dia.DiagType = "1"
  511. dia.MaindiagFlag = "0"
  512. dia.DiagSrtNo = strconv.FormatInt(int64(index+1), 10)
  513. dia.DiagCode = subitem.CountryCode
  514. dia.DiagName = subitem.ClassName
  515. dia.DiagDept = "肾内科"
  516. dia.DiagDrNo = doctor.DoctorNumber
  517. dia.DiagDrName = doctor.UserName
  518. tempTime3 := time.Unix(item.PreTime, 0)
  519. timeFormatTwo := tempTime3.Format("2006-01-02 15:04:05")
  520. dia.DiagTime = timeFormatTwo
  521. cFYLJG001.Diseinfo = append(cFYLJG001.Diseinfo, dia)
  522. }
  523. }
  524. fmt.Println(cFYLJG001)
  525. service.GetCFYLJG001(miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, cFYLJG001)
  526. }
  527. }
  528. func (c *HisApiController) GetCFYLJG002() {
  529. admin_user_id, _ := c.GetInt64("admin_user_id")
  530. id, _ := c.GetInt64("id")
  531. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  532. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  533. flow, _ := service.Getflow(id)
  534. his, _ := service.GetHisPatientByNumber(flow.MID)
  535. inputData := make(map[string]interface{})
  536. inputData["rxtracecode"] = flow.RxTraceCode
  537. inputData["hirxno"] = flow.HiRxno
  538. inputData["mdtrtid"] = flow.MID
  539. inputData["patnname"] = his.PsnName
  540. inputData["psncerttype"] = his.PsnCertType
  541. inputData["certno"] = his.Certno
  542. inputData["fixmedinsname"] = miConfig.OrgName
  543. inputData["fixmedinscode"] = miConfig.Code
  544. inputData["drcode"] = ""
  545. inputData["prscdrname"] = ""
  546. inputData["phardeptname"] = ""
  547. inputData["phardeptcode"] = ""
  548. inputData["pharprofttlcodg"] = ""
  549. inputData["pharprofttlname"] = ""
  550. inputData["pharcode"] = ""
  551. inputData["rxfrquname"] = ""
  552. inputData["pharcerttype"] = ""
  553. inputData["pharcertno"] = ""
  554. inputData["pharname"] = ""
  555. inputData["pharpraccertno"] = ""
  556. inputData["pharchktime"] = ""
  557. bytesData, _ := json.Marshal(inputData)
  558. fmt.Println(bytesData)
  559. //// 使用 SM3 计算 JSON 数据的哈希值
  560. //hash := sm3.New()
  561. //hash.Write(bytesData)
  562. //hashValue := hash.Sum(nil)
  563. //
  564. //// 加载 SM2 私钥
  565. //privateKeyBytes, err := ioutil.ReadFile("path/to/private_key.pem")
  566. //if err != nil {
  567. // fmt.Println("Failed to read private key file:", err)
  568. // return
  569. //}
  570. //privateKey, err := sm2.ParsePKCS8PrivateKey(privateKeyBytes)
  571. //if err != nil {
  572. // fmt.Println("Failed to parse private key:", err)
  573. // return
  574. //}
  575. //
  576. //// 使用私钥对哈希值进行签名
  577. //r, s, err := sm2.Sign(rand.Reader, privateKey.(*sm2.PrivateKey), hashValue, nil)
  578. //if err != nil {
  579. // fmt.Println("Failed to sign data:", err)
  580. // return
  581. //}
  582. //signature, err := syntax.EncodeSM2Signature(r, s)
  583. //if err != nil {
  584. // fmt.Println("Failed to encode signature:", err)
  585. // return
  586. //}
  587. //
  588. //// 构建 CMS/PKCS#7 Detached 数据结构
  589. //// 这里只包含签名值和原始数据
  590. //signedData := &pkix.ContentInfo{
  591. // ContentType: pkix.SignedDataOID,
  592. // Content: &pkix.SignedData{
  593. // Version: 3,
  594. // DigestAlgorithms: []pkix.AlgorithmIdentifier{{Algorithm: sm3.OID}},
  595. // EncapContentInfo: pkix.EncapContentInfo{
  596. // EContentType: pkix.DataOID,
  597. // EContent: jsonBytes,
  598. // },
  599. // Certificates: []pkix.Certificate{},
  600. // CRLs: []pkix.CertificateList{},
  601. // SignerInfos: []pkix.SignerInfo{},
  602. // DigestEncryptionAlgorithm: pkix.AlgorithmIdentifier{
  603. // Algorithm: sm2.SignAlgorithmSM2WithSM3,
  604. // },
  605. // EncryptedDigest: signature,
  606. // },
  607. //}
  608. //
  609. //// 使用 DER 编码进行序列化
  610. //derBytes, err := syntax.Marshal(signedData)
  611. //if err != nil {
  612. // fmt.Println("Failed to marshal CMS/PKCS#7 data:", err)
  613. // return
  614. //}
  615. service.GetCFYLJG002(miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, "", "", "")
  616. }
  617. func (c *HisApiController) GetCFYLJG003() {
  618. admin_user_id, _ := c.GetInt64("admin_user_id")
  619. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  620. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  621. var cFYLJG003 models.CFYLJG003
  622. service.GetCFYLJG003(miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, cFYLJG003)
  623. }
  624. func (c *HisApiController) GetCFYLJG004() {
  625. admin_user_id, _ := c.GetInt64("admin_user_id")
  626. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  627. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  628. var cFYLJG004 models.CFYLJG004
  629. service.GetCFYLJG004(miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, cFYLJG004)
  630. }
  631. func (c *HisApiController) GetCFYLJG005() {
  632. admin_user_id, _ := c.GetInt64("admin_user_id")
  633. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  634. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  635. var cFYLJG005 models.CFYLJG005
  636. service.GetCFYLJG005(miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, cFYLJG005)
  637. }
  638. func (c *HisApiController) GetCFYLJG006() {
  639. admin_user_id, _ := c.GetInt64("admin_user_id")
  640. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  641. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  642. var cFYLJG006 models.CFYLJG006
  643. service.GetCFYLJG006(miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, cFYLJG006)
  644. }
  645. func (c *HisApiController) GetCFYLJG007() {
  646. admin_user_id, _ := c.GetInt64("admin_user_id")
  647. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  648. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  649. var cFYLJG007 models.CFYLJG007
  650. service.GetCFYLJG007(miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, cFYLJG007)
  651. }
  652. func (c *HisApiController) GetBL4201A() {
  653. order_id, _ := c.GetInt64("order_id")
  654. admin_user_id, _ := c.GetInt64("admin_user_id")
  655. order, _ := service.GetHisOrderByIDTwo(order_id)
  656. his, _ := service.GetInHospitalRecordByNumber(order.MdtrtId)
  657. order_info, _ := service.GetHisOrderInfoByNumber(order.MdtrtId)
  658. order_info_two, _ := service.GetHisOrderInfoByNumberTwo(order.MdtrtId)
  659. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  660. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  661. department, _ := service.GetDepartMentDetail(his.Departments)
  662. pre, _ := service.GetNewHisPrescriptionByNumber(order.Number)
  663. doctor, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, pre.Creator)
  664. if order.ID == 0 {
  665. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisOrderNoExistParamWrong)
  666. return
  667. }
  668. var struct4201A models.Struct4201A
  669. var fsiOPFLDs []models.FsiOwnpayPatnFeeListDDTO
  670. for _, items := range order_info {
  671. memo := make(map[string]interface{})
  672. var fsiOPFLD models.FsiOwnpayPatnFeeListDDTO
  673. fsiOPFLD.FixmedinsMdtrtID = items.OrderNumber
  674. fsiOPFLD.MedType = "14"
  675. fsiOPFLD.BkkpSn = items.FeedetlSn
  676. fsiOPFLD.FixmedinsCode = miConfig.Code
  677. fsiOPFLD.FixmedinsName = miConfig.OrgName
  678. fsiOPFLD.Cnt = fmt.Sprintf("%.2f", items.Cnt)
  679. fsiOPFLD.Pric = fmt.Sprintf("%.2f", items.Pric)
  680. fsiOPFLD.DetItemFeeSumamt = fmt.Sprintf("%.2f", items.DetItemFeeSumamt)
  681. if items.AdviceId > 0 && items.ProjectId == 0 && items.HisDoctorAdviceInfo.BaseDrugLib.IsUser != 1 && len(items.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber) > 0 {
  682. fsiOPFLD.FeeOcurTime = time.Unix(items.HisDoctorAdviceInfo.CreatedTime, 0).Format("2006-01-02 15:04:05")
  683. fsiOPFLD.MedListCodg = items.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber
  684. fsiOPFLD.MedinsListCodg = items.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber
  685. fsiOPFLD.MedinsListName = items.HisDoctorAdviceInfo.BaseDrugLib.DrugName
  686. fsiOPFLD.Prodname = items.HisDoctorAdviceInfo.BaseDrugLib.DrugName
  687. fsiOPFLD.BilgDeptName = department.Name
  688. fsiOPFLD.BilgDeptCodg = department.Number
  689. fsiOPFLD.BilgDrCode = doctor.DoctorNumber
  690. fsiOPFLD.BilgDrName = doctor.UserName
  691. fsiOPFLD.MedChrgitmType = "09"
  692. memo["hosp_appr_flag"] = "1"
  693. memo["invoice_no"] = order.MdtrtId
  694. memo["memo"] = "自费"
  695. bytesData, _ := json.Marshal(memo)
  696. fsiOPFLD.Memo = string(bytesData)
  697. fsiOPFLDs = append(fsiOPFLDs, fsiOPFLD)
  698. } else if items.AdviceId == 0 && items.ProjectId > 0 {
  699. if items.HisPrescriptionProject.Type == 2 && len(items.HisPrescriptionProject.HisProject.MedicalCode) > 0 {
  700. fsiOPFLD.FeeOcurTime = time.Unix(items.HisPrescriptionProject.Ctime, 0).Format("2006-01-02 15:04:05")
  701. fsiOPFLD.MedListCodg = items.HisPrescriptionProject.HisProject.MedicalCode
  702. fsiOPFLD.MedinsListCodg = items.HisPrescriptionProject.HisProject.MedicalCode
  703. fsiOPFLD.MedinsListName = items.HisPrescriptionProject.HisProject.ProjectName
  704. fsiOPFLD.Prodname = items.HisPrescriptionProject.HisProject.ProjectName
  705. fsiOPFLD.BilgDeptName = department.Name
  706. fsiOPFLD.BilgDeptCodg = department.Number
  707. fsiOPFLD.BilgDrCode = doctor.DoctorNumber
  708. fsiOPFLD.BilgDrName = doctor.UserName
  709. switch items.HisPrescriptionProject.HisProject.CostClassify {
  710. case 0:
  711. break
  712. case 1:
  713. fsiOPFLD.MedChrgitmType = "14"
  714. break
  715. case 2:
  716. fsiOPFLD.MedChrgitmType = "05"
  717. break
  718. case 3:
  719. fsiOPFLD.MedChrgitmType = "03"
  720. break
  721. case 4:
  722. fsiOPFLD.MedChrgitmType = "03"
  723. break
  724. case 5:
  725. fsiOPFLD.MedChrgitmType = "08"
  726. break
  727. case 6:
  728. fsiOPFLD.MedChrgitmType = "14"
  729. break
  730. case 7:
  731. fsiOPFLD.MedChrgitmType = "14"
  732. break
  733. case 8:
  734. fsiOPFLD.MedChrgitmType = "03"
  735. break
  736. case 9:
  737. fsiOPFLD.MedChrgitmType = "14"
  738. break
  739. case 10:
  740. fsiOPFLD.MedChrgitmType = "14"
  741. break
  742. case 11:
  743. fsiOPFLD.MedChrgitmType = "06"
  744. break
  745. case 12:
  746. fsiOPFLD.MedChrgitmType = "12"
  747. break
  748. case 13:
  749. fsiOPFLD.MedChrgitmType = "01"
  750. break
  751. case 14:
  752. fsiOPFLD.MedChrgitmType = "04"
  753. break
  754. case 15:
  755. fsiOPFLD.MedChrgitmType = "14"
  756. break
  757. }
  758. memo["hosp_appr_flag"] = "1"
  759. memo["invoice_no"] = order.MdtrtId
  760. memo["memo"] = "自费"
  761. bytesData, _ := json.Marshal(memo)
  762. fsiOPFLD.Memo = string(bytesData)
  763. fsiOPFLDs = append(fsiOPFLDs, fsiOPFLD)
  764. } else if items.HisPrescriptionProject.Type == 3 && items.HisPrescriptionProject.GoodInfo.IsUser != 1 && len(items.HisPrescriptionProject.GoodInfo.MedicalInsuranceNumber) > 0 {
  765. fsiOPFLD.FeeOcurTime = time.Unix(items.HisPrescriptionProject.Ctime, 0).Format("2006-01-02 15:04:05")
  766. fsiOPFLD.MedListCodg = items.HisPrescriptionProject.GoodInfo.MedicalInsuranceNumber
  767. fsiOPFLD.MedinsListCodg = items.HisPrescriptionProject.GoodInfo.MedicalInsuranceNumber
  768. fsiOPFLD.BilgDeptName = department.Name
  769. fsiOPFLD.BilgDeptCodg = department.Number
  770. fsiOPFLD.BilgDrCode = doctor.DoctorNumber
  771. fsiOPFLD.BilgDrName = doctor.UserName
  772. fsiOPFLD.MedinsListName = items.HisPrescriptionProject.GoodInfo.GoodName
  773. fsiOPFLD.Prodname = items.HisPrescriptionProject.GoodInfo.GoodName
  774. fsiOPFLD.MedChrgitmType = "08"
  775. memo["hosp_appr_flag"] = "1"
  776. memo["invoice_no"] = order.MdtrtId
  777. memo["memo"] = "自费"
  778. bytesData, _ := json.Marshal(memo)
  779. fsiOPFLD.Memo = string(bytesData)
  780. fsiOPFLDs = append(fsiOPFLDs, fsiOPFLD)
  781. }
  782. }
  783. }
  784. for _, items := range order_info_two {
  785. memo := make(map[string]interface{})
  786. var fsiOPFLD models.FsiOwnpayPatnFeeListDDTO
  787. fsiOPFLD.FixmedinsMdtrtID = items.OrderNumber
  788. fsiOPFLD.MedType = "14"
  789. fsiOPFLD.BkkpSn = items.FeedetlSn
  790. fsiOPFLD.FixmedinsCode = miConfig.Code
  791. fsiOPFLD.FixmedinsName = miConfig.OrgName
  792. fsiOPFLD.Cnt = fmt.Sprintf("%.2f", items.Cnt)
  793. fsiOPFLD.Pric = fmt.Sprintf("%.2f", items.Pric)
  794. fsiOPFLD.DetItemFeeSumamt = fmt.Sprintf("%.2f", items.DetItemFeeSumamt)
  795. if items.AdviceId > 0 && items.ProjectId == 0 && items.HisDoctorAdviceInfo.BaseDrugLib.IsUser != 1 && len(items.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber) > 0 {
  796. fsiOPFLD.FeeOcurTime = time.Unix(items.HisDoctorAdviceInfo.CreatedTime, 0).Format("2006-01-02 15:04:05")
  797. fsiOPFLD.MedListCodg = items.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber
  798. fsiOPFLD.MedinsListCodg = items.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber
  799. fsiOPFLD.MedinsListName = items.HisDoctorAdviceInfo.BaseDrugLib.DrugName
  800. fsiOPFLD.Prodname = items.HisDoctorAdviceInfo.BaseDrugLib.DrugName
  801. fsiOPFLD.BilgDeptName = department.Name
  802. fsiOPFLD.BilgDeptCodg = department.Number
  803. fsiOPFLD.BilgDrCode = doctor.DoctorNumber
  804. fsiOPFLD.BilgDrName = doctor.UserName
  805. fsiOPFLD.MedChrgitmType = "09"
  806. memo["hosp_appr_flag"] = "1"
  807. memo["invoice_no"] = order.MdtrtId
  808. memo["memo"] = "自费"
  809. bytesData, _ := json.Marshal(memo)
  810. fsiOPFLD.Memo = string(bytesData)
  811. fsiOPFLDs = append(fsiOPFLDs, fsiOPFLD)
  812. } else if items.AdviceId == 0 && items.ProjectId > 0 {
  813. if items.HisPrescriptionProject.Type == 2 && len(items.HisPrescriptionProject.HisProject.MedicalCode) > 0 {
  814. fsiOPFLD.FeeOcurTime = time.Unix(items.HisPrescriptionProject.Ctime, 0).Format("2006-01-02 15:04:05")
  815. fsiOPFLD.MedListCodg = items.HisPrescriptionProject.HisProject.MedicalCode
  816. fsiOPFLD.MedinsListName = items.HisPrescriptionProject.HisProject.ProjectName
  817. fsiOPFLD.Prodname = items.HisPrescriptionProject.HisProject.ProjectName
  818. fsiOPFLD.MedinsListCodg = items.HisPrescriptionProject.HisProject.MedicalCode
  819. fsiOPFLD.BilgDeptName = department.Name
  820. fsiOPFLD.BilgDeptCodg = department.Number
  821. fsiOPFLD.BilgDrCode = doctor.DoctorNumber
  822. fsiOPFLD.BilgDrName = doctor.UserName
  823. switch items.HisPrescriptionProject.HisProject.CostClassify {
  824. case 0:
  825. break
  826. case 1:
  827. fsiOPFLD.MedChrgitmType = "14"
  828. break
  829. case 2:
  830. fsiOPFLD.MedChrgitmType = "05"
  831. break
  832. case 3:
  833. fsiOPFLD.MedChrgitmType = "03"
  834. break
  835. case 4:
  836. fsiOPFLD.MedChrgitmType = "03"
  837. break
  838. case 5:
  839. fsiOPFLD.MedChrgitmType = "08"
  840. break
  841. case 6:
  842. fsiOPFLD.MedChrgitmType = "14"
  843. break
  844. case 7:
  845. fsiOPFLD.MedChrgitmType = "14"
  846. break
  847. case 8:
  848. fsiOPFLD.MedChrgitmType = "03"
  849. break
  850. case 9:
  851. fsiOPFLD.MedChrgitmType = "14"
  852. break
  853. case 10:
  854. fsiOPFLD.MedChrgitmType = "14"
  855. break
  856. case 11:
  857. fsiOPFLD.MedChrgitmType = "06"
  858. break
  859. case 12:
  860. fsiOPFLD.MedChrgitmType = "12"
  861. break
  862. case 13:
  863. fsiOPFLD.MedChrgitmType = "01"
  864. break
  865. case 14:
  866. fsiOPFLD.MedChrgitmType = "04"
  867. break
  868. case 15:
  869. fsiOPFLD.MedChrgitmType = "14"
  870. break
  871. }
  872. memo["hosp_appr_flag"] = "1"
  873. memo["invoice_no"] = order.MdtrtId
  874. memo["memo"] = "自费"
  875. bytesData, _ := json.Marshal(memo)
  876. fsiOPFLD.Memo = string(bytesData)
  877. fsiOPFLDs = append(fsiOPFLDs, fsiOPFLD)
  878. } else if items.HisPrescriptionProject.Type == 3 && len(items.HisPrescriptionProject.GoodInfo.MedicalInsuranceNumber) > 0 && items.HisPrescriptionProject.GoodInfo.IsUser != 1 {
  879. fsiOPFLD.FeeOcurTime = time.Unix(items.HisPrescriptionProject.Ctime, 0).Format("2006-01-02 15:04:05")
  880. fsiOPFLD.MedListCodg = items.HisPrescriptionProject.GoodInfo.MedicalInsuranceNumber
  881. fsiOPFLD.MedinsListCodg = items.HisPrescriptionProject.GoodInfo.MedicalInsuranceNumber
  882. fsiOPFLD.BilgDeptName = department.Name
  883. fsiOPFLD.BilgDeptCodg = department.Number
  884. fsiOPFLD.BilgDrCode = doctor.DoctorNumber
  885. fsiOPFLD.BilgDrName = doctor.UserName
  886. fsiOPFLD.MedinsListName = items.HisPrescriptionProject.GoodInfo.GoodName
  887. fsiOPFLD.Prodname = items.HisPrescriptionProject.GoodInfo.GoodName
  888. fsiOPFLD.MedChrgitmType = "08"
  889. memo["hosp_appr_flag"] = "1"
  890. memo["invoice_no"] = order.MdtrtId
  891. memo["memo"] = "自费"
  892. bytesData, _ := json.Marshal(memo)
  893. fsiOPFLD.Memo = string(bytesData)
  894. fsiOPFLDs = append(fsiOPFLDs, fsiOPFLD)
  895. }
  896. }
  897. }
  898. fmt.Println(fsiOPFLDs)
  899. struct4201A.Fopfd = fsiOPFLDs
  900. fmt.Println(struct4201A.Fopfd)
  901. result, requestLog := service.Gdyb4201A(miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, struct4201A)
  902. saveLog(result, requestLog, "4201A", "自费费用明细上传")
  903. var res2 ResultSix
  904. var respJSON2 map[string]interface{}
  905. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  906. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  907. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  908. return
  909. }
  910. userJSONBytes2, _ := json.Marshal(respJSON2)
  911. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  912. utils.ErrorLog("解析失败:%v", err)
  913. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  914. return
  915. }
  916. if res2.Infcode != 0 {
  917. c.ServeSuccessJSON(map[string]interface{}{
  918. "failed_code": -10,
  919. "msg": res2.ErrMsg,
  920. })
  921. return
  922. } else {
  923. order.IsUploadOrderInfo = 1
  924. service.UpdateOrder(order)
  925. c.ServeSuccessJSON(map[string]interface{}{
  926. "msg": "上传成功",
  927. })
  928. }
  929. }
  930. func (c *HisApiController) Get2505() {
  931. miConfig, _ := service.FindMedicalInsuranceInfo(10215)
  932. 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")
  933. }
  934. func (c *HisApiController) Get4201A() {
  935. order_id, _ := c.GetInt64("order_id")
  936. admin_user_id, _ := c.GetInt64("admin_user_id")
  937. order, _ := service.GetHisOrderByIDTwo(order_id)
  938. his, _ := service.GetInHospitalRecordByNumber(order.MdtrtId)
  939. order_info, _ := service.GetHisOrderInfoByNumber(order.MdtrtId)
  940. order_info_two, _ := service.GetHisOrderInfoByNumberTwo(order.MdtrtId)
  941. //order_info = append(order_info, order_info_two...)
  942. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  943. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  944. department, _ := service.GetDepartMentDetail(his.Departments)
  945. pre, _ := service.GetNewHisPrescriptionByNumber(order.Number)
  946. doctor, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, pre.Creator)
  947. if order.ID == 0 {
  948. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisOrderNoExistParamWrong)
  949. return
  950. }
  951. var struct4201A models.Struct4201A
  952. var fsiOPFLDs []models.FsiOwnpayPatnFeeListDDTO
  953. for _, items := range order_info {
  954. memo := make(map[string]interface{})
  955. var fsiOPFLD models.FsiOwnpayPatnFeeListDDTO
  956. fsiOPFLD.FixmedinsMdtrtID = items.OrderNumber
  957. fsiOPFLD.MedType = "14"
  958. fsiOPFLD.BkkpSn = items.FeedetlSn
  959. fsiOPFLD.FixmedinsCode = miConfig.Code
  960. fsiOPFLD.FixmedinsName = miConfig.OrgName
  961. fsiOPFLD.Cnt = fmt.Sprintf("%.2f", items.Cnt)
  962. fsiOPFLD.Pric = fmt.Sprintf("%.2f", items.Pric)
  963. fsiOPFLD.DetItemFeeSumamt = fmt.Sprintf("%.2f", items.DetItemFeeSumamt)
  964. if items.AdviceId > 0 && items.ProjectId == 0 && items.HisDoctorAdviceInfo.BaseDrugLib.IsUser != 1 && len(items.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber) > 0 {
  965. fsiOPFLD.FeeOcurTime = time.Unix(items.HisDoctorAdviceInfo.CreatedTime, 0).Format("2006-01-02 15:04:05")
  966. fsiOPFLD.MedListCodg = items.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber
  967. fsiOPFLD.MedinsListCodg = items.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber
  968. fsiOPFLD.MedinsListName = items.HisDoctorAdviceInfo.BaseDrugLib.DrugName
  969. fsiOPFLD.Prodname = items.HisDoctorAdviceInfo.BaseDrugLib.DrugName
  970. fsiOPFLD.BilgDeptName = department.Name
  971. fsiOPFLD.BilgDeptCodg = department.Number
  972. fsiOPFLD.BilgDrCode = doctor.DoctorNumber
  973. fsiOPFLD.BilgDrName = doctor.UserName
  974. fsiOPFLD.MedChrgitmType = "09"
  975. memo["hosp_appr_flag"] = "1"
  976. memo["invoice_no"] = order.MdtrtId
  977. memo["memo"] = "自费"
  978. bytesData, _ := json.Marshal(memo)
  979. fsiOPFLD.Memo = string(bytesData)
  980. fsiOPFLDs = append(fsiOPFLDs, fsiOPFLD)
  981. } else if items.AdviceId == 0 && items.ProjectId > 0 {
  982. if items.HisPrescriptionProject.Type == 2 && len(items.HisPrescriptionProject.HisProject.MedicalCode) > 0 {
  983. fsiOPFLD.FeeOcurTime = time.Unix(items.HisPrescriptionProject.Ctime, 0).Format("2006-01-02 15:04:05")
  984. fsiOPFLD.MedListCodg = items.HisPrescriptionProject.HisProject.MedicalCode
  985. fsiOPFLD.MedinsListCodg = items.HisPrescriptionProject.HisProject.MedicalCode
  986. fsiOPFLD.MedinsListName = items.HisPrescriptionProject.HisProject.ProjectName
  987. fsiOPFLD.Prodname = items.HisPrescriptionProject.HisProject.ProjectName
  988. fsiOPFLD.BilgDeptName = department.Name
  989. fsiOPFLD.BilgDeptCodg = department.Number
  990. fsiOPFLD.BilgDrCode = doctor.DoctorNumber
  991. fsiOPFLD.BilgDrName = doctor.UserName
  992. switch items.HisPrescriptionProject.HisProject.CostClassify {
  993. case 0:
  994. break
  995. case 1:
  996. fsiOPFLD.MedChrgitmType = "14"
  997. break
  998. case 2:
  999. fsiOPFLD.MedChrgitmType = "05"
  1000. break
  1001. case 3:
  1002. fsiOPFLD.MedChrgitmType = "03"
  1003. break
  1004. case 4:
  1005. fsiOPFLD.MedChrgitmType = "03"
  1006. break
  1007. case 5:
  1008. fsiOPFLD.MedChrgitmType = "08"
  1009. break
  1010. case 6:
  1011. fsiOPFLD.MedChrgitmType = "14"
  1012. break
  1013. case 7:
  1014. fsiOPFLD.MedChrgitmType = "14"
  1015. break
  1016. case 8:
  1017. fsiOPFLD.MedChrgitmType = "03"
  1018. break
  1019. case 9:
  1020. fsiOPFLD.MedChrgitmType = "14"
  1021. break
  1022. case 10:
  1023. fsiOPFLD.MedChrgitmType = "14"
  1024. break
  1025. case 11:
  1026. fsiOPFLD.MedChrgitmType = "06"
  1027. break
  1028. case 12:
  1029. fsiOPFLD.MedChrgitmType = "12"
  1030. break
  1031. case 13:
  1032. fsiOPFLD.MedChrgitmType = "01"
  1033. break
  1034. case 14:
  1035. fsiOPFLD.MedChrgitmType = "04"
  1036. break
  1037. case 15:
  1038. fsiOPFLD.MedChrgitmType = "14"
  1039. break
  1040. }
  1041. memo["hosp_appr_flag"] = "1"
  1042. memo["invoice_no"] = order.MdtrtId
  1043. memo["memo"] = "自费"
  1044. bytesData, _ := json.Marshal(memo)
  1045. fsiOPFLD.Memo = string(bytesData)
  1046. fsiOPFLDs = append(fsiOPFLDs, fsiOPFLD)
  1047. } else if items.HisPrescriptionProject.Type == 3 && items.HisPrescriptionProject.GoodInfo.IsUser != 1 && len(items.HisPrescriptionProject.GoodInfo.MedicalInsuranceNumber) > 0 {
  1048. fsiOPFLD.FeeOcurTime = time.Unix(items.HisPrescriptionProject.Ctime, 0).Format("2006-01-02 15:04:05")
  1049. fsiOPFLD.MedListCodg = items.HisPrescriptionProject.GoodInfo.MedicalInsuranceNumber
  1050. fsiOPFLD.MedinsListCodg = items.HisPrescriptionProject.GoodInfo.MedicalInsuranceNumber
  1051. fsiOPFLD.BilgDeptName = department.Name
  1052. fsiOPFLD.BilgDeptCodg = department.Number
  1053. fsiOPFLD.BilgDrCode = doctor.DoctorNumber
  1054. fsiOPFLD.BilgDrName = doctor.UserName
  1055. fsiOPFLD.MedinsListName = items.HisPrescriptionProject.GoodInfo.GoodName
  1056. fsiOPFLD.Prodname = items.HisPrescriptionProject.GoodInfo.GoodName
  1057. fsiOPFLD.MedChrgitmType = "08"
  1058. memo["hosp_appr_flag"] = "1"
  1059. memo["invoice_no"] = order.MdtrtId
  1060. memo["memo"] = "自费"
  1061. bytesData, _ := json.Marshal(memo)
  1062. fsiOPFLD.Memo = string(bytesData)
  1063. fsiOPFLDs = append(fsiOPFLDs, fsiOPFLD)
  1064. }
  1065. }
  1066. }
  1067. for _, items := range order_info_two {
  1068. memo := make(map[string]interface{})
  1069. var fsiOPFLD models.FsiOwnpayPatnFeeListDDTO
  1070. fsiOPFLD.FixmedinsMdtrtID = items.OrderNumber
  1071. fsiOPFLD.MedType = "14"
  1072. fsiOPFLD.BkkpSn = items.FeedetlSn
  1073. fsiOPFLD.FixmedinsCode = miConfig.Code
  1074. fsiOPFLD.FixmedinsName = miConfig.OrgName
  1075. fsiOPFLD.Cnt = fmt.Sprintf("%.2f", items.Cnt)
  1076. fsiOPFLD.Pric = fmt.Sprintf("%.2f", items.Pric)
  1077. fsiOPFLD.DetItemFeeSumamt = fmt.Sprintf("%.2f", items.DetItemFeeSumamt)
  1078. if items.AdviceId > 0 && items.ProjectId == 0 && items.HisDoctorAdviceInfo.BaseDrugLib.IsUser != 1 && len(items.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber) > 0 {
  1079. fsiOPFLD.FeeOcurTime = time.Unix(items.HisDoctorAdviceInfo.CreatedTime, 0).Format("2006-01-02 15:04:05")
  1080. fsiOPFLD.MedListCodg = items.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber
  1081. fsiOPFLD.MedinsListCodg = items.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber
  1082. fsiOPFLD.MedinsListName = items.HisDoctorAdviceInfo.BaseDrugLib.DrugName
  1083. fsiOPFLD.Prodname = items.HisDoctorAdviceInfo.BaseDrugLib.DrugName
  1084. fsiOPFLD.BilgDeptName = department.Name
  1085. fsiOPFLD.BilgDeptCodg = department.Number
  1086. fsiOPFLD.BilgDrCode = doctor.DoctorNumber
  1087. fsiOPFLD.BilgDrName = doctor.UserName
  1088. fsiOPFLD.MedChrgitmType = "09"
  1089. memo["hosp_appr_flag"] = "1"
  1090. memo["invoice_no"] = order.MdtrtId
  1091. memo["memo"] = "自费"
  1092. bytesData, _ := json.Marshal(memo)
  1093. fsiOPFLD.Memo = string(bytesData)
  1094. fsiOPFLDs = append(fsiOPFLDs, fsiOPFLD)
  1095. } else if items.AdviceId == 0 && items.ProjectId > 0 {
  1096. if items.HisPrescriptionProject.Type == 2 && len(items.HisPrescriptionProject.HisProject.MedicalCode) > 0 {
  1097. fsiOPFLD.FeeOcurTime = time.Unix(items.HisPrescriptionProject.Ctime, 0).Format("2006-01-02 15:04:05")
  1098. fsiOPFLD.MedListCodg = items.HisPrescriptionProject.HisProject.MedicalCode
  1099. fsiOPFLD.MedinsListName = items.HisPrescriptionProject.HisProject.ProjectName
  1100. fsiOPFLD.Prodname = items.HisPrescriptionProject.HisProject.ProjectName
  1101. fsiOPFLD.MedinsListCodg = items.HisPrescriptionProject.HisProject.MedicalCode
  1102. fsiOPFLD.BilgDeptName = department.Name
  1103. fsiOPFLD.BilgDeptCodg = department.Number
  1104. fsiOPFLD.BilgDrCode = doctor.DoctorNumber
  1105. fsiOPFLD.BilgDrName = doctor.UserName
  1106. switch items.HisPrescriptionProject.HisProject.CostClassify {
  1107. case 0:
  1108. break
  1109. case 1:
  1110. fsiOPFLD.MedChrgitmType = "14"
  1111. break
  1112. case 2:
  1113. fsiOPFLD.MedChrgitmType = "05"
  1114. break
  1115. case 3:
  1116. fsiOPFLD.MedChrgitmType = "03"
  1117. break
  1118. case 4:
  1119. fsiOPFLD.MedChrgitmType = "03"
  1120. break
  1121. case 5:
  1122. fsiOPFLD.MedChrgitmType = "08"
  1123. break
  1124. case 6:
  1125. fsiOPFLD.MedChrgitmType = "14"
  1126. break
  1127. case 7:
  1128. fsiOPFLD.MedChrgitmType = "14"
  1129. break
  1130. case 8:
  1131. fsiOPFLD.MedChrgitmType = "03"
  1132. break
  1133. case 9:
  1134. fsiOPFLD.MedChrgitmType = "14"
  1135. break
  1136. case 10:
  1137. fsiOPFLD.MedChrgitmType = "14"
  1138. break
  1139. case 11:
  1140. fsiOPFLD.MedChrgitmType = "06"
  1141. break
  1142. case 12:
  1143. fsiOPFLD.MedChrgitmType = "12"
  1144. break
  1145. case 13:
  1146. fsiOPFLD.MedChrgitmType = "01"
  1147. break
  1148. case 14:
  1149. fsiOPFLD.MedChrgitmType = "04"
  1150. break
  1151. case 15:
  1152. fsiOPFLD.MedChrgitmType = "14"
  1153. break
  1154. }
  1155. memo["hosp_appr_flag"] = "1"
  1156. memo["invoice_no"] = order.MdtrtId
  1157. memo["memo"] = "自费"
  1158. bytesData, _ := json.Marshal(memo)
  1159. fsiOPFLD.Memo = string(bytesData)
  1160. fsiOPFLDs = append(fsiOPFLDs, fsiOPFLD)
  1161. } else if items.HisPrescriptionProject.Type == 3 && len(items.HisPrescriptionProject.GoodInfo.MedicalInsuranceNumber) > 0 && items.HisPrescriptionProject.GoodInfo.IsUser != 1 {
  1162. fsiOPFLD.FeeOcurTime = time.Unix(items.HisPrescriptionProject.Ctime, 0).Format("2006-01-02 15:04:05")
  1163. fsiOPFLD.MedListCodg = items.HisPrescriptionProject.GoodInfo.MedicalInsuranceNumber
  1164. fsiOPFLD.MedinsListCodg = items.HisPrescriptionProject.GoodInfo.MedicalInsuranceNumber
  1165. fsiOPFLD.BilgDeptName = department.Name
  1166. fsiOPFLD.BilgDeptCodg = department.Number
  1167. fsiOPFLD.BilgDrCode = doctor.DoctorNumber
  1168. fsiOPFLD.BilgDrName = doctor.UserName
  1169. fsiOPFLD.MedinsListName = items.HisPrescriptionProject.GoodInfo.GoodName
  1170. fsiOPFLD.Prodname = items.HisPrescriptionProject.GoodInfo.GoodName
  1171. fsiOPFLD.MedChrgitmType = "08"
  1172. memo["hosp_appr_flag"] = "1"
  1173. memo["invoice_no"] = order.MdtrtId
  1174. memo["memo"] = "自费"
  1175. bytesData, _ := json.Marshal(memo)
  1176. fsiOPFLD.Memo = string(bytesData)
  1177. fsiOPFLDs = append(fsiOPFLDs, fsiOPFLD)
  1178. }
  1179. }
  1180. }
  1181. fmt.Println(fsiOPFLDs)
  1182. struct4201A.Fopfd = fsiOPFLDs
  1183. fmt.Println(struct4201A.Fopfd)
  1184. result, requestLog := service.Gdyb4201A(miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, struct4201A)
  1185. saveLog(result, requestLog, "4201A", "自费费用明细上传")
  1186. var res2 ResultSix
  1187. var respJSON2 map[string]interface{}
  1188. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  1189. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  1190. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1191. return
  1192. }
  1193. userJSONBytes2, _ := json.Marshal(respJSON2)
  1194. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  1195. utils.ErrorLog("解析失败:%v", err)
  1196. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1197. return
  1198. }
  1199. if res2.Infcode != 0 {
  1200. c.ServeSuccessJSON(map[string]interface{}{
  1201. "failed_code": -10,
  1202. "msg": res2.ErrMsg,
  1203. })
  1204. return
  1205. } else {
  1206. order.IsUploadOrderInfo = 1
  1207. service.UpdateOrder(order)
  1208. c.ServeSuccessJSON(map[string]interface{}{
  1209. "msg": "上传成功",
  1210. })
  1211. }
  1212. }
  1213. func (c *HisApiController) Get4202() {
  1214. order_id, _ := c.GetInt64("order_id")
  1215. admin_user_id, _ := c.GetInt64("admin_user_id")
  1216. order, _ := service.GetHisOrderByIDTwo(order_id)
  1217. his, _ := service.GetInHospitalRecordByNumber(order.MdtrtId)
  1218. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  1219. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  1220. if order.ID == 0 {
  1221. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisOrderNoExistParamWrong)
  1222. return
  1223. }
  1224. var struct4202 models.Struct4202
  1225. struct4202.OwnPayPatnMdtrtD.FixmedinsMdtrtID = his.Number
  1226. struct4202.OwnPayPatnMdtrtD.FixmedinsCode = miConfig.Code
  1227. struct4202.OwnPayPatnMdtrtD.FixmedinsName = miConfig.OrgName
  1228. struct4202.OwnPayPatnMdtrtD.PsnCertType = "01"
  1229. struct4202.OwnPayPatnMdtrtD.Certno = his.IdCardNo
  1230. struct4202.OwnPayPatnMdtrtD.PsnName = his.Name
  1231. struct4202.OwnPayPatnMdtrtD.Begntime = his.InHosptialTime
  1232. struct4202.OwnPayPatnMdtrtD.MedType = "14"
  1233. struct4202.OwnPayPatnMdtrtD.ValiFlag = "1"
  1234. struct4202.OwnPayPatnMdtrtD.MedfeeSumamt = fmt.Sprintf("%.2f", order.MedfeeSumamt)
  1235. diagnosis_ids := strings.Split(his.Diagnosis, ",")
  1236. var config []*models.HisXtDiagnoseConfig
  1237. for _, item := range diagnosis_ids {
  1238. id, _ := strconv.ParseInt(item, 10, 64)
  1239. diagnosisConfig, _ := service.FindDiagnoseById(id)
  1240. config = append(config, &diagnosisConfig)
  1241. }
  1242. var tempDiaginfos []models.OwnPayPatnDiagListD
  1243. for index, item := range config {
  1244. if index == 0 {
  1245. var tempDiaginfo models.OwnPayPatnDiagListD
  1246. tempDiaginfo.InoutDiagType = "1"
  1247. tempDiaginfo.DiagCode = item.CountryCode
  1248. tempDiaginfo.DiagName = item.CountryContentName
  1249. tempDiaginfo.DiagType = "1"
  1250. tempDiaginfo.DiagSrtNo = "1"
  1251. tempDiaginfo.MaindiagFlag = "1"
  1252. tempDiaginfo.ValiFlag = "1"
  1253. tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  1254. } else {
  1255. var tempDiaginfo models.OwnPayPatnDiagListD
  1256. tempDiaginfo.DiagCode = item.CountryCode
  1257. tempDiaginfo.DiagName = item.CountryContentName
  1258. tempDiaginfo.DiagType = "2"
  1259. tempDiaginfo.DiagSrtNo = strconv.FormatInt(int64(index+1), 10)
  1260. tempDiaginfo.MaindiagFlag = "0"
  1261. tempDiaginfo.ValiFlag = "1"
  1262. tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  1263. }
  1264. }
  1265. struct4202.ODiagListD = tempDiaginfos
  1266. result, requestLog := service.Gdyb4202(miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, struct4202)
  1267. saveLog(result, requestLog, "4202", "自费就诊和诊断信息上传")
  1268. var res2 ResultSix
  1269. var respJSON2 map[string]interface{}
  1270. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  1271. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  1272. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1273. return
  1274. }
  1275. userJSONBytes2, _ := json.Marshal(respJSON2)
  1276. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  1277. utils.ErrorLog("解析失败:%v", err)
  1278. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1279. return
  1280. }
  1281. if res2.Infcode != 0 {
  1282. c.ServeSuccessJSON(map[string]interface{}{
  1283. "failed_code": -10,
  1284. "msg": res2.ErrMsg,
  1285. })
  1286. return
  1287. } else {
  1288. order.IsUploadDiagnose = 1
  1289. service.UpdateOrder(order)
  1290. c.ServeSuccessJSON(map[string]interface{}{
  1291. "msg": "上传成功",
  1292. })
  1293. }
  1294. }
  1295. func (c *HisApiController) Get4203() {
  1296. admin_user_id, _ := c.GetInt64("admin_user_id")
  1297. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  1298. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  1299. order_id, _ := c.GetInt64("order_id")
  1300. order, _ := service.GetHisOrderByIDTwo1111(order_id)
  1301. number := ""
  1302. his, _ := service.GetHisPatientByNumber(order.MdtrtId)
  1303. hospital, _ := service.GetInHospitalRecordByNumber(order.MdtrtId)
  1304. if his.ID == 0 {
  1305. number = hospital.Number
  1306. } else {
  1307. number = his.Number
  1308. }
  1309. result, requestLog := service.Gdyb4203(miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, number)
  1310. saveLog(result, requestLog, "4203", "自费就诊与结算明细上传完成")
  1311. var res2 ResultSix
  1312. var respJSON2 map[string]interface{}
  1313. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  1314. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  1315. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1316. return
  1317. }
  1318. userJSONBytes2, _ := json.Marshal(respJSON2)
  1319. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  1320. utils.ErrorLog("解析失败:%v", err)
  1321. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1322. return
  1323. }
  1324. if res2.Infcode != 0 {
  1325. c.ServeSuccessJSON(map[string]interface{}{
  1326. "failed_code": -10,
  1327. "msg": res2.ErrMsg,
  1328. })
  1329. return
  1330. } else {
  1331. order.IsUploadSuccess = 1
  1332. service.UpdateOrderTwo(order)
  1333. c.ServeSuccessJSON(map[string]interface{}{
  1334. "msg": "上传成功",
  1335. })
  1336. }
  1337. }
  1338. func (c *HisApiController) Get4205() {
  1339. order_id, _ := c.GetInt64("order_id")
  1340. admin_user_id, _ := c.GetInt64("admin_user_id")
  1341. fapiao_code := c.GetString("fapiao_code")
  1342. order, _ := service.GetHisOrderByIDTwo1111(order_id)
  1343. his, _ := service.GetHisPatientByNumber(order.MdtrtId)
  1344. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  1345. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  1346. order_info, _ := service.GetHisOrderInfoByNumber(order.Number)
  1347. order_info_two, _ := service.GetHisOrderInfoByNumberTwo(order.Number)
  1348. //order_info = append(order_info, order_info_two...)
  1349. department, _ := service.GetDepartMentDetail(his.Departments)
  1350. pre, _ := service.GetNewHisPrescriptionByNumber(order.Number)
  1351. doctor, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, pre.Creator)
  1352. if order.ID == 0 {
  1353. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisOrderNoExistParamWrong)
  1354. return
  1355. }
  1356. var struct4201A models.Struct4201A
  1357. var fsiOPFLDs []models.FsiOwnpayPatnFeeListDDTO
  1358. for _, items := range order_info {
  1359. memo := make(map[string]interface{})
  1360. var fsiOPFLD models.FsiOwnpayPatnFeeListDDTO
  1361. fsiOPFLD.FixmedinsMdtrtID = items.OrderNumber
  1362. fsiOPFLD.MedType = pre.MedType
  1363. fsiOPFLD.FixmedinsCode = miConfig.Code
  1364. fsiOPFLD.FixmedinsName = miConfig.OrgName
  1365. fsiOPFLD.Cnt = fmt.Sprintf("%.2f", items.Cnt)
  1366. fsiOPFLD.Pric = fmt.Sprintf("%.2f", items.Pric)
  1367. fsiOPFLD.DetItemFeeSumamt = fmt.Sprintf("%.2f", items.DetItemFeeSumamt)
  1368. if items.AdviceId > 0 && items.ProjectId == 0 && items.HisDoctorAdviceInfo.BaseDrugLib.IsUser != 1 && len(items.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber) > 0 {
  1369. fsiOPFLD.FeeOcurTime = time.Unix(items.HisDoctorAdviceInfo.CreatedTime, 0).Format("2006-01-02 15:04:05")
  1370. fsiOPFLD.MedListCodg = items.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber
  1371. fsiOPFLD.BkkpSn = items.HisDoctorAdviceInfo.FeedetlSn
  1372. fsiOPFLD.MedinsListCodg = items.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber
  1373. fsiOPFLD.MedinsListName = items.HisDoctorAdviceInfo.BaseDrugLib.DrugName
  1374. fsiOPFLD.Prodname = items.HisDoctorAdviceInfo.BaseDrugLib.DrugName
  1375. fsiOPFLD.BilgDeptName = department.Name
  1376. fsiOPFLD.BilgDeptCodg = department.Number
  1377. fsiOPFLD.BilgDrCode = doctor.DoctorNumber
  1378. fsiOPFLD.BilgDrName = doctor.UserName
  1379. fsiOPFLD.MedChrgitmType = "09"
  1380. memo["hosp_appr_flag"] = "1"
  1381. memo["invoice_no"] = fapiao_code
  1382. memo["memo"] = "自费"
  1383. bytesData, _ := json.Marshal(memo)
  1384. fsiOPFLD.Memo = string(bytesData)
  1385. fsiOPFLDs = append(fsiOPFLDs, fsiOPFLD)
  1386. } else if items.AdviceId == 0 && items.ProjectId > 0 {
  1387. fsiOPFLD.BkkpSn = items.HisPrescriptionProject.FeedetlSn
  1388. if items.HisPrescriptionProject.Type == 2 && len(items.HisPrescriptionProject.HisProject.MedicalCode) > 0 {
  1389. fsiOPFLD.FeeOcurTime = time.Unix(items.HisPrescriptionProject.Ctime, 0).Format("2006-01-02 15:04:05")
  1390. fsiOPFLD.MedListCodg = items.HisPrescriptionProject.HisProject.MedicalCode
  1391. fsiOPFLD.MedinsListCodg = items.HisPrescriptionProject.HisProject.MedicalCode
  1392. fsiOPFLD.MedinsListName = items.HisPrescriptionProject.HisProject.ProjectName
  1393. fsiOPFLD.Prodname = items.HisPrescriptionProject.HisProject.ProjectName
  1394. fsiOPFLD.BilgDeptName = department.Name
  1395. fsiOPFLD.BilgDeptCodg = department.Number
  1396. fsiOPFLD.BilgDrCode = doctor.DoctorNumber
  1397. fsiOPFLD.BilgDrName = doctor.UserName
  1398. switch items.HisPrescriptionProject.HisProject.CostClassify {
  1399. case 0:
  1400. break
  1401. case 1:
  1402. fsiOPFLD.MedChrgitmType = "14"
  1403. break
  1404. case 2:
  1405. fsiOPFLD.MedChrgitmType = "05"
  1406. break
  1407. case 3:
  1408. fsiOPFLD.MedChrgitmType = "03"
  1409. break
  1410. case 4:
  1411. fsiOPFLD.MedChrgitmType = "03"
  1412. break
  1413. case 5:
  1414. fsiOPFLD.MedChrgitmType = "08"
  1415. break
  1416. case 6:
  1417. fsiOPFLD.MedChrgitmType = "14"
  1418. break
  1419. case 7:
  1420. fsiOPFLD.MedChrgitmType = "14"
  1421. break
  1422. case 8:
  1423. fsiOPFLD.MedChrgitmType = "03"
  1424. break
  1425. case 9:
  1426. fsiOPFLD.MedChrgitmType = "14"
  1427. break
  1428. case 10:
  1429. fsiOPFLD.MedChrgitmType = "14"
  1430. break
  1431. case 11:
  1432. fsiOPFLD.MedChrgitmType = "06"
  1433. break
  1434. case 12:
  1435. fsiOPFLD.MedChrgitmType = "12"
  1436. break
  1437. case 13:
  1438. fsiOPFLD.MedChrgitmType = "01"
  1439. break
  1440. case 14:
  1441. fsiOPFLD.MedChrgitmType = "04"
  1442. break
  1443. case 15:
  1444. fsiOPFLD.MedChrgitmType = "14"
  1445. break
  1446. }
  1447. memo["hosp_appr_flag"] = "1"
  1448. memo["invoice_no"] = fapiao_code
  1449. memo["memo"] = "自费"
  1450. bytesData, _ := json.Marshal(memo)
  1451. fsiOPFLD.Memo = string(bytesData)
  1452. fsiOPFLDs = append(fsiOPFLDs, fsiOPFLD)
  1453. } else if items.HisPrescriptionProject.Type == 3 && items.HisPrescriptionProject.GoodInfo.IsUser != 1 && len(items.HisPrescriptionProject.GoodInfo.MedicalInsuranceNumber) > 0 {
  1454. fsiOPFLD.FeeOcurTime = time.Unix(items.HisPrescriptionProject.Ctime, 0).Format("2006-01-02 15:04:05")
  1455. fsiOPFLD.MedListCodg = items.HisPrescriptionProject.GoodInfo.MedicalInsuranceNumber
  1456. fsiOPFLD.MedinsListCodg = items.HisPrescriptionProject.GoodInfo.MedicalInsuranceNumber
  1457. fsiOPFLD.BilgDeptName = department.Name
  1458. fsiOPFLD.BilgDeptCodg = department.Number
  1459. fsiOPFLD.BilgDrCode = doctor.DoctorNumber
  1460. fsiOPFLD.BilgDrName = doctor.UserName
  1461. fsiOPFLD.MedinsListName = items.HisPrescriptionProject.GoodInfo.GoodName
  1462. fsiOPFLD.Prodname = items.HisPrescriptionProject.GoodInfo.GoodName
  1463. fsiOPFLD.MedChrgitmType = "08"
  1464. memo["hosp_appr_flag"] = "1"
  1465. memo["invoice_no"] = fapiao_code
  1466. memo["memo"] = "自费"
  1467. bytesData, _ := json.Marshal(memo)
  1468. fsiOPFLD.Memo = string(bytesData)
  1469. fsiOPFLDs = append(fsiOPFLDs, fsiOPFLD)
  1470. }
  1471. }
  1472. }
  1473. for _, items := range order_info_two {
  1474. memo := make(map[string]interface{})
  1475. var fsiOPFLD models.FsiOwnpayPatnFeeListDDTO
  1476. fsiOPFLD.FixmedinsMdtrtID = items.OrderNumber
  1477. fsiOPFLD.MedType = pre.MedType
  1478. fsiOPFLD.BkkpSn = items.FeedetlSn
  1479. fsiOPFLD.FixmedinsCode = miConfig.Code
  1480. fsiOPFLD.FixmedinsName = miConfig.OrgName
  1481. fsiOPFLD.Cnt = fmt.Sprintf("%.2f", items.Cnt)
  1482. fsiOPFLD.Pric = fmt.Sprintf("%.2f", items.Pric)
  1483. fsiOPFLD.DetItemFeeSumamt = fmt.Sprintf("%.2f", items.DetItemFeeSumamt)
  1484. if items.AdviceId > 0 && items.ProjectId == 0 && items.HisDoctorAdviceInfo.BaseDrugLib.IsUser != 1 && len(items.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber) > 0 {
  1485. fsiOPFLD.FeeOcurTime = time.Unix(items.HisDoctorAdviceInfo.CreatedTime, 0).Format("2006-01-02 15:04:05")
  1486. fsiOPFLD.MedListCodg = items.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber
  1487. fsiOPFLD.MedinsListCodg = items.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber
  1488. fsiOPFLD.MedinsListName = items.HisDoctorAdviceInfo.BaseDrugLib.DrugName
  1489. fsiOPFLD.Prodname = items.HisDoctorAdviceInfo.BaseDrugLib.DrugName
  1490. fsiOPFLD.BilgDeptName = department.Name
  1491. fsiOPFLD.BilgDeptCodg = department.Number
  1492. fsiOPFLD.BilgDrCode = doctor.DoctorNumber
  1493. fsiOPFLD.BilgDrName = doctor.UserName
  1494. fsiOPFLD.MedChrgitmType = "09"
  1495. memo["hosp_appr_flag"] = "1"
  1496. memo["invoice_no"] = fapiao_code
  1497. memo["memo"] = "自费"
  1498. bytesData, _ := json.Marshal(memo)
  1499. fsiOPFLD.Memo = string(bytesData)
  1500. fsiOPFLDs = append(fsiOPFLDs, fsiOPFLD)
  1501. } else if items.AdviceId == 0 && items.ProjectId > 0 {
  1502. fsiOPFLD.BkkpSn = items.HisPrescriptionProject.FeedetlSn
  1503. if items.HisPrescriptionProject.Type == 2 && len(items.HisPrescriptionProject.HisProject.MedicalCode) > 0 {
  1504. fsiOPFLD.FeeOcurTime = time.Unix(items.HisPrescriptionProject.Ctime, 0).Format("2006-01-02 15:04:05")
  1505. fsiOPFLD.MedListCodg = items.HisPrescriptionProject.HisProject.MedicalCode
  1506. fsiOPFLD.MedinsListName = items.HisPrescriptionProject.HisProject.ProjectName
  1507. fsiOPFLD.Prodname = items.HisPrescriptionProject.HisProject.ProjectName
  1508. fsiOPFLD.MedinsListCodg = items.HisPrescriptionProject.HisProject.MedicalCode
  1509. fsiOPFLD.BilgDeptName = department.Name
  1510. fsiOPFLD.BilgDeptCodg = department.Number
  1511. fsiOPFLD.BilgDrCode = doctor.DoctorNumber
  1512. fsiOPFLD.BilgDrName = doctor.UserName
  1513. switch items.HisPrescriptionProject.HisProject.CostClassify {
  1514. case 0:
  1515. break
  1516. case 1:
  1517. fsiOPFLD.MedChrgitmType = "14"
  1518. break
  1519. case 2:
  1520. fsiOPFLD.MedChrgitmType = "05"
  1521. break
  1522. case 3:
  1523. fsiOPFLD.MedChrgitmType = "03"
  1524. break
  1525. case 4:
  1526. fsiOPFLD.MedChrgitmType = "03"
  1527. break
  1528. case 5:
  1529. fsiOPFLD.MedChrgitmType = "08"
  1530. break
  1531. case 6:
  1532. fsiOPFLD.MedChrgitmType = "14"
  1533. break
  1534. case 7:
  1535. fsiOPFLD.MedChrgitmType = "14"
  1536. break
  1537. case 8:
  1538. fsiOPFLD.MedChrgitmType = "03"
  1539. break
  1540. case 9:
  1541. fsiOPFLD.MedChrgitmType = "14"
  1542. break
  1543. case 10:
  1544. fsiOPFLD.MedChrgitmType = "14"
  1545. break
  1546. case 11:
  1547. fsiOPFLD.MedChrgitmType = "06"
  1548. break
  1549. case 12:
  1550. fsiOPFLD.MedChrgitmType = "12"
  1551. break
  1552. case 13:
  1553. fsiOPFLD.MedChrgitmType = "01"
  1554. break
  1555. case 14:
  1556. fsiOPFLD.MedChrgitmType = "04"
  1557. break
  1558. case 15:
  1559. fsiOPFLD.MedChrgitmType = "14"
  1560. break
  1561. }
  1562. memo["hosp_appr_flag"] = "1"
  1563. memo["invoice_no"] = fapiao_code
  1564. memo["memo"] = "自费"
  1565. bytesData, _ := json.Marshal(memo)
  1566. fsiOPFLD.Memo = string(bytesData)
  1567. fsiOPFLDs = append(fsiOPFLDs, fsiOPFLD)
  1568. } else if items.HisPrescriptionProject.Type == 3 && len(items.HisPrescriptionProject.GoodInfo.MedicalInsuranceNumber) > 0 && items.HisPrescriptionProject.GoodInfo.IsUser != 1 {
  1569. fsiOPFLD.FeeOcurTime = time.Unix(items.HisPrescriptionProject.Ctime, 0).Format("2006-01-02 15:04:05")
  1570. fsiOPFLD.MedListCodg = items.HisPrescriptionProject.GoodInfo.MedicalInsuranceNumber
  1571. fsiOPFLD.MedinsListCodg = items.HisPrescriptionProject.GoodInfo.MedicalInsuranceNumber
  1572. fsiOPFLD.BilgDeptName = department.Name
  1573. fsiOPFLD.BilgDeptCodg = department.Number
  1574. fsiOPFLD.BilgDrCode = doctor.DoctorNumber
  1575. fsiOPFLD.BilgDrName = doctor.UserName
  1576. fsiOPFLD.MedinsListName = items.HisPrescriptionProject.GoodInfo.GoodName
  1577. fsiOPFLD.Prodname = items.HisPrescriptionProject.GoodInfo.GoodName
  1578. fsiOPFLD.MedChrgitmType = "08"
  1579. memo["hosp_appr_flag"] = "1"
  1580. memo["invoice_no"] = fapiao_code
  1581. memo["memo"] = "自费"
  1582. bytesData, _ := json.Marshal(memo)
  1583. fsiOPFLD.Memo = string(bytesData)
  1584. fsiOPFLDs = append(fsiOPFLDs, fsiOPFLD)
  1585. }
  1586. }
  1587. }
  1588. fmt.Println(fsiOPFLDs)
  1589. struct4201A.Fopfd = fsiOPFLDs
  1590. fmt.Println(struct4201A.Fopfd)
  1591. var struct4202 models.Struct4202
  1592. timeLayout := "2006-01-02 15:04:05"
  1593. dataTimeStr := time.Unix(his.Ctime, 0).Format(timeLayout)
  1594. struct4202.OwnPayPatnMdtrtD.FixmedinsMdtrtID = his.Number
  1595. struct4202.OwnPayPatnMdtrtD.FixmedinsCode = miConfig.Code
  1596. struct4202.OwnPayPatnMdtrtD.FixmedinsName = miConfig.OrgName
  1597. struct4202.OwnPayPatnMdtrtD.PsnCertType = "01"
  1598. struct4202.OwnPayPatnMdtrtD.Certno = his.IdCardNo
  1599. struct4202.OwnPayPatnMdtrtD.PsnName = his.Name
  1600. struct4202.OwnPayPatnMdtrtD.Begntime = dataTimeStr
  1601. struct4202.OwnPayPatnMdtrtD.MedType = pre.MedType
  1602. struct4202.OwnPayPatnMdtrtD.ValiFlag = "1"
  1603. struct4202.OwnPayPatnMdtrtD.MedfeeSumamt = fmt.Sprintf("%.2f", order.MedfeeSumamt)
  1604. diagnosis_ids := strings.Split(his.Diagnosis, ",")
  1605. var config []*models.HisXtDiagnoseConfig
  1606. for _, item := range diagnosis_ids {
  1607. id, _ := strconv.ParseInt(item, 10, 64)
  1608. diagnosisConfig, _ := service.FindDiagnoseById(id)
  1609. config = append(config, &diagnosisConfig)
  1610. }
  1611. var tempDiaginfos []models.OwnPayPatnDiagListD
  1612. for index, item := range config {
  1613. if index == 0 {
  1614. var tempDiaginfo models.OwnPayPatnDiagListD
  1615. tempDiaginfo.InoutDiagType = "1"
  1616. tempDiaginfo.DiagCode = item.CountryCode
  1617. tempDiaginfo.DiagName = item.CountryContentName
  1618. tempDiaginfo.DiagType = "1"
  1619. tempDiaginfo.DiagSrtNo = "1"
  1620. tempDiaginfo.MaindiagFlag = "1"
  1621. tempDiaginfo.ValiFlag = "1"
  1622. tempDiaginfo.DiagDrName = doctor.UserName
  1623. tempDiaginfo.DiagDrCode = doctor.DoctorNumber
  1624. tempDiaginfo.DiagTime = time.Unix(pre.Ctime, 0).Format("2006-01-02 15:04:05")
  1625. tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  1626. } else {
  1627. var tempDiaginfo models.OwnPayPatnDiagListD
  1628. tempDiaginfo.DiagCode = item.CountryCode
  1629. tempDiaginfo.DiagName = item.CountryContentName
  1630. tempDiaginfo.DiagType = "2"
  1631. tempDiaginfo.DiagSrtNo = strconv.FormatInt(int64(index+1), 10)
  1632. tempDiaginfo.MaindiagFlag = "0"
  1633. tempDiaginfo.ValiFlag = "1"
  1634. tempDiaginfo.DiagDrName = doctor.UserName
  1635. tempDiaginfo.DiagDrCode = doctor.DoctorNumber
  1636. tempDiaginfo.DiagTime = time.Unix(pre.Ctime, 0).Format("2006-01-02 15:04:05")
  1637. tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  1638. }
  1639. }
  1640. struct4202.ODiagListD = tempDiaginfos
  1641. result, requestLog := service.Gdyb4205(miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, struct4202, struct4201A)
  1642. saveLog(result, requestLog, "4205", "自费就诊和诊断信息上传")
  1643. var res2 ResultSix
  1644. var respJSON2 map[string]interface{}
  1645. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  1646. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  1647. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1648. return
  1649. }
  1650. userJSONBytes2, _ := json.Marshal(respJSON2)
  1651. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  1652. utils.ErrorLog("解析失败:%v", err)
  1653. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1654. return
  1655. }
  1656. if res2.Infcode != 0 {
  1657. c.ServeSuccessJSON(map[string]interface{}{
  1658. "failed_code": -10,
  1659. "msg": res2.ErrMsg,
  1660. })
  1661. return
  1662. } else {
  1663. order.IsUploadDiagnose = 1
  1664. order.IsUploadOrderInfo = 1
  1665. service.UpdateOrderTwo(order)
  1666. c.ServeSuccessJSON(map[string]interface{}{
  1667. "msg": "上传成功",
  1668. })
  1669. }
  1670. }
  1671. func (c *HisApiController) Get4207() {
  1672. admin_user_id, _ := c.GetInt64("admin_user_id")
  1673. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  1674. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  1675. order_id, _ := c.GetInt64("order_id")
  1676. order, _ := service.GetHisOrderByIDTwo(order_id)
  1677. //his, _ := service.GetInHospitalRecordByNumber(order.MdtrtId)
  1678. var struct4207 models.Struct4207
  1679. struct4207.PageNum = "1"
  1680. struct4207.PageSize = "1000"
  1681. struct4207.FixmedinsCode = miConfig.Code
  1682. struct4207.FixmedinsMdtrtID = order.Number
  1683. result, requestLog := service.Gdyb4207(miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, struct4207)
  1684. saveLog(result, requestLog, "4207", "查询")
  1685. var res2 ResultSix
  1686. var respJSON2 map[string]interface{}
  1687. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  1688. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  1689. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1690. return
  1691. }
  1692. userJSONBytes2, _ := json.Marshal(respJSON2)
  1693. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  1694. utils.ErrorLog("解析失败:%v", err)
  1695. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1696. return
  1697. }
  1698. if res2.Infcode != 0 {
  1699. c.ServeSuccessJSON(map[string]interface{}{
  1700. "failed_code": -10,
  1701. "msg": res2.ErrMsg,
  1702. })
  1703. return
  1704. } else {
  1705. c.ServeSuccessJSON(map[string]interface{}{
  1706. "msg": "查询成功",
  1707. })
  1708. }
  1709. }
  1710. func (c *HisApiController) Get4208() {
  1711. admin_user_id, _ := c.GetInt64("admin_user_id")
  1712. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  1713. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  1714. order_id, _ := c.GetInt64("order_id")
  1715. order, _ := service.GetHisOrderByIDTwo(order_id)
  1716. his, _ := service.GetInHospitalRecordByNumber(order.MdtrtId)
  1717. var struct4208 models.Struct4208
  1718. struct4208.PageNum = "1"
  1719. struct4208.PageSize = "1000"
  1720. struct4208.PsnCertType = "01"
  1721. struct4208.Certno = his.Certno
  1722. struct4208.MedType = order.MedType
  1723. struct4208.PsnName = his.Name
  1724. result, requestLog := service.Gdyb4208(miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, struct4208)
  1725. saveLog(result, requestLog, "4208", "查询")
  1726. var res2 ResultSix
  1727. var respJSON2 map[string]interface{}
  1728. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  1729. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  1730. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1731. return
  1732. }
  1733. userJSONBytes2, _ := json.Marshal(respJSON2)
  1734. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  1735. utils.ErrorLog("解析失败:%v", err)
  1736. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1737. return
  1738. }
  1739. if res2.Infcode != 0 {
  1740. c.ServeSuccessJSON(map[string]interface{}{
  1741. "failed_code": -10,
  1742. "msg": res2.ErrMsg,
  1743. })
  1744. return
  1745. } else {
  1746. c.ServeSuccessJSON(map[string]interface{}{
  1747. "msg": "查询成功",
  1748. })
  1749. }
  1750. }
  1751. func (c *HisApiController) Get4209() {
  1752. admin_user_id, _ := c.GetInt64("admin_user_id")
  1753. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  1754. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  1755. order_id, _ := c.GetInt64("order_id")
  1756. order, _ := service.GetHisOrderByIDTwo(order_id)
  1757. //his, _ := service.GetInHospitalRecordByNumber(order.MdtrtId)
  1758. var struct4209 models.Struct4209
  1759. struct4209.FixmedinsMdtrtID = order.Number
  1760. struct4209.FixmedinsCode = miConfig.Code
  1761. struct4209.PageSize = "1000"
  1762. struct4209.PageNum = "1"
  1763. result, requestLog := service.Gdyb4209(miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, struct4209)
  1764. saveLog(result, requestLog, "4209", "查询")
  1765. var res2 ResultSix
  1766. var respJSON2 map[string]interface{}
  1767. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  1768. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  1769. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1770. return
  1771. }
  1772. userJSONBytes2, _ := json.Marshal(respJSON2)
  1773. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  1774. utils.ErrorLog("解析失败:%v", err)
  1775. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1776. return
  1777. }
  1778. if res2.Infcode != 0 {
  1779. c.ServeSuccessJSON(map[string]interface{}{
  1780. "failed_code": -10,
  1781. "msg": res2.ErrMsg,
  1782. })
  1783. return
  1784. } else {
  1785. c.ServeSuccessJSON(map[string]interface{}{
  1786. "msg": "查询成功",
  1787. })
  1788. }
  1789. }
  1790. type Result3101 struct {
  1791. Infcode string `json:"infcode"`
  1792. InfRefmsgid string `json:"inf_refmsgid"`
  1793. RefmsgTime string `json:"refmsg_time"`
  1794. RespondTime string `json:"respond_time"`
  1795. Enctype string `json:"enctype"`
  1796. Signtype string `json:"signtype"`
  1797. ErrMsg string `json:"err_msg"`
  1798. Output struct {
  1799. Result []struct {
  1800. JudgeResultDetailDtos []struct {
  1801. VolaItemType string `json:"vola_item_type"`
  1802. MdtrtID string `json:"mdtrt_id"`
  1803. JrdID string `json:"jrd_id"`
  1804. PatnID string `json:"patn_id"`
  1805. RxID string `json:"rx_id"`
  1806. VolaAmt interface{} `json:"vola_amt"`
  1807. } `json:"judge_result_detail_dtos"`
  1808. RuleID string `json:"rule_id"`
  1809. VolaEvid string `json:"vola_evid"`
  1810. MdtrtID string `json:"mdtrt_id"`
  1811. RuleName string `json:"rule_name"`
  1812. VolaAmtStas string `json:"vola_amt_stas"`
  1813. JrID string `json:"jr_id"`
  1814. PatnID string `json:"patn_id"`
  1815. SevDeg string `json:"sev_deg"`
  1816. VolaAmt float64 `json:"vola_amt"`
  1817. VolaBhvrType string `json:"vola_bhvr_type"`
  1818. VolaCont string `json:"vola_cont"`
  1819. } `json:"result"`
  1820. } `json:"output"`
  1821. }
  1822. func (c *HisApiController) ReadEleToken() {
  1823. admin_user_id, _ := c.GetInt64("admin_user_id")
  1824. his_patient_id, _ := c.GetInt64("his_patient_id")
  1825. adminUser := c.GetAdminUserInfo()
  1826. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  1827. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  1828. his, _ := service.GetNewHisPatientInfoFour(c.GetAdminUserInfo().CurrentOrgId, his_patient_id)
  1829. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  1830. tokens := ReadEleCard(admin_user_id, c.GetAdminUserInfo().CurrentOrgId, c)
  1831. if len(tokens) > 0 {
  1832. c.ServeSuccessJSON(map[string]interface{}{
  1833. "msg": "读取成功",
  1834. })
  1835. } else {
  1836. c.ServeSuccessJSON(map[string]interface{}{
  1837. "failed_code": -10,
  1838. "msg": "读取失败",
  1839. })
  1840. }
  1841. } else if miConfig.MdtrtareaAdmvs == "350500" {
  1842. _, outPutInfo, errMsg := service.ReadEleCardForSettle(miConfig.Code, roles.UserName, roles.AdminUserId)
  1843. if len(errMsg) == 0 {
  1844. type ELeData struct {
  1845. Data struct {
  1846. IdNo string `json:"idNo"`
  1847. IdType string `json:"idType"`
  1848. UserName string `json:"userName"`
  1849. EcToken string `json:"ecToken"`
  1850. InsuOrg string `json:"insuOrg"`
  1851. Gender string `json:"gender"`
  1852. Birthday string `json:"birthday"`
  1853. Nationality string `json:"nationality"`
  1854. Email string `json:"email"`
  1855. Extra string `json:"extra"`
  1856. } `json:"data"`
  1857. Code int `json:"code"`
  1858. Message string `json:"message"`
  1859. }
  1860. var ele ELeData
  1861. err := json.Unmarshal([]byte(outPutInfo), &ele)
  1862. if err != nil {
  1863. utils.ErrorLog("解析失败:%v", err)
  1864. }
  1865. token := ele.Data.EcToken
  1866. if len(token) > 0 {
  1867. psn := &models.HisPsn{
  1868. PsnNo: his.PsnNo,
  1869. Age: 0,
  1870. PatientId: his.PatientId,
  1871. Certno: his.Certno,
  1872. Brdy: his.Brdy,
  1873. Gend: his.Gend,
  1874. Naty: his.Naty,
  1875. PsnCertType: his.PsnCertType,
  1876. PsnName: his.PsnName,
  1877. Idetinfo: his.Idetinfo,
  1878. Insuinfo: his.Iinfo,
  1879. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  1880. CardInfo: outPutInfo,
  1881. VerifyNumber: token,
  1882. }
  1883. service.CreateHisPsn(psn)
  1884. }
  1885. if len(token) > 0 {
  1886. c.ServeSuccessJSON(map[string]interface{}{
  1887. "msg": "读取成功",
  1888. })
  1889. } else {
  1890. c.ServeSuccessJSON(map[string]interface{}{
  1891. "failed_code": -10,
  1892. "msg": "读取失败",
  1893. })
  1894. }
  1895. }
  1896. } else if miConfig.MdtrtareaAdmvs == "360399" {
  1897. if initFlag == 0 {
  1898. c.TestGetJiangXiBasBaseInit()
  1899. }
  1900. json_result := GetJxEleBaseInfo(c.GetAdminUserInfo().CurrentOrgId)
  1901. type ELeData struct {
  1902. Data struct {
  1903. IdNo string `json:"idNo"`
  1904. IdType string `json:"idType"`
  1905. UserName string `json:"userName"`
  1906. EcToken string `json:"ecToken"`
  1907. InsuOrg string `json:"insuOrg"`
  1908. Gender string `json:"gender"`
  1909. Birthday string `json:"birthday"`
  1910. Nationality string `json:"nationality"`
  1911. Email string `json:"email"`
  1912. Extra string `json:"extra"`
  1913. } `json:"data"`
  1914. Code int `json:"code"`
  1915. Message string `json:"message"`
  1916. }
  1917. var ele ELeData
  1918. err := json.Unmarshal([]byte(json_result), &ele)
  1919. if err != nil {
  1920. utils.ErrorLog("解析失败:%v", err)
  1921. }
  1922. token := ele.Data.EcToken
  1923. token = Remove0000(token)
  1924. fmt.Println(ele.Data.UserName)
  1925. 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)
  1926. saveLog(result2, requestLog2, "1101", "获取人员信息")
  1927. var res ResultTwo
  1928. if err := json.Unmarshal([]byte(result2), &res); err != nil {
  1929. utils.ErrorLog("解析失败:%v", err)
  1930. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1931. return
  1932. }
  1933. if res.Infcode == 0 {
  1934. patient, err := service.GetPatientByNumber(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  1935. if err == gorm.ErrRecordNotFound {
  1936. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  1937. return
  1938. } else if err != nil {
  1939. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  1940. return
  1941. } else {
  1942. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  1943. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  1944. infoStr := string(Iinfos)
  1945. idetinfoStr := string(Idetinfos)
  1946. psn := &models.HisPsn{
  1947. PsnNo: res.Output.Baseinfo.PsnNo,
  1948. Age: res.Output.Baseinfo.Age,
  1949. PatientId: patient.ID,
  1950. Certno: res.Output.Baseinfo.Certno,
  1951. Brdy: res.Output.Baseinfo.Brdy,
  1952. Gend: res.Output.Baseinfo.Gend,
  1953. Naty: res.Output.Baseinfo.Naty,
  1954. PsnCertType: res.Output.Baseinfo.PsnCertType,
  1955. PsnName: res.Output.Baseinfo.PsnName,
  1956. Idetinfo: idetinfoStr,
  1957. Insuinfo: infoStr,
  1958. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  1959. CardInfo: "",
  1960. VerifyNumber: token,
  1961. }
  1962. service.CreateHisPsn(psn)
  1963. c.ServeSuccessJSON(map[string]interface{}{
  1964. "patient": patient,
  1965. "number": token,
  1966. })
  1967. }
  1968. } else {
  1969. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  1970. return
  1971. }
  1972. } else if miConfig.MdtrtareaAdmvs == "430800" {
  1973. idNo := c.GetString("idNo")
  1974. userName := c.GetString("userName")
  1975. ecToken := c.GetString("ecToken")
  1976. insuOrg := c.GetString("insuOrg")
  1977. result2, requestLog2 := service.Hnyb1101ForEleCert(miConfig.OrgName, roles.UserName, miConfig.Code, insuOrg, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, miConfig.Url, miConfig.AccessKey, ecToken, "", idNo, userName)
  1978. saveLog(result2, requestLog2, "1101", "获取人员信息")
  1979. var res ResultTwo
  1980. if err := json.Unmarshal([]byte(result2), &res); err != nil {
  1981. utils.ErrorLog("解析失败:%v", err)
  1982. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1983. return
  1984. }
  1985. if res.Infcode == 0 {
  1986. patient, err := service.GetPatientByNumber(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  1987. if err == gorm.ErrRecordNotFound {
  1988. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  1989. return
  1990. } else if err != nil {
  1991. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  1992. return
  1993. } else {
  1994. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  1995. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  1996. infoStr := string(Iinfos)
  1997. idetinfoStr := string(Idetinfos)
  1998. psn := &models.HisPsn{
  1999. PsnNo: res.Output.Baseinfo.PsnNo,
  2000. Age: res.Output.Baseinfo.Age,
  2001. PatientId: patient.ID,
  2002. Certno: res.Output.Baseinfo.Certno,
  2003. Brdy: res.Output.Baseinfo.Brdy,
  2004. Gend: res.Output.Baseinfo.Gend,
  2005. Naty: res.Output.Baseinfo.Naty,
  2006. PsnCertType: res.Output.Baseinfo.PsnCertType,
  2007. PsnName: res.Output.Baseinfo.PsnName,
  2008. Idetinfo: idetinfoStr,
  2009. Insuinfo: infoStr,
  2010. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  2011. CardInfo: "",
  2012. VerifyNumber: ecToken,
  2013. InsuplcAdmdvs: insuOrg,
  2014. }
  2015. service.CreateHisPsn(psn)
  2016. c.ServeSuccessJSON(map[string]interface{}{
  2017. "patient": patient,
  2018. "number": ecToken,
  2019. })
  2020. }
  2021. } else {
  2022. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  2023. return
  2024. }
  2025. } else {
  2026. //if initFlag == 0 {
  2027. // c.TestGetBasBaseInit()
  2028. //}
  2029. //token := c.GetEleBaseInfo()
  2030. //token = Remove0000(token)
  2031. type ELeData struct {
  2032. Code string `json:"code"`
  2033. Data struct {
  2034. Aac002 string `json:"aac002"`
  2035. Aaz500 string `json:"aaz500"`
  2036. ActCardNo string `json:"actCardNo"`
  2037. Bab520 string `json:"bab520"`
  2038. Bkz543 string `json:"bkz543"`
  2039. BusinessType string `json:"businessType"`
  2040. CertfCodg string `json:"certfCodg"`
  2041. EcIndexNo string `json:"ecIndexNo"`
  2042. EcToken string `json:"ecToken"`
  2043. ID0000 string `json:"id0000"`
  2044. IDNo string `json:"idNo"`
  2045. IDType string `json:"idType"`
  2046. Idcode string `json:"idcode"`
  2047. IdentityToken string `json:"identity_token"`
  2048. InsuOrg string `json:"insuOrg"`
  2049. OfficeID string `json:"officeId"`
  2050. OfficeName string `json:"officeName"`
  2051. OperatorID string `json:"operatorId"`
  2052. OperatorName string `json:"operatorName"`
  2053. OrgID string `json:"orgId"`
  2054. UserName string `json:"userName"`
  2055. } `json:"data"`
  2056. Infno interface{} `json:"infno"`
  2057. Message string `json:"message"`
  2058. OrgID string `json:"orgId"`
  2059. TransType string `json:"transType"`
  2060. }
  2061. _, result := GetELeInfoThree(miConfig.Code, "1", roles.UserName)
  2062. fmt.Println(result)
  2063. outPutInfo := Remove0000(result)
  2064. fmt.Println(outPutInfo)
  2065. var ele ELeData
  2066. err := json.Unmarshal([]byte(outPutInfo), &ele)
  2067. if err != nil {
  2068. utils.ErrorLog("解析失败:%v", err)
  2069. }
  2070. token := ele.Data.EcToken
  2071. if len(token) > 0 {
  2072. result2, requestLog2 := service.Gdyb1101ForEleCerttwo(miConfig.OrgName, roles.UserName, miConfig.Code, ele.Data.InsuOrg, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, token, ele.Data.UserName, ele.Data.IDNo)
  2073. saveLog(result2, requestLog2, "1101", "获取人员信息")
  2074. var res ResultTwo
  2075. if err := json.Unmarshal([]byte(result2), &res); err != nil {
  2076. utils.ErrorLog("解析失败:%v", err)
  2077. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2078. return
  2079. }
  2080. if res.Infcode == 0 {
  2081. patient, err := service.GetPatientByNumber(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  2082. if err == gorm.ErrRecordNotFound {
  2083. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  2084. return
  2085. } else if err != nil {
  2086. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  2087. return
  2088. } else {
  2089. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  2090. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  2091. infoStr := string(Iinfos)
  2092. idetinfoStr := string(Idetinfos)
  2093. psn := &models.HisPsn{
  2094. PsnNo: res.Output.Baseinfo.PsnNo,
  2095. Age: res.Output.Baseinfo.Age,
  2096. PatientId: patient.ID,
  2097. Certno: res.Output.Baseinfo.Certno,
  2098. Brdy: res.Output.Baseinfo.Brdy,
  2099. Gend: res.Output.Baseinfo.Gend,
  2100. Naty: res.Output.Baseinfo.Naty,
  2101. PsnCertType: res.Output.Baseinfo.PsnCertType,
  2102. PsnName: res.Output.Baseinfo.PsnName,
  2103. Idetinfo: idetinfoStr,
  2104. Insuinfo: infoStr,
  2105. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  2106. CardInfo: "",
  2107. VerifyNumber: token,
  2108. }
  2109. service.CreateHisPsn(psn)
  2110. c.ServeSuccessJSON(map[string]interface{}{
  2111. "msg": "读取成功",
  2112. })
  2113. }
  2114. } else {
  2115. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  2116. return
  2117. }
  2118. } else {
  2119. c.ServeSuccessJSON(map[string]interface{}{
  2120. "failed_code": -10,
  2121. "msg": "读取失败",
  2122. })
  2123. }
  2124. }
  2125. }
  2126. func (c *HisApiController) Get9001() {
  2127. adminUser := c.GetAdminUserInfo()
  2128. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  2129. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, 185)
  2130. if miConfig.MdtrtareaAdmvs == "350500" {
  2131. service.GetFjAuthorizationInfo(miConfig.Code)
  2132. } else if miConfig.MdtrtareaAdmvs == "131023" {
  2133. result, _ := service.HeBeiyb9001(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, 1669)
  2134. var dat map[string]interface{}
  2135. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  2136. fmt.Println(dat)
  2137. } else {
  2138. fmt.Println(err)
  2139. }
  2140. userJSONBytes, _ := json.Marshal(dat)
  2141. var res models.Result9001
  2142. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  2143. utils.ErrorLog("解析失败:%v", err)
  2144. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2145. return
  2146. }
  2147. } else {
  2148. result, _ := service.Gdyb9001(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, 1669)
  2149. var dat map[string]interface{}
  2150. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  2151. fmt.Println(dat)
  2152. } else {
  2153. fmt.Println(err)
  2154. }
  2155. userJSONBytes, _ := json.Marshal(dat)
  2156. var res models.Result9001
  2157. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  2158. utils.ErrorLog("解析失败:%v", err)
  2159. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2160. return
  2161. }
  2162. }
  2163. }
  2164. 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) {
  2165. var res Result3101
  2166. adminUser := c.GetAdminUserInfo()
  2167. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  2168. //his, _ := service.GetNewHisPatientInfoFour(c.GetAdminUserInfo().CurrentOrgId, his_patient_id)
  2169. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  2170. //record_time := c.GetString("record_time")
  2171. //trig_scen := c.GetString("trig_scen")
  2172. timeLayout := "2006-01-02"
  2173. loc, _ := time.LoadLocation("Local")
  2174. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  2175. if err != nil {
  2176. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  2177. return res
  2178. }
  2179. recordDateTime := theTime.Unix()
  2180. var patientPrescription models.HisPrescriptionInfo
  2181. //patientPrescription, _ = service.FindHisPatientPrescriptionInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  2182. //if patientPrescription.ID == 0 {
  2183. patientPrescription, _ = service.FindLastPatientPrescriptionInfoTwo(adminUser.CurrentOrgId, patient_id, recordDateTime)
  2184. //}
  2185. department, _ := service.GetDepartMentDetail(patientPrescription.Departments)
  2186. doctor_info, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, patientPrescription.DoctorId)
  2187. //
  2188. diagnosis_ids := strings.Split(patientPrescription.Diagnosis, ",")
  2189. //prescriptions, _ := service.GetNewHisPrescriptionTen(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  2190. var pp models.PublicParams
  2191. pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  2192. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  2193. pp.FixmedinsName = miConfig.OrgName
  2194. pp.FixmedinsCode = miConfig.Code
  2195. pp.RequestUrl = miConfig.Url
  2196. pp.Cainfo = miConfig.Cainfo
  2197. pp.SecretKey = miConfig.SecretKey
  2198. pp.AccessKey = miConfig.AccessKey
  2199. pp.OpterName = roles.UserName
  2200. var config []*models.HisXtDiagnoseConfig
  2201. for _, item := range diagnosis_ids {
  2202. id, _ := strconv.ParseInt(item, 10, 64)
  2203. diagnosisConfig, _ := service.FindDiagnoseById(id)
  2204. config = append(config, &diagnosisConfig)
  2205. }
  2206. var pd models.PatientDtos
  2207. pd.PatnID = his.PsnNo
  2208. pd.PatnName = his.Name
  2209. pd.Gend = his.Gend
  2210. pd.Brdy = his.Brdy
  2211. pd.Poolarea = miConfig.MdtrtareaAdmvs
  2212. pd.CurrMdtrtID = his.Number
  2213. var fed models.FsiEncounterDtos
  2214. fed.MdtrtID = his.Number
  2215. fed.MedinsID = miConfig.Code
  2216. fed.MedinsName = miConfig.OrgName
  2217. fed.MedinsAdmdvs = miConfig.MdtrtareaAdmvs
  2218. fed.MedMdtrtType = "1"
  2219. fed.MedinsType = "1"
  2220. fed.MedinsLv = "11"
  2221. tm := time.Unix(his.RecordDate, 0)
  2222. s_tm := tm.Format("2006-01-02 15:04:05")
  2223. fed.AdmDate = s_tm
  2224. fed.DscgDate = s_tm
  2225. fed.DscgMainDiseCodg = config[0].CountryCode
  2226. fed.DscgMainDiseName = config[0].CountryContentName
  2227. //诊断信息
  2228. var fdds []*models.FsiDiagnoseDtos
  2229. for index, item := range config {
  2230. if index == 0 {
  2231. var fdd models.FsiDiagnoseDtos
  2232. fdd.DiseID = strconv.FormatInt(item.ID, 10)
  2233. fdd.InoutDiseType = "1"
  2234. fdd.MaindiseFlag = "1"
  2235. fdd.DiseDate = s_tm
  2236. fdd.DiasSrtNo = "1"
  2237. fdd.DiseName = item.CountryContentName
  2238. fdd.DiseCodg = item.CountryCode
  2239. fdds = append(fdds, &fdd)
  2240. } else {
  2241. var fdd models.FsiDiagnoseDtos
  2242. fdd.DiseID = strconv.FormatInt(item.ID, 10)
  2243. fdd.InoutDiseType = "1"
  2244. fdd.MaindiseFlag = "1"
  2245. fdd.DiseDate = s_tm
  2246. fdd.DiasSrtNo = strconv.FormatInt(int64(index), 10)
  2247. fdd.DiseName = item.CountryContentName
  2248. fdd.DiseCodg = item.CountryCode
  2249. fdds = append(fdds, &fdd)
  2250. }
  2251. }
  2252. fed.DrCodg = strconv.FormatInt(doctor_info.ID, 10)
  2253. fed.AdmDeptCodg = strconv.FormatInt(department.ID, 10)
  2254. fed.AdmDeptName = department.Name
  2255. fed.DscgDeptCodg = strconv.FormatInt(department.ID, 10)
  2256. fed.DscgDeptName = department.Name
  2257. fed.MedMdtrtType = "1"
  2258. fed.MedType = "11"
  2259. //if his.Insutype == "390" {
  2260. // fed.MedType = "1402"
  2261. //} else {
  2262. // fed.MedType = "9933"
  2263. //}
  2264. var orders []*models.FsiOrderDtos
  2265. if trig_scen == "2" {
  2266. //处方医嘱信息
  2267. for _, item := range prescriptions {
  2268. for _, subItem := range item.HisDoctorAdviceInfo {
  2269. var order models.FsiOrderDtos
  2270. order.RxID = strconv.FormatInt(item.ID, 10)
  2271. order.Rxno = strconv.FormatInt(item.ID, 10)
  2272. order.LongDrordFlag = "0"
  2273. order.HilistType = "1"
  2274. order.ChrgType = "1"
  2275. order.DrordBhvr = "-"
  2276. order.HilistCode = subItem.BaseDrugLib.MedicalInsuranceNumber
  2277. order.HosplistName = subItem.BaseDrugLib.DrugName
  2278. order.HilistLv = "1"
  2279. order.HilistPric = fmt.Sprintf("%.2f", subItem.Price)
  2280. order.HosplistCode = subItem.BaseDrugLib.MedicalInsuranceNumber
  2281. order.HosplistName = subItem.BaseDrugLib.DrugName
  2282. order.Cnt = fmt.Sprintf("%.2f", subItem.PrescribingNumber)
  2283. order.Pric = fmt.Sprintf("%.2f", subItem.Price)
  2284. order.Sumamt = fmt.Sprintf("%.2f", (subItem.PrescribingNumber * subItem.Price))
  2285. order.OwnpayAmt = ""
  2286. order.SelfpayAmt = ""
  2287. order.Spec = ""
  2288. order.SpecUnt = ""
  2289. order.DrordBegnDate = s_tm
  2290. order.DrordStopDate = ""
  2291. order.DrordDrCodg = "1"
  2292. order.DrordDeptName = department.Name
  2293. order.DrordDrCodg = "1"
  2294. order.DrordDrName = doctor_info.UserName
  2295. order.DrordDrProfttl = ""
  2296. order.CurrDrordFlag = "1"
  2297. orders = append(orders, &order)
  2298. }
  2299. for _, subItem := range item.HisPrescriptionProject {
  2300. if subItem.Type == 2 {
  2301. var order models.FsiOrderDtos
  2302. order.RxID = strconv.FormatInt(item.ID, 10)
  2303. order.Rxno = strconv.FormatInt(item.ID, 10)
  2304. order.LongDrordFlag = "0"
  2305. order.HilistType = "1"
  2306. order.ChrgType = "1"
  2307. order.DrordBhvr = "-"
  2308. order.HilistCode = subItem.HisProject.MedicalCode
  2309. order.HosplistName = subItem.HisProject.ProjectName
  2310. order.HilistLv = "1"
  2311. order.HilistPric = fmt.Sprintf("%.2f", subItem.Price)
  2312. order.HosplistCode = subItem.HisProject.MedicalCode
  2313. order.HosplistName = subItem.HisProject.ProjectName
  2314. order.Cnt = subItem.Count
  2315. cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  2316. order.Pric = fmt.Sprintf("%.2f", subItem.Price)
  2317. order.Sumamt = fmt.Sprintf("%.2f", subItem.Price*cnt)
  2318. order.OwnpayAmt = ""
  2319. order.SelfpayAmt = ""
  2320. order.Spec = ""
  2321. order.SpecUnt = ""
  2322. order.DrordBegnDate = s_tm
  2323. order.DrordStopDate = ""
  2324. order.DrordDrCodg = "1"
  2325. order.DrordDeptName = department.Name
  2326. order.DrordDrCodg = "1"
  2327. order.DrordDrName = doctor_info.UserName
  2328. order.DrordDrProfttl = ""
  2329. order.CurrDrordFlag = "1"
  2330. orders = append(orders, &order)
  2331. }
  2332. if subItem.Type == 3 {
  2333. var order models.FsiOrderDtos
  2334. order.RxID = strconv.FormatInt(item.ID, 10)
  2335. order.Rxno = strconv.FormatInt(item.ID, 10)
  2336. order.LongDrordFlag = "0"
  2337. order.HilistType = "1"
  2338. order.ChrgType = "1"
  2339. order.DrordBhvr = "-"
  2340. order.HilistCode = subItem.GoodInfo.MedicalInsuranceNumber
  2341. order.HosplistName = subItem.GoodInfo.GoodName
  2342. order.HilistLv = "1"
  2343. order.HilistPric = fmt.Sprintf("%.2f", subItem.Price)
  2344. order.HosplistCode = subItem.GoodInfo.MedicalInsuranceNumber
  2345. order.HosplistName = subItem.GoodInfo.GoodName
  2346. order.Cnt = subItem.Count
  2347. cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  2348. order.Pric = fmt.Sprintf("%.2f", subItem.Price)
  2349. order.Sumamt = fmt.Sprintf("%.2f", subItem.Price*cnt)
  2350. order.OwnpayAmt = ""
  2351. order.SelfpayAmt = ""
  2352. order.Spec = ""
  2353. order.SpecUnt = ""
  2354. order.DrordBegnDate = s_tm
  2355. order.DrordStopDate = ""
  2356. order.DrordDrCodg = "1"
  2357. order.DrordDeptName = department.Name
  2358. order.DrordDrCodg = "1"
  2359. order.DrordDrName = doctor_info.UserName
  2360. order.DrordDrProfttl = ""
  2361. order.CurrDrordFlag = "1"
  2362. orders = append(orders, &order)
  2363. }
  2364. }
  2365. }
  2366. //处方医嘱信息
  2367. }
  2368. fed.MatnStas = "0"
  2369. fed.MedfeeSumamt = "0"
  2370. fed.OwnpayAmt = "0"
  2371. fed.SelfpayAmt = "0"
  2372. fed.AcctPayamt = "0"
  2373. fed.MaAmt = "0"
  2374. fed.HifpPayamt = "0"
  2375. fed.SetlTotlnum = "1"
  2376. fed.Insutype = his.Insutype
  2377. fed.ReimFlag = "0"
  2378. fed.OutSetlFlag = "0"
  2379. var fopd []*models.FsiOperationDtosData
  2380. data := make(map[string]interface{})
  2381. data["fed"] = fed
  2382. data["fdd"] = fdds
  2383. data["fod"] = orders
  2384. data["pd"] = pd
  2385. data["pp"] = pp
  2386. data["fopd"] = fopd
  2387. data["trig_scen"] = trig_scen
  2388. fmt.Println(data)
  2389. fmt.Println(fed)
  2390. fmt.Println(fdds)
  2391. fmt.Println(orders)
  2392. fmt.Println(pd)
  2393. fmt.Println(pp)
  2394. fmt.Println(fopd)
  2395. client := &http.Client{}
  2396. bytesData, _ := json.Marshal(data)
  2397. var req *http.Request
  2398. if miConfig.MdtrtareaAdmvs == "320921" {
  2399. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3101", bytes.NewReader(bytesData))
  2400. } else {
  2401. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3101", bytes.NewReader(bytesData))
  2402. }
  2403. resp, _ := client.Do(req)
  2404. defer resp.Body.Close()
  2405. body, ioErr := ioutil.ReadAll(resp.Body)
  2406. if ioErr != nil {
  2407. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  2408. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2409. return res
  2410. }
  2411. var respJSON map[string]interface{}
  2412. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  2413. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  2414. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2415. return res
  2416. }
  2417. respJSON = respJSON["data"].(map[string]interface{})["request_log"].(map[string]interface{})
  2418. fmt.Println(respJSON)
  2419. result, _ := json.Marshal(respJSON)
  2420. fmt.Println(result)
  2421. if err := json.Unmarshal([]byte(result), &res); err != nil {
  2422. utils.ErrorLog("解析失败:%v", err)
  2423. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2424. return res
  2425. }
  2426. return res
  2427. }
  2428. 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) {
  2429. adminUser := c.GetAdminUserInfo()
  2430. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  2431. his, _ := service.GetNewHisPatientInfoFour(c.GetAdminUserInfo().CurrentOrgId, his_patient_id)
  2432. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  2433. //record_time := c.GetString("record_time")
  2434. //trig_scen := c.GetString("trig_scen")
  2435. timeLayout := "2006-01-02"
  2436. loc, _ := time.LoadLocation("Local")
  2437. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  2438. if err != nil {
  2439. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  2440. return res
  2441. }
  2442. recordDateTime := theTime.Unix()
  2443. var patientPrescription models.HisPrescriptionInfo
  2444. patientPrescription, _ = service.FindHisPatientPrescriptionInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  2445. if patientPrescription.ID == 0 {
  2446. patientPrescription, _ = service.FindLastPatientPrescriptionInfo(adminUser.CurrentOrgId, patient_id, recordDateTime)
  2447. }
  2448. department, _ := service.GetDepartMentDetail(patientPrescription.Departments)
  2449. doctor_info, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, patientPrescription.DoctorId)
  2450. //
  2451. diagnosis_ids := strings.Split(patientPrescription.Diagnosis, ",")
  2452. //prescriptions, _ := service.GetNewHisPrescriptionTen(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  2453. var pp models.PublicParams
  2454. pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  2455. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  2456. pp.FixmedinsName = miConfig.OrgName
  2457. pp.FixmedinsCode = miConfig.Code
  2458. pp.RequestUrl = miConfig.Url
  2459. pp.Cainfo = miConfig.Cainfo
  2460. pp.SecretKey = miConfig.SecretKey
  2461. pp.AccessKey = miConfig.AccessKey
  2462. pp.OpterName = roles.UserName
  2463. var config []*models.HisXtDiagnoseConfig
  2464. for _, item := range diagnosis_ids {
  2465. id, _ := strconv.ParseInt(item, 10, 64)
  2466. diagnosisConfig, _ := service.FindDiagnoseById(id)
  2467. config = append(config, &diagnosisConfig)
  2468. }
  2469. var pd models.PatientDtos
  2470. pd.PatnID = his.PsnNo
  2471. pd.PatnName = his.Name
  2472. pd.Gend = his.Gend
  2473. pd.Brdy = his.Brdy
  2474. pd.Poolarea = his.InsuplcAdmdvs
  2475. pd.CurrMdtrtID = his.Number
  2476. var fed models.FsiEncounterDtos
  2477. fed.MdtrtID = his.Number
  2478. fed.MedinsID = miConfig.Code
  2479. fed.MedinsName = miConfig.OrgName
  2480. fed.MedinsAdmdvs = miConfig.MdtrtareaAdmvs
  2481. fed.MedMdtrtType = "1"
  2482. fed.MedinsType = "1"
  2483. fed.MedinsLv = "11"
  2484. tm := time.Unix(his.RecordDate, 0)
  2485. s_tm := tm.Format("2006-01-02 15:04:05")
  2486. fed.AdmDate = s_tm
  2487. fed.DscgDate = s_tm
  2488. fed.DscgMainDiseCodg = config[0].CountryCode
  2489. fed.DscgMainDiseName = config[0].CountryContentName
  2490. //诊断信息
  2491. var fdds []*models.FsiDiagnoseDtos
  2492. for index, item := range config {
  2493. if index == 0 {
  2494. var fdd models.FsiDiagnoseDtos
  2495. fdd.DiseID = strconv.FormatInt(item.ID, 10)
  2496. fdd.InoutDiseType = "1"
  2497. fdd.MaindiseFlag = "1"
  2498. fdd.DiseDate = s_tm
  2499. fdd.DiasSrtNo = "1"
  2500. fdd.DiseName = item.CountryContentName
  2501. fdd.DiseCodg = item.CountryCode
  2502. fdds = append(fdds, &fdd)
  2503. } else {
  2504. var fdd models.FsiDiagnoseDtos
  2505. fdd.DiseID = strconv.FormatInt(item.ID, 10)
  2506. fdd.InoutDiseType = "1"
  2507. fdd.MaindiseFlag = "1"
  2508. fdd.DiseDate = s_tm
  2509. fdd.DiasSrtNo = strconv.FormatInt(int64(index), 10)
  2510. fdd.DiseName = item.CountryContentName
  2511. fdd.DiseCodg = item.CountryCode
  2512. fdds = append(fdds, &fdd)
  2513. }
  2514. }
  2515. fed.DrCodg = strconv.FormatInt(doctor_info.ID, 10)
  2516. fed.AdmDeptCodg = strconv.FormatInt(department.ID, 10)
  2517. fed.AdmDeptName = department.Name
  2518. fed.DscgDeptCodg = strconv.FormatInt(department.ID, 10)
  2519. fed.DscgDeptName = department.Name
  2520. fed.MedMdtrtType = "1"
  2521. fed.MedType = "11"
  2522. //if his.Insutype == "390" {
  2523. // fed.MedType = "1402"
  2524. //} else {
  2525. // fed.MedType = "9933"
  2526. //}
  2527. var orders []*models.FsiOrderDtos
  2528. if trig_scen == "2" {
  2529. //处方医嘱信息
  2530. for _, item := range prescriptions {
  2531. for _, subItem := range item.HisDoctorAdviceInfo {
  2532. var order models.FsiOrderDtos
  2533. order.RxID = strconv.FormatInt(item.ID, 10)
  2534. order.Rxno = strconv.FormatInt(item.ID, 10)
  2535. order.LongDrordFlag = "0"
  2536. order.HilistType = "1"
  2537. order.ChrgType = "1"
  2538. order.DrordBhvr = "-"
  2539. order.HilistCode = subItem.BaseDrugLib.MedicalInsuranceNumber
  2540. order.HosplistName = subItem.BaseDrugLib.DrugName
  2541. order.HilistLv = "1"
  2542. order.HilistPric = fmt.Sprintf("%.2f", subItem.Price)
  2543. order.HosplistCode = subItem.BaseDrugLib.MedicalInsuranceNumber
  2544. order.HosplistName = subItem.BaseDrugLib.DrugName
  2545. order.Cnt = fmt.Sprintf("%.2f", subItem.PrescribingNumber)
  2546. order.Pric = fmt.Sprintf("%.2f", subItem.Price)
  2547. order.Sumamt = fmt.Sprintf("%.2f", (subItem.PrescribingNumber * subItem.Price))
  2548. order.OwnpayAmt = ""
  2549. order.SelfpayAmt = ""
  2550. order.Spec = ""
  2551. order.SpecUnt = ""
  2552. order.DrordBegnDate = s_tm
  2553. order.DrordStopDate = ""
  2554. order.DrordDrCodg = "1"
  2555. order.DrordDeptName = department.Name
  2556. order.DrordDrCodg = "1"
  2557. order.DrordDrName = doctor_info.UserName
  2558. order.DrordDrProfttl = ""
  2559. order.CurrDrordFlag = "1"
  2560. orders = append(orders, &order)
  2561. }
  2562. for _, subItem := range item.HisPrescriptionProject {
  2563. if subItem.Type == 2 {
  2564. var order models.FsiOrderDtos
  2565. order.RxID = strconv.FormatInt(item.ID, 10)
  2566. order.Rxno = strconv.FormatInt(item.ID, 10)
  2567. order.LongDrordFlag = "0"
  2568. order.HilistType = "1"
  2569. order.ChrgType = "1"
  2570. order.DrordBhvr = "-"
  2571. order.HilistCode = subItem.HisProject.MedicalCode
  2572. order.HosplistName = subItem.HisProject.ProjectName
  2573. order.HilistLv = "1"
  2574. order.HilistPric = fmt.Sprintf("%.2f", subItem.Price)
  2575. order.HosplistCode = subItem.HisProject.MedicalCode
  2576. order.HosplistName = subItem.HisProject.ProjectName
  2577. order.Cnt = subItem.Count
  2578. cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  2579. order.Pric = fmt.Sprintf("%.2f", subItem.Price)
  2580. order.Sumamt = fmt.Sprintf("%.2f", subItem.Price*cnt)
  2581. order.OwnpayAmt = ""
  2582. order.SelfpayAmt = ""
  2583. order.Spec = ""
  2584. order.SpecUnt = ""
  2585. order.DrordBegnDate = s_tm
  2586. order.DrordStopDate = ""
  2587. order.DrordDrCodg = "1"
  2588. order.DrordDeptName = department.Name
  2589. order.DrordDrCodg = "1"
  2590. order.DrordDrName = doctor_info.UserName
  2591. order.DrordDrProfttl = ""
  2592. order.CurrDrordFlag = "1"
  2593. orders = append(orders, &order)
  2594. }
  2595. if subItem.Type == 3 {
  2596. var order models.FsiOrderDtos
  2597. order.RxID = strconv.FormatInt(item.ID, 10)
  2598. order.Rxno = strconv.FormatInt(item.ID, 10)
  2599. order.LongDrordFlag = "0"
  2600. order.HilistType = "1"
  2601. order.ChrgType = "1"
  2602. order.DrordBhvr = "-"
  2603. order.HilistCode = subItem.GoodInfo.MedicalInsuranceNumber
  2604. order.HosplistName = subItem.GoodInfo.GoodName
  2605. order.HilistLv = "1"
  2606. order.HilistPric = fmt.Sprintf("%.2f", subItem.Price)
  2607. order.HosplistCode = subItem.GoodInfo.MedicalInsuranceNumber
  2608. order.HosplistName = subItem.GoodInfo.GoodName
  2609. order.Cnt = subItem.Count
  2610. cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  2611. order.Pric = fmt.Sprintf("%.2f", subItem.Price)
  2612. order.Sumamt = fmt.Sprintf("%.2f", subItem.Price*cnt)
  2613. order.OwnpayAmt = ""
  2614. order.SelfpayAmt = ""
  2615. order.Spec = ""
  2616. order.SpecUnt = ""
  2617. order.DrordBegnDate = s_tm
  2618. order.DrordStopDate = ""
  2619. order.DrordDrCodg = "1"
  2620. order.DrordDeptName = department.Name
  2621. order.DrordDrCodg = "1"
  2622. order.DrordDrName = doctor_info.UserName
  2623. order.DrordDrProfttl = ""
  2624. order.CurrDrordFlag = "1"
  2625. orders = append(orders, &order)
  2626. }
  2627. }
  2628. }
  2629. //处方医嘱信息
  2630. }
  2631. fed.MatnStas = "0"
  2632. fed.MedfeeSumamt = "0"
  2633. fed.OwnpayAmt = "0"
  2634. fed.SelfpayAmt = "0"
  2635. fed.AcctPayamt = "0"
  2636. fed.MaAmt = "0"
  2637. fed.HifpPayamt = "0"
  2638. fed.SetlTotlnum = "1"
  2639. fed.Insutype = his.Insutype
  2640. fed.ReimFlag = "0"
  2641. fed.OutSetlFlag = "0"
  2642. var fopd []*models.FsiOperationDtosData
  2643. data := make(map[string]interface{})
  2644. data["fed"] = fed
  2645. data["fdd"] = fdds
  2646. data["fod"] = orders
  2647. data["pd"] = pd
  2648. data["pp"] = pp
  2649. data["fopd"] = fopd
  2650. data["trig_scen"] = trig_scen
  2651. fmt.Println(data)
  2652. fmt.Println(fed)
  2653. fmt.Println(fdds)
  2654. fmt.Println(orders)
  2655. fmt.Println(pd)
  2656. fmt.Println(pp)
  2657. fmt.Println(fopd)
  2658. client := &http.Client{}
  2659. bytesData, _ := json.Marshal(data)
  2660. var req *http.Request
  2661. if miConfig.MdtrtareaAdmvs == "320921" {
  2662. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3101", bytes.NewReader(bytesData))
  2663. } else {
  2664. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3101", bytes.NewReader(bytesData))
  2665. }
  2666. resp, _ := client.Do(req)
  2667. defer resp.Body.Close()
  2668. body, ioErr := ioutil.ReadAll(resp.Body)
  2669. if ioErr != nil {
  2670. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  2671. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2672. return res
  2673. }
  2674. var respJSON map[string]interface{}
  2675. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  2676. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  2677. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2678. return res
  2679. }
  2680. respJSON = respJSON["data"].(map[string]interface{})["request_log"].(map[string]interface{})
  2681. result, _ := json.Marshal(respJSON)
  2682. if err := json.Unmarshal([]byte(result), &res); err != nil {
  2683. utils.ErrorLog("解析失败:%v", err)
  2684. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2685. return res
  2686. }
  2687. return res
  2688. }
  2689. func Check3102(c *HisApiController, patient_id int64, his_patient_id int64, admin_user_id int64, trig_scen string, order_id int64) (res Result3101) {
  2690. ////patient_id, _ := c.GetInt64("patient_id")
  2691. //order_id, _ := c.GetInt64("order_id")
  2692. ////his_patient_id, _ := c.GetInt64("his_patient_id")
  2693. ////admin_user_id, _ := c.GetInt64("admin_user_id")
  2694. //trig_scen := c.GetString("trig_scen")
  2695. adminUser := c.GetAdminUserInfo()
  2696. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  2697. his, _ := service.GetNewHisPatientInfoFour(c.GetAdminUserInfo().CurrentOrgId, his_patient_id)
  2698. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  2699. record_time := c.GetString("record_time")
  2700. order, _ := service.GetHisOrderByID(order_id)
  2701. timeLayout := "2006-01-02"
  2702. loc, _ := time.LoadLocation("Local")
  2703. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  2704. if err != nil {
  2705. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  2706. return
  2707. }
  2708. recordDateTime := theTime.Unix()
  2709. var patientPrescription models.HisPrescriptionInfo
  2710. patientPrescription, _ = service.FindHisPatientPrescriptionInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  2711. if patientPrescription.ID == 0 {
  2712. patientPrescription, _ = service.FindLastPatientPrescriptionInfo(adminUser.CurrentOrgId, patient_id, recordDateTime)
  2713. }
  2714. department, _ := service.GetDepartMentDetail(patientPrescription.Departments)
  2715. doctor_info, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, patientPrescription.DoctorId)
  2716. //
  2717. diagnosis_ids := strings.Split(his.Diagnosis, ",")
  2718. prescriptions, _ := service.GetNewHisPrescriptionTen(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  2719. var pp models.PublicParams
  2720. pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  2721. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  2722. pp.FixmedinsName = miConfig.OrgName
  2723. pp.FixmedinsCode = miConfig.Code
  2724. pp.RequestUrl = miConfig.Url
  2725. pp.Cainfo = miConfig.Cainfo
  2726. pp.SecretKey = miConfig.SecretKey
  2727. pp.AccessKey = miConfig.AccessKey
  2728. pp.OpterName = roles.UserName
  2729. var config []*models.HisXtDiagnoseConfig
  2730. for _, item := range diagnosis_ids {
  2731. id, _ := strconv.ParseInt(item, 10, 64)
  2732. diagnosisConfig, _ := service.FindDiagnoseById(id)
  2733. config = append(config, &diagnosisConfig)
  2734. }
  2735. var pd models.PatientDtos
  2736. pd.PatnID = his.PsnNo
  2737. pd.PatnName = his.Name
  2738. pd.Gend = his.Gend
  2739. pd.Brdy = his.Brdy
  2740. pd.Poolarea = his.InsuplcAdmdvs
  2741. pd.CurrMdtrtID = his.Number
  2742. var fed models.FsiEncounterDtos
  2743. fed.MdtrtID = his.Number
  2744. fed.MedinsID = miConfig.Code
  2745. fed.MedinsName = miConfig.OrgName
  2746. fed.MedinsAdmdvs = miConfig.MdtrtareaAdmvs
  2747. fed.MedMdtrtType = "1"
  2748. fed.MedinsType = "1"
  2749. fed.MedinsLv = "11"
  2750. tm := time.Unix(his.RecordDate, 0)
  2751. s_tm := tm.Format("2006-01-02 15:04:05")
  2752. fed.AdmDate = s_tm
  2753. fed.DscgDate = s_tm
  2754. fed.DscgMainDiseCodg = config[0].CountryCode
  2755. fed.DscgMainDiseName = config[0].CountryContentName
  2756. //诊断信息
  2757. var fdds []*models.FsiDiagnoseDtos
  2758. for index, item := range config {
  2759. if index == 0 {
  2760. var fdd models.FsiDiagnoseDtos
  2761. fdd.DiseID = strconv.FormatInt(item.ID, 10)
  2762. fdd.InoutDiseType = "1"
  2763. fdd.MaindiseFlag = "1"
  2764. fdd.DiseDate = s_tm
  2765. fdd.DiasSrtNo = "1"
  2766. fdd.DiseName = item.CountryContentName
  2767. fdd.DiseCodg = item.CountryCode
  2768. fdds = append(fdds, &fdd)
  2769. } else {
  2770. var fdd models.FsiDiagnoseDtos
  2771. fdd.DiseID = strconv.FormatInt(item.ID, 10)
  2772. fdd.InoutDiseType = "1"
  2773. fdd.MaindiseFlag = "1"
  2774. fdd.DiseDate = s_tm
  2775. fdd.DiasSrtNo = strconv.FormatInt(int64(index), 10)
  2776. fdd.DiseName = item.CountryContentName
  2777. fdd.DiseCodg = item.CountryCode
  2778. fdds = append(fdds, &fdd)
  2779. }
  2780. }
  2781. fed.DrCodg = strconv.FormatInt(doctor_info.ID, 10)
  2782. fed.AdmDeptCodg = strconv.FormatInt(department.ID, 10)
  2783. fed.AdmDeptName = department.Name
  2784. fed.DscgDeptCodg = strconv.FormatInt(department.ID, 10)
  2785. fed.DscgDeptName = department.Name
  2786. fed.MedType = order.MedType
  2787. //处方医嘱信息
  2788. var orders []*models.FsiOrderDtos
  2789. //for _, item := range prescriptions {
  2790. // for _, subItem := range item.HisDoctorAdviceInfo {
  2791. // var order models.FsiOrderDtos
  2792. // order.RxID = strconv.FormatInt(item.ID, 10)
  2793. // order.Rxno = strconv.FormatInt(item.ID, 10)
  2794. // order.LongDrordFlag = "0"
  2795. // order.HilistType = "1"
  2796. // order.ChrgType = "1"
  2797. // order.DrordBhvr = "-"
  2798. // order.HilistCode = subItem.BaseDrugLib.MedicalInsuranceNumber
  2799. // order.HosplistName = subItem.BaseDrugLib.DrugName
  2800. // order.HilistLv = "1"
  2801. // order.HilistPric = strconv.FormatFloat(subItem.Price, 'E', -1, 64)
  2802. // order.HosplistCode = subItem.BaseDrugLib.MedicalInsuranceNumber
  2803. // order.HosplistName = subItem.BaseDrugLib.DrugName
  2804. // order.Cnt = strconv.FormatFloat(subItem.PrescribingNumber, 'E', -1, 64)
  2805. // order.Pric = strconv.FormatFloat(subItem.Price, 'E', -1, 64)
  2806. // order.Sumamt = strconv.FormatFloat((subItem.Price * subItem.PrescribingNumber), 'E', -1, 64)
  2807. // order.OwnpayAmt = ""
  2808. // order.SelfpayAmt = ""
  2809. // order.Spec = ""
  2810. // order.SpecUnt = ""
  2811. // order.DrordBegnDate = s_tm
  2812. // order.DrordStopDate = ""
  2813. // order.DrordDrCodg = "1"
  2814. // order.DrordDeptName = department.Name
  2815. // order.DrordDrCodg = "1"
  2816. // order.DrordDrName = doctor_info.UserName
  2817. // order.DrordDrProfttl = ""
  2818. // order.CurrDrordFlag = "1"
  2819. // orders = append(orders, &order)
  2820. // }
  2821. // for _, subItem := range item.HisPrescriptionProject {
  2822. // if subItem.Type == 2 {
  2823. // var order models.FsiOrderDtos
  2824. // order.RxID = strconv.FormatInt(item.ID, 10)
  2825. // order.Rxno = strconv.FormatInt(item.ID, 10)
  2826. // order.LongDrordFlag = "0"
  2827. // order.HilistType = "1"
  2828. // order.ChrgType = "1"
  2829. // order.DrordBhvr = "-"
  2830. // order.HilistCode = subItem.HisProject.MedicalCode
  2831. // order.HosplistName = subItem.HisProject.ProjectName
  2832. // order.HilistLv = "1"
  2833. // order.HilistPric = strconv.FormatFloat(subItem.Price, 'E', -1, 64)
  2834. // order.HosplistCode = subItem.HisProject.MedicalCode
  2835. // order.HosplistName = subItem.HisProject.ProjectName
  2836. // order.Cnt = subItem.Count
  2837. // cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  2838. //
  2839. // order.Pric = strconv.FormatFloat(subItem.Price, 'E', -1, 64)
  2840. // order.Sumamt = strconv.FormatFloat((subItem.Price * cnt), 'E', -1, 64)
  2841. // order.OwnpayAmt = ""
  2842. // order.SelfpayAmt = ""
  2843. // order.Spec = ""
  2844. // order.SpecUnt = ""
  2845. // order.DrordBegnDate = s_tm
  2846. // order.DrordStopDate = ""
  2847. // order.DrordDrCodg = "1"
  2848. // order.DrordDeptName = department.Name
  2849. // order.DrordDrCodg = "1"
  2850. // order.DrordDrName = doctor_info.UserName
  2851. // order.DrordDrProfttl = ""
  2852. // order.CurrDrordFlag = "1"
  2853. // orders = append(orders, &order)
  2854. //
  2855. // }
  2856. // if subItem.Type == 3 {
  2857. //
  2858. // var order models.FsiOrderDtos
  2859. // order.RxID = strconv.FormatInt(item.ID, 10)
  2860. // order.Rxno = strconv.FormatInt(item.ID, 10)
  2861. // order.LongDrordFlag = "0"
  2862. // order.HilistType = "1"
  2863. // order.ChrgType = "1"
  2864. // order.DrordBhvr = "-"
  2865. // order.HilistCode = subItem.GoodInfo.MedicalInsuranceNumber
  2866. // order.HosplistName = subItem.GoodInfo.GoodName
  2867. // order.HilistLv = "1"
  2868. // order.HilistPric = strconv.FormatFloat(subItem.Price, 'E', -1, 64)
  2869. // order.HosplistCode = subItem.GoodInfo.MedicalInsuranceNumber
  2870. // order.HosplistName = subItem.GoodInfo.GoodName
  2871. // order.Cnt = subItem.Count
  2872. // cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  2873. // order.Pric = strconv.FormatFloat(subItem.Price, 'E', -1, 64)
  2874. // order.Sumamt = strconv.FormatFloat((subItem.Price * cnt), 'E', -1, 64)
  2875. // order.OwnpayAmt = ""
  2876. // order.SelfpayAmt = ""
  2877. // order.Spec = ""
  2878. // order.SpecUnt = ""
  2879. // order.DrordBegnDate = s_tm
  2880. // order.DrordStopDate = ""
  2881. // order.DrordDrCodg = "1"
  2882. // order.DrordDeptName = department.Name
  2883. // order.DrordDrCodg = "1"
  2884. // order.DrordDrName = doctor_info.UserName
  2885. // order.DrordDrProfttl = ""
  2886. // order.CurrDrordFlag = "1"
  2887. // orders = append(orders, &order)
  2888. //
  2889. // }
  2890. // }
  2891. //}
  2892. for _, item := range prescriptions {
  2893. for _, subItem := range item.HisDoctorAdviceInfo {
  2894. var order models.FsiOrderDtos
  2895. order.RxID = strconv.FormatInt(item.ID, 10)
  2896. order.Rxno = strconv.FormatInt(item.ID, 10)
  2897. order.LongDrordFlag = "0"
  2898. order.HilistType = "1"
  2899. order.ChrgType = "1"
  2900. order.DrordBhvr = "-"
  2901. order.HilistCode = subItem.BaseDrugLib.MedicalInsuranceNumber
  2902. order.HosplistName = subItem.BaseDrugLib.DrugName
  2903. order.HilistLv = "1"
  2904. order.HilistPric = fmt.Sprintf("%.2f", subItem.Price)
  2905. order.HosplistCode = subItem.BaseDrugLib.MedicalInsuranceNumber
  2906. order.HosplistName = subItem.BaseDrugLib.DrugName
  2907. order.Cnt = fmt.Sprintf("%.2f", subItem.PrescribingNumber)
  2908. order.Pric = fmt.Sprintf("%.2f", subItem.Price)
  2909. order.Sumamt = fmt.Sprintf("%.2f", (subItem.PrescribingNumber * subItem.Price))
  2910. order.OwnpayAmt = ""
  2911. order.SelfpayAmt = ""
  2912. order.Spec = ""
  2913. order.SpecUnt = ""
  2914. order.DrordBegnDate = s_tm
  2915. order.DrordStopDate = ""
  2916. order.DrordDrCodg = "1"
  2917. order.DrordDeptName = department.Name
  2918. order.DrordDrCodg = "1"
  2919. order.DrordDrName = doctor_info.UserName
  2920. order.DrordDrProfttl = ""
  2921. order.CurrDrordFlag = "1"
  2922. orders = append(orders, &order)
  2923. }
  2924. for _, subItem := range item.HisPrescriptionProject {
  2925. if subItem.Type == 2 {
  2926. var order models.FsiOrderDtos
  2927. order.RxID = strconv.FormatInt(item.ID, 10)
  2928. order.Rxno = strconv.FormatInt(item.ID, 10)
  2929. order.LongDrordFlag = "0"
  2930. order.HilistType = "1"
  2931. order.ChrgType = "1"
  2932. order.DrordBhvr = "-"
  2933. order.HilistCode = subItem.HisProject.MedicalCode
  2934. order.HosplistName = subItem.HisProject.ProjectName
  2935. order.HilistLv = "1"
  2936. order.HilistPric = fmt.Sprintf("%.2f", subItem.Price)
  2937. order.HosplistCode = subItem.HisProject.MedicalCode
  2938. order.HosplistName = subItem.HisProject.ProjectName
  2939. order.Cnt = subItem.Count
  2940. cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  2941. order.Pric = fmt.Sprintf("%.2f", subItem.Price)
  2942. order.Sumamt = fmt.Sprintf("%.2f", subItem.Price*cnt)
  2943. order.OwnpayAmt = ""
  2944. order.SelfpayAmt = ""
  2945. order.Spec = ""
  2946. order.SpecUnt = ""
  2947. order.DrordBegnDate = s_tm
  2948. order.DrordStopDate = ""
  2949. order.DrordDrCodg = "1"
  2950. order.DrordDeptName = department.Name
  2951. order.DrordDrCodg = "1"
  2952. order.DrordDrName = doctor_info.UserName
  2953. order.DrordDrProfttl = ""
  2954. order.CurrDrordFlag = "1"
  2955. orders = append(orders, &order)
  2956. }
  2957. if subItem.Type == 3 {
  2958. var order models.FsiOrderDtos
  2959. order.RxID = strconv.FormatInt(item.ID, 10)
  2960. order.Rxno = strconv.FormatInt(item.ID, 10)
  2961. order.LongDrordFlag = "0"
  2962. order.HilistType = "1"
  2963. order.ChrgType = "1"
  2964. order.DrordBhvr = "-"
  2965. order.HilistCode = subItem.GoodInfo.MedicalInsuranceNumber
  2966. order.HosplistName = subItem.GoodInfo.GoodName
  2967. order.HilistLv = "1"
  2968. order.HilistPric = fmt.Sprintf("%.2f", subItem.Price)
  2969. order.HosplistCode = subItem.GoodInfo.MedicalInsuranceNumber
  2970. order.HosplistName = subItem.GoodInfo.GoodName
  2971. order.Cnt = subItem.Count
  2972. cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  2973. order.Pric = fmt.Sprintf("%.2f", subItem.Price)
  2974. order.Sumamt = fmt.Sprintf("%.2f", subItem.Price*cnt)
  2975. order.OwnpayAmt = ""
  2976. order.SelfpayAmt = ""
  2977. order.Spec = ""
  2978. order.SpecUnt = ""
  2979. order.DrordBegnDate = s_tm
  2980. order.DrordStopDate = ""
  2981. order.DrordDrCodg = "1"
  2982. order.DrordDeptName = department.Name
  2983. order.DrordDrCodg = "1"
  2984. order.DrordDrName = doctor_info.UserName
  2985. order.DrordDrProfttl = ""
  2986. order.CurrDrordFlag = "1"
  2987. orders = append(orders, &order)
  2988. }
  2989. }
  2990. }
  2991. //处方医嘱信息
  2992. fed.MatnStas = "0"
  2993. fed.MedfeeSumamt = fmt.Sprintf("%.2f", order.MedfeeSumamt)
  2994. fed.OwnpayAmt = fmt.Sprintf("%.2f", order.FulamtOwnpayAmt)
  2995. fed.SelfpayAmt = fmt.Sprintf("%.2f", order.PreselfpayAmt)
  2996. fed.AcctPayamt = fmt.Sprintf("%.2f", order.AcctPay)
  2997. fed.MaAmt = fmt.Sprintf("%.2f", order.MafPay)
  2998. fed.HifpPayamt = fmt.Sprintf("%.2f", order.HifpPay)
  2999. fed.SetlTotlnum = "1"
  3000. fed.Insutype = his.Insutype
  3001. fed.ReimFlag = "0"
  3002. fed.OutSetlFlag = "0"
  3003. var fopd []*models.FsiOperationDtosData
  3004. data := make(map[string]interface{})
  3005. data["fed"] = fed
  3006. data["fdd"] = fdds
  3007. data["fod"] = orders
  3008. data["pd"] = pd
  3009. data["pp"] = pp
  3010. data["fopd"] = fopd
  3011. data["trig_scen"] = trig_scen
  3012. client := &http.Client{}
  3013. bytesData, _ := json.Marshal(data)
  3014. var req *http.Request
  3015. if miConfig.MdtrtareaAdmvs == "320921" {
  3016. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3102", bytes.NewReader(bytesData))
  3017. } else {
  3018. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3102", bytes.NewReader(bytesData))
  3019. }
  3020. resp, _ := client.Do(req)
  3021. defer resp.Body.Close()
  3022. body, ioErr := ioutil.ReadAll(resp.Body)
  3023. if ioErr != nil {
  3024. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  3025. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3026. return res
  3027. }
  3028. var respJSON map[string]interface{}
  3029. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  3030. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  3031. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3032. return res
  3033. }
  3034. respJSON = respJSON["data"].(map[string]interface{})["request_log"].(map[string]interface{})
  3035. result, _ := json.Marshal(respJSON)
  3036. if err := json.Unmarshal([]byte(result), &res); err != nil {
  3037. utils.ErrorLog("解析失败:%v", err)
  3038. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3039. return res
  3040. }
  3041. return res
  3042. //手术操作集合
  3043. //手术操作集合
  3044. }
  3045. func (c *HisApiController) Check() {
  3046. psn_no := c.GetString("psn_no")
  3047. in := c.GetString("in")
  3048. mt := c.GetString("mt")
  3049. baseParams := models.BaseParams{
  3050. SecretKey: "MSDBYGxXm1Mtyi3PtOUB7n1ktcxwyW57",
  3051. FixmedinsCode: "H15049901371",
  3052. InsuplcAdmdvs: "150499",
  3053. MdtrtareaAdmvs: "150499",
  3054. OrgName: "赤峰费森血液透析中心",
  3055. Doctor: "1111",
  3056. }
  3057. service.Gdyb2001(baseParams, psn_no, in, mt)
  3058. }
  3059. func (c *HisApiController) GetPsnNcdsInfo() {
  3060. admin_user_id, _ := c.GetInt64("admin_user_id")
  3061. patient_id, _ := c.GetInt64("patient_id")
  3062. id, _ := c.GetInt64("id")
  3063. adminUser := c.GetAdminUserInfo()
  3064. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  3065. //config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  3066. //patient, _ := service.GetPatientByID(c.GetAdminUserInfo().CurrentOrgId, id)
  3067. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  3068. psn_record, _ := service.GetPsnNCDSRecordById(id)
  3069. //
  3070. //if psn_record.ID == 0 {
  3071. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorPsnRecordNoExistWrong)
  3072. // return
  3073. //}
  3074. var res Result5301
  3075. var res10265 Result5301For10265
  3076. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  3077. psn_info, _ := service.GetPsnByPatientId(patient_id)
  3078. var api string
  3079. if miConfig.MdtrtareaAdmvs == "320921" {
  3080. 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 +
  3081. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&psn_no=" + psn_info.PsnNo + "&cainfo=" + miConfig.Cainfo
  3082. } else {
  3083. 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 +
  3084. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&psn_no=" + psn_info.PsnNo + "&cainfo=" + miConfig.Cainfo
  3085. }
  3086. resp, requestErr := http.Get(api)
  3087. if requestErr != nil {
  3088. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3089. return
  3090. }
  3091. body, ioErr := ioutil.ReadAll(resp.Body)
  3092. if ioErr != nil {
  3093. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  3094. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3095. return
  3096. }
  3097. var respJSON map[string]interface{}
  3098. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  3099. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  3100. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3101. return
  3102. }
  3103. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  3104. result, _ := json.Marshal(respJSON)
  3105. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  3106. utils.ErrorLog("解析失败:%v", err)
  3107. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3108. return
  3109. }
  3110. res.ErrMsg = res10265.ErrMsg
  3111. res.Output = res10265.Output
  3112. res.InfRefmsgid = res10265.InfRefmsgid
  3113. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  3114. res.Infcode = infocode
  3115. } else if miConfig.MdtrtareaAdmvs == "360399" {
  3116. p, _ := service.GetHisPatientById(patient_id)
  3117. result, _ := service.Jxyb5301(p.PsnNo, miConfig.OrgName, role.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, miConfig.Url, miConfig.AccessKey, "")
  3118. var dat map[string]interface{}
  3119. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  3120. fmt.Println(dat)
  3121. } else {
  3122. fmt.Println(err)
  3123. }
  3124. userJSONBytes, _ := json.Marshal(dat)
  3125. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  3126. utils.ErrorLog("解析失败:%v", err)
  3127. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3128. return
  3129. }
  3130. } else if miConfig.MdtrtareaAdmvs == "430800" {
  3131. p, _ := service.GetHisPatientById(patient_id)
  3132. result, _ := service.Hnyb5301(p.PsnNo, miConfig.OrgName, role.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, miConfig.Url, miConfig.AccessKey, "")
  3133. var dat map[string]interface{}
  3134. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  3135. fmt.Println(dat)
  3136. } else {
  3137. fmt.Println(err)
  3138. }
  3139. userJSONBytes, _ := json.Marshal(dat)
  3140. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  3141. utils.ErrorLog("解析失败:%v", err)
  3142. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3143. return
  3144. }
  3145. } else {
  3146. result := service.Gdyb5301(psn_record.PsnNo, miConfig.OrgName, role.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey)
  3147. var dat map[string]interface{}
  3148. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  3149. fmt.Println(dat)
  3150. } else {
  3151. fmt.Println(err)
  3152. }
  3153. userJSONBytes, _ := json.Marshal(dat)
  3154. if miConfig.Code == "H15049901371" {
  3155. if err := json.Unmarshal(userJSONBytes, &res10265); err != nil {
  3156. utils.ErrorLog("解析失败:%v", err)
  3157. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3158. return
  3159. }
  3160. res.InfRefmsgid = res10265.InfRefmsgid
  3161. res.Output = res10265.Output
  3162. res.ErrMsg = res10265.ErrMsg
  3163. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  3164. res.Infcode = infocode
  3165. } else {
  3166. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  3167. utils.ErrorLog("解析失败:%v", err)
  3168. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3169. return
  3170. }
  3171. }
  3172. }
  3173. if res.Infcode == 0 {
  3174. c.ServeSuccessJSON(map[string]interface{}{
  3175. "result": res.Output.Result,
  3176. })
  3177. }
  3178. }
  3179. func (c *HisApiController) CheckInsutype() {
  3180. his_patient_id, _ := c.GetInt64("his_patient_id")
  3181. admin_user_id, _ := c.GetInt64("admin_user_id")
  3182. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  3183. his, _ := service.GetNewHisPatientInfoFour(c.GetAdminUserInfo().CurrentOrgId, his_patient_id)
  3184. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  3185. result := service.Gdyb90100(his.PsnNo, miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey)
  3186. var dat map[string]interface{}
  3187. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  3188. fmt.Println(dat)
  3189. } else {
  3190. fmt.Println(err)
  3191. }
  3192. userJSONBytes, _ := json.Marshal(dat)
  3193. var res Result90100
  3194. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  3195. utils.ErrorLog("解析失败:%v", err)
  3196. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3197. return
  3198. }
  3199. if res.Infcode != 0 {
  3200. c.ServeSuccessJSON(map[string]interface{}{
  3201. "failed_code": -10,
  3202. "msg": res.ErrMsg,
  3203. })
  3204. return
  3205. } else {
  3206. fmt.Println(res)
  3207. }
  3208. }
  3209. func (c *HisApiController) CheckCardPWD() {
  3210. card_pwd := c.GetString("card_pwd")
  3211. his_patient_id, _ := c.GetInt64("his_patient_id")
  3212. admin_user_id, _ := c.GetInt64("admin_user_id")
  3213. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  3214. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  3215. his, _ := service.GetNewHisPatientInfoFour(c.GetAdminUserInfo().CurrentOrgId, his_patient_id)
  3216. psn, _ := service.GetPsnByPatientId(his.PatientId)
  3217. bas := strings.Split(psn.CardInfo, "|")
  3218. basNumber := bas[2]
  3219. if psn.InsuplcAdmdvs[:4] == "4403" {
  3220. result := service.Gdyb90991(his.PsnNo, miConfig.OrgName, roles.UserName, miConfig.Code, his.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, card_pwd, basNumber)
  3221. var dat map[string]interface{}
  3222. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  3223. fmt.Println(dat)
  3224. } else {
  3225. fmt.Println(err)
  3226. }
  3227. userJSONBytes, _ := json.Marshal(dat)
  3228. var res Result90991
  3229. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  3230. utils.ErrorLog("解析失败:%v", err)
  3231. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3232. return
  3233. }
  3234. if res.Infcode != 0 {
  3235. c.ServeSuccessJSON(map[string]interface{}{
  3236. "failed_code": -10,
  3237. "msg": res.ErrMsg,
  3238. })
  3239. return
  3240. } else {
  3241. if res.Output.Result.SscnoCheckStat == "0" && res.Output.Result.CardStat != "10" {
  3242. var msg string
  3243. switch res.Output.Result.CardStat {
  3244. case "00":
  3245. msg = "未激活"
  3246. break
  3247. case "10":
  3248. msg = "激活"
  3249. break
  3250. case "20":
  3251. msg = "窗口挂失"
  3252. break
  3253. case "21":
  3254. msg = "电话挂失"
  3255. break
  3256. case "22":
  3257. msg = "单位网上申报挂失"
  3258. break
  3259. case "23":
  3260. msg = "保健办挂失"
  3261. break
  3262. case "24":
  3263. msg = "个人网上挂失"
  3264. break
  3265. case "25":
  3266. msg = "网上服务大厅挂失"
  3267. break
  3268. case "30":
  3269. msg = "注销"
  3270. break
  3271. case "40":
  3272. msg = "回收"
  3273. break
  3274. case "99":
  3275. msg = "制卡中(无效卡)"
  3276. break
  3277. }
  3278. c.ServeSuccessJSON(map[string]interface{}{
  3279. "failed_code": -10,
  3280. "msg": msg,
  3281. })
  3282. return
  3283. } else {
  3284. c.ServeSuccessJSON(map[string]interface{}{
  3285. "msg": "校验成功",
  3286. })
  3287. return
  3288. }
  3289. }
  3290. } else {
  3291. c.ServeSuccessJSON(map[string]interface{}{
  3292. "msg": "校验成功",
  3293. })
  3294. return
  3295. }
  3296. }
  3297. func (c *HisApiController) CheckCardPWDTwo() {
  3298. //card_pwd := c.GetString("card_pwd")
  3299. //his_patient_id, _ := c.GetInt64("his_patient_id")
  3300. admin_user_id, _ := c.GetInt64("admin_user_id")
  3301. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  3302. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  3303. result := service.Gdyb90991("44030000000629690364", miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, "000000", "BDM421363")
  3304. var dat map[string]interface{}
  3305. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  3306. fmt.Println(dat)
  3307. } else {
  3308. fmt.Println(err)
  3309. }
  3310. userJSONBytes, _ := json.Marshal(dat)
  3311. var res Result90991
  3312. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  3313. utils.ErrorLog("解析失败:%v", err)
  3314. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3315. return
  3316. }
  3317. if res.Infcode != 0 {
  3318. c.ServeSuccessJSON(map[string]interface{}{
  3319. "failed_code": -10,
  3320. "msg": res.ErrMsg,
  3321. })
  3322. return
  3323. } else {
  3324. if res.Output.Result.SscnoCheckStat == "0" {
  3325. var msg string
  3326. switch res.Output.Result.CardStat {
  3327. case "00":
  3328. msg = "未激活"
  3329. break
  3330. case "10":
  3331. msg = "激活"
  3332. break
  3333. case "20":
  3334. msg = "窗口挂失"
  3335. break
  3336. case "21":
  3337. msg = "电话挂失"
  3338. break
  3339. case "22":
  3340. msg = "单位网上申报挂失"
  3341. break
  3342. case "23":
  3343. msg = "保健办挂失"
  3344. break
  3345. case "24":
  3346. msg = "个人网上挂失"
  3347. break
  3348. case "25":
  3349. msg = "网上服务大厅挂失"
  3350. break
  3351. case "30":
  3352. msg = "注销"
  3353. break
  3354. case "40":
  3355. msg = "回收"
  3356. break
  3357. case "99":
  3358. msg = "制卡中(无效卡)"
  3359. break
  3360. }
  3361. c.ServeSuccessJSON(map[string]interface{}{
  3362. "failed_code": -10,
  3363. "msg": msg,
  3364. })
  3365. return
  3366. } else {
  3367. c.ServeSuccessJSON(map[string]interface{}{
  3368. "msg": "校验成功",
  3369. })
  3370. return
  3371. }
  3372. }
  3373. }
  3374. type ELeCertData struct {
  3375. Data struct {
  3376. Extra string `json:"extra"`
  3377. IDNo string `json:"idNo"`
  3378. IDType string `json:"idType"`
  3379. EcToken string `json:"ecToken"`
  3380. InsuOrg string `json:"insuOrg"`
  3381. UserName string `json:"userName"`
  3382. EcIndexNo string `json:"ecIndexNo"`
  3383. Gender string `json:"gender"`
  3384. Birthday string `json:"birthday"`
  3385. Nationality string `json:"nationality"`
  3386. Email string `json:"email"`
  3387. } `json:"OutData"`
  3388. }
  3389. func (c *HisApiController) ReadCard() {
  3390. id_card_type, _ := c.GetInt64("id_card_type")
  3391. admin_user_id, _ := c.GetInt64("admin_user_id")
  3392. certificates, _ := c.GetInt64("certificates")
  3393. //insuplc_admdvs_str := c.GetString("insuplc_admdvs")
  3394. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  3395. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  3396. switch id_card_type {
  3397. case 1:
  3398. if miConfig.MdtrtareaAdmvs == "421300" {
  3399. var res ResultTwo
  3400. api := "http://192.168.124.4:9532/" + "hbyb/1101?cert_no=" + "" +
  3401. "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  3402. "&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)
  3403. resp, requestErr := http.Get(api)
  3404. if requestErr != nil {
  3405. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3406. return
  3407. }
  3408. body, ioErr := ioutil.ReadAll(resp.Body)
  3409. if ioErr != nil {
  3410. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  3411. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3412. return
  3413. }
  3414. var respJSON map[string]interface{}
  3415. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  3416. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  3417. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3418. return
  3419. }
  3420. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  3421. result, _ := json.Marshal(respJSON)
  3422. fmt.Println("log")
  3423. fmt.Println(string(result))
  3424. if err := json.Unmarshal([]byte(result), &res); err != nil {
  3425. utils.ErrorLog("解析失败:%v", err)
  3426. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3427. return
  3428. }
  3429. if res.Infcode == 0 {
  3430. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  3431. if err == gorm.ErrRecordNotFound {
  3432. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  3433. return
  3434. } else if err != nil {
  3435. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  3436. return
  3437. } else {
  3438. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  3439. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  3440. infoStr := string(Iinfos)
  3441. idetinfoStr := string(Idetinfos)
  3442. psn := &models.HisPsn{
  3443. PsnNo: res.Output.Baseinfo.PsnNo,
  3444. Age: res.Output.Baseinfo.Age,
  3445. PatientId: patient.ID,
  3446. Certno: res.Output.Baseinfo.Certno,
  3447. Brdy: res.Output.Baseinfo.Brdy,
  3448. Gend: res.Output.Baseinfo.Gend,
  3449. Naty: res.Output.Baseinfo.Naty,
  3450. PsnCertType: res.Output.Baseinfo.PsnCertType,
  3451. PsnName: res.Output.Baseinfo.PsnName,
  3452. Idetinfo: idetinfoStr,
  3453. Insuinfo: infoStr,
  3454. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  3455. }
  3456. service.CreateHisPsn(psn)
  3457. c.ServeSuccessJSON(map[string]interface{}{
  3458. "patient": patient,
  3459. "number": res.Output.Baseinfo.Certno,
  3460. })
  3461. }
  3462. } else {
  3463. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  3464. return
  3465. }
  3466. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  3467. var api string
  3468. if miConfig.MdtrtareaAdmvs == "320921" {
  3469. 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 +
  3470. "&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
  3471. fmt.Println(api)
  3472. } else {
  3473. 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 +
  3474. "&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)
  3475. }
  3476. resp, requestErr := http.Get(api)
  3477. if requestErr != nil {
  3478. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3479. return
  3480. }
  3481. body, ioErr := ioutil.ReadAll(resp.Body)
  3482. if ioErr != nil {
  3483. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  3484. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3485. return
  3486. }
  3487. var respJSON map[string]interface{}
  3488. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  3489. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  3490. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3491. return
  3492. }
  3493. var status string
  3494. status = respJSON["data"].(map[string]interface{})["status"].(string)
  3495. card_type := respJSON["data"].(map[string]interface{})["type"].(string)
  3496. //console.log()
  3497. fmt.Println("type===")
  3498. fmt.Println(card_type)
  3499. var token string
  3500. var res ResultTwo //1101结果
  3501. var res10265 ResultTwo10265 //1101结果
  3502. var card_info string //卡信息
  3503. var busi_card_info string
  3504. card_info = respJSON["data"].(map[string]interface{})["card_info"].(string)
  3505. busi_card_info = respJSON["data"].(map[string]interface{})["busi_card_info"].(string)
  3506. if status == "0" { //读卡成功
  3507. if card_type == "1" {
  3508. respJSON = respJSON["data"].(map[string]interface{})["result"].(map[string]interface{})
  3509. result, _ := json.Marshal(respJSON)
  3510. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  3511. utils.ErrorLog("解析失败:%v", err)
  3512. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3513. return
  3514. }
  3515. res.ErrMsg = res10265.ErrMsg
  3516. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  3517. res.Infcode = infocode
  3518. res.Output = res10265.Output
  3519. res.InfRefmsgid = res10265.InfRefmsgid
  3520. } else {
  3521. //var card_info string //卡信息
  3522. //var busi_card_info string
  3523. token = respJSON["data"].(map[string]interface{})["token"].(string)
  3524. //busi_card_info = respJSON["data"].(map[string]interface{})["busi_card_info"].(string)
  3525. //fmt.Println(card_info)
  3526. //fmt.Println(busi_card_info)
  3527. respJSON = respJSON["data"].(map[string]interface{})["result"].(map[string]interface{})
  3528. result, _ := json.Marshal(respJSON)
  3529. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  3530. utils.ErrorLog("解析失败:%v", err)
  3531. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3532. return
  3533. }
  3534. res.ErrMsg = res10265.ErrMsg
  3535. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  3536. res.Infcode = infocode
  3537. res.Output = res10265.Output
  3538. res.InfRefmsgid = res10265.InfRefmsgid
  3539. }
  3540. if res.Infcode == 0 {
  3541. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  3542. if err == gorm.ErrRecordNotFound {
  3543. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  3544. return
  3545. } else if err != nil {
  3546. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  3547. return
  3548. } else {
  3549. if card_type == "1" {
  3550. bas := strings.Split(card_info, "|")
  3551. basNumber := bas[2]
  3552. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  3553. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  3554. infoStr := string(Iinfos)
  3555. idetinfoStr := string(Idetinfos)
  3556. psn := &models.HisPsn{
  3557. PsnNo: res.Output.Baseinfo.PsnNo,
  3558. Age: res.Output.Baseinfo.Age,
  3559. PatientId: patient.ID,
  3560. Certno: res.Output.Baseinfo.Certno,
  3561. Brdy: res.Output.Baseinfo.Brdy,
  3562. Gend: res.Output.Baseinfo.Gend,
  3563. Naty: res.Output.Baseinfo.Naty,
  3564. PsnCertType: res.Output.Baseinfo.PsnCertType,
  3565. PsnName: res.Output.Baseinfo.PsnName,
  3566. Idetinfo: idetinfoStr,
  3567. Insuinfo: infoStr,
  3568. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  3569. CardInfo: card_info,
  3570. VerifyNumber: busi_card_info,
  3571. }
  3572. service.CreateHisPsn(psn)
  3573. var rf []*ResultFive
  3574. json.Unmarshal([]byte(infoStr), &rf)
  3575. var insutypes []*ResultFive
  3576. var insutype string
  3577. var is390 int = 0
  3578. var is310 int = 0
  3579. for _, item := range rf {
  3580. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  3581. insutypes = append(insutypes, item)
  3582. }
  3583. }
  3584. if len(insutypes) == 1 {
  3585. insutype = insutypes[0].Insutype
  3586. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  3587. } else {
  3588. for _, i := range insutypes {
  3589. if i.Insutype == "390" {
  3590. is390 = 1
  3591. }
  3592. if i.Insutype == "310" {
  3593. is310 = 1
  3594. }
  3595. }
  3596. }
  3597. if is390 == 1 {
  3598. insutype = "390"
  3599. }
  3600. if is310 == 1 {
  3601. insutype = "310"
  3602. }
  3603. if len(insutypes) == 0 {
  3604. insutype = "310"
  3605. }
  3606. c.ServeSuccessJSON(map[string]interface{}{
  3607. "patient": patient,
  3608. "number": basNumber,
  3609. "insutype": insutype,
  3610. })
  3611. } else {
  3612. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  3613. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  3614. infoStr := string(Iinfos)
  3615. idetinfoStr := string(Idetinfos)
  3616. psn := &models.HisPsn{
  3617. PsnNo: res.Output.Baseinfo.PsnNo,
  3618. Age: res.Output.Baseinfo.Age,
  3619. PatientId: patient.ID,
  3620. Certno: res.Output.Baseinfo.Certno,
  3621. Brdy: res.Output.Baseinfo.Brdy,
  3622. Gend: res.Output.Baseinfo.Gend,
  3623. Naty: res.Output.Baseinfo.Naty,
  3624. PsnCertType: res.Output.Baseinfo.PsnCertType,
  3625. PsnName: res.Output.Baseinfo.PsnName,
  3626. Idetinfo: idetinfoStr,
  3627. Insuinfo: infoStr,
  3628. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  3629. CardInfo: card_info,
  3630. VerifyNumber: token,
  3631. }
  3632. service.CreateHisPsn(psn)
  3633. c.ServeSuccessJSON(map[string]interface{}{
  3634. "patient": patient,
  3635. "number": token,
  3636. })
  3637. }
  3638. }
  3639. } else {
  3640. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  3641. return
  3642. }
  3643. } else { //读卡失败
  3644. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  3645. return
  3646. }
  3647. } else if miConfig.MdtrtareaAdmvs == "350500" {
  3648. cardnum, cardCode, id_card_no, name, errmsg := c.GetFjBasBaseInfo()
  3649. cardnum = DeleteExtraSpaceTwo(cardnum)
  3650. cardCode = DeleteExtraSpaceTwo(cardCode)
  3651. id_card_no = DeleteExtraSpaceTwo(id_card_no)
  3652. name = DeleteExtraSpaceTwo(name)
  3653. errmsg = DeleteExtraSpaceTwo(errmsg)
  3654. cardnum = Remove0000(cardnum)
  3655. cardCode = Remove0000(cardCode)
  3656. id_card_no = Remove0000(id_card_no)
  3657. name = Remove0000(name)
  3658. errmsg = Remove0000(errmsg)
  3659. patient, _ := service.GetPatientByIDCard(id_card_no, miConfig.UserOrgId)
  3660. basStr := cardnum + "|" + cardCode + "|" + id_card_no + "|" + name
  3661. //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)
  3662. //fmt.Println(result2)
  3663. //fmt.Println(requestLog2)
  3664. //fmt.Println(errMsgLog2)
  3665. 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)
  3666. saveLog(result, requestLog, "1101", "获取人员信息")
  3667. fmt.Println(errMsgLog)
  3668. if len(errMsgLog) > 0 {
  3669. } else {
  3670. var dat map[string]interface{}
  3671. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  3672. fmt.Println(dat)
  3673. } else {
  3674. fmt.Println(err)
  3675. }
  3676. userJSONBytes, _ := json.Marshal(dat)
  3677. var res ResultTwo
  3678. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  3679. utils.ErrorLog("解析失败:%v", err)
  3680. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3681. return
  3682. }
  3683. res.ErrMsg = errMsgLog
  3684. if res.Infcode == 0 {
  3685. patient, err := service.GetPatientByNumber(id_card_no, c.GetAdminUserInfo().CurrentOrgId)
  3686. if err == gorm.ErrRecordNotFound {
  3687. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  3688. return
  3689. } else if err != nil {
  3690. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  3691. return
  3692. } else {
  3693. fmt.Println(res)
  3694. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  3695. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  3696. infoStr := string(Iinfos)
  3697. idetinfoStr := string(Idetinfos)
  3698. var rf []*ResultFive
  3699. json.Unmarshal([]byte(infoStr), &rf)
  3700. var insutypes []*ResultFive
  3701. var insutype string
  3702. var is390 int = 0
  3703. var is310 int = 0
  3704. for _, item := range rf {
  3705. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  3706. insutypes = append(insutypes, item)
  3707. }
  3708. }
  3709. if len(insutypes) == 1 {
  3710. insutype = insutypes[0].Insutype
  3711. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  3712. } else {
  3713. for _, i := range insutypes {
  3714. if i.Insutype == "390" {
  3715. is390 = 1
  3716. }
  3717. if i.Insutype == "310" {
  3718. is310 = 1
  3719. }
  3720. }
  3721. }
  3722. if is390 == 1 {
  3723. insutype = "390"
  3724. }
  3725. if is310 == 1 {
  3726. insutype = "310"
  3727. }
  3728. if len(insutypes) == 0 {
  3729. insutype = "390"
  3730. }
  3731. var insuplc_admdvs string
  3732. for _, item := range rf {
  3733. if item.Insutype == insutype {
  3734. insuplc_admdvs = item.InsuplcAdmdvs
  3735. }
  3736. }
  3737. psn := &models.HisPsn{
  3738. PsnNo: res.Output.Baseinfo.PsnNo,
  3739. Age: res.Output.Baseinfo.Age,
  3740. PatientId: patient.ID,
  3741. Certno: res.Output.Baseinfo.Certno,
  3742. Brdy: res.Output.Baseinfo.Brdy,
  3743. Gend: res.Output.Baseinfo.Gend,
  3744. Naty: res.Output.Baseinfo.Naty,
  3745. PsnCertType: res.Output.Baseinfo.PsnCertType,
  3746. PsnName: res.Output.Baseinfo.PsnName,
  3747. Idetinfo: idetinfoStr,
  3748. Insuinfo: infoStr,
  3749. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  3750. CardInfo: basStr,
  3751. VerifyNumber: "",
  3752. InsuplcAdmdvs: insuplc_admdvs,
  3753. }
  3754. service.CreateHisPsn(psn)
  3755. c.ServeSuccessJSON(map[string]interface{}{
  3756. "patient": patient,
  3757. "number": cardnum,
  3758. "insutype": insutype,
  3759. })
  3760. }
  3761. } else {
  3762. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  3763. return
  3764. }
  3765. }
  3766. } else if miConfig.MdtrtareaAdmvs == "360399" {
  3767. fmt.Println(initFlag)
  3768. fmt.Println("initFlag")
  3769. if initFlag == 0 {
  3770. c.TestGetJiangXiBasBaseInit()
  3771. }
  3772. basStr := c.GetBasBaseInfo()
  3773. if len(basStr) == 0 {
  3774. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeReadCardException)
  3775. return
  3776. }
  3777. fmt.Println(basStr)
  3778. bas := strings.Split(basStr, "|")
  3779. basNumber := bas[1]
  3780. fmt.Println(basNumber)
  3781. card_sn := bas[3]
  3782. fmt.Println(card_sn)
  3783. 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, "")
  3784. //result := service.Jxyb1101(basNumber, miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, id_card_type, card_sn, certificates)
  3785. var dat map[string]interface{}
  3786. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  3787. fmt.Println(dat)
  3788. } else {
  3789. fmt.Println(err)
  3790. }
  3791. userJSONBytes, _ := json.Marshal(dat)
  3792. var res ResultTwo
  3793. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  3794. utils.ErrorLog("解析失败:%v", err)
  3795. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3796. return
  3797. }
  3798. if res.Infcode == 0 {
  3799. patient, err := service.GetPatientByNumber(basNumber, c.GetAdminUserInfo().CurrentOrgId)
  3800. if err == gorm.ErrRecordNotFound {
  3801. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  3802. return
  3803. } else if err != nil {
  3804. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  3805. return
  3806. } else {
  3807. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  3808. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  3809. infoStr := string(Iinfos)
  3810. idetinfoStr := string(Idetinfos)
  3811. psn := &models.HisPsn{
  3812. PsnNo: res.Output.Baseinfo.PsnNo,
  3813. Age: res.Output.Baseinfo.Age,
  3814. PatientId: patient.ID,
  3815. Certno: res.Output.Baseinfo.Certno,
  3816. Brdy: res.Output.Baseinfo.Brdy,
  3817. Gend: res.Output.Baseinfo.Gend,
  3818. Naty: res.Output.Baseinfo.Naty,
  3819. PsnCertType: res.Output.Baseinfo.PsnCertType,
  3820. PsnName: res.Output.Baseinfo.PsnName,
  3821. Idetinfo: idetinfoStr,
  3822. Insuinfo: infoStr,
  3823. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  3824. CardInfo: basStr,
  3825. VerifyNumber: "",
  3826. }
  3827. service.CreateHisPsn(psn)
  3828. var rf []*ResultFive
  3829. json.Unmarshal([]byte(infoStr), &rf)
  3830. var insutypes []*ResultFive
  3831. var insutype string
  3832. var is390 int = 0
  3833. var is310 int = 0
  3834. for _, item := range rf {
  3835. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  3836. insutypes = append(insutypes, item)
  3837. }
  3838. }
  3839. if len(insutypes) == 1 {
  3840. insutype = insutypes[0].Insutype
  3841. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  3842. } else {
  3843. for _, i := range insutypes {
  3844. if i.Insutype == "390" {
  3845. is390 = 1
  3846. }
  3847. if i.Insutype == "310" {
  3848. is310 = 1
  3849. }
  3850. }
  3851. }
  3852. if is390 == 1 {
  3853. insutype = "390"
  3854. }
  3855. if is310 == 1 {
  3856. insutype = "310"
  3857. }
  3858. if len(insutypes) == 0 {
  3859. insutype = "310"
  3860. }
  3861. c.ServeSuccessJSON(map[string]interface{}{
  3862. "patient": patient,
  3863. "number": basNumber,
  3864. "insutype": insutype,
  3865. })
  3866. }
  3867. } else {
  3868. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  3869. return
  3870. }
  3871. } else if miConfig.MdtrtareaAdmvs == "430800" {
  3872. fmt.Println(initFlag)
  3873. fmt.Println("initFlag")
  3874. if initFlag == 0 {
  3875. c.TestGetHnBasBaseInit()
  3876. }
  3877. basStr := c.GetBasBaseInfo()
  3878. if len(basStr) == 0 {
  3879. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeReadCardException)
  3880. return
  3881. }
  3882. fmt.Println(basStr)
  3883. bas := strings.Split(basStr, "|")
  3884. basNumber := bas[1]
  3885. fmt.Println(basNumber)
  3886. card_sn := bas[3]
  3887. card_no := bas[2]
  3888. fmt.Println(card_sn)
  3889. name := bas[4]
  3890. name = ConvertToString(name, "gbk", "utf-8")
  3891. 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)
  3892. //result := service.Jxyb1101(basNumber, miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, id_card_type, card_sn, certificates)
  3893. var dat map[string]interface{}
  3894. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  3895. fmt.Println(dat)
  3896. } else {
  3897. fmt.Println(err)
  3898. }
  3899. userJSONBytes, _ := json.Marshal(dat)
  3900. var res ResultTwo
  3901. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  3902. utils.ErrorLog("解析失败:%v", err)
  3903. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3904. return
  3905. }
  3906. if res.Infcode == 0 {
  3907. patient, err := service.GetPatientByNumber(basNumber, c.GetAdminUserInfo().CurrentOrgId)
  3908. if err == gorm.ErrRecordNotFound {
  3909. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  3910. return
  3911. } else if err != nil {
  3912. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  3913. return
  3914. } else {
  3915. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  3916. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  3917. infoStr := string(Iinfos)
  3918. idetinfoStr := string(Idetinfos)
  3919. psn := &models.HisPsn{
  3920. PsnNo: res.Output.Baseinfo.PsnNo,
  3921. Age: res.Output.Baseinfo.Age,
  3922. PatientId: patient.ID,
  3923. Certno: res.Output.Baseinfo.Certno,
  3924. Brdy: res.Output.Baseinfo.Brdy,
  3925. Gend: res.Output.Baseinfo.Gend,
  3926. Naty: res.Output.Baseinfo.Naty,
  3927. PsnCertType: res.Output.Baseinfo.PsnCertType,
  3928. PsnName: res.Output.Baseinfo.PsnName,
  3929. Idetinfo: idetinfoStr,
  3930. Insuinfo: infoStr,
  3931. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  3932. CardInfo: basStr,
  3933. VerifyNumber: "",
  3934. }
  3935. service.CreateHisPsn(psn)
  3936. var rf []*ResultFive
  3937. json.Unmarshal([]byte(infoStr), &rf)
  3938. var insutypes []*ResultFive
  3939. var insutype string
  3940. var is390 int = 0
  3941. var is310 int = 0
  3942. for _, item := range rf {
  3943. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  3944. insutypes = append(insutypes, item)
  3945. }
  3946. }
  3947. if len(insutypes) == 1 {
  3948. insutype = insutypes[0].Insutype
  3949. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  3950. } else {
  3951. for _, i := range insutypes {
  3952. if i.Insutype == "390" {
  3953. is390 = 1
  3954. }
  3955. if i.Insutype == "310" {
  3956. is310 = 1
  3957. }
  3958. }
  3959. }
  3960. if is390 == 1 {
  3961. insutype = "390"
  3962. }
  3963. if is310 == 1 {
  3964. insutype = "310"
  3965. }
  3966. if len(insutypes) == 0 {
  3967. insutype = "310"
  3968. }
  3969. c.ServeSuccessJSON(map[string]interface{}{
  3970. "patient": patient,
  3971. "number": basNumber,
  3972. "insutype": insutype,
  3973. })
  3974. }
  3975. } else {
  3976. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  3977. return
  3978. }
  3979. } else {
  3980. if initFlag == 0 {
  3981. c.TestGetBasBaseInit()
  3982. }
  3983. basStr := c.GetBasBaseInfo()
  3984. if len(basStr) == 0 {
  3985. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeReadCardException)
  3986. return
  3987. }
  3988. fmt.Println(basStr)
  3989. bas := strings.Split(basStr, "|")
  3990. basNumber := bas[1]
  3991. fmt.Println(basNumber)
  3992. card_sn := bas[3]
  3993. fmt.Println(card_sn)
  3994. cardNumber := bas[2]
  3995. fmt.Println(cardNumber)
  3996. patient, _ := service.GetPatientByIDCard(basNumber, miConfig.UserOrgId)
  3997. var result string
  3998. if bas[0][:2] == "44" {
  3999. 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)
  4000. } else {
  4001. 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)
  4002. }
  4003. var dat map[string]interface{}
  4004. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  4005. fmt.Println(dat)
  4006. } else {
  4007. fmt.Println(err)
  4008. }
  4009. userJSONBytes, _ := json.Marshal(dat)
  4010. var res ResultTwo
  4011. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  4012. utils.ErrorLog("解析失败:%v", err)
  4013. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4014. return
  4015. }
  4016. if res.Infcode == 0 {
  4017. patient, err := service.GetPatientByNumber(basNumber, c.GetAdminUserInfo().CurrentOrgId)
  4018. if err == gorm.ErrRecordNotFound {
  4019. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  4020. return
  4021. } else if err != nil {
  4022. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  4023. return
  4024. } else {
  4025. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  4026. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  4027. infoStr := string(Iinfos)
  4028. idetinfoStr := string(Idetinfos)
  4029. var rf []*ResultFive
  4030. json.Unmarshal([]byte(infoStr), &rf)
  4031. var insutypes []*ResultFive
  4032. var insutype string
  4033. var is390 int = 0
  4034. var is310 int = 0
  4035. var insuplc_admdvs string
  4036. for _, item := range rf {
  4037. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  4038. insutypes = append(insutypes, item)
  4039. }
  4040. }
  4041. if len(insutypes) == 1 {
  4042. insutype = insutypes[0].Insutype
  4043. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  4044. } else {
  4045. for _, i := range insutypes {
  4046. if i.Insutype == "390" {
  4047. is390 = 1
  4048. }
  4049. if i.Insutype == "310" {
  4050. is310 = 1
  4051. }
  4052. }
  4053. }
  4054. if is390 == 1 {
  4055. insutype = "390"
  4056. }
  4057. if is310 == 1 {
  4058. insutype = "310"
  4059. }
  4060. if len(insutypes) == 0 {
  4061. insutype = "310"
  4062. }
  4063. for _, item := range rf {
  4064. if item.Insutype == insutype {
  4065. insuplc_admdvs = item.InsuplcAdmdvs
  4066. }
  4067. }
  4068. psn := &models.HisPsn{
  4069. PsnNo: res.Output.Baseinfo.PsnNo,
  4070. Age: res.Output.Baseinfo.Age,
  4071. PatientId: patient.ID,
  4072. Certno: res.Output.Baseinfo.Certno,
  4073. Brdy: res.Output.Baseinfo.Brdy,
  4074. Gend: res.Output.Baseinfo.Gend,
  4075. Naty: res.Output.Baseinfo.Naty,
  4076. PsnCertType: res.Output.Baseinfo.PsnCertType,
  4077. PsnName: res.Output.Baseinfo.PsnName,
  4078. Idetinfo: idetinfoStr,
  4079. Insuinfo: infoStr,
  4080. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  4081. CardInfo: basStr,
  4082. VerifyNumber: "",
  4083. InsuplcAdmdvs: insuplc_admdvs,
  4084. }
  4085. service.CreateHisPsn(psn)
  4086. c.ServeSuccessJSON(map[string]interface{}{
  4087. "patient": patient,
  4088. "number": basNumber,
  4089. })
  4090. }
  4091. } else {
  4092. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  4093. return
  4094. }
  4095. break
  4096. }
  4097. case 2:
  4098. if miConfig.MdtrtareaAdmvs == "430800" {
  4099. if initFlag == 0 {
  4100. c.TestGetHnBasBaseInit()
  4101. }
  4102. SFZStr := c.GetSFZBaseInfo()
  4103. if len(SFZStr) == 0 {
  4104. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeReadCardException)
  4105. return
  4106. }
  4107. fmt.Println(SFZStr)
  4108. id_card_str := strings.Split(SFZStr, "^")
  4109. card_no := id_card_str[0]
  4110. patient, _ := service.GetPatientByNumber(card_no, c.GetAdminUserInfo().CurrentOrgId)
  4111. //name := id_card_str[1]
  4112. //name = ConvertToString(name, "gbk", "utf-8")
  4113. 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)
  4114. var dat map[string]interface{}
  4115. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  4116. fmt.Println(dat)
  4117. } else {
  4118. fmt.Println(err)
  4119. }
  4120. userJSONBytes, _ := json.Marshal(dat)
  4121. var res ResultTwo
  4122. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  4123. utils.ErrorLog("解析失败:%v", err)
  4124. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4125. return
  4126. }
  4127. if res.Infcode == 0 {
  4128. patient, err := service.GetPatientByNumber(card_no, c.GetAdminUserInfo().CurrentOrgId)
  4129. if err == gorm.ErrRecordNotFound {
  4130. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  4131. return
  4132. } else if err != nil {
  4133. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  4134. return
  4135. } else {
  4136. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  4137. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  4138. infoStr := string(Iinfos)
  4139. idetinfoStr := string(Idetinfos)
  4140. psn := &models.HisPsn{
  4141. PsnNo: res.Output.Baseinfo.PsnNo,
  4142. Age: res.Output.Baseinfo.Age,
  4143. PatientId: patient.ID,
  4144. Certno: res.Output.Baseinfo.Certno,
  4145. Brdy: res.Output.Baseinfo.Brdy,
  4146. Gend: res.Output.Baseinfo.Gend,
  4147. Naty: res.Output.Baseinfo.Naty,
  4148. PsnCertType: res.Output.Baseinfo.PsnCertType,
  4149. PsnName: res.Output.Baseinfo.PsnName,
  4150. Idetinfo: idetinfoStr,
  4151. Insuinfo: infoStr,
  4152. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  4153. CardInfo: SFZStr,
  4154. VerifyNumber: "",
  4155. }
  4156. service.CreateHisPsn(psn)
  4157. var rf []*ResultFive
  4158. json.Unmarshal([]byte(infoStr), &rf)
  4159. var insutypes []*ResultFive
  4160. var insutype string
  4161. var is390 int = 0
  4162. var is310 int = 0
  4163. for _, item := range rf {
  4164. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  4165. insutypes = append(insutypes, item)
  4166. }
  4167. }
  4168. if len(insutypes) == 1 {
  4169. insutype = insutypes[0].Insutype
  4170. } else {
  4171. for _, i := range insutypes {
  4172. if i.Insutype == "390" {
  4173. is390 = 1
  4174. }
  4175. if i.Insutype == "310" {
  4176. is310 = 1
  4177. }
  4178. }
  4179. }
  4180. if is390 == 1 {
  4181. insutype = "390"
  4182. }
  4183. if is310 == 1 {
  4184. insutype = "310"
  4185. }
  4186. if len(insutypes) == 0 {
  4187. insutype = "310"
  4188. }
  4189. c.ServeSuccessJSON(map[string]interface{}{
  4190. "patient": patient,
  4191. "number": card_no,
  4192. "insutype": insutype,
  4193. })
  4194. }
  4195. } else {
  4196. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  4197. return
  4198. }
  4199. } else {
  4200. SFZStr := c.GetSFZBaseInfo()
  4201. id_card_str := strings.Split(SFZStr, "^")
  4202. id_card_number := id_card_str[0]
  4203. card_sn := ""
  4204. result := service.Gdyb1101B(id_card_number, miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, id_card_type, card_sn, certificates, "", "")
  4205. var dat map[string]interface{}
  4206. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  4207. fmt.Println(dat)
  4208. } else {
  4209. fmt.Println(err)
  4210. }
  4211. userJSONBytes, _ := json.Marshal(dat)
  4212. var res ResultTwo
  4213. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  4214. utils.ErrorLog("解析失败:%v", err)
  4215. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4216. return
  4217. }
  4218. if res.Infcode == 0 {
  4219. patient, err := service.GetPatientByNumber(id_card_number, c.GetAdminUserInfo().CurrentOrgId)
  4220. if err == gorm.ErrRecordNotFound {
  4221. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  4222. return
  4223. } else if err != nil {
  4224. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  4225. return
  4226. } else {
  4227. c.ServeSuccessJSON(map[string]interface{}{
  4228. "patient": patient,
  4229. "number": id_card_number,
  4230. })
  4231. }
  4232. } else {
  4233. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  4234. return
  4235. }
  4236. }
  4237. break
  4238. case 3:
  4239. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  4240. var api string
  4241. if miConfig.MdtrtareaAdmvs == "320921" {
  4242. 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 +
  4243. "&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
  4244. fmt.Println(api)
  4245. } else {
  4246. 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 +
  4247. "&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)
  4248. }
  4249. resp, requestErr := http.Get(api)
  4250. if requestErr != nil {
  4251. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4252. return
  4253. }
  4254. body, ioErr := ioutil.ReadAll(resp.Body)
  4255. if ioErr != nil {
  4256. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  4257. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4258. return
  4259. }
  4260. var respJSON map[string]interface{}
  4261. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  4262. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  4263. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4264. return
  4265. }
  4266. var status string
  4267. status = respJSON["data"].(map[string]interface{})["status"].(string)
  4268. card_type := respJSON["data"].(map[string]interface{})["type"].(string)
  4269. var token string
  4270. var res ResultTwo //1101结果
  4271. var res10265 ResultTwo10265 //1101结果
  4272. var card_info string //卡信息
  4273. var busi_card_info string
  4274. //card_info = respJSON["data"].(map[string]interface{})["card_info"].(string)
  4275. busi_card_info = respJSON["data"].(map[string]interface{})["busi_card_info"].(string)
  4276. if status == "0" { //读卡成功
  4277. if card_type == "1" {
  4278. respJSON = respJSON["data"].(map[string]interface{})["result"].(map[string]interface{})
  4279. result, _ := json.Marshal(respJSON)
  4280. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  4281. utils.ErrorLog("解析失败:%v", err)
  4282. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4283. return
  4284. }
  4285. res.ErrMsg = res10265.ErrMsg
  4286. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  4287. res.Infcode = infocode
  4288. res.Output = res10265.Output
  4289. res.InfRefmsgid = res10265.InfRefmsgid
  4290. } else {
  4291. //var card_info string //卡信息
  4292. //var busi_card_info string
  4293. token = respJSON["data"].(map[string]interface{})["token"].(string)
  4294. //busi_card_info = respJSON["data"].(map[string]interface{})["busi_card_info"].(string)
  4295. //fmt.Println(card_info)
  4296. //fmt.Println(busi_card_info)
  4297. respJSON = respJSON["data"].(map[string]interface{})["result"].(map[string]interface{})
  4298. result, _ := json.Marshal(respJSON)
  4299. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  4300. utils.ErrorLog("解析失败:%v", err)
  4301. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4302. return
  4303. }
  4304. res.ErrMsg = res10265.ErrMsg
  4305. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  4306. res.Infcode = infocode
  4307. res.Output = res10265.Output
  4308. res.InfRefmsgid = res10265.InfRefmsgid
  4309. }
  4310. if res.Infcode == 0 {
  4311. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  4312. if err == gorm.ErrRecordNotFound {
  4313. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  4314. return
  4315. } else if err != nil {
  4316. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  4317. return
  4318. } else {
  4319. if card_type == "1" {
  4320. bas := strings.Split(card_info, "|")
  4321. basNumber := bas[2]
  4322. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  4323. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  4324. infoStr := string(Iinfos)
  4325. idetinfoStr := string(Idetinfos)
  4326. psn := &models.HisPsn{
  4327. PsnNo: res.Output.Baseinfo.PsnNo,
  4328. Age: res.Output.Baseinfo.Age,
  4329. PatientId: patient.ID,
  4330. Certno: res.Output.Baseinfo.Certno,
  4331. Brdy: res.Output.Baseinfo.Brdy,
  4332. Gend: res.Output.Baseinfo.Gend,
  4333. Naty: res.Output.Baseinfo.Naty,
  4334. PsnCertType: res.Output.Baseinfo.PsnCertType,
  4335. PsnName: res.Output.Baseinfo.PsnName,
  4336. Idetinfo: idetinfoStr,
  4337. Insuinfo: infoStr,
  4338. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  4339. CardInfo: card_info,
  4340. VerifyNumber: busi_card_info,
  4341. }
  4342. service.CreateHisPsn(psn)
  4343. c.ServeSuccessJSON(map[string]interface{}{
  4344. "patient": patient,
  4345. "number": basNumber,
  4346. })
  4347. } else {
  4348. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  4349. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  4350. infoStr := string(Iinfos)
  4351. idetinfoStr := string(Idetinfos)
  4352. psn := &models.HisPsn{
  4353. PsnNo: res.Output.Baseinfo.PsnNo,
  4354. Age: res.Output.Baseinfo.Age,
  4355. PatientId: patient.ID,
  4356. Certno: res.Output.Baseinfo.Certno,
  4357. Brdy: res.Output.Baseinfo.Brdy,
  4358. Gend: res.Output.Baseinfo.Gend,
  4359. Naty: res.Output.Baseinfo.Naty,
  4360. PsnCertType: res.Output.Baseinfo.PsnCertType,
  4361. PsnName: res.Output.Baseinfo.PsnName,
  4362. Idetinfo: idetinfoStr,
  4363. Insuinfo: infoStr,
  4364. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  4365. CardInfo: card_info,
  4366. VerifyNumber: token,
  4367. }
  4368. service.CreateHisPsn(psn)
  4369. var rf []*ResultFive
  4370. json.Unmarshal([]byte(infoStr), &rf)
  4371. var insutypes []*ResultFive
  4372. var insutype string
  4373. var is390 int = 0
  4374. var is310 int = 0
  4375. for _, item := range rf {
  4376. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  4377. insutypes = append(insutypes, item)
  4378. }
  4379. }
  4380. if len(insutypes) == 1 {
  4381. insutype = insutypes[0].Insutype
  4382. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  4383. } else {
  4384. for _, i := range insutypes {
  4385. if i.Insutype == "390" {
  4386. is390 = 1
  4387. }
  4388. if i.Insutype == "310" {
  4389. is310 = 1
  4390. }
  4391. }
  4392. }
  4393. if is390 == 1 {
  4394. insutype = "390"
  4395. }
  4396. if is310 == 1 {
  4397. insutype = "310"
  4398. }
  4399. if len(insutypes) == 0 {
  4400. insutype = "310"
  4401. }
  4402. c.ServeSuccessJSON(map[string]interface{}{
  4403. "patient": patient,
  4404. "number": token,
  4405. "insutype": insutype,
  4406. })
  4407. }
  4408. }
  4409. } else {
  4410. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  4411. return
  4412. }
  4413. } else { //读卡失败
  4414. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  4415. return
  4416. }
  4417. }
  4418. break
  4419. case 4:
  4420. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  4421. var api string
  4422. if miConfig.MdtrtareaAdmvs == "320921" {
  4423. 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 +
  4424. "&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
  4425. fmt.Println(api)
  4426. } else {
  4427. 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 +
  4428. "&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)
  4429. }
  4430. resp, requestErr := http.Get(api)
  4431. if requestErr != nil {
  4432. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4433. return
  4434. }
  4435. body, ioErr := ioutil.ReadAll(resp.Body)
  4436. if ioErr != nil {
  4437. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  4438. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4439. return
  4440. }
  4441. var respJSON map[string]interface{}
  4442. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  4443. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  4444. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4445. return
  4446. }
  4447. var status string
  4448. status = respJSON["data"].(map[string]interface{})["status"].(string)
  4449. //card_type := respJSON["data"].(map[string]interface{})["type"].(string)
  4450. var token string
  4451. var res ResultTwo //1101结果
  4452. var res10265 ResultTwo10265 //1101结果
  4453. if status == "0" { //读卡成功
  4454. var card_info string //卡信息
  4455. var busi_card_info string
  4456. token = respJSON["data"].(map[string]interface{})["token"].(string)
  4457. busi_card_info = respJSON["data"].(map[string]interface{})["busi_card_info"].(string)
  4458. card_info = respJSON["data"].(map[string]interface{})["card_info"].(string)
  4459. fmt.Println(card_info)
  4460. fmt.Println(busi_card_info)
  4461. respJSON = respJSON["data"].(map[string]interface{})["result"].(map[string]interface{})
  4462. result, _ := json.Marshal(respJSON)
  4463. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  4464. utils.ErrorLog("解析失败:%v", err)
  4465. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4466. return
  4467. }
  4468. res.ErrMsg = res10265.ErrMsg
  4469. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  4470. res.Infcode = infocode
  4471. res.Output = res10265.Output
  4472. res.InfRefmsgid = res10265.InfRefmsgid
  4473. if res.Infcode == 0 {
  4474. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  4475. if err == gorm.ErrRecordNotFound {
  4476. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  4477. return
  4478. } else if err != nil {
  4479. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  4480. return
  4481. } else {
  4482. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  4483. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  4484. infoStr := string(Iinfos)
  4485. idetinfoStr := string(Idetinfos)
  4486. psn := &models.HisPsn{
  4487. PsnNo: res.Output.Baseinfo.PsnNo,
  4488. Age: res.Output.Baseinfo.Age,
  4489. PatientId: patient.ID,
  4490. Certno: res.Output.Baseinfo.Certno,
  4491. Brdy: res.Output.Baseinfo.Brdy,
  4492. Gend: res.Output.Baseinfo.Gend,
  4493. Naty: res.Output.Baseinfo.Naty,
  4494. PsnCertType: res.Output.Baseinfo.PsnCertType,
  4495. PsnName: res.Output.Baseinfo.PsnName,
  4496. Idetinfo: idetinfoStr,
  4497. Insuinfo: infoStr,
  4498. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  4499. CardInfo: card_info,
  4500. VerifyNumber: token,
  4501. }
  4502. var rf []*ResultFive
  4503. json.Unmarshal([]byte(infoStr), &rf)
  4504. var insutypes []*ResultFive
  4505. var insutype string
  4506. var is390 int = 0
  4507. var is310 int = 0
  4508. for _, item := range rf {
  4509. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  4510. insutypes = append(insutypes, item)
  4511. }
  4512. }
  4513. if len(insutypes) == 1 {
  4514. insutype = insutypes[0].Insutype
  4515. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  4516. } else {
  4517. for _, i := range insutypes {
  4518. if i.Insutype == "390" {
  4519. is390 = 1
  4520. }
  4521. if i.Insutype == "310" {
  4522. is310 = 1
  4523. }
  4524. }
  4525. }
  4526. if is390 == 1 {
  4527. insutype = "390"
  4528. }
  4529. if is310 == 1 {
  4530. insutype = "310"
  4531. }
  4532. if len(insutypes) == 0 {
  4533. insutype = "310"
  4534. }
  4535. service.CreateHisPsn(psn)
  4536. c.ServeSuccessJSON(map[string]interface{}{
  4537. "patient": patient,
  4538. "number": token,
  4539. "insutype": insutype,
  4540. })
  4541. }
  4542. } else {
  4543. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  4544. return
  4545. }
  4546. } else { //读卡失败
  4547. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  4548. return
  4549. }
  4550. } else if miConfig.MdtrtareaAdmvs == "430800" {
  4551. idNo := c.GetString("idNo")
  4552. userName := c.GetString("userName")
  4553. ecToken := c.GetString("ecToken")
  4554. insuOrg := c.GetString("insuOrg")
  4555. result2, requestLog2 := service.Hnyb1101ForEleCert(miConfig.OrgName, roles.UserName, miConfig.Code, insuOrg, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, miConfig.Url, miConfig.AccessKey, ecToken, "", idNo, userName)
  4556. saveLog(result2, requestLog2, "1101", "获取人员信息")
  4557. var res ResultTwo
  4558. if err := json.Unmarshal([]byte(result2), &res); err != nil {
  4559. utils.ErrorLog("解析失败:%v", err)
  4560. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4561. return
  4562. }
  4563. if res.Infcode == 0 {
  4564. patient, err := service.GetPatientByNumber(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  4565. if err == gorm.ErrRecordNotFound {
  4566. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  4567. return
  4568. } else if err != nil {
  4569. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  4570. return
  4571. } else {
  4572. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  4573. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  4574. infoStr := string(Iinfos)
  4575. idetinfoStr := string(Idetinfos)
  4576. psn := &models.HisPsn{
  4577. PsnNo: res.Output.Baseinfo.PsnNo,
  4578. Age: res.Output.Baseinfo.Age,
  4579. PatientId: patient.ID,
  4580. Certno: res.Output.Baseinfo.Certno,
  4581. Brdy: res.Output.Baseinfo.Brdy,
  4582. Gend: res.Output.Baseinfo.Gend,
  4583. Naty: res.Output.Baseinfo.Naty,
  4584. PsnCertType: res.Output.Baseinfo.PsnCertType,
  4585. PsnName: res.Output.Baseinfo.PsnName,
  4586. Idetinfo: idetinfoStr,
  4587. Insuinfo: infoStr,
  4588. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  4589. CardInfo: "",
  4590. Stage: "1",
  4591. VerifyNumber: ecToken,
  4592. InsuplcAdmdvs: insuOrg,
  4593. }
  4594. service.CreateHisPsn(psn)
  4595. var rf []*ResultFive
  4596. json.Unmarshal([]byte(infoStr), &rf)
  4597. var insutypes []*ResultFive
  4598. var insutype string
  4599. var is390 int = 0
  4600. var is310 int = 0
  4601. for _, item := range rf {
  4602. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  4603. insutypes = append(insutypes, item)
  4604. }
  4605. }
  4606. if len(insutypes) == 1 {
  4607. insutype = insutypes[0].Insutype
  4608. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  4609. } else {
  4610. for _, i := range insutypes {
  4611. if i.Insutype == "390" {
  4612. is390 = 1
  4613. }
  4614. if i.Insutype == "310" {
  4615. is310 = 1
  4616. }
  4617. }
  4618. }
  4619. if is390 == 1 {
  4620. insutype = "390"
  4621. }
  4622. if is310 == 1 {
  4623. insutype = "310"
  4624. }
  4625. if len(insutypes) == 0 {
  4626. insutype = "310"
  4627. }
  4628. c.ServeSuccessJSON(map[string]interface{}{
  4629. "patient": patient,
  4630. "number": ecToken,
  4631. "insutype": insutype,
  4632. })
  4633. }
  4634. } else {
  4635. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  4636. return
  4637. }
  4638. } else if miConfig.MdtrtareaAdmvs == "360399" {
  4639. //if initFlag == 0 {
  4640. c.TestGetJiangXiBasBaseInit()
  4641. //}
  4642. //if initEleFlag == 0 {
  4643. // GetJxEleBaseInitInfo(c.GetAdminUserInfo().CurrentOrgId)
  4644. //}
  4645. json_result := GetJxEleBaseInfo(c.GetAdminUserInfo().CurrentOrgId)
  4646. type ELeData struct {
  4647. Data struct {
  4648. IdNo string `json:"idNo"`
  4649. IdType string `json:"idType"`
  4650. UserName string `json:"userName"`
  4651. EcToken string `json:"ecToken"`
  4652. InsuOrg string `json:"insuOrg"`
  4653. Gender string `json:"gender"`
  4654. Birthday string `json:"birthday"`
  4655. Nationality string `json:"nationality"`
  4656. Email string `json:"email"`
  4657. Extra string `json:"extra"`
  4658. } `json:"data"`
  4659. Code int `json:"code"`
  4660. Message string `json:"message"`
  4661. }
  4662. var ele ELeData
  4663. err := json.Unmarshal([]byte(json_result), &ele)
  4664. if err != nil {
  4665. utils.ErrorLog("解析失败:%v", err)
  4666. }
  4667. token := ele.Data.EcToken
  4668. token = Remove0000(token)
  4669. 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)
  4670. saveLog(result2, requestLog2, "1101", "获取人员信息")
  4671. var res ResultTwo
  4672. if err := json.Unmarshal([]byte(result2), &res); err != nil {
  4673. utils.ErrorLog("解析失败:%v", err)
  4674. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4675. return
  4676. }
  4677. if res.Infcode == 0 {
  4678. patient, err := service.GetPatientByNumber(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  4679. if err == gorm.ErrRecordNotFound {
  4680. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  4681. return
  4682. } else if err != nil {
  4683. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  4684. return
  4685. } else {
  4686. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  4687. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  4688. infoStr := string(Iinfos)
  4689. idetinfoStr := string(Idetinfos)
  4690. psn := &models.HisPsn{
  4691. PsnNo: res.Output.Baseinfo.PsnNo,
  4692. Age: res.Output.Baseinfo.Age,
  4693. PatientId: patient.ID,
  4694. Certno: res.Output.Baseinfo.Certno,
  4695. Brdy: res.Output.Baseinfo.Brdy,
  4696. Gend: res.Output.Baseinfo.Gend,
  4697. Naty: res.Output.Baseinfo.Naty,
  4698. PsnCertType: res.Output.Baseinfo.PsnCertType,
  4699. PsnName: res.Output.Baseinfo.PsnName,
  4700. Idetinfo: idetinfoStr,
  4701. Insuinfo: infoStr,
  4702. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  4703. CardInfo: "",
  4704. //RecordDate:
  4705. VerifyNumber: token,
  4706. }
  4707. service.CreateHisPsn(psn)
  4708. var rf []*ResultFive
  4709. json.Unmarshal([]byte(infoStr), &rf)
  4710. var insutypes []*ResultFive
  4711. var insutype string
  4712. var is390 int = 0
  4713. var is310 int = 0
  4714. for _, item := range rf {
  4715. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  4716. insutypes = append(insutypes, item)
  4717. }
  4718. }
  4719. if len(insutypes) == 1 {
  4720. insutype = insutypes[0].Insutype
  4721. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  4722. } else {
  4723. for _, i := range insutypes {
  4724. if i.Insutype == "390" {
  4725. is390 = 1
  4726. }
  4727. if i.Insutype == "310" {
  4728. is310 = 1
  4729. }
  4730. }
  4731. }
  4732. if is390 == 1 {
  4733. insutype = "390"
  4734. }
  4735. if is310 == 1 {
  4736. insutype = "310"
  4737. }
  4738. if len(insutypes) == 0 {
  4739. insutype = "310"
  4740. }
  4741. c.ServeSuccessJSON(map[string]interface{}{
  4742. "patient": patient,
  4743. "number": token,
  4744. "insutype": insutype,
  4745. })
  4746. }
  4747. } else {
  4748. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  4749. return
  4750. }
  4751. } else if miConfig.MdtrtareaAdmvs == "430800" {
  4752. //if initFlag == 0 {
  4753. c.TestGetJiangXiBasBaseInit()
  4754. //}
  4755. //if initEleFlag == 0 {
  4756. // GetJxEleBaseInitInfo(c.GetAdminUserInfo().CurrentOrgId)
  4757. //}
  4758. json_result := GetJxEleBaseInfo(c.GetAdminUserInfo().CurrentOrgId)
  4759. type ELeData struct {
  4760. Data struct {
  4761. IdNo string `json:"idNo"`
  4762. IdType string `json:"idType"`
  4763. UserName string `json:"userName"`
  4764. EcToken string `json:"ecToken"`
  4765. InsuOrg string `json:"insuOrg"`
  4766. Gender string `json:"gender"`
  4767. Birthday string `json:"birthday"`
  4768. Nationality string `json:"nationality"`
  4769. Email string `json:"email"`
  4770. Extra string `json:"extra"`
  4771. } `json:"data"`
  4772. Code int `json:"code"`
  4773. Message string `json:"message"`
  4774. }
  4775. var ele ELeData
  4776. err := json.Unmarshal([]byte(json_result), &ele)
  4777. if err != nil {
  4778. utils.ErrorLog("解析失败:%v", err)
  4779. }
  4780. token := ele.Data.EcToken
  4781. token = Remove0000(token)
  4782. 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)
  4783. saveLog(result2, requestLog2, "1101", "获取人员信息")
  4784. var res ResultTwo
  4785. if err := json.Unmarshal([]byte(result2), &res); err != nil {
  4786. utils.ErrorLog("解析失败:%v", err)
  4787. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4788. return
  4789. }
  4790. if res.Infcode == 0 {
  4791. patient, err := service.GetPatientByNumber(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  4792. if err == gorm.ErrRecordNotFound {
  4793. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  4794. return
  4795. } else if err != nil {
  4796. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  4797. return
  4798. } else {
  4799. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  4800. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  4801. infoStr := string(Iinfos)
  4802. idetinfoStr := string(Idetinfos)
  4803. psn := &models.HisPsn{
  4804. PsnNo: res.Output.Baseinfo.PsnNo,
  4805. Age: res.Output.Baseinfo.Age,
  4806. PatientId: patient.ID,
  4807. Certno: res.Output.Baseinfo.Certno,
  4808. Brdy: res.Output.Baseinfo.Brdy,
  4809. Gend: res.Output.Baseinfo.Gend,
  4810. Naty: res.Output.Baseinfo.Naty,
  4811. PsnCertType: res.Output.Baseinfo.PsnCertType,
  4812. PsnName: res.Output.Baseinfo.PsnName,
  4813. Idetinfo: idetinfoStr,
  4814. Insuinfo: infoStr,
  4815. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  4816. CardInfo: "",
  4817. VerifyNumber: token,
  4818. }
  4819. service.CreateHisPsn(psn)
  4820. var rf []*ResultFive
  4821. json.Unmarshal([]byte(infoStr), &rf)
  4822. var insutypes []*ResultFive
  4823. var insutype string
  4824. var is390 int = 0
  4825. var is310 int = 0
  4826. for _, item := range rf {
  4827. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  4828. insutypes = append(insutypes, item)
  4829. }
  4830. }
  4831. if len(insutypes) == 1 {
  4832. insutype = insutypes[0].Insutype
  4833. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  4834. } else {
  4835. for _, i := range insutypes {
  4836. if i.Insutype == "390" {
  4837. is390 = 1
  4838. }
  4839. if i.Insutype == "310" {
  4840. is310 = 1
  4841. }
  4842. }
  4843. }
  4844. if is390 == 1 {
  4845. insutype = "390"
  4846. }
  4847. if is310 == 1 {
  4848. insutype = "310"
  4849. }
  4850. if len(insutypes) == 0 {
  4851. insutype = "310"
  4852. }
  4853. c.ServeSuccessJSON(map[string]interface{}{
  4854. "patient": patient,
  4855. "number": token,
  4856. "insutype": insutype,
  4857. })
  4858. }
  4859. } else {
  4860. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  4861. return
  4862. }
  4863. } else if miConfig.MdtrtareaAdmvs == "350500" {
  4864. type ELeData struct {
  4865. Code string `json:"code"`
  4866. Data struct {
  4867. Aac002 string `json:"aac002"`
  4868. Aaz500 string `json:"aaz500"`
  4869. ActCardNo string `json:"actCardNo"`
  4870. Bab520 string `json:"bab520"`
  4871. Bkz543 string `json:"bkz543"`
  4872. BusinessType string `json:"businessType"`
  4873. CertfCodg string `json:"certfCodg"`
  4874. EcIndexNo string `json:"ecIndexNo"`
  4875. EcToken string `json:"ecToken"`
  4876. ID0000 string `json:"id0000"`
  4877. IDNo string `json:"idNo"`
  4878. IDType string `json:"idType"`
  4879. Idcode string `json:"idcode"`
  4880. IdentityToken string `json:"identity_token"`
  4881. InsuOrg string `json:"insuOrg"`
  4882. OfficeID string `json:"officeId"`
  4883. OfficeName string `json:"officeName"`
  4884. OperatorID string `json:"operatorId"`
  4885. OperatorName string `json:"operatorName"`
  4886. OrgID string `json:"orgId"`
  4887. UserName string `json:"userName"`
  4888. } `json:"data"`
  4889. Infno interface{} `json:"infno"`
  4890. Message string `json:"message"`
  4891. OrgID string `json:"orgId"`
  4892. TransType string `json:"transType"`
  4893. }
  4894. inputInfo, outPutInfo, _ := service.ReadEleCard(miConfig.Code)
  4895. outPutInfo = Remove0000(outPutInfo)
  4896. if len(outPutInfo) > 0 {
  4897. var ele ELeData
  4898. err := json.Unmarshal([]byte(outPutInfo), &ele)
  4899. if err != nil {
  4900. utils.ErrorLog("解析失败:%v", err)
  4901. }
  4902. token := ele.Data.EcToken
  4903. fmt.Println(inputInfo)
  4904. fmt.Println(outPutInfo)
  4905. 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)
  4906. saveLog(result, requestLog, "1101", "获取人员信息")
  4907. var dat map[string]interface{}
  4908. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  4909. fmt.Println(dat)
  4910. } else {
  4911. fmt.Println(err)
  4912. }
  4913. userJSONBytes, _ := json.Marshal(dat)
  4914. var res ResultTwo
  4915. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  4916. utils.ErrorLog("解析失败:%v", err)
  4917. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4918. return
  4919. }
  4920. res.ErrMsg = errMsgLog
  4921. if res.Infcode == 0 {
  4922. patient, err := service.GetPatientByNumber(ele.Data.IDNo, c.GetAdminUserInfo().CurrentOrgId)
  4923. if err == gorm.ErrRecordNotFound {
  4924. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  4925. return
  4926. } else if err != nil {
  4927. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  4928. return
  4929. } else {
  4930. fmt.Println(res)
  4931. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  4932. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  4933. infoStr := string(Iinfos)
  4934. idetinfoStr := string(Idetinfos)
  4935. psn := &models.HisPsn{
  4936. PsnNo: res.Output.Baseinfo.PsnNo,
  4937. Age: res.Output.Baseinfo.Age,
  4938. PatientId: patient.ID,
  4939. Certno: res.Output.Baseinfo.Certno,
  4940. Brdy: res.Output.Baseinfo.Brdy,
  4941. Gend: res.Output.Baseinfo.Gend,
  4942. Naty: res.Output.Baseinfo.Naty,
  4943. PsnCertType: res.Output.Baseinfo.PsnCertType,
  4944. PsnName: res.Output.Baseinfo.PsnName,
  4945. Idetinfo: idetinfoStr,
  4946. Insuinfo: infoStr,
  4947. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  4948. CardInfo: outPutInfo,
  4949. VerifyNumber: token,
  4950. InsuplcAdmdvs: ele.Data.InsuOrg,
  4951. }
  4952. service.CreateHisPsn(psn)
  4953. var rf []*ResultFive
  4954. json.Unmarshal([]byte(infoStr), &rf)
  4955. var insutypes []*ResultFive
  4956. var insutype string
  4957. var is390 int = 0
  4958. var is310 int = 0
  4959. for _, item := range rf {
  4960. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  4961. insutypes = append(insutypes, item)
  4962. }
  4963. }
  4964. if len(insutypes) == 1 {
  4965. insutype = insutypes[0].Insutype
  4966. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  4967. } else {
  4968. for _, i := range insutypes {
  4969. if i.Insutype == "390" {
  4970. is390 = 1
  4971. }
  4972. if i.Insutype == "310" {
  4973. is310 = 1
  4974. }
  4975. }
  4976. }
  4977. if is390 == 1 {
  4978. insutype = "390"
  4979. }
  4980. if is310 == 1 {
  4981. insutype = "310"
  4982. }
  4983. if len(insutypes) == 0 {
  4984. insutype = "310"
  4985. }
  4986. c.ServeSuccessJSON(map[string]interface{}{
  4987. "patient": patient,
  4988. "number": token,
  4989. "insutype": insutype,
  4990. })
  4991. }
  4992. } else {
  4993. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  4994. return
  4995. }
  4996. }
  4997. } else {
  4998. type ELeData struct {
  4999. Code string `json:"code"`
  5000. Data struct {
  5001. Aac002 string `json:"aac002"`
  5002. Aaz500 string `json:"aaz500"`
  5003. ActCardNo string `json:"actCardNo"`
  5004. Bab520 string `json:"bab520"`
  5005. Bkz543 string `json:"bkz543"`
  5006. BusinessType string `json:"businessType"`
  5007. CertfCodg string `json:"certfCodg"`
  5008. EcIndexNo string `json:"ecIndexNo"`
  5009. EcToken string `json:"ecToken"`
  5010. ID0000 string `json:"id0000"`
  5011. IDNo string `json:"idNo"`
  5012. IDType string `json:"idType"`
  5013. Idcode string `json:"idcode"`
  5014. IdentityToken string `json:"identity_token"`
  5015. InsuOrg string `json:"insuOrg"`
  5016. OfficeID string `json:"officeId"`
  5017. OfficeName string `json:"officeName"`
  5018. OperatorID string `json:"operatorId"`
  5019. OperatorName string `json:"operatorName"`
  5020. OrgID string `json:"orgId"`
  5021. UserName string `json:"userName"`
  5022. } `json:"data"`
  5023. Infno interface{} `json:"infno"`
  5024. Message string `json:"message"`
  5025. OrgID string `json:"orgId"`
  5026. TransType string `json:"transType"`
  5027. }
  5028. _, result := GetELeInfo(miConfig.Code, "1", roles.UserName)
  5029. fmt.Println(result)
  5030. outPutInfo := Remove0000(result)
  5031. fmt.Println(outPutInfo)
  5032. if len(outPutInfo) > 0 {
  5033. var ele ELeData
  5034. err := json.Unmarshal([]byte(outPutInfo), &ele)
  5035. if err != nil {
  5036. utils.ErrorLog("解析失败:%v", err)
  5037. }
  5038. token := ele.Data.EcToken
  5039. fmt.Println(outPutInfo)
  5040. result, requestLog := service.Gdyb1101ForEleCert(miConfig.OrgName, roles.UserName, miConfig.Code, ele.Data.InsuOrg, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, token, ele.Data.UserName, ele.Data.IDNo)
  5041. saveLog(result, requestLog, "1101", "获取人员信息")
  5042. var dat map[string]interface{}
  5043. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  5044. fmt.Println(dat)
  5045. } else {
  5046. fmt.Println(err)
  5047. }
  5048. userJSONBytes, _ := json.Marshal(dat)
  5049. var res ResultTwo
  5050. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  5051. utils.ErrorLog("解析失败:%v", err)
  5052. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5053. return
  5054. }
  5055. if res.Infcode == 0 {
  5056. patient, err := service.GetPatientByNumber(ele.Data.IDNo, c.GetAdminUserInfo().CurrentOrgId)
  5057. if err == gorm.ErrRecordNotFound {
  5058. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  5059. return
  5060. } else if err != nil {
  5061. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  5062. return
  5063. } else {
  5064. fmt.Println(res)
  5065. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  5066. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  5067. infoStr := string(Iinfos)
  5068. idetinfoStr := string(Idetinfos)
  5069. psn := &models.HisPsn{
  5070. PsnNo: res.Output.Baseinfo.PsnNo,
  5071. Age: res.Output.Baseinfo.Age,
  5072. PatientId: patient.ID,
  5073. Certno: res.Output.Baseinfo.Certno,
  5074. Brdy: res.Output.Baseinfo.Brdy,
  5075. Gend: res.Output.Baseinfo.Gend,
  5076. Naty: res.Output.Baseinfo.Naty,
  5077. PsnCertType: res.Output.Baseinfo.PsnCertType,
  5078. PsnName: res.Output.Baseinfo.PsnName,
  5079. Idetinfo: idetinfoStr,
  5080. Insuinfo: infoStr,
  5081. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  5082. CardInfo: outPutInfo,
  5083. VerifyNumber: token,
  5084. InsuplcAdmdvs: ele.Data.InsuOrg,
  5085. }
  5086. service.CreateHisPsn(psn)
  5087. var rf []*ResultFive
  5088. json.Unmarshal([]byte(infoStr), &rf)
  5089. var insutypes []*ResultFive
  5090. var insutype string
  5091. var is390 int = 0
  5092. var is310 int = 0
  5093. for _, item := range rf {
  5094. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  5095. insutypes = append(insutypes, item)
  5096. }
  5097. }
  5098. if len(insutypes) == 1 {
  5099. insutype = insutypes[0].Insutype
  5100. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  5101. } else {
  5102. for _, i := range insutypes {
  5103. if i.Insutype == "390" {
  5104. is390 = 1
  5105. }
  5106. if i.Insutype == "310" {
  5107. is310 = 1
  5108. }
  5109. }
  5110. }
  5111. if is390 == 1 {
  5112. insutype = "390"
  5113. }
  5114. if is310 == 1 {
  5115. insutype = "310"
  5116. }
  5117. if len(insutypes) == 0 {
  5118. insutype = "310"
  5119. }
  5120. c.ServeSuccessJSON(map[string]interface{}{
  5121. "patient": patient,
  5122. "number": token,
  5123. "insutype": insutype,
  5124. })
  5125. }
  5126. } else {
  5127. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  5128. return
  5129. }
  5130. }
  5131. //fmt.Println(result)
  5132. //
  5133. //if initFlag == 0 {
  5134. // c.TestGetBasBaseInit()
  5135. //}
  5136. //token := c.GetEleBaseInfo()
  5137. //
  5138. //token = Remove0000(token)
  5139. //
  5140. //result2, requestLog2 := service.Gdyb1101ForEleCert(miConfig.OrgName, roles.UserName, miConfig.Code, insuplc_admdvs_str, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, token, "", "")
  5141. //saveLog(result2, requestLog2, "1101", "获取人员信息")
  5142. ////
  5143. //var res ResultTwo
  5144. //if err := json.Unmarshal([]byte(result2), &res); err != nil {
  5145. // utils.ErrorLog("解析失败:%v", err)
  5146. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5147. // return
  5148. //}
  5149. //
  5150. //if res.Infcode == 0 {
  5151. // patient, err := service.GetPatientByNumber(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  5152. // if err == gorm.ErrRecordNotFound {
  5153. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  5154. // return
  5155. // } else if err != nil {
  5156. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  5157. // return
  5158. //
  5159. // } else {
  5160. // Iinfos, _ := json.Marshal(res.Output.Iinfo)
  5161. // Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  5162. // infoStr := string(Iinfos)
  5163. // idetinfoStr := string(Idetinfos)
  5164. //
  5165. //
  5166. //
  5167. //
  5168. // var rf []*ResultFive
  5169. // json.Unmarshal([]byte(infoStr), &rf)
  5170. //
  5171. // var insutypes []*ResultFive
  5172. // var insutype string
  5173. // var is390 int = 0
  5174. // var is310 int = 0
  5175. // var insuplc_admdvs string
  5176. //
  5177. // for _, item := range rf {
  5178. // if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  5179. // insutypes = append(insutypes, item)
  5180. // }
  5181. // }
  5182. //
  5183. // if len(insutypes) == 1 {
  5184. // insutype = insutypes[0].Insutype
  5185. // //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  5186. // } else {
  5187. // for _, i := range insutypes {
  5188. // if i.Insutype == "390" {
  5189. // is390 = 1
  5190. // }
  5191. //
  5192. // if i.Insutype == "310" {
  5193. // is310 = 1
  5194. // }
  5195. // }
  5196. // }
  5197. // if is390 == 1 {
  5198. // insutype = "390"
  5199. // }
  5200. //
  5201. // if is310 == 1 {
  5202. // insutype = "310"
  5203. // }
  5204. // if len(insutypes) == 0 {
  5205. // insutype = "310"
  5206. // }
  5207. // for _, item := range rf {
  5208. // if item.Insutype == insutype {
  5209. // insuplc_admdvs = item.InsuplcAdmdvs
  5210. // }
  5211. // }
  5212. // psn := &models.HisPsn{
  5213. // PsnNo: res.Output.Baseinfo.PsnNo,
  5214. // Age: res.Output.Baseinfo.Age,
  5215. // PatientId: patient.ID,
  5216. // Certno: res.Output.Baseinfo.Certno,
  5217. // Brdy: res.Output.Baseinfo.Brdy,
  5218. // Gend: res.Output.Baseinfo.Gend,
  5219. // Naty: res.Output.Baseinfo.Naty,
  5220. // PsnCertType: res.Output.Baseinfo.PsnCertType,
  5221. // PsnName: res.Output.Baseinfo.PsnName,
  5222. // Idetinfo: idetinfoStr,
  5223. // Insuinfo: infoStr,
  5224. // UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  5225. // CardInfo: "",
  5226. // VerifyNumber: token,
  5227. // InsuplcAdmdvs: insuplc_admdvs,
  5228. // }
  5229. // service.CreateHisPsn(psn)
  5230. //
  5231. // c.ServeSuccessJSON(map[string]interface{}{
  5232. // "patient": patient,
  5233. // "number": token,
  5234. // })
  5235. // }
  5236. //} else {
  5237. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  5238. // return
  5239. //}
  5240. }
  5241. break
  5242. }
  5243. }
  5244. var initFlag int64 = 0
  5245. var initEleFlag int64 = 0
  5246. func (c *HisApiController) TestGetBasBaseInit() {
  5247. DllDef := syscall.MustLoadDLL("SSCard.dll")
  5248. Iinit := DllDef.MustFindProc("Init")
  5249. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  5250. ret, _, err := Iinit.Call(StrPtr("http://igb.hsa.gdgov.cn/gdyb_api/prd/api/card/initDll"), StrPtr(miConfig.InsuplcAdmdvs))
  5251. if ret != 0 {
  5252. fmt.Println("SSCard的报错原因:", err)
  5253. fmt.Println("SSCard的运算结果为:", ret)
  5254. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeReadCardException)
  5255. return
  5256. }
  5257. result := int(ret)
  5258. fmt.Println("SSCard的运算结果为1:", result)
  5259. initFlag = 1
  5260. return
  5261. }
  5262. func (c *HisApiController) HandleJiangXiReadCard() {
  5263. fmt.Println("~~~~~~")
  5264. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  5265. admin_user_id, _ := c.GetInt64("admin_user_id")
  5266. id_card_type, _ := c.GetInt64("id_card_type")
  5267. //certificates, _ := c.GetInt64("certificates")
  5268. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  5269. if initFlag == 0 {
  5270. c.TestGetJiangXiBasBaseInit()
  5271. }
  5272. basStr := c.GetBasBaseInfo()
  5273. if len(basStr) == 0 {
  5274. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeReadCardException)
  5275. return
  5276. }
  5277. fmt.Println(basStr)
  5278. bas := strings.Split(basStr, "|")
  5279. basNumber := bas[1]
  5280. fmt.Println(basNumber)
  5281. card_sn := bas[3]
  5282. fmt.Println(card_sn)
  5283. 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, "")
  5284. //result := service.Jxyb1101(basNumber, miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, id_card_type, card_sn, certificates)
  5285. var dat map[string]interface{}
  5286. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  5287. fmt.Println(dat)
  5288. } else {
  5289. fmt.Println(err)
  5290. }
  5291. userJSONBytes, _ := json.Marshal(dat)
  5292. var res ResultTwo
  5293. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  5294. utils.ErrorLog("解析失败:%v", err)
  5295. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5296. return
  5297. }
  5298. if res.Infcode == 0 {
  5299. patient, err := service.GetPatientByNumber(basNumber, c.GetAdminUserInfo().CurrentOrgId)
  5300. if err == gorm.ErrRecordNotFound {
  5301. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  5302. return
  5303. } else if err != nil {
  5304. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  5305. return
  5306. } else {
  5307. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  5308. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  5309. infoStr := string(Iinfos)
  5310. idetinfoStr := string(Idetinfos)
  5311. psn := &models.HisPsn{
  5312. PsnNo: res.Output.Baseinfo.PsnNo,
  5313. Age: res.Output.Baseinfo.Age,
  5314. PatientId: patient.ID,
  5315. Certno: res.Output.Baseinfo.Certno,
  5316. Brdy: res.Output.Baseinfo.Brdy,
  5317. Gend: res.Output.Baseinfo.Gend,
  5318. Naty: res.Output.Baseinfo.Naty,
  5319. PsnCertType: res.Output.Baseinfo.PsnCertType,
  5320. PsnName: res.Output.Baseinfo.PsnName,
  5321. Idetinfo: idetinfoStr,
  5322. Insuinfo: infoStr,
  5323. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  5324. CardInfo: basStr,
  5325. VerifyNumber: "",
  5326. }
  5327. service.CreateHisPsn(psn)
  5328. c.ServeSuccessJSON(map[string]interface{}{
  5329. "patient": patient,
  5330. "number": basNumber,
  5331. })
  5332. }
  5333. } else {
  5334. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  5335. return
  5336. }
  5337. }
  5338. func (c *HisApiController) TestGetHnBasBaseInit() {
  5339. DllDef := syscall.MustLoadDLL("SSCard.dll")
  5340. Iinit := DllDef.MustFindProc("Init")
  5341. //miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  5342. //http://10.77.211.236/CSB/hsa-fsi-1303
  5343. ret, _, err := Iinit.Call(StrPtr("http://10.93.32.89:20001/hsa-hgs-adapt/api/card/initDll"), StrPtr("430100|10.93.32.89:20001"))
  5344. if ret != 0 {
  5345. fmt.Println("SSCard的报错原因:", err)
  5346. fmt.Println("SSCard的运算结果为:", ret)
  5347. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeReadCardException)
  5348. return
  5349. }
  5350. result := int(ret)
  5351. fmt.Println("SSCard的运算结果为1:", result)
  5352. initFlag = 1
  5353. return
  5354. }
  5355. func (c *HisApiController) TestGetJiangXiBasBaseInit() {
  5356. DllDef := syscall.MustLoadDLL("SSCard.dll")
  5357. Iinit := DllDef.MustFindProc("Init")
  5358. //miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  5359. //http://10.77.211.236/CSB/hsa-fsi-1303
  5360. ret, _, err := Iinit.Call(StrPtr("http://10.77.224.18:9001/1.0.0/agent-card-init"), StrPtr("360399"))
  5361. if ret != 0 {
  5362. fmt.Println("SSCard的报错原因:", err)
  5363. fmt.Println("SSCard的运算结果为:", ret)
  5364. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeReadCardException)
  5365. return
  5366. }
  5367. result := int(ret)
  5368. fmt.Println("SSCard的运算结果为1:", result)
  5369. initFlag = 1
  5370. return
  5371. }
  5372. func (c *HisApiController) GetSFZBaseInfo() string {
  5373. DllDef := syscall.MustLoadDLL("SSCard.dll")
  5374. readCard := DllDef.MustFindProc("ReadSFZ")
  5375. if readCard == nil {
  5376. fmt.Println("readcard is nil")
  5377. readCard = DllDef.MustFindProc("ReadSFZ")
  5378. }
  5379. str := make([]byte, 8096)
  5380. str1 := make([]byte, 8096)
  5381. r, _, _ := readCard.Call((uintptr)(unsafe.Pointer(&str[0])), IntPtr(8096), (uintptr)(unsafe.Pointer(&str1[0])), IntPtr(8096))
  5382. fmt.Println(r)
  5383. return Remove0000(string(str))
  5384. }
  5385. func (c *HisApiController) GetEleBaseInfo() string {
  5386. DllDef := syscall.MustLoadDLL("SSCard.dll")
  5387. readCard := DllDef.MustFindProc("GetQRBase")
  5388. fmt.Println(readCard)
  5389. if readCard == nil {
  5390. fmt.Println("readcard is nil")
  5391. readCard = DllDef.MustFindProc("GetQRBase")
  5392. }
  5393. str := make([]byte, 1024)
  5394. str1 := make([]byte, 1024)
  5395. ret2, _, _ := readCard.Call(uintptr(180), (uintptr)(unsafe.Pointer(&str[0])), uintptr(1024), (uintptr)(unsafe.Pointer(&str1[0])), uintptr(1024))
  5396. fmt.Println(ret2)
  5397. fmt.Println(string(str1))
  5398. fmt.Println(string(str))
  5399. fmt.Println(":", ConvertToString(string(str1), "gbk", "utf-8"))
  5400. fmt.Println(":", ConvertToString(string(str), "gbk", "utf-8"))
  5401. if ret2 != 0 {
  5402. return ""
  5403. }
  5404. return string(str)
  5405. }
  5406. func GetHnEleBaseInfo(code string, operator_id int64, operator_name string) (string, string) {
  5407. DllDef := syscall.MustLoadDLL("NationECCode.dll")
  5408. readCard := DllDef.MustFindProc("NationEcTrans")
  5409. fmt.Println(readCard)
  5410. fmt.Println("!!!!!")
  5411. pBusiCardInfo := make([]byte, 2048)
  5412. input := make(map[string]interface{})
  5413. inputData := make(map[string]interface{})
  5414. inputData["orgId"] = code
  5415. inputData["businessType"] = "01101"
  5416. inputData["operatorId"] = "1"
  5417. inputData["operatorName"] = "admin"
  5418. inputData["officeId"] = "001"
  5419. inputData["officeName"] = "血透室"
  5420. inputData["deviceType"] = ""
  5421. input["data"] = inputData
  5422. input["orgId"] = code
  5423. input["transType"] = "ec.query"
  5424. bytesData, _ := json.Marshal(input)
  5425. ret2, _, _ := readCard.Call(StrPtr("https://10.93.32.89:20001/localcfc/api/hsecfc/localQrCodeQuery"), StrPtr(string(bytesData)), (uintptr)(unsafe.Pointer(&pBusiCardInfo[0])))
  5426. fmt.Println(ret2)
  5427. fmt.Println(DeleteExtraSpace(string(pBusiCardInfo)))
  5428. fmt.Println(":", ConvertToString(DeleteExtraSpace(string(pBusiCardInfo)), "gbk", "utf-8"))
  5429. return DeleteExtraSpace(""), DeleteExtraSpace(string(pBusiCardInfo))
  5430. }
  5431. func GetgdEleBaseInfo(code string, operator_id int64, operator_name string) (string, string) {
  5432. DllDef := syscall.MustLoadDLL("NationECCode.dll")
  5433. readCard := DllDef.MustFindProc("NationEcTrans")
  5434. fmt.Println(readCard)
  5435. fmt.Println("!!!!!")
  5436. pBusiCardInfo := make([]byte, 2048)
  5437. input := make(map[string]interface{})
  5438. inputData := make(map[string]interface{})
  5439. inputData["orgId"] = code
  5440. inputData["businessType"] = "01101"
  5441. inputData["operatorId"] = "9"
  5442. inputData["operatorName"] = "admin"
  5443. inputData["officeId"] = "001"
  5444. inputData["officeName"] = "血透室"
  5445. inputData["deviceType"] = ""
  5446. input["data"] = inputData
  5447. input["orgId"] = code
  5448. input["transType"] = "ec.query"
  5449. bytesData, _ := json.Marshal(input)
  5450. 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])))
  5451. fmt.Println(ret2)
  5452. fmt.Println(DeleteExtraSpace(string(pBusiCardInfo)))
  5453. fmt.Println(":", ConvertToString(DeleteExtraSpace(string(pBusiCardInfo)), "gbk", "utf-8"))
  5454. return DeleteExtraSpace(""), ConvertToString(DeleteExtraSpace(string(pBusiCardInfo)), "gbk", "utf-8")
  5455. }
  5456. func GetgdEleBaseInfoTwo(code string, operator_id int64, operator_name string) (string, string) {
  5457. DllDef := syscall.MustLoadDLL("NationECCode.dll")
  5458. readCard := DllDef.MustFindProc("NationEcTrans")
  5459. fmt.Println(readCard)
  5460. fmt.Println("!!!!!")
  5461. pBusiCardInfo := make([]byte, 2048)
  5462. input := make(map[string]interface{})
  5463. inputData := make(map[string]interface{})
  5464. inputData["orgId"] = code
  5465. inputData["businessType"] = "01301"
  5466. inputData["operatorId"] = "9"
  5467. inputData["operatorName"] = "admin"
  5468. inputData["officeId"] = "001"
  5469. inputData["officeName"] = "血透室"
  5470. inputData["deviceType"] = ""
  5471. input["data"] = inputData
  5472. input["orgId"] = code
  5473. input["transType"] = "ec.query"
  5474. bytesData, _ := json.Marshal(input)
  5475. 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])))
  5476. fmt.Println(ret2)
  5477. fmt.Println(DeleteExtraSpace(string(pBusiCardInfo)))
  5478. fmt.Println(":", ConvertToString(DeleteExtraSpace(string(pBusiCardInfo)), "gbk", "utf-8"))
  5479. return DeleteExtraSpace(""), ConvertToString(DeleteExtraSpace(string(pBusiCardInfo)), "gbk", "utf-8")
  5480. }
  5481. func GetJxEleBaseInfo(org_id int64) string {
  5482. DllDef := syscall.MustLoadDLL("SSCard.dll")
  5483. readCard := DllDef.MustFindProc("NationEcTrans")
  5484. miConfig, _ := service.FindMedicalInsuranceInfo(org_id)
  5485. if readCard == nil {
  5486. fmt.Println("readcard is nil")
  5487. readCard = DllDef.MustFindProc("NationEcTrans")
  5488. }
  5489. str1 := make([]byte, 1024)
  5490. data := make(map[string]interface{})
  5491. inputData := make(map[string]interface{})
  5492. inputData["orgId"] = miConfig.Code
  5493. inputData["businessType"] = "01101"
  5494. inputData["operatorId"] = "test001"
  5495. inputData["operatorName"] = "cn"
  5496. inputData["officeId"] = "32760"
  5497. inputData["officeName"] = "waike"
  5498. inputData["deviceType"] = ""
  5499. data["data"] = inputData
  5500. data["transType"] = "ec.query"
  5501. data["extra "] = ""
  5502. data["orgId"] = miConfig.Code
  5503. bytesData, _ := json.Marshal(data)
  5504. //bytesData, _ := json.Marshal(data)
  5505. //bytesData = []byte(ConvertToString(string(bytesData), "utf-8", "gbk"))
  5506. ret2, _, _ := readCard.Call(StrPtr("http://10.77.224.18:9001/1.0.0/localQrCodeQuery"), (uintptr)(unsafe.Pointer(&bytesData[0])), (uintptr)(unsafe.Pointer(&str1[0])))
  5507. fmt.Println(ret2)
  5508. fmt.Println(string(str1))
  5509. fmt.Println(":", ConvertToString(string(str1), "gbk", "utf-8"))
  5510. if ret2 != 0 {
  5511. return ""
  5512. }
  5513. return Remove0000(ConvertToString(string(str1), "gbk", "utf-8"))
  5514. }
  5515. func GetJxEleBaseInitInfo(org_id int64) string {
  5516. DllDef := syscall.MustLoadDLL("SSCard.dll")
  5517. readCard := DllDef.MustFindProc("NationEcTrans")
  5518. miConfig, _ := service.FindMedicalInsuranceInfo(org_id)
  5519. if readCard == nil {
  5520. fmt.Println("readcard is nil")
  5521. readCard = DllDef.MustFindProc("NationEcTrans")
  5522. }
  5523. str1 := make([]byte, 2048)
  5524. data := make(map[string]interface{})
  5525. inputData := make(map[string]interface{})
  5526. inputData["orgId"] = miConfig.Code
  5527. inputData["businessType"] = "01101"
  5528. inputData["operatorId"] = "1"
  5529. inputData["operatorName"] = "huangchuang"
  5530. inputData["officeId"] = "101"
  5531. inputData["officeName"] = "xuetou"
  5532. inputData["deviceType"] = ""
  5533. data["data"] = inputData
  5534. data["transType"] = "ec.query"
  5535. data["orgId"] = miConfig.Code
  5536. bytesData, _ := json.Marshal(data)
  5537. bytesData = []byte(ConvertToString(string(bytesData), "utf-8", "gbk"))
  5538. ret2, _, _ := readCard.Call(StrPtr("http://10.77.224.18:9001/1.0.0/getEncDynamicKey"), (uintptr)(unsafe.Pointer(&bytesData[0])), (uintptr)(unsafe.Pointer(&str1[0])))
  5539. fmt.Println("http://10.77.224.18:9001/1.0.0/getEncDynamicKey")
  5540. fmt.Println(ret2)
  5541. fmt.Println(string(str1))
  5542. fmt.Println(":", ConvertToString(string(str1), "gbk", "utf-8"))
  5543. if ret2 != 0 {
  5544. return ""
  5545. }
  5546. if len(Remove0000(ConvertToString(string(str1), "gbk", "utf-8"))) > 0 {
  5547. initEleFlag = 1
  5548. }
  5549. return Remove0000(ConvertToString(string(str1), "gbk", "utf-8"))
  5550. }
  5551. func (c *HisApiController) GetBasBaseInfo() string {
  5552. DllDef := syscall.MustLoadDLL("SSCard.dll")
  5553. readCard := DllDef.MustFindProc("ReadCardBas")
  5554. if readCard == nil {
  5555. fmt.Println("readcard is nil")
  5556. readCard = DllDef.MustFindProc("ReadCardBas")
  5557. }
  5558. str := make([]byte, 1024)
  5559. str1 := make([]byte, 1024)
  5560. ret2, _, _ := readCard.Call((uintptr)(unsafe.Pointer(&str[0])), uintptr(1024), (uintptr)(unsafe.Pointer(&str1[0])), uintptr(1024))
  5561. fmt.Println(string(str1))
  5562. fmt.Println(string(str))
  5563. fmt.Println(":", ConvertToString(string(str1), "gbk", "utf-8"))
  5564. fmt.Println(":", ConvertToString(string(str), "gbk", "utf-8"))
  5565. if ret2 != 0 {
  5566. return ""
  5567. }
  5568. return string(str)
  5569. }
  5570. func (c *HisApiController) GetFjBasBaseInfo() (string, string, string, string, string) {
  5571. DllDef := syscall.MustLoadDLL("chs_fjs_standard.dll")
  5572. readCard := DllDef.MustFindProc("read_cardinfo")
  5573. if readCard == nil {
  5574. fmt.Println("readcard is nil")
  5575. readCard = DllDef.MustFindProc("read_cardinfo")
  5576. }
  5577. str := make([]byte, 1024) //卡号
  5578. str1 := make([]byte, 1024) //卡识别码
  5579. str2 := make([]byte, 1024) //身份证号
  5580. str3 := make([]byte, 1024) //姓名
  5581. str4 := make([]byte, 1024) //错误信息
  5582. 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])))
  5583. fmt.Println(string(str1))
  5584. fmt.Println(string(str))
  5585. fmt.Println(string(str2))
  5586. fmt.Println(string(str3))
  5587. fmt.Println(string(str4))
  5588. fmt.Println(":", ConvertToString(string(str1), "gbk", "utf-8"))
  5589. fmt.Println(":", ConvertToString(string(str), "gbk", "utf-8"))
  5590. fmt.Println(":", ConvertToString(string(str2), "gbk", "utf-8"))
  5591. fmt.Println(":", ConvertToString(string(str3), "gbk", "utf-8"))
  5592. fmt.Println(":", ConvertToString(string(str4), "gbk", "utf-8"))
  5593. if ret2 != 0 {
  5594. return "", "", "", "", ""
  5595. }
  5596. return string(str), string(str1), string(str2), string(str3), string(str4)
  5597. }
  5598. type CustomFundPay struct {
  5599. FundPayType string `json:"fund_pay_type"`
  5600. FundPayamt float64 `json:"fund_payamt"`
  5601. }
  5602. func (c *HisApiController) GetSettleList() {
  5603. order_id, _ := c.GetInt64("order_id")
  5604. admin_user_id, _ := c.GetInt64("admin_user_id")
  5605. order, _ := service.GetHisOrderByIDTwo(order_id)
  5606. roles, _ := service.GetDoctorListTwo(c.GetAdminUserInfo().CurrentOrgId)
  5607. his, _ := service.GetHisPatientByNumber(order.MdtrtId)
  5608. admin, _ := service.GetAdminUserByUserID(roles[0].AdminUserId)
  5609. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  5610. depart, _ := service.GetDepartMentDetail(curRoles.DepartmentId)
  5611. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  5612. pre, _ := service.GetNewHisPrescriptionByNumber(order.Number)
  5613. doctor, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, pre.Creator)
  5614. if order.ID == 0 {
  5615. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisOrderNoExistParamWrong)
  5616. return
  5617. }
  5618. //last_order, _ := service.GetLastHisOrder(c.GetAdminUserInfo().CurrentOrgId)
  5619. //max_order, _ := service.GetLastHisOrderTwo(c.GetAdminUserInfo().CurrentOrgId)
  5620. //count, _ := strconv.ParseInt(max_order.FaPiaoNumber, 10, 64)
  5621. //fmt.Println(count)
  5622. //var zero string
  5623. //number := count + 1
  5624. //if number >= 1000 {
  5625. // zero = "0000" + strconv.FormatInt(number, 10)
  5626. //} else if number >= 10000 {
  5627. // zero = "000" + strconv.FormatInt(number, 10)
  5628. //} else if number >= 100000 {
  5629. // zero = "00" + strconv.FormatInt(number, 10)
  5630. //} else if number >= 1000000 {
  5631. // zero = "0" + strconv.FormatInt(number, 10)
  5632. //} else {
  5633. // zero = strconv.FormatInt(number, 10)
  5634. //}
  5635. //fmt.Println(zero)
  5636. struct4101 := service.Struct4101{
  5637. PsnNo: order.PsnNo,
  5638. MdtrtId: order.MdtrtId,
  5639. SetlId: order.SetlId,
  5640. PsnName: order.PsnName,
  5641. Gend: order.Gend,
  5642. Brdy: his.Brdy,
  5643. Age: his.Age,
  5644. Naty: order.Naty,
  5645. PatnCertType: "01",
  5646. Certno: order.Certno,
  5647. Prfs: "90",
  5648. ConerName: roles[0].UserName,
  5649. PatnRlts: "99",
  5650. ConerAddr: miConfig.OrgName,
  5651. ConerTel: admin.Mobile,
  5652. HiType: order.Insutype,
  5653. Insuplc: miConfig.InsuplcAdmdvs,
  5654. MaindiagFlag: "1",
  5655. BillCode: order.SetlId,
  5656. BillNo: order.SetlId,
  5657. BizSn: order.Number,
  5658. PsnSelfPay: order.PsnPartAmt,
  5659. PsnOwnPay: order.PsnPartAmt,
  5660. AcctPay: order.AcctPay,
  5661. PsnCashpay: order.PsnCashPay,
  5662. HiPaymtd: "1",
  5663. Hsorg: miConfig.InsuplcAdmdvs,
  5664. HsorgOpter: miConfig.InsuplcAdmdvs,
  5665. MedinsFillPsn: curRoles.UserName,
  5666. MedinsFillDept: depart.Name,
  5667. IptMedType: "2",
  5668. }
  5669. struct4101.SetlBegnDate = order.SetlTime
  5670. struct4101.SetlEndDate = order.SetlTime
  5671. time_arr := strings.Split(order.SetlTime, " ")
  5672. struct4101.AdmTime = time_arr[0]
  5673. struct4101.AdmEndTime = time_arr[0]
  5674. var rf []CustomFundPay
  5675. json.Unmarshal([]byte(order.SetlDetail), &rf)
  5676. var tempFunPays []service.CustomStruct
  5677. for _, item := range rf {
  5678. var tempFunPay service.CustomStruct
  5679. tempFunPay.FundPayamt = item.FundPayamt
  5680. tempFunPay.FundPayType = item.FundPayType
  5681. tempFunPays = append(tempFunPays, tempFunPay)
  5682. }
  5683. struct4101.CustomStruct = tempFunPays
  5684. var tempDiaginfos []service.DiaginfoStructTwo
  5685. var tempOpspdiseinfo2 service.OpspdiseinfoStruct
  5686. var tempOpspdiseinfos []service.OpspdiseinfoStruct
  5687. diagnosis_ids := strings.Split(his.Diagnosis, ",")
  5688. var config []*models.HisXtDiagnoseConfig
  5689. for _, item := range diagnosis_ids {
  5690. id, _ := strconv.ParseInt(item, 10, 64)
  5691. diagnosisConfig, _ := service.FindDiagnoseById(id)
  5692. config = append(config, &diagnosisConfig)
  5693. }
  5694. for index, item := range config {
  5695. if index == 0 {
  5696. var tempDiaginfo service.DiaginfoStructTwo
  5697. tempDiaginfo.DiagCode = item.CountryCode
  5698. tempDiaginfo.DiagName = item.CountryContentName
  5699. tempDiaginfo.DiagType = "1"
  5700. tempDiaginfo.MaindiagFlag = "1"
  5701. tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  5702. } else {
  5703. var tempDiaginfo service.DiaginfoStructTwo
  5704. tempDiaginfo.DiagCode = item.CountryCode
  5705. tempDiaginfo.DiagName = item.CountryContentName
  5706. tempDiaginfo.DiagType = "2"
  5707. tempDiaginfo.MaindiagFlag = "0"
  5708. tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  5709. }
  5710. }
  5711. struct4101.Diseinfo = tempDiaginfos
  5712. sickConfigTwo, _ := service.FindSickById(his.SickType)
  5713. tempOpspdiseinfo2.DiagCode = sickConfigTwo.ContentCode
  5714. tempOpspdiseinfo2.DiagName = sickConfigTwo.CountryContentName
  5715. tempOpspdiseinfo2.OprnOprtCode = sickConfigTwo.ContentCode
  5716. tempOpspdiseinfo2.OprnOprtName = sickConfigTwo.CountryContentName
  5717. tempOpspdiseinfos = append(tempOpspdiseinfos, tempOpspdiseinfo2)
  5718. struct4101.OpspdiseinfoStruct = tempOpspdiseinfos
  5719. var iteminfo service.IteminfoStruct
  5720. var bedCostTotal float64 = 0 //床位总费
  5721. var bedCostSelfTotal float64 = 0 //床位自费
  5722. var bedCostPartSelfTotal float64 = 0 //床位部分项目自费
  5723. var operationCostTotal float64 = 0 //手术费
  5724. var operationCostSelfTotal float64 = 0 //手术费
  5725. var operationCostPartSelfTotal float64 = 0 //手术费
  5726. var otherCostTotal float64 = 0 //其他费用
  5727. var otherCostSelfTotal float64 = 0 //其他费用
  5728. var otherCostPartSelfTotal float64 = 0 //其他费用
  5729. var materialCostTotal float64 = 0 //材料费
  5730. var materialCostSelfTotal float64 = 0 //材料费
  5731. var materialCostPartSelfTotal float64 = 0 //材料费
  5732. var westernMedicineCostTotal float64 = 0 //西药费
  5733. var westernMedicineCostSelfTotal float64 = 0 //西药费
  5734. var westernMedicineCostPartSelfTotal float64 = 0 //西药费
  5735. var chineseTraditionalMedicineCostTotal float64 = 0 //中成药
  5736. var chineseTraditionalMedicineCostSelfTotal float64 = 0 //中成药
  5737. var chineseTraditionalMedicineCostPartSelfTotal float64 = 0 //中成药
  5738. var checkCostTotal float64 = 0 //检查费
  5739. var checkCostSelfTotal float64 = 0 //检查费
  5740. var checkCostPartSelfTotal float64 = 0 //检查费
  5741. var laboratoryCostTotal float64 = 0 //化验费
  5742. var laboratoryCostSelfTotal float64 = 0 //化验费
  5743. var laboratoryCostPartSelfTotal float64 = 0 //化验费
  5744. var treatCostTotal float64 = 0 //治疗费用
  5745. var treatCostSelfTotal float64 = 0 //治疗费用
  5746. var treatCostPartSelfTotal float64 = 0 //治疗费用
  5747. decimal.DivisionPrecision = 2
  5748. var bed_fulamt_ownpay_amt float64 = 0
  5749. var operation_fulamt_ownpay_amt float64 = 0
  5750. var other_fulamt_ownpay_amt float64 = 0
  5751. var westernMedicine_fulamt_ownpay_amt float64 = 0
  5752. var chineseTraditional_fulamt_ownpay_amt float64 = 0
  5753. var check_fulamt_ownpay_amt float64 = 0
  5754. var material_fulamt_ownpay_amt float64 = 0
  5755. var laboratory_fulamt_ownpay_amt float64 = 0
  5756. var treat_fulamt_ownpay_amt float64 = 0
  5757. var bed_claa_sunmfee float64 = 0
  5758. var bed_clab_amt float64 = 0
  5759. var bed_other_amt float64 = 0
  5760. var operation_claa_sunmfee float64 = 0
  5761. var operation_clab_amt float64 = 0
  5762. var operation_other_amt float64 = 0
  5763. var other_claa_sunmfee float64 = 0
  5764. var other_clab_amt float64 = 0
  5765. var other_other_amt float64 = 0
  5766. var westernMedicine_claa_sunmfee float64 = 0
  5767. var westernMedicine_clab_amt float64 = 0
  5768. var westernMedicine_other_amt float64 = 0
  5769. var chineseTraditional_claa_sunmfee float64 = 0
  5770. var chineseTraditional_clab_amt float64 = 0
  5771. var chineseTraditional_other_amt float64 = 0
  5772. var check_claa_sunmfee float64 = 0
  5773. var check_clab_amt float64 = 0
  5774. var check_other_amt float64 = 0
  5775. var material_claa_sunmfee float64 = 0
  5776. var material_clab_amt float64 = 0
  5777. var material_other_amt float64 = 0
  5778. var laboratory_claa_sunmfee float64 = 0
  5779. var laboratory_clab_amt float64 = 0
  5780. var laboratory_other_amt float64 = 0
  5781. var treat_claa_sunmfee float64 = 0
  5782. var treat_clab_amt float64 = 0
  5783. var treat_other_amt float64 = 0
  5784. for _, item := range order.HisOrderInfo {
  5785. if item.MedChrgitmType == "01" { //床位费
  5786. bedCostTotal, _ = decimal.NewFromFloat(bedCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  5787. bedCostSelfTotal, _ = decimal.NewFromFloat(bedCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  5788. bedCostPartSelfTotal, _ = decimal.NewFromFloat(bedCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  5789. bed_fulamt_ownpay_amt, _ = decimal.NewFromFloat(bed_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  5790. if item.ChrgitmLv == "1" {
  5791. bed_claa_sunmfee, _ = decimal.NewFromFloat(bed_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  5792. }
  5793. if item.ChrgitmLv == "2" {
  5794. bed_clab_amt, _ = decimal.NewFromFloat(bed_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  5795. }
  5796. if item.ChrgitmLv == "3" {
  5797. bed_other_amt, _ = decimal.NewFromFloat(bed_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  5798. }
  5799. }
  5800. if item.MedChrgitmType == "03" { //检查费
  5801. checkCostTotal, _ = decimal.NewFromFloat(checkCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  5802. checkCostSelfTotal, _ = decimal.NewFromFloat(checkCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  5803. checkCostPartSelfTotal, _ = decimal.NewFromFloat(checkCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  5804. check_fulamt_ownpay_amt, _ = decimal.NewFromFloat(check_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  5805. if item.ChrgitmLv == "1" {
  5806. check_claa_sunmfee, _ = decimal.NewFromFloat(check_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  5807. }
  5808. if item.ChrgitmLv == "2" {
  5809. check_clab_amt, _ = decimal.NewFromFloat(check_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  5810. }
  5811. if item.ChrgitmLv == "3" {
  5812. check_other_amt, _ = decimal.NewFromFloat(check_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  5813. }
  5814. }
  5815. if item.MedChrgitmType == "04" { //化验费
  5816. laboratoryCostTotal, _ = decimal.NewFromFloat(laboratoryCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  5817. laboratoryCostSelfTotal, _ = decimal.NewFromFloat(laboratoryCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  5818. laboratoryCostPartSelfTotal, _ = decimal.NewFromFloat(laboratoryCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  5819. laboratory_fulamt_ownpay_amt, _ = decimal.NewFromFloat(laboratory_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  5820. if item.ChrgitmLv == "1" {
  5821. laboratory_claa_sunmfee, _ = decimal.NewFromFloat(laboratory_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  5822. }
  5823. if item.ChrgitmLv == "2" {
  5824. laboratory_clab_amt, _ = decimal.NewFromFloat(laboratory_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  5825. }
  5826. if item.ChrgitmLv == "3" {
  5827. laboratory_other_amt, _ = decimal.NewFromFloat(laboratory_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  5828. }
  5829. }
  5830. if item.MedChrgitmType == "05" { //治疗费
  5831. treatCostTotal, _ = decimal.NewFromFloat(treatCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  5832. treatCostSelfTotal, _ = decimal.NewFromFloat(treatCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  5833. treatCostPartSelfTotal, _ = decimal.NewFromFloat(treatCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  5834. treat_fulamt_ownpay_amt, _ = decimal.NewFromFloat(treat_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  5835. if item.ChrgitmLv == "1" {
  5836. treat_claa_sunmfee, _ = decimal.NewFromFloat(treat_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  5837. }
  5838. if item.ChrgitmLv == "2" {
  5839. treat_clab_amt, _ = decimal.NewFromFloat(treat_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  5840. }
  5841. if item.ChrgitmLv == "3" {
  5842. treat_other_amt, _ = decimal.NewFromFloat(treat_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  5843. }
  5844. }
  5845. if item.MedChrgitmType == "06" { //手术费
  5846. operationCostTotal, _ = decimal.NewFromFloat(operationCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  5847. operationCostSelfTotal, _ = decimal.NewFromFloat(operationCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  5848. operationCostPartSelfTotal, _ = decimal.NewFromFloat(operationCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  5849. operation_fulamt_ownpay_amt, _ = decimal.NewFromFloat(operation_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  5850. if item.ChrgitmLv == "1" {
  5851. operation_claa_sunmfee, _ = decimal.NewFromFloat(operation_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  5852. }
  5853. if item.ChrgitmLv == "2" {
  5854. operation_clab_amt, _ = decimal.NewFromFloat(operation_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  5855. }
  5856. if item.ChrgitmLv == "3" {
  5857. operation_other_amt, _ = decimal.NewFromFloat(operation_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  5858. }
  5859. }
  5860. if item.MedChrgitmType == "08" { //材料费
  5861. materialCostTotal, _ = decimal.NewFromFloat(materialCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  5862. materialCostSelfTotal, _ = decimal.NewFromFloat(materialCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  5863. materialCostPartSelfTotal, _ = decimal.NewFromFloat(materialCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  5864. material_fulamt_ownpay_amt, _ = decimal.NewFromFloat(material_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  5865. if item.ChrgitmLv == "1" {
  5866. material_claa_sunmfee, _ = decimal.NewFromFloat(material_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  5867. }
  5868. if item.ChrgitmLv == "2" {
  5869. material_clab_amt, _ = decimal.NewFromFloat(material_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  5870. }
  5871. if item.ChrgitmLv == "3" {
  5872. material_other_amt, _ = decimal.NewFromFloat(material_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  5873. }
  5874. }
  5875. if item.MedChrgitmType == "09" { //西药费
  5876. westernMedicineCostTotal, _ = decimal.NewFromFloat(westernMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  5877. westernMedicineCostSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  5878. westernMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  5879. westernMedicine_fulamt_ownpay_amt, _ = decimal.NewFromFloat(westernMedicine_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  5880. if item.ChrgitmLv == "1" {
  5881. westernMedicine_claa_sunmfee, _ = decimal.NewFromFloat(westernMedicine_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  5882. }
  5883. if item.ChrgitmLv == "2" {
  5884. westernMedicine_clab_amt, _ = decimal.NewFromFloat(westernMedicine_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  5885. }
  5886. if item.ChrgitmLv == "3" {
  5887. westernMedicine_other_amt, _ = decimal.NewFromFloat(westernMedicine_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  5888. }
  5889. }
  5890. if item.MedChrgitmType == "11" { //中成费
  5891. chineseTraditionalMedicineCostTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  5892. chineseTraditionalMedicineCostSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  5893. chineseTraditionalMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  5894. chineseTraditional_fulamt_ownpay_amt, _ = decimal.NewFromFloat(chineseTraditional_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  5895. if item.ChrgitmLv == "1" {
  5896. chineseTraditional_claa_sunmfee, _ = decimal.NewFromFloat(chineseTraditional_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  5897. }
  5898. if item.ChrgitmLv == "2" {
  5899. chineseTraditional_clab_amt, _ = decimal.NewFromFloat(chineseTraditional_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  5900. }
  5901. if item.ChrgitmLv == "3" {
  5902. chineseTraditional_other_amt, _ = decimal.NewFromFloat(chineseTraditional_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  5903. }
  5904. }
  5905. if item.MedChrgitmType == "14" { //其他费
  5906. otherCostTotal, _ = decimal.NewFromFloat(otherCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  5907. otherCostSelfTotal, _ = decimal.NewFromFloat(otherCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  5908. otherCostPartSelfTotal, _ = decimal.NewFromFloat(otherCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  5909. other_fulamt_ownpay_amt, _ = decimal.NewFromFloat(other_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  5910. if item.ChrgitmLv == "1" {
  5911. other_claa_sunmfee, _ = decimal.NewFromFloat(other_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  5912. }
  5913. if item.ChrgitmLv == "2" {
  5914. other_clab_amt, _ = decimal.NewFromFloat(other_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  5915. }
  5916. if item.ChrgitmLv == "3" {
  5917. other_other_amt, _ = decimal.NewFromFloat(other_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  5918. }
  5919. }
  5920. }
  5921. var iteminfoStructs []service.IteminfoStruct
  5922. if bedCostTotal != 0 {
  5923. iteminfo.MedChrgitm = "01"
  5924. iteminfo.FulamtOwnpayAmt = bed_fulamt_ownpay_amt
  5925. iteminfo.Amt = bedCostTotal
  5926. iteminfo.ClaaSumfee = bed_claa_sunmfee
  5927. iteminfo.ClabAmt = bed_clab_amt
  5928. iteminfo.OthAmt = bed_other_amt
  5929. iteminfoStructs = append(iteminfoStructs, iteminfo)
  5930. }
  5931. if checkCostTotal != 0 {
  5932. iteminfo.MedChrgitm = "03"
  5933. iteminfo.FulamtOwnpayAmt = check_fulamt_ownpay_amt
  5934. iteminfo.Amt = checkCostTotal
  5935. iteminfo.ClaaSumfee = check_claa_sunmfee
  5936. iteminfo.ClabAmt = check_clab_amt
  5937. iteminfo.OthAmt = check_other_amt
  5938. iteminfoStructs = append(iteminfoStructs, iteminfo)
  5939. }
  5940. if laboratoryCostTotal != 0 {
  5941. iteminfo.MedChrgitm = "04"
  5942. iteminfo.FulamtOwnpayAmt = laboratory_fulamt_ownpay_amt
  5943. iteminfo.Amt = laboratoryCostTotal
  5944. iteminfo.ClaaSumfee = laboratory_claa_sunmfee
  5945. iteminfo.ClabAmt = laboratory_clab_amt
  5946. iteminfo.OthAmt = laboratory_other_amt
  5947. iteminfoStructs = append(iteminfoStructs, iteminfo)
  5948. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  5949. }
  5950. if treatCostTotal != 0 {
  5951. iteminfo.MedChrgitm = "05"
  5952. iteminfo.FulamtOwnpayAmt = treat_fulamt_ownpay_amt
  5953. iteminfo.Amt = treatCostTotal
  5954. iteminfo.ClaaSumfee = treat_claa_sunmfee
  5955. iteminfo.ClabAmt = treat_clab_amt
  5956. iteminfo.OthAmt = treat_other_amt
  5957. iteminfoStructs = append(iteminfoStructs, iteminfo)
  5958. //(struct4101.IteminfoStruct, iteminfo)
  5959. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  5960. }
  5961. if operationCostTotal != 0 {
  5962. iteminfo.MedChrgitm = "06"
  5963. iteminfo.FulamtOwnpayAmt = bed_fulamt_ownpay_amt
  5964. iteminfo.Amt = operationCostTotal
  5965. iteminfo.ClaaSumfee = operation_claa_sunmfee
  5966. iteminfo.ClabAmt = operation_clab_amt
  5967. iteminfo.OthAmt = operation_other_amt
  5968. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  5969. iteminfoStructs = append(iteminfoStructs, iteminfo)
  5970. }
  5971. if materialCostTotal != 0 {
  5972. iteminfo.MedChrgitm = "08"
  5973. iteminfo.FulamtOwnpayAmt = material_fulamt_ownpay_amt
  5974. iteminfo.Amt = materialCostTotal
  5975. iteminfo.ClaaSumfee = material_claa_sunmfee
  5976. iteminfo.ClabAmt = material_clab_amt
  5977. iteminfo.OthAmt = material_other_amt
  5978. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  5979. iteminfoStructs = append(iteminfoStructs, iteminfo)
  5980. }
  5981. if westernMedicineCostTotal != 0 {
  5982. iteminfo.MedChrgitm = "09"
  5983. iteminfo.FulamtOwnpayAmt = westernMedicine_fulamt_ownpay_amt
  5984. iteminfo.Amt = westernMedicineCostTotal
  5985. iteminfo.ClaaSumfee = westernMedicine_claa_sunmfee
  5986. iteminfo.ClabAmt = westernMedicine_clab_amt
  5987. iteminfo.OthAmt = westernMedicine_other_amt
  5988. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  5989. iteminfoStructs = append(iteminfoStructs, iteminfo)
  5990. }
  5991. if chineseTraditionalMedicineCostTotal != 0 {
  5992. iteminfo.MedChrgitm = "11"
  5993. iteminfo.FulamtOwnpayAmt = westernMedicine_fulamt_ownpay_amt
  5994. iteminfo.Amt = westernMedicineCostTotal
  5995. iteminfo.ClaaSumfee = westernMedicine_claa_sunmfee
  5996. iteminfo.ClabAmt = westernMedicine_clab_amt
  5997. iteminfo.OthAmt = westernMedicine_other_amt
  5998. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  5999. iteminfoStructs = append(iteminfoStructs, iteminfo)
  6000. }
  6001. if otherCostTotal != 0 {
  6002. iteminfo.MedChrgitm = "14"
  6003. iteminfo.FulamtOwnpayAmt = other_fulamt_ownpay_amt
  6004. iteminfo.Amt = otherCostTotal
  6005. iteminfo.ClaaSumfee = other_claa_sunmfee
  6006. iteminfo.ClabAmt = other_clab_amt
  6007. iteminfo.OthAmt = other_other_amt
  6008. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  6009. iteminfoStructs = append(iteminfoStructs, iteminfo)
  6010. }
  6011. struct4101.IteminfoStruct = iteminfoStructs
  6012. struct4101.Ntly = "中国"
  6013. struct4101.AdmCaty = "A03.06"
  6014. struct4101.DoctorName = doctor.UserName
  6015. struct4101.DoctorCode = doctor.DoctorNumber
  6016. var res ResultSeventeen
  6017. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  6018. struct4101.BillCode = order.Number
  6019. struct4101.BillNo = order.SetlId
  6020. var resOther ResultSeventeenOther
  6021. var pp models.PublicParams
  6022. pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  6023. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  6024. pp.FixmedinsName = miConfig.OrgName
  6025. pp.FixmedinsCode = miConfig.Code
  6026. pp.RequestUrl = miConfig.Url
  6027. pp.Cainfo = miConfig.Cainfo
  6028. pp.SecretKey = miConfig.SecretKey
  6029. pp.AccessKey = miConfig.AccessKey
  6030. pp.OpterName = curRoles.UserName
  6031. client := &http.Client{}
  6032. var req *http.Request
  6033. data := make(map[string]interface{})
  6034. data["struct4101"] = struct4101
  6035. data["pp"] = pp
  6036. bytesData, _ := json.Marshal(data)
  6037. if miConfig.MdtrtareaAdmvs == "320921" {
  6038. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/4101", bytes.NewReader(bytesData))
  6039. } else {
  6040. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/4101", bytes.NewReader(bytesData))
  6041. }
  6042. resp, _ := client.Do(req)
  6043. defer resp.Body.Close()
  6044. body, ioErr := ioutil.ReadAll(resp.Body)
  6045. if ioErr != nil {
  6046. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  6047. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6048. return
  6049. }
  6050. var respJSON map[string]interface{}
  6051. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  6052. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  6053. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6054. return
  6055. }
  6056. respJSON = respJSON["data"].(map[string]interface{})["request_log"].(map[string]interface{})
  6057. userJSONBytes, _ := json.Marshal(respJSON)
  6058. fmt.Println("log")
  6059. fmt.Println(string(userJSONBytes))
  6060. if err := json.Unmarshal(userJSONBytes, &resOther); err != nil {
  6061. utils.ErrorLog("解析失败:%v", err)
  6062. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6063. return
  6064. }
  6065. res.InfRefmsgid = resOther.InfRefmsgid
  6066. res.Output = resOther.Output
  6067. res.ErrMsg = resOther.ErrMsg
  6068. infocode, _ := strconv.ParseInt(resOther.Infcode, 10, 64)
  6069. res.Infcode = infocode
  6070. } else if miConfig.MdtrtareaAdmvs == "360399" {
  6071. var pp models.PublicParams
  6072. pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  6073. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  6074. pp.FixmedinsName = miConfig.OrgName
  6075. pp.FixmedinsCode = miConfig.Code
  6076. pp.RequestUrl = miConfig.Url
  6077. pp.Cainfo = miConfig.Cainfo
  6078. pp.SecretKey = miConfig.SecretKey
  6079. pp.AccessKey = miConfig.AccessKey
  6080. pp.OpterName = curRoles.UserName
  6081. result, _ := service.Jxyb4101(struct4101, pp)
  6082. var dat map[string]interface{}
  6083. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  6084. fmt.Println(dat)
  6085. } else {
  6086. fmt.Println(err)
  6087. }
  6088. userJSONBytes, _ := json.Marshal(dat)
  6089. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  6090. utils.ErrorLog("解析失败:%v", err)
  6091. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6092. return
  6093. }
  6094. } else if miConfig.MdtrtareaAdmvs == "430800" {
  6095. var pp models.PublicParams
  6096. pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  6097. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  6098. pp.FixmedinsName = miConfig.OrgName
  6099. pp.FixmedinsCode = miConfig.Code
  6100. pp.RequestUrl = miConfig.Url
  6101. pp.Cainfo = miConfig.Cainfo
  6102. pp.SecretKey = miConfig.SecretKey
  6103. pp.AccessKey = miConfig.AccessKey
  6104. pp.OpterName = curRoles.UserName
  6105. result, _ := service.Hnyb4101(struct4101, pp)
  6106. var dat map[string]interface{}
  6107. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  6108. fmt.Println(dat)
  6109. } else {
  6110. fmt.Println(err)
  6111. }
  6112. userJSONBytes, _ := json.Marshal(dat)
  6113. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  6114. utils.ErrorLog("解析失败:%v", err)
  6115. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6116. return
  6117. }
  6118. } else {
  6119. result, _ := service.Gdyb4101(struct4101, miConfig.SecretKey, miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.UserOrgId)
  6120. var dat map[string]interface{}
  6121. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  6122. fmt.Println(dat)
  6123. } else {
  6124. fmt.Println(err)
  6125. }
  6126. userJSONBytes, _ := json.Marshal(dat)
  6127. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  6128. utils.ErrorLog("解析失败:%v", err)
  6129. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6130. return
  6131. }
  6132. }
  6133. if res.Infcode != 0 {
  6134. c.ServeSuccessJSON(map[string]interface{}{
  6135. "failed_code": -10,
  6136. "msg": res.ErrMsg,
  6137. })
  6138. return
  6139. } else {
  6140. //order.FaPiaoNumber = zero
  6141. //order.FaPiaoCode = last_order.FaPiaoCode
  6142. //service.UpdateOrder(order)
  6143. hisFundSettleListResult := &models.HisFundSettleListResult{
  6144. Number: res.Output.SetlListId,
  6145. Status: 1,
  6146. Ctime: time.Now().Unix(),
  6147. Mtime: time.Now().Unix(),
  6148. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  6149. IsUpload: 1,
  6150. OrderId: order_id,
  6151. }
  6152. service.CreateUploadRecord(hisFundSettleListResult)
  6153. c.ServeSuccessJSON(map[string]interface{}{
  6154. "msg": "上传成功",
  6155. "result": hisFundSettleListResult,
  6156. })
  6157. return
  6158. }
  6159. }
  6160. func (c *HisApiController) GetSettleListHospital() {
  6161. order_id, _ := c.GetInt64("order_id")
  6162. admin_user_id, _ := c.GetInt64("admin_user_id")
  6163. order, _ := service.GetHisOrderByIDTwo(order_id)
  6164. roles, _ := service.GetDoctorListTwo(c.GetAdminUserInfo().CurrentOrgId)
  6165. his, _ := service.GetInHospitalRecordByNumber(order.MdtrtId)
  6166. admin, _ := service.GetAdminUserByUserID(roles[0].AdminUserId)
  6167. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  6168. depart, _ := service.GetDepartMentDetail(curRoles.DepartmentId)
  6169. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  6170. if order.ID == 0 {
  6171. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisOrderNoExistParamWrong)
  6172. return
  6173. }
  6174. last_order, _ := service.GetLastHisOrder(c.GetAdminUserInfo().CurrentOrgId)
  6175. max_order, _ := service.GetLastHisOrderTwo(c.GetAdminUserInfo().CurrentOrgId)
  6176. count, _ := strconv.ParseInt(max_order.FaPiaoNumber, 10, 64)
  6177. fmt.Println(count)
  6178. var zero string
  6179. number := count + 1
  6180. if number >= 1000 {
  6181. zero = "0000" + strconv.FormatInt(number, 10)
  6182. } else if number >= 10000 {
  6183. zero = "000" + strconv.FormatInt(number, 10)
  6184. } else if number >= 100000 {
  6185. zero = "00" + strconv.FormatInt(number, 10)
  6186. } else if number >= 1000000 {
  6187. zero = "0" + strconv.FormatInt(number, 10)
  6188. } else {
  6189. zero = strconv.FormatInt(number, 10)
  6190. }
  6191. fmt.Println(zero)
  6192. struct4101 := service.Struct4101{
  6193. PsnNo: order.PsnNo,
  6194. MdtrtId: order.MdtrtId,
  6195. SetlId: order.SetlId,
  6196. PsnName: order.PsnName,
  6197. Gend: order.Gend,
  6198. Brdy: his.Brdy,
  6199. Age: int64(order.Age),
  6200. Naty: order.Naty,
  6201. PatnCertType: "01",
  6202. Certno: order.Certno,
  6203. Prfs: "90",
  6204. ConerName: roles[0].UserName,
  6205. PatnRlts: "99",
  6206. ConerAddr: miConfig.OrgName,
  6207. ConerTel: admin.Mobile,
  6208. HiType: order.Insutype,
  6209. Insuplc: miConfig.InsuplcAdmdvs,
  6210. MaindiagFlag: "1",
  6211. BillCode: order.SetlId,
  6212. BillNo: order.SetlId,
  6213. BizSn: order.Number,
  6214. PsnSelfPay: order.PsnPartAmt,
  6215. PsnOwnPay: order.PsnPartAmt,
  6216. AcctPay: order.AcctPay,
  6217. PsnCashpay: order.PsnCashPay,
  6218. HiPaymtd: "1",
  6219. Hsorg: miConfig.InsuplcAdmdvs,
  6220. HsorgOpter: miConfig.InsuplcAdmdvs,
  6221. MedinsFillPsn: curRoles.UserName,
  6222. MedinsFillDept: depart.Name,
  6223. IptMedType: "2",
  6224. AdmTime: his.InHosptialTime,
  6225. AdmEndTime: his.OutHosptialTime,
  6226. }
  6227. struct4101.SetlBegnDate = order.SetlTime
  6228. struct4101.SetlEndDate = order.SetlTime
  6229. var rf []CustomFundPay
  6230. json.Unmarshal([]byte(order.SetlDetail), &rf)
  6231. var tempFunPays []service.CustomStruct
  6232. for _, item := range rf {
  6233. var tempFunPay service.CustomStruct
  6234. tempFunPay.FundPayamt = item.FundPayamt
  6235. tempFunPay.FundPayType = item.FundPayType
  6236. tempFunPays = append(tempFunPays, tempFunPay)
  6237. }
  6238. struct4101.CustomStruct = tempFunPays
  6239. var tempDiaginfos []service.DiaginfoStructTwo
  6240. var tempOpspdiseinfo2 service.OpspdiseinfoStruct
  6241. var tempOpspdiseinfos []service.OpspdiseinfoStruct
  6242. diagnosis_ids := strings.Split(his.Diagnosis, ",")
  6243. var config []*models.HisXtDiagnoseConfig
  6244. for _, item := range diagnosis_ids {
  6245. id, _ := strconv.ParseInt(item, 10, 64)
  6246. diagnosisConfig, _ := service.FindDiagnoseById(id)
  6247. config = append(config, &diagnosisConfig)
  6248. }
  6249. for index, item := range config {
  6250. if index == 0 {
  6251. var tempDiaginfo service.DiaginfoStructTwo
  6252. tempDiaginfo.DiagCode = item.CountryCode
  6253. tempDiaginfo.DiagName = item.CountryContentName
  6254. tempDiaginfo.DiagType = "1"
  6255. tempDiaginfo.MaindiagFlag = "1"
  6256. tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  6257. } else {
  6258. var tempDiaginfo service.DiaginfoStructTwo
  6259. tempDiaginfo.DiagCode = item.CountryCode
  6260. tempDiaginfo.DiagName = item.CountryContentName
  6261. tempDiaginfo.DiagType = "2"
  6262. tempDiaginfo.MaindiagFlag = "0"
  6263. tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  6264. }
  6265. }
  6266. struct4101.Diseinfo = tempDiaginfos
  6267. sickConfigTwo, _ := service.FindSickById(his.SickType)
  6268. tempOpspdiseinfo2.DiagCode = sickConfigTwo.ContentCode
  6269. tempOpspdiseinfo2.DiagName = sickConfigTwo.CountryContentName
  6270. tempOpspdiseinfo2.OprnOprtCode = ""
  6271. tempOpspdiseinfo2.OprnOprtName = ""
  6272. tempOpspdiseinfos = append(tempOpspdiseinfos, tempOpspdiseinfo2)
  6273. struct4101.OpspdiseinfoStruct = tempOpspdiseinfos
  6274. var iteminfo service.IteminfoStruct
  6275. var bedCostTotal float64 = 0 //床位总费
  6276. var bedCostSelfTotal float64 = 0 //床位自费
  6277. var bedCostPartSelfTotal float64 = 0 //床位部分项目自费
  6278. var operationCostTotal float64 = 0 //手术费
  6279. var operationCostSelfTotal float64 = 0 //手术费
  6280. var operationCostPartSelfTotal float64 = 0 //手术费
  6281. var otherCostTotal float64 = 0 //其他费用
  6282. var otherCostSelfTotal float64 = 0 //其他费用
  6283. var otherCostPartSelfTotal float64 = 0 //其他费用
  6284. var materialCostTotal float64 = 0 //材料费
  6285. var materialCostSelfTotal float64 = 0 //材料费
  6286. var materialCostPartSelfTotal float64 = 0 //材料费
  6287. var westernMedicineCostTotal float64 = 0 //西药费
  6288. var westernMedicineCostSelfTotal float64 = 0 //西药费
  6289. var westernMedicineCostPartSelfTotal float64 = 0 //西药费
  6290. var chineseTraditionalMedicineCostTotal float64 = 0 //中成药
  6291. var chineseTraditionalMedicineCostSelfTotal float64 = 0 //中成药
  6292. var chineseTraditionalMedicineCostPartSelfTotal float64 = 0 //中成药
  6293. var checkCostTotal float64 = 0 //检查费
  6294. var checkCostSelfTotal float64 = 0 //检查费
  6295. var checkCostPartSelfTotal float64 = 0 //检查费
  6296. var laboratoryCostTotal float64 = 0 //化验费
  6297. var laboratoryCostSelfTotal float64 = 0 //化验费
  6298. var laboratoryCostPartSelfTotal float64 = 0 //化验费
  6299. var treatCostTotal float64 = 0 //治疗费用
  6300. var treatCostSelfTotal float64 = 0 //治疗费用
  6301. var treatCostPartSelfTotal float64 = 0 //治疗费用
  6302. decimal.DivisionPrecision = 2
  6303. var bed_fulamt_ownpay_amt float64 = 0
  6304. var operation_fulamt_ownpay_amt float64 = 0
  6305. var other_fulamt_ownpay_amt float64 = 0
  6306. var westernMedicine_fulamt_ownpay_amt float64 = 0
  6307. var chineseTraditional_fulamt_ownpay_amt float64 = 0
  6308. var check_fulamt_ownpay_amt float64 = 0
  6309. var material_fulamt_ownpay_amt float64 = 0
  6310. var laboratory_fulamt_ownpay_amt float64 = 0
  6311. var treat_fulamt_ownpay_amt float64 = 0
  6312. var bed_claa_sunmfee float64 = 0
  6313. var bed_clab_amt float64 = 0
  6314. var bed_other_amt float64 = 0
  6315. var operation_claa_sunmfee float64 = 0
  6316. var operation_clab_amt float64 = 0
  6317. var operation_other_amt float64 = 0
  6318. var other_claa_sunmfee float64 = 0
  6319. var other_clab_amt float64 = 0
  6320. var other_other_amt float64 = 0
  6321. var westernMedicine_claa_sunmfee float64 = 0
  6322. var westernMedicine_clab_amt float64 = 0
  6323. var westernMedicine_other_amt float64 = 0
  6324. var chineseTraditional_claa_sunmfee float64 = 0
  6325. var chineseTraditional_clab_amt float64 = 0
  6326. var chineseTraditional_other_amt float64 = 0
  6327. var check_claa_sunmfee float64 = 0
  6328. var check_clab_amt float64 = 0
  6329. var check_other_amt float64 = 0
  6330. var material_claa_sunmfee float64 = 0
  6331. var material_clab_amt float64 = 0
  6332. var material_other_amt float64 = 0
  6333. var laboratory_claa_sunmfee float64 = 0
  6334. var laboratory_clab_amt float64 = 0
  6335. var laboratory_other_amt float64 = 0
  6336. var treat_claa_sunmfee float64 = 0
  6337. var treat_clab_amt float64 = 0
  6338. var treat_other_amt float64 = 0
  6339. for _, item := range order.HisOrderInfo {
  6340. if item.MedChrgitmType == "01" { //床位费
  6341. bedCostTotal, _ = decimal.NewFromFloat(bedCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  6342. bedCostSelfTotal, _ = decimal.NewFromFloat(bedCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  6343. bedCostPartSelfTotal, _ = decimal.NewFromFloat(bedCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  6344. bed_fulamt_ownpay_amt, _ = decimal.NewFromFloat(bed_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  6345. if item.ChrgitmLv == "1" {
  6346. bed_claa_sunmfee, _ = decimal.NewFromFloat(bed_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  6347. }
  6348. if item.ChrgitmLv == "2" {
  6349. bed_clab_amt, _ = decimal.NewFromFloat(bed_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  6350. }
  6351. if item.ChrgitmLv == "3" {
  6352. bed_other_amt, _ = decimal.NewFromFloat(bed_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  6353. }
  6354. }
  6355. if item.MedChrgitmType == "03" { //检查费
  6356. checkCostTotal, _ = decimal.NewFromFloat(checkCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  6357. checkCostSelfTotal, _ = decimal.NewFromFloat(checkCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  6358. checkCostPartSelfTotal, _ = decimal.NewFromFloat(checkCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  6359. check_fulamt_ownpay_amt, _ = decimal.NewFromFloat(check_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  6360. if item.ChrgitmLv == "1" {
  6361. check_claa_sunmfee, _ = decimal.NewFromFloat(check_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  6362. }
  6363. if item.ChrgitmLv == "2" {
  6364. check_clab_amt, _ = decimal.NewFromFloat(check_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  6365. }
  6366. if item.ChrgitmLv == "3" {
  6367. check_other_amt, _ = decimal.NewFromFloat(check_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  6368. }
  6369. }
  6370. if item.MedChrgitmType == "04" { //化验费
  6371. laboratoryCostTotal, _ = decimal.NewFromFloat(laboratoryCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  6372. laboratoryCostSelfTotal, _ = decimal.NewFromFloat(laboratoryCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  6373. laboratoryCostPartSelfTotal, _ = decimal.NewFromFloat(laboratoryCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  6374. laboratory_fulamt_ownpay_amt, _ = decimal.NewFromFloat(laboratory_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  6375. if item.ChrgitmLv == "1" {
  6376. laboratory_claa_sunmfee, _ = decimal.NewFromFloat(laboratory_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  6377. }
  6378. if item.ChrgitmLv == "2" {
  6379. laboratory_clab_amt, _ = decimal.NewFromFloat(laboratory_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  6380. }
  6381. if item.ChrgitmLv == "3" {
  6382. laboratory_other_amt, _ = decimal.NewFromFloat(laboratory_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  6383. }
  6384. }
  6385. if item.MedChrgitmType == "05" { //治疗费
  6386. treatCostTotal, _ = decimal.NewFromFloat(treatCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  6387. treatCostSelfTotal, _ = decimal.NewFromFloat(treatCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  6388. treatCostPartSelfTotal, _ = decimal.NewFromFloat(treatCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  6389. treat_fulamt_ownpay_amt, _ = decimal.NewFromFloat(treat_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  6390. if item.ChrgitmLv == "1" {
  6391. treat_claa_sunmfee, _ = decimal.NewFromFloat(treat_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  6392. }
  6393. if item.ChrgitmLv == "2" {
  6394. treat_clab_amt, _ = decimal.NewFromFloat(treat_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  6395. }
  6396. if item.ChrgitmLv == "3" {
  6397. treat_other_amt, _ = decimal.NewFromFloat(treat_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  6398. }
  6399. }
  6400. if item.MedChrgitmType == "06" { //手术费
  6401. operationCostTotal, _ = decimal.NewFromFloat(operationCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  6402. operationCostSelfTotal, _ = decimal.NewFromFloat(operationCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  6403. operationCostPartSelfTotal, _ = decimal.NewFromFloat(operationCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  6404. operation_fulamt_ownpay_amt, _ = decimal.NewFromFloat(operation_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  6405. if item.ChrgitmLv == "1" {
  6406. operation_claa_sunmfee, _ = decimal.NewFromFloat(operation_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  6407. }
  6408. if item.ChrgitmLv == "2" {
  6409. operation_clab_amt, _ = decimal.NewFromFloat(operation_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  6410. }
  6411. if item.ChrgitmLv == "3" {
  6412. operation_other_amt, _ = decimal.NewFromFloat(operation_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  6413. }
  6414. }
  6415. if item.MedChrgitmType == "08" { //材料费
  6416. materialCostTotal, _ = decimal.NewFromFloat(materialCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  6417. materialCostSelfTotal, _ = decimal.NewFromFloat(materialCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  6418. materialCostPartSelfTotal, _ = decimal.NewFromFloat(materialCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  6419. material_fulamt_ownpay_amt, _ = decimal.NewFromFloat(material_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  6420. if item.ChrgitmLv == "1" {
  6421. material_claa_sunmfee, _ = decimal.NewFromFloat(material_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  6422. }
  6423. if item.ChrgitmLv == "2" {
  6424. material_clab_amt, _ = decimal.NewFromFloat(material_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  6425. }
  6426. if item.ChrgitmLv == "3" {
  6427. material_other_amt, _ = decimal.NewFromFloat(material_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  6428. }
  6429. }
  6430. if item.MedChrgitmType == "09" { //西药费
  6431. westernMedicineCostTotal, _ = decimal.NewFromFloat(westernMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  6432. westernMedicineCostSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  6433. westernMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  6434. westernMedicine_fulamt_ownpay_amt, _ = decimal.NewFromFloat(westernMedicine_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  6435. if item.ChrgitmLv == "1" {
  6436. westernMedicine_claa_sunmfee, _ = decimal.NewFromFloat(westernMedicine_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  6437. }
  6438. if item.ChrgitmLv == "2" {
  6439. westernMedicine_clab_amt, _ = decimal.NewFromFloat(westernMedicine_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  6440. }
  6441. if item.ChrgitmLv == "3" {
  6442. westernMedicine_other_amt, _ = decimal.NewFromFloat(westernMedicine_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  6443. }
  6444. }
  6445. if item.MedChrgitmType == "11" { //中成费
  6446. chineseTraditionalMedicineCostTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  6447. chineseTraditionalMedicineCostSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  6448. chineseTraditionalMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  6449. chineseTraditional_fulamt_ownpay_amt, _ = decimal.NewFromFloat(chineseTraditional_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  6450. if item.ChrgitmLv == "1" {
  6451. chineseTraditional_claa_sunmfee, _ = decimal.NewFromFloat(chineseTraditional_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  6452. }
  6453. if item.ChrgitmLv == "2" {
  6454. chineseTraditional_clab_amt, _ = decimal.NewFromFloat(chineseTraditional_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  6455. }
  6456. if item.ChrgitmLv == "3" {
  6457. chineseTraditional_other_amt, _ = decimal.NewFromFloat(chineseTraditional_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  6458. }
  6459. }
  6460. if item.MedChrgitmType == "14" { //其他费
  6461. otherCostTotal, _ = decimal.NewFromFloat(otherCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  6462. otherCostSelfTotal, _ = decimal.NewFromFloat(otherCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  6463. otherCostPartSelfTotal, _ = decimal.NewFromFloat(otherCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  6464. other_fulamt_ownpay_amt, _ = decimal.NewFromFloat(other_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  6465. if item.ChrgitmLv == "1" {
  6466. other_claa_sunmfee, _ = decimal.NewFromFloat(other_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  6467. }
  6468. if item.ChrgitmLv == "2" {
  6469. other_clab_amt, _ = decimal.NewFromFloat(other_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  6470. }
  6471. if item.ChrgitmLv == "3" {
  6472. other_other_amt, _ = decimal.NewFromFloat(other_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  6473. }
  6474. }
  6475. }
  6476. var iteminfoStructs []service.IteminfoStruct
  6477. if bedCostTotal != 0 {
  6478. iteminfo.MedChrgitm = "01"
  6479. iteminfo.FulamtOwnpayAmt = bed_fulamt_ownpay_amt
  6480. iteminfo.Amt = bedCostTotal
  6481. iteminfo.ClaaSumfee = bed_claa_sunmfee
  6482. iteminfo.ClabAmt = bed_clab_amt
  6483. iteminfo.OthAmt = bed_other_amt
  6484. iteminfoStructs = append(iteminfoStructs, iteminfo)
  6485. }
  6486. if checkCostTotal != 0 {
  6487. iteminfo.MedChrgitm = "03"
  6488. iteminfo.FulamtOwnpayAmt = check_fulamt_ownpay_amt
  6489. iteminfo.Amt = checkCostTotal
  6490. iteminfo.ClaaSumfee = check_claa_sunmfee
  6491. iteminfo.ClabAmt = check_clab_amt
  6492. iteminfo.OthAmt = check_other_amt
  6493. iteminfoStructs = append(iteminfoStructs, iteminfo)
  6494. }
  6495. if laboratoryCostTotal != 0 {
  6496. iteminfo.MedChrgitm = "04"
  6497. iteminfo.FulamtOwnpayAmt = laboratory_fulamt_ownpay_amt
  6498. iteminfo.Amt = laboratoryCostTotal
  6499. iteminfo.ClaaSumfee = laboratory_claa_sunmfee
  6500. iteminfo.ClabAmt = laboratory_clab_amt
  6501. iteminfo.OthAmt = laboratory_other_amt
  6502. iteminfoStructs = append(iteminfoStructs, iteminfo)
  6503. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  6504. }
  6505. if treatCostTotal != 0 {
  6506. iteminfo.MedChrgitm = "05"
  6507. iteminfo.FulamtOwnpayAmt = treat_fulamt_ownpay_amt
  6508. iteminfo.Amt = treatCostTotal
  6509. iteminfo.ClaaSumfee = treat_claa_sunmfee
  6510. iteminfo.ClabAmt = treat_clab_amt
  6511. iteminfo.OthAmt = treat_other_amt
  6512. iteminfoStructs = append(iteminfoStructs, iteminfo)
  6513. //(struct4101.IteminfoStruct, iteminfo)
  6514. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  6515. }
  6516. if operationCostTotal != 0 {
  6517. iteminfo.MedChrgitm = "06"
  6518. iteminfo.FulamtOwnpayAmt = bed_fulamt_ownpay_amt
  6519. iteminfo.Amt = operationCostTotal
  6520. iteminfo.ClaaSumfee = operation_claa_sunmfee
  6521. iteminfo.ClabAmt = operation_clab_amt
  6522. iteminfo.OthAmt = operation_other_amt
  6523. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  6524. iteminfoStructs = append(iteminfoStructs, iteminfo)
  6525. }
  6526. if materialCostTotal != 0 {
  6527. iteminfo.MedChrgitm = "08"
  6528. iteminfo.FulamtOwnpayAmt = material_fulamt_ownpay_amt
  6529. iteminfo.Amt = materialCostTotal
  6530. iteminfo.ClaaSumfee = material_claa_sunmfee
  6531. iteminfo.ClabAmt = material_clab_amt
  6532. iteminfo.OthAmt = material_other_amt
  6533. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  6534. iteminfoStructs = append(iteminfoStructs, iteminfo)
  6535. }
  6536. if westernMedicineCostTotal != 0 {
  6537. iteminfo.MedChrgitm = "09"
  6538. iteminfo.FulamtOwnpayAmt = westernMedicine_fulamt_ownpay_amt
  6539. iteminfo.Amt = westernMedicineCostTotal
  6540. iteminfo.ClaaSumfee = westernMedicine_claa_sunmfee
  6541. iteminfo.ClabAmt = westernMedicine_clab_amt
  6542. iteminfo.OthAmt = westernMedicine_other_amt
  6543. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  6544. iteminfoStructs = append(iteminfoStructs, iteminfo)
  6545. }
  6546. if chineseTraditionalMedicineCostTotal != 0 {
  6547. iteminfo.MedChrgitm = "11"
  6548. iteminfo.FulamtOwnpayAmt = westernMedicine_fulamt_ownpay_amt
  6549. iteminfo.Amt = westernMedicineCostTotal
  6550. iteminfo.ClaaSumfee = westernMedicine_claa_sunmfee
  6551. iteminfo.ClabAmt = westernMedicine_clab_amt
  6552. iteminfo.OthAmt = westernMedicine_other_amt
  6553. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  6554. iteminfoStructs = append(iteminfoStructs, iteminfo)
  6555. }
  6556. if otherCostTotal != 0 {
  6557. iteminfo.MedChrgitm = "14"
  6558. iteminfo.FulamtOwnpayAmt = other_fulamt_ownpay_amt
  6559. iteminfo.Amt = otherCostTotal
  6560. iteminfo.ClaaSumfee = other_claa_sunmfee
  6561. iteminfo.ClabAmt = other_clab_amt
  6562. iteminfo.OthAmt = other_other_amt
  6563. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  6564. iteminfoStructs = append(iteminfoStructs, iteminfo)
  6565. }
  6566. struct4101.IteminfoStruct = iteminfoStructs
  6567. struct4101.Ntly = "中国"
  6568. struct4101.AdmCaty = "A03.06"
  6569. var resOther ResultSeventeenOther
  6570. var res ResultSeventeen
  6571. if miConfig.MdtrtareaAdmvs == "150499" {
  6572. var pp models.PublicParams
  6573. pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  6574. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  6575. pp.FixmedinsName = miConfig.OrgName
  6576. pp.FixmedinsCode = miConfig.Code
  6577. pp.RequestUrl = miConfig.Url
  6578. pp.Cainfo = miConfig.Cainfo
  6579. pp.SecretKey = miConfig.SecretKey
  6580. pp.AccessKey = miConfig.AccessKey
  6581. pp.OpterName = curRoles.UserName
  6582. client := &http.Client{}
  6583. var req *http.Request
  6584. data := make(map[string]interface{})
  6585. data["struct4101"] = struct4101
  6586. data["pp"] = pp
  6587. bytesData, _ := json.Marshal(data)
  6588. req, _ = http.NewRequest("POST", "http://172.16.13.254:9532/"+"nmyb/4101", bytes.NewReader(bytesData))
  6589. resp, _ := client.Do(req)
  6590. defer resp.Body.Close()
  6591. body, ioErr := ioutil.ReadAll(resp.Body)
  6592. if ioErr != nil {
  6593. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  6594. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6595. return
  6596. }
  6597. var respJSON map[string]interface{}
  6598. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  6599. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  6600. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6601. return
  6602. }
  6603. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  6604. userJSONBytes, _ := json.Marshal(respJSON)
  6605. if err := json.Unmarshal(userJSONBytes, &resOther); err != nil {
  6606. utils.ErrorLog("解析失败:%v", err)
  6607. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6608. return
  6609. }
  6610. res.InfRefmsgid = resOther.InfRefmsgid
  6611. res.Output = resOther.Output
  6612. res.ErrMsg = resOther.ErrMsg
  6613. infocode, _ := strconv.ParseInt(resOther.Infcode, 10, 64)
  6614. res.Infcode = infocode
  6615. } else {
  6616. result, _ := service.Gdyb4101(struct4101, miConfig.SecretKey, miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.UserOrgId)
  6617. var dat map[string]interface{}
  6618. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  6619. fmt.Println(dat)
  6620. } else {
  6621. fmt.Println(err)
  6622. }
  6623. userJSONBytes, _ := json.Marshal(dat)
  6624. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  6625. utils.ErrorLog("解析失败:%v", err)
  6626. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6627. return
  6628. }
  6629. }
  6630. if res.Infcode != 0 {
  6631. c.ServeSuccessJSON(map[string]interface{}{
  6632. "failed_code": -10,
  6633. "msg": res.ErrMsg,
  6634. })
  6635. return
  6636. } else {
  6637. if miConfig.MdtrtareaAdmvs != "150499" {
  6638. order.FaPiaoNumber = zero
  6639. order.FaPiaoCode = last_order.FaPiaoCode
  6640. service.UpdateOrder(order)
  6641. }
  6642. hisFundSettleListResult := &models.HisFundSettleListResult{
  6643. Number: res.Output.SetlListId,
  6644. Status: 1,
  6645. Ctime: time.Now().Unix(),
  6646. Mtime: time.Now().Unix(),
  6647. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  6648. IsUpload: 1,
  6649. OrderId: order_id,
  6650. }
  6651. service.CreateUploadRecord(hisFundSettleListResult)
  6652. c.ServeSuccessJSON(map[string]interface{}{
  6653. "msg": "上传成功",
  6654. "result": hisFundSettleListResult,
  6655. })
  6656. return
  6657. }
  6658. }
  6659. //func (c *HisApiController) GetBatchSettleList() {
  6660. // orders, _ := service.GetAllHisOrder(10106)
  6661. // for _, item := range orders {
  6662. // order_id := item.ID
  6663. // order, _ := service.GetHisOrderByIDTwo(order_id)
  6664. // roles, _ := service.GetDoctorListTwo(c.GetAdminUserInfo().CurrentOrgId)
  6665. // his, _ := service.GetHisPatientByNumber(order.MdtrtId)
  6666. // admin, _ := service.GetAdminUserByUserID(roles[0].AdminUserId)
  6667. // curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, 2495)
  6668. // depart, _ := service.GetDepartMentDetail(curRoles.DepartmentId)
  6669. // miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  6670. //
  6671. // pre, _ := service.GetNewHisPrescriptionByNumber(order.Number)
  6672. //
  6673. // doctor, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, pre.Creator)
  6674. //
  6675. // if order.ID == 0 {
  6676. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisOrderNoExistParamWrong)
  6677. // return
  6678. // }
  6679. // if his.BalanceAccountsType == 2 {
  6680. // continue
  6681. // }
  6682. // struct4101 := service.Struct4101{
  6683. // PsnNo: order.PsnNo,
  6684. // MdtrtId: order.MdtrtId,
  6685. // SetlId: order.SetlId,
  6686. // PsnName: order.PsnName,
  6687. // Gend: order.Gend,
  6688. // Brdy: his.Brdy,
  6689. // Age: his.Age,
  6690. // Naty: order.Naty,
  6691. // PatnCertType: "01",
  6692. // Certno: order.Certno,
  6693. // Prfs: "90",
  6694. // ConerName: roles[0].UserName,
  6695. // PatnRlts: "99",
  6696. // ConerAddr: miConfig.OrgName,
  6697. // ConerTel: admin.Mobile,
  6698. // HiType: order.Insutype,
  6699. // Insuplc: his.InsuplcAdmdvs,
  6700. // MaindiagFlag: "1",
  6701. // BillCode: order.SetlId,
  6702. // BillNo: order.SetlId,
  6703. // BizSn: order.Number,
  6704. // PsnSelfPay: order.PsnPartAmt,
  6705. // PsnOwnPay: order.PsnPartAmt,
  6706. // AcctPay: order.AcctPay,
  6707. // PsnCashpay: order.PsnCashPay,
  6708. // HiPaymtd: "1",
  6709. // Hsorg: his.InsuplcAdmdvs,
  6710. // HsorgOpter: his.InsuplcAdmdvs,
  6711. // MedinsFillPsn: curRoles.UserName,
  6712. // MedinsFillDept: depart.Name,
  6713. // IptMedType: "2",
  6714. // }
  6715. // struct4101.SetlBegnDate = order.SetlTime
  6716. // struct4101.SetlEndDate = order.SetlTime
  6717. // //if order.SettleType == 1 {
  6718. // // t := time.Unix(int64(order.SettleAccountsDate), 0)
  6719. // // dateStr := t.Format("2006-01-02")
  6720. // // struct4101.SetlBegnDate = dateStr
  6721. // // struct4101.SetlEndDate = dateStr
  6722. // //} else {
  6723. // // t := time.Unix(int64(order.SettleStartTime), 0)
  6724. // // t2 := time.Unix(int64(order.SettleEndTime), 0)
  6725. // // dateStartStr := t.Format("2006-01-02")
  6726. // // dateEndStr := t2.Format("2006-01-02")
  6727. // // struct4101.SetlBegnDate = dateStartStr
  6728. // // struct4101.SetlEndDate = dateEndStr
  6729. // //}
  6730. //
  6731. // var rf []CustomFundPay
  6732. // json.Unmarshal([]byte(order.SetlDetail), &rf)
  6733. //
  6734. // var tempFunPays []service.CustomStruct
  6735. // var tempFunPay610100 service.CustomStruct
  6736. //
  6737. // for _, item := range rf {
  6738. // if item.FundPayType == "610100" {
  6739. // tempFunPay610100.FundPayamt, _ = decimal.NewFromFloat(tempFunPay610100.FundPayamt).Add(decimal.NewFromFloat(item.FundPayamt)).Float64()
  6740. // tempFunPay610100.FundPayType = item.FundPayType
  6741. // } else {
  6742. // var tempFunPay service.CustomStruct
  6743. // tempFunPay.FundPayamt = item.FundPayamt
  6744. // tempFunPay.FundPayType = item.FundPayType
  6745. // tempFunPays = append(tempFunPays, tempFunPay)
  6746. // }
  6747. // }
  6748. // tempFunPays = append(tempFunPays, tempFunPay610100)
  6749. // struct4101.CustomStruct = tempFunPays
  6750. //
  6751. // var tempDiaginfos []service.DiaginfoStructTwo
  6752. // var tempOpspdiseinfo2 service.OpspdiseinfoStruct
  6753. // var tempOpspdiseinfos []service.OpspdiseinfoStruct
  6754. //
  6755. // diagnosis_ids := strings.Split(his.Diagnosis, ",")
  6756. // var config []*models.HisXtDiagnoseConfig
  6757. // for _, item := range diagnosis_ids {
  6758. // id, _ := strconv.ParseInt(item, 10, 64)
  6759. // diagnosisConfig, _ := service.FindDiagnoseById(id)
  6760. // config = append(config, &diagnosisConfig)
  6761. // }
  6762. //
  6763. // for index, item := range config {
  6764. // if index == 0 {
  6765. // var tempDiaginfo service.DiaginfoStructTwo
  6766. // tempDiaginfo.DiagCode = item.CountryCode
  6767. // tempDiaginfo.DiagName = item.CountryContentName
  6768. // tempDiaginfo.DiagType = "1"
  6769. // tempDiaginfo.MaindiagFlag = "1"
  6770. // tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  6771. // } else {
  6772. //
  6773. // var tempDiaginfo service.DiaginfoStructTwo
  6774. // tempDiaginfo.DiagCode = item.CountryCode
  6775. // tempDiaginfo.DiagName = item.CountryContentName
  6776. // tempDiaginfo.DiagType = "2"
  6777. // tempDiaginfo.MaindiagFlag = "0"
  6778. // tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  6779. // }
  6780. // }
  6781. // struct4101.Diseinfo = tempDiaginfos
  6782. //
  6783. // sickConfigTwo, _ := service.FindSickById(his.SickType)
  6784. // tempOpspdiseinfo2.DiagCode = sickConfigTwo.ContentCode
  6785. // tempOpspdiseinfo2.DiagName = sickConfigTwo.CountryContentName
  6786. // tempOpspdiseinfo2.OprnOprtCode = ""
  6787. // tempOpspdiseinfo2.OprnOprtName = ""
  6788. // tempOpspdiseinfos = append(tempOpspdiseinfos, tempOpspdiseinfo2)
  6789. // struct4101.OpspdiseinfoStruct = tempOpspdiseinfos
  6790. //
  6791. // var iteminfo service.IteminfoStruct
  6792. //
  6793. // var bedCostTotal float64 = 0 //床位总费
  6794. // var bedCostSelfTotal float64 = 0 //床位自费
  6795. // var bedCostPartSelfTotal float64 = 0 //床位部分项目自费
  6796. //
  6797. // var examineCostTotal float64 = 0 //诊查总费
  6798. // var examineCostSelfTotal float64 = 0 //诊查自费
  6799. // var examineCostPartSelfTotal float64 = 0 //诊查部分项目自费
  6800. //
  6801. // var nursingCostTotal float64 = 0 //护理总费
  6802. // var nursingCostSelfTotal float64 = 0 //护理自费
  6803. // var nursingCostPartSelfTotal float64 = 0 //护理部分项目自费
  6804. //
  6805. // var chineseMedicineCostTotal float64 = 0 //中成药
  6806. // var chineseMedicineCostSelfTotal float64 = 0 //中成药
  6807. // var chineseMedicineCostPartSelfTotal float64 = 0 //中成药
  6808. //
  6809. // var commonlyTreatmentCostTotal float64 = 0 //一般诊疗费
  6810. // var commonlyTreatmentCostSelfTotal float64 = 0 //一般诊疗费
  6811. // var commonlyTreatmentCostPartSelfTotal float64 = 0 //一般诊疗费
  6812. //
  6813. // var registerCostTotal float64 = 0 //一般诊疗费
  6814. // var registerCostSelfTotal float64 = 0 //一般诊疗费
  6815. // var registerPartSelfTotal float64 = 0 //一般诊疗费
  6816. //
  6817. // var operationCostTotal float64 = 0 //手术费
  6818. // var operationCostSelfTotal float64 = 0 //手术费
  6819. // var operationCostPartSelfTotal float64 = 0 //手术费
  6820. //
  6821. // var otherCostTotal float64 = 0 //其他费用
  6822. // var otherCostSelfTotal float64 = 0 //其他费用
  6823. // var otherCostPartSelfTotal float64 = 0 //其他费用
  6824. //
  6825. // var materialCostTotal float64 = 0 //材料费
  6826. // var materialCostSelfTotal float64 = 0 //材料费
  6827. // var materialCostPartSelfTotal float64 = 0 //材料费
  6828. //
  6829. // var westernMedicineCostTotal float64 = 0 //西药费
  6830. // var westernMedicineCostSelfTotal float64 = 0 //西药费
  6831. // var westernMedicineCostPartSelfTotal float64 = 0 //西药费
  6832. //
  6833. // var chineseTraditionalMedicineCostTotal float64 = 0 //中成药
  6834. // var chineseTraditionalMedicineCostSelfTotal float64 = 0 //中成药
  6835. // var chineseTraditionalMedicineCostPartSelfTotal float64 = 0 //中成药
  6836. //
  6837. // var checkCostTotal float64 = 0 //检查费
  6838. // var checkCostSelfTotal float64 = 0 //检查费
  6839. // var checkCostPartSelfTotal float64 = 0 //检查费
  6840. //
  6841. // var laboratoryCostTotal float64 = 0 //化验费
  6842. // var laboratoryCostSelfTotal float64 = 0 //化验费
  6843. // var laboratoryCostPartSelfTotal float64 = 0 //化验费
  6844. //
  6845. // var treatCostTotal float64 = 0 //治疗费用
  6846. // var treatCostSelfTotal float64 = 0 //治疗费用
  6847. // var treatCostPartSelfTotal float64 = 0 //治疗费用
  6848. //
  6849. // decimal.DivisionPrecision = 2
  6850. //
  6851. // var bed_fulamt_ownpay_amt float64 = 0
  6852. //
  6853. // var examine_fulamt_ownpay_amt float64 = 0
  6854. //
  6855. // var nursing_fulamt_ownpay_amt float64 = 0
  6856. //
  6857. // var chinese_medicine_fulamt_ownpay_amt float64 = 0
  6858. //
  6859. // var commonly_treatment_fulamt_ownpay_amt float64 = 0
  6860. //
  6861. // var register_fulamt_ownpay_amt float64 = 0
  6862. //
  6863. // var operation_fulamt_ownpay_amt float64 = 0
  6864. // var other_fulamt_ownpay_amt float64 = 0
  6865. // var westernMedicine_fulamt_ownpay_amt float64 = 0
  6866. // var chineseTraditional_fulamt_ownpay_amt float64 = 0
  6867. // var check_fulamt_ownpay_amt float64 = 0
  6868. // var material_fulamt_ownpay_amt float64 = 0
  6869. // var laboratory_fulamt_ownpay_amt float64 = 0
  6870. // var treat_fulamt_ownpay_amt float64 = 0
  6871. //
  6872. // var bed_claa_sunmfee float64 = 0
  6873. // var bed_clab_amt float64 = 0
  6874. // var bed_other_amt float64 = 0
  6875. //
  6876. // var examine_claa_sunmfee float64 = 0
  6877. // var examine_clab_amt float64 = 0
  6878. // var examine_other_amt float64 = 0
  6879. //
  6880. // var nursing_claa_sunmfee float64 = 0
  6881. // var nursing_clab_amt float64 = 0
  6882. // var nursing_other_amt float64 = 0
  6883. //
  6884. // var chinese_medicine_claa_sunmfee float64 = 0
  6885. // var chinese_medicine_clab_amt float64 = 0
  6886. // var chinese_medicine_other_amt float64 = 0
  6887. //
  6888. // var commonly_treatment_claa_sunmfee float64 = 0
  6889. // var commonly_treatment_clab_amt float64 = 0
  6890. // var commonly_treatment_other_amt float64 = 0
  6891. //
  6892. // var operation_claa_sunmfee float64 = 0
  6893. // var operation_clab_amt float64 = 0
  6894. // var operation_other_amt float64 = 0
  6895. //
  6896. // var other_claa_sunmfee float64 = 0
  6897. // var other_clab_amt float64 = 0
  6898. // var other_other_amt float64 = 0
  6899. //
  6900. // var westernMedicine_claa_sunmfee float64 = 0
  6901. // var westernMedicine_clab_amt float64 = 0
  6902. // var westernMedicine_other_amt float64 = 0
  6903. //
  6904. // var chineseTraditional_claa_sunmfee float64 = 0
  6905. // var chineseTraditional_clab_amt float64 = 0
  6906. // var chineseTraditional_other_amt float64 = 0
  6907. //
  6908. // var check_claa_sunmfee float64 = 0
  6909. // var check_clab_amt float64 = 0
  6910. // var check_other_amt float64 = 0
  6911. //
  6912. // var material_claa_sunmfee float64 = 0
  6913. // var material_clab_amt float64 = 0
  6914. // var material_other_amt float64 = 0
  6915. //
  6916. // var laboratory_claa_sunmfee float64 = 0
  6917. // var laboratory_clab_amt float64 = 0
  6918. // var laboratory_other_amt float64 = 0
  6919. //
  6920. // var treat_claa_sunmfee float64 = 0
  6921. // var treat_clab_amt float64 = 0
  6922. // var treat_other_amt float64 = 0
  6923. //
  6924. // var register_claa_sunmfee float64 = 0
  6925. // var register_clab_amt float64 = 0
  6926. // var register_other_amt float64 = 0
  6927. //
  6928. // for _, item := range order.HisOrderInfo {
  6929. // if item.MedChrgitmType == "01" { //床位费
  6930. // bedCostTotal, _ = decimal.NewFromFloat(bedCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  6931. // bedCostSelfTotal, _ = decimal.NewFromFloat(bedCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  6932. // bedCostPartSelfTotal, _ = decimal.NewFromFloat(bedCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  6933. // bed_fulamt_ownpay_amt, _ = decimal.NewFromFloat(bed_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  6934. // if item.ChrgitmLv == "1" {
  6935. // bed_claa_sunmfee, _ = decimal.NewFromFloat(bed_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  6936. // }
  6937. // if item.ChrgitmLv == "2" {
  6938. // bed_clab_amt, _ = decimal.NewFromFloat(bed_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  6939. //
  6940. // }
  6941. // if item.ChrgitmLv == "3" {
  6942. // bed_other_amt, _ = decimal.NewFromFloat(bed_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  6943. // }
  6944. //
  6945. // }
  6946. //
  6947. // if item.MedChrgitmType == "02" { //诊查
  6948. // examineCostTotal, _ = decimal.NewFromFloat(examineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  6949. // examineCostSelfTotal, _ = decimal.NewFromFloat(examineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  6950. // examineCostPartSelfTotal, _ = decimal.NewFromFloat(examineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  6951. // examine_fulamt_ownpay_amt, _ = decimal.NewFromFloat(examine_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  6952. // if item.ChrgitmLv == "1" {
  6953. // examine_claa_sunmfee, _ = decimal.NewFromFloat(examine_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  6954. // }
  6955. // if item.ChrgitmLv == "2" {
  6956. // examine_clab_amt, _ = decimal.NewFromFloat(examine_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  6957. //
  6958. // }
  6959. // if item.ChrgitmLv == "3" {
  6960. // examine_other_amt, _ = decimal.NewFromFloat(examine_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  6961. // }
  6962. //
  6963. // }
  6964. //
  6965. // if item.MedChrgitmType == "03" { //检查费
  6966. // checkCostTotal, _ = decimal.NewFromFloat(checkCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  6967. // checkCostSelfTotal, _ = decimal.NewFromFloat(checkCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  6968. // checkCostPartSelfTotal, _ = decimal.NewFromFloat(checkCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  6969. // check_fulamt_ownpay_amt, _ = decimal.NewFromFloat(check_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  6970. // if item.ChrgitmLv == "1" {
  6971. //
  6972. // check_claa_sunmfee, _ = decimal.NewFromFloat(check_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  6973. //
  6974. // }
  6975. // if item.ChrgitmLv == "2" {
  6976. // check_clab_amt, _ = decimal.NewFromFloat(check_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  6977. //
  6978. // }
  6979. // if item.ChrgitmLv == "3" {
  6980. // check_other_amt, _ = decimal.NewFromFloat(check_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  6981. // }
  6982. // }
  6983. //
  6984. // if item.MedChrgitmType == "04" { //化验费
  6985. // laboratoryCostTotal, _ = decimal.NewFromFloat(laboratoryCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  6986. // laboratoryCostSelfTotal, _ = decimal.NewFromFloat(laboratoryCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  6987. // laboratoryCostPartSelfTotal, _ = decimal.NewFromFloat(laboratoryCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  6988. // laboratory_fulamt_ownpay_amt, _ = decimal.NewFromFloat(laboratory_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  6989. // if item.ChrgitmLv == "1" {
  6990. //
  6991. // laboratory_claa_sunmfee, _ = decimal.NewFromFloat(laboratory_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  6992. //
  6993. // }
  6994. // if item.ChrgitmLv == "2" {
  6995. // laboratory_clab_amt, _ = decimal.NewFromFloat(laboratory_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  6996. //
  6997. // }
  6998. // if item.ChrgitmLv == "3" {
  6999. // laboratory_other_amt, _ = decimal.NewFromFloat(laboratory_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  7000. // }
  7001. // }
  7002. //
  7003. // if item.MedChrgitmType == "05" { //治疗费
  7004. // treatCostTotal, _ = decimal.NewFromFloat(treatCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  7005. // treatCostSelfTotal, _ = decimal.NewFromFloat(treatCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  7006. // treatCostPartSelfTotal, _ = decimal.NewFromFloat(treatCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  7007. // treat_fulamt_ownpay_amt, _ = decimal.NewFromFloat(treat_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  7008. // if item.ChrgitmLv == "1" {
  7009. //
  7010. // treat_claa_sunmfee, _ = decimal.NewFromFloat(treat_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  7011. //
  7012. // }
  7013. // if item.ChrgitmLv == "2" {
  7014. // treat_clab_amt, _ = decimal.NewFromFloat(treat_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  7015. //
  7016. // }
  7017. // if item.ChrgitmLv == "3" {
  7018. // treat_other_amt, _ = decimal.NewFromFloat(treat_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  7019. // }
  7020. // }
  7021. //
  7022. // if item.MedChrgitmType == "06" { //手术费
  7023. // operationCostTotal, _ = decimal.NewFromFloat(operationCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  7024. // operationCostSelfTotal, _ = decimal.NewFromFloat(operationCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  7025. // operationCostPartSelfTotal, _ = decimal.NewFromFloat(operationCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  7026. // operation_fulamt_ownpay_amt, _ = decimal.NewFromFloat(operation_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  7027. //
  7028. // if item.ChrgitmLv == "1" {
  7029. //
  7030. // operation_claa_sunmfee, _ = decimal.NewFromFloat(operation_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  7031. //
  7032. // }
  7033. // if item.ChrgitmLv == "2" {
  7034. // operation_clab_amt, _ = decimal.NewFromFloat(operation_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  7035. //
  7036. // }
  7037. // if item.ChrgitmLv == "3" {
  7038. // operation_other_amt, _ = decimal.NewFromFloat(operation_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  7039. // }
  7040. // }
  7041. //
  7042. // if item.MedChrgitmType == "07" { //手术费
  7043. // nursingCostTotal, _ = decimal.NewFromFloat(nursingCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  7044. // nursingCostSelfTotal, _ = decimal.NewFromFloat(nursingCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  7045. // nursingCostPartSelfTotal, _ = decimal.NewFromFloat(nursingCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  7046. // nursing_fulamt_ownpay_amt, _ = decimal.NewFromFloat(nursing_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  7047. //
  7048. // if item.ChrgitmLv == "1" {
  7049. //
  7050. // nursing_claa_sunmfee, _ = decimal.NewFromFloat(nursing_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  7051. //
  7052. // }
  7053. // if item.ChrgitmLv == "2" {
  7054. // nursing_clab_amt, _ = decimal.NewFromFloat(nursing_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  7055. //
  7056. // }
  7057. // if item.ChrgitmLv == "3" {
  7058. // nursing_other_amt, _ = decimal.NewFromFloat(nursing_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  7059. // }
  7060. // }
  7061. //
  7062. // if item.MedChrgitmType == "08" { //材料费
  7063. // materialCostTotal, _ = decimal.NewFromFloat(materialCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  7064. // materialCostSelfTotal, _ = decimal.NewFromFloat(materialCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  7065. // materialCostPartSelfTotal, _ = decimal.NewFromFloat(materialCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  7066. // material_fulamt_ownpay_amt, _ = decimal.NewFromFloat(material_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  7067. // if item.ChrgitmLv == "1" {
  7068. //
  7069. // material_claa_sunmfee, _ = decimal.NewFromFloat(material_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  7070. //
  7071. // }
  7072. // if item.ChrgitmLv == "2" {
  7073. // material_clab_amt, _ = decimal.NewFromFloat(material_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  7074. //
  7075. // }
  7076. // if item.ChrgitmLv == "3" {
  7077. // material_other_amt, _ = decimal.NewFromFloat(material_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  7078. // }
  7079. // }
  7080. // if item.MedChrgitmType == "09" { //西药费
  7081. // westernMedicineCostTotal, _ = decimal.NewFromFloat(westernMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  7082. // westernMedicineCostSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  7083. // westernMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  7084. // westernMedicine_fulamt_ownpay_amt, _ = decimal.NewFromFloat(westernMedicine_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  7085. // if item.ChrgitmLv == "1" {
  7086. // westernMedicine_claa_sunmfee, _ = decimal.NewFromFloat(westernMedicine_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  7087. // }
  7088. // if item.ChrgitmLv == "2" {
  7089. // westernMedicine_clab_amt, _ = decimal.NewFromFloat(westernMedicine_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  7090. // }
  7091. // if item.ChrgitmLv == "3" {
  7092. // westernMedicine_other_amt, _ = decimal.NewFromFloat(westernMedicine_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  7093. // }
  7094. // }
  7095. // if item.MedChrgitmType == "10" { //中药饮片
  7096. // chineseMedicineCostTotal, _ = decimal.NewFromFloat(chineseMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  7097. // chineseMedicineCostSelfTotal, _ = decimal.NewFromFloat(chineseMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  7098. // chineseMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(chineseMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  7099. // chinese_medicine_fulamt_ownpay_amt, _ = decimal.NewFromFloat(chinese_medicine_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  7100. // if item.ChrgitmLv == "1" {
  7101. // chinese_medicine_claa_sunmfee, _ = decimal.NewFromFloat(chinese_medicine_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  7102. // }
  7103. // if item.ChrgitmLv == "2" {
  7104. // chinese_medicine_clab_amt, _ = decimal.NewFromFloat(chinese_medicine_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  7105. // }
  7106. // if item.ChrgitmLv == "3" {
  7107. // chinese_medicine_other_amt, _ = decimal.NewFromFloat(chinese_medicine_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  7108. // }
  7109. // }
  7110. //
  7111. // if item.MedChrgitmType == "11" { //中成费
  7112. // chineseTraditionalMedicineCostTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  7113. // chineseTraditionalMedicineCostSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  7114. // chineseTraditionalMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  7115. // chineseTraditional_fulamt_ownpay_amt, _ = decimal.NewFromFloat(chineseTraditional_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  7116. // if item.ChrgitmLv == "1" {
  7117. //
  7118. // chineseTraditional_claa_sunmfee, _ = decimal.NewFromFloat(chineseTraditional_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  7119. //
  7120. // }
  7121. // if item.ChrgitmLv == "2" {
  7122. // chineseTraditional_clab_amt, _ = decimal.NewFromFloat(chineseTraditional_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  7123. //
  7124. // }
  7125. // if item.ChrgitmLv == "3" {
  7126. // chineseTraditional_other_amt, _ = decimal.NewFromFloat(chineseTraditional_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  7127. // }
  7128. // }
  7129. //
  7130. // if item.MedChrgitmType == "12" { //中成费
  7131. // commonlyTreatmentCostTotal, _ = decimal.NewFromFloat(commonlyTreatmentCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  7132. // commonlyTreatmentCostSelfTotal, _ = decimal.NewFromFloat(commonlyTreatmentCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  7133. // commonlyTreatmentCostPartSelfTotal, _ = decimal.NewFromFloat(commonlyTreatmentCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  7134. // commonly_treatment_fulamt_ownpay_amt, _ = decimal.NewFromFloat(commonly_treatment_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  7135. // if item.ChrgitmLv == "1" {
  7136. //
  7137. // commonly_treatment_claa_sunmfee, _ = decimal.NewFromFloat(commonly_treatment_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  7138. //
  7139. // }
  7140. // if item.ChrgitmLv == "2" {
  7141. // commonly_treatment_clab_amt, _ = decimal.NewFromFloat(commonly_treatment_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  7142. //
  7143. // }
  7144. // if item.ChrgitmLv == "3" {
  7145. // commonly_treatment_other_amt, _ = decimal.NewFromFloat(commonly_treatment_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  7146. // }
  7147. // }
  7148. //
  7149. // if item.MedChrgitmType == "13" { //中成费
  7150. // registerCostTotal, _ = decimal.NewFromFloat(registerCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  7151. // registerCostSelfTotal, _ = decimal.NewFromFloat(registerCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  7152. // registerPartSelfTotal, _ = decimal.NewFromFloat(registerPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  7153. // register_fulamt_ownpay_amt, _ = decimal.NewFromFloat(register_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  7154. // if item.ChrgitmLv == "1" {
  7155. //
  7156. // register_claa_sunmfee, _ = decimal.NewFromFloat(register_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  7157. //
  7158. // }
  7159. // if item.ChrgitmLv == "2" {
  7160. // register_clab_amt, _ = decimal.NewFromFloat(register_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  7161. //
  7162. // }
  7163. // if item.ChrgitmLv == "3" {
  7164. // register_other_amt, _ = decimal.NewFromFloat(register_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  7165. // }
  7166. // }
  7167. //
  7168. // if item.MedChrgitmType == "14" { //其他费
  7169. // otherCostTotal, _ = decimal.NewFromFloat(otherCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  7170. // otherCostSelfTotal, _ = decimal.NewFromFloat(otherCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  7171. // otherCostPartSelfTotal, _ = decimal.NewFromFloat(otherCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  7172. // other_fulamt_ownpay_amt, _ = decimal.NewFromFloat(other_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  7173. // if item.ChrgitmLv == "1" {
  7174. // other_claa_sunmfee, _ = decimal.NewFromFloat(other_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  7175. //
  7176. // }
  7177. // if item.ChrgitmLv == "2" {
  7178. // other_clab_amt, _ = decimal.NewFromFloat(other_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  7179. //
  7180. // }
  7181. // if item.ChrgitmLv == "3" {
  7182. // other_other_amt, _ = decimal.NewFromFloat(other_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  7183. // }
  7184. // }
  7185. //
  7186. // }
  7187. //
  7188. // var iteminfoStructs []service.IteminfoStruct
  7189. //
  7190. // if bedCostTotal != 0 {
  7191. // iteminfo.MedChrgitm = "01"
  7192. // iteminfo.FulamtOwnpayAmt = bed_fulamt_ownpay_amt
  7193. // iteminfo.Amt = bedCostTotal
  7194. // iteminfo.ClaaSumfee = bed_claa_sunmfee
  7195. // iteminfo.ClabAmt = bed_clab_amt
  7196. // iteminfo.OthAmt = bed_other_amt
  7197. // iteminfoStructs = append(iteminfoStructs, iteminfo)
  7198. // }
  7199. //
  7200. // if examineCostTotal != 0 {
  7201. // iteminfo.MedChrgitm = "02"
  7202. // iteminfo.FulamtOwnpayAmt = examine_fulamt_ownpay_amt
  7203. // iteminfo.Amt = examineCostTotal
  7204. // iteminfo.ClaaSumfee = examine_claa_sunmfee
  7205. // iteminfo.ClabAmt = examine_clab_amt
  7206. // iteminfo.OthAmt = examine_other_amt
  7207. // //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  7208. // iteminfoStructs = append(iteminfoStructs, iteminfo)
  7209. // }
  7210. //
  7211. // if checkCostTotal != 0 {
  7212. // iteminfo.MedChrgitm = "03"
  7213. // iteminfo.FulamtOwnpayAmt = check_fulamt_ownpay_amt
  7214. // iteminfo.Amt = checkCostTotal
  7215. // iteminfo.ClaaSumfee = check_claa_sunmfee
  7216. // iteminfo.ClabAmt = check_clab_amt
  7217. // iteminfo.OthAmt = check_other_amt
  7218. // iteminfoStructs = append(iteminfoStructs, iteminfo)
  7219. //
  7220. // }
  7221. //
  7222. // if laboratoryCostTotal != 0 {
  7223. // iteminfo.MedChrgitm = "04"
  7224. // iteminfo.FulamtOwnpayAmt = laboratory_fulamt_ownpay_amt
  7225. // iteminfo.Amt = laboratoryCostTotal
  7226. // iteminfo.ClaaSumfee = laboratory_claa_sunmfee
  7227. // iteminfo.ClabAmt = laboratory_clab_amt
  7228. // iteminfo.OthAmt = laboratory_other_amt
  7229. // iteminfoStructs = append(iteminfoStructs, iteminfo)
  7230. //
  7231. // //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  7232. //
  7233. // }
  7234. //
  7235. // if treatCostTotal != 0 {
  7236. // iteminfo.MedChrgitm = "05"
  7237. // iteminfo.FulamtOwnpayAmt = treat_fulamt_ownpay_amt
  7238. // iteminfo.Amt = treatCostTotal
  7239. // iteminfo.ClaaSumfee = treat_claa_sunmfee
  7240. // iteminfo.ClabAmt = treat_clab_amt
  7241. // iteminfo.OthAmt = treat_other_amt
  7242. // iteminfoStructs = append(iteminfoStructs, iteminfo)
  7243. // //(struct4101.IteminfoStruct, iteminfo)
  7244. // //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  7245. // }
  7246. //
  7247. // if operationCostTotal != 0 {
  7248. // iteminfo.MedChrgitm = "06"
  7249. // iteminfo.FulamtOwnpayAmt = bed_fulamt_ownpay_amt
  7250. // iteminfo.Amt = operationCostTotal
  7251. // iteminfo.ClaaSumfee = operation_claa_sunmfee
  7252. // iteminfo.ClabAmt = operation_clab_amt
  7253. // iteminfo.OthAmt = operation_other_amt
  7254. // //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  7255. // iteminfoStructs = append(iteminfoStructs, iteminfo)
  7256. // }
  7257. //
  7258. // if nursingCostTotal != 0 {
  7259. // iteminfo.MedChrgitm = "07"
  7260. // iteminfo.FulamtOwnpayAmt = nursing_fulamt_ownpay_amt
  7261. // iteminfo.Amt = nursingCostTotal
  7262. // iteminfo.ClaaSumfee = nursing_claa_sunmfee
  7263. // iteminfo.ClabAmt = nursing_clab_amt
  7264. // iteminfo.OthAmt = nursing_other_amt
  7265. // iteminfoStructs = append(iteminfoStructs, iteminfo)
  7266. // }
  7267. //
  7268. // if materialCostTotal != 0 {
  7269. // iteminfo.MedChrgitm = "08"
  7270. // iteminfo.FulamtOwnpayAmt = material_fulamt_ownpay_amt
  7271. // iteminfo.Amt = materialCostTotal
  7272. // iteminfo.ClaaSumfee = material_claa_sunmfee
  7273. // iteminfo.ClabAmt = material_clab_amt
  7274. // iteminfo.OthAmt = material_other_amt
  7275. // //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  7276. // iteminfoStructs = append(iteminfoStructs, iteminfo)
  7277. // }
  7278. //
  7279. // if westernMedicineCostTotal != 0 {
  7280. // iteminfo.MedChrgitm = "09"
  7281. // iteminfo.FulamtOwnpayAmt = westernMedicine_fulamt_ownpay_amt
  7282. // iteminfo.Amt = westernMedicineCostTotal
  7283. // iteminfo.ClaaSumfee = westernMedicine_claa_sunmfee
  7284. // iteminfo.ClabAmt = westernMedicine_clab_amt
  7285. // iteminfo.OthAmt = westernMedicine_other_amt
  7286. // //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  7287. // iteminfoStructs = append(iteminfoStructs, iteminfo)
  7288. //
  7289. // }
  7290. //
  7291. // if chineseMedicineCostTotal != 0 {
  7292. // iteminfo.MedChrgitm = "10"
  7293. // iteminfo.FulamtOwnpayAmt = chinese_medicine_fulamt_ownpay_amt
  7294. // iteminfo.Amt = chineseMedicineCostTotal
  7295. // iteminfo.ClaaSumfee = chinese_medicine_claa_sunmfee
  7296. // iteminfo.ClabAmt = chinese_medicine_clab_amt
  7297. // iteminfo.OthAmt = chinese_medicine_other_amt
  7298. // //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  7299. // iteminfoStructs = append(iteminfoStructs, iteminfo)
  7300. //
  7301. // }
  7302. //
  7303. // if chineseTraditionalMedicineCostTotal != 0 {
  7304. // iteminfo.MedChrgitm = "11"
  7305. // iteminfo.FulamtOwnpayAmt = westernMedicine_fulamt_ownpay_amt
  7306. // iteminfo.Amt = westernMedicineCostTotal
  7307. // iteminfo.ClaaSumfee = westernMedicine_claa_sunmfee
  7308. // iteminfo.ClabAmt = westernMedicine_clab_amt
  7309. // iteminfo.OthAmt = westernMedicine_other_amt
  7310. // //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  7311. // iteminfoStructs = append(iteminfoStructs, iteminfo)
  7312. //
  7313. // }
  7314. //
  7315. // if commonlyTreatmentCostTotal != 0 {
  7316. // iteminfo.MedChrgitm = "12"
  7317. // iteminfo.FulamtOwnpayAmt = commonly_treatment_fulamt_ownpay_amt
  7318. // iteminfo.Amt = commonlyTreatmentCostTotal
  7319. // iteminfo.ClaaSumfee = commonly_treatment_claa_sunmfee
  7320. // iteminfo.ClabAmt = commonly_treatment_clab_amt
  7321. // iteminfo.OthAmt = commonly_treatment_other_amt
  7322. // //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  7323. // iteminfoStructs = append(iteminfoStructs, iteminfo)
  7324. //
  7325. // }
  7326. //
  7327. // if registerCostTotal != 0 {
  7328. // iteminfo.MedChrgitm = "13"
  7329. // iteminfo.FulamtOwnpayAmt = register_fulamt_ownpay_amt
  7330. // iteminfo.Amt = registerCostTotal
  7331. // iteminfo.ClaaSumfee = register_claa_sunmfee
  7332. // iteminfo.ClabAmt = register_clab_amt
  7333. // iteminfo.OthAmt = register_other_amt
  7334. // //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  7335. // iteminfoStructs = append(iteminfoStructs, iteminfo)
  7336. //
  7337. // }
  7338. //
  7339. // if otherCostTotal != 0 {
  7340. // iteminfo.MedChrgitm = "14"
  7341. // iteminfo.FulamtOwnpayAmt = other_fulamt_ownpay_amt
  7342. // iteminfo.Amt = otherCostTotal
  7343. // iteminfo.ClaaSumfee = other_claa_sunmfee
  7344. // iteminfo.ClabAmt = other_clab_amt
  7345. // iteminfo.OthAmt = other_other_amt
  7346. // //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  7347. // iteminfoStructs = append(iteminfoStructs, iteminfo)
  7348. //
  7349. // }
  7350. // struct4101.IteminfoStruct = iteminfoStructs
  7351. // time_arr := strings.Split(order.SetlTime, " ")
  7352. // struct4101.AdmTime = time_arr[0]
  7353. // struct4101.AdmEndTime = time_arr[0]
  7354. //
  7355. // struct4101.DoctorName = doctor.UserName
  7356. // struct4101.DoctorCode = doctor.DoctorNumber
  7357. //
  7358. // struct4101.Ntly = "中国"
  7359. // struct4101.AdmCaty = "A03.06"
  7360. // var res ResultSeventeen
  7361. // if miConfig.MdtrtareaAdmvs == "421300" {
  7362. // data := make(map[string]interface{})
  7363. // data["struct4101"] = struct4101
  7364. // data["secret_key"] = miConfig.SecretKey
  7365. // data["org_name"] = miConfig.OrgName
  7366. // data["opera"] = curRoles.UserName
  7367. // data["code"] = miConfig.Code
  7368. // data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  7369. // data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  7370. //
  7371. // client := &http.Client{}
  7372. // bytesData, _ := json.Marshal(data)
  7373. // req, _ := http.NewRequest("POST", "http://192.168.124.4:9532/"+"hbyb/4101", bytes.NewReader(bytesData))
  7374. // resp, _ := client.Do(req)
  7375. // defer resp.Body.Close()
  7376. // body, ioErr := ioutil.ReadAll(resp.Body)
  7377. // if ioErr != nil {
  7378. // utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  7379. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7380. // return
  7381. // }
  7382. // var respJSON map[string]interface{}
  7383. // if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  7384. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  7385. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7386. // return
  7387. // }
  7388. //
  7389. // respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  7390. // userJSONBytes, _ := json.Marshal(respJSON)
  7391. // if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  7392. // utils.ErrorLog("解析失败:%v", err)
  7393. // //c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7394. // adminUser := c.GetAdminUserInfo()
  7395. // errlog := &models.HisOrderError{
  7396. // UserOrgId: adminUser.CurrentOrgId,
  7397. // Ctime: time.Now().Unix(),
  7398. // Mtime: time.Now().Unix(),
  7399. // ErrMsg: res.ErrMsg + "解析失败",
  7400. // Status: 1,
  7401. // PatientId: order_id,
  7402. // Stage: 10088,
  7403. // }
  7404. // service.CreateErrMsgLog(errlog)
  7405. // continue
  7406. // }
  7407. //
  7408. // } else {
  7409. // result := service.Gdyb4101(struct4101, miConfig.SecretKey, miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, c.GetAdminUserInfo().CurrentOrgId)
  7410. // fmt.Println(result)
  7411. //
  7412. // var dat map[string]interface{}
  7413. // if err := json.Unmarshal([]byte(result), &dat); err == nil {
  7414. // fmt.Println(dat)
  7415. // } else {
  7416. // fmt.Println(err)
  7417. // }
  7418. // userJSONBytes, _ := json.Marshal(dat)
  7419. // if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  7420. // utils.ErrorLog("解析失败:%v", err)
  7421. // //c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7422. // adminUser := c.GetAdminUserInfo()
  7423. // errlog := &models.HisOrderError{
  7424. // UserOrgId: adminUser.CurrentOrgId,
  7425. // Ctime: time.Now().Unix(),
  7426. // Mtime: time.Now().Unix(),
  7427. // ErrMsg: res.ErrMsg + "解析失败",
  7428. // Status: 1,
  7429. // PatientId: order_id,
  7430. // Stage: 10106,
  7431. // }
  7432. // service.CreateErrMsgLog(errlog)
  7433. // continue
  7434. // }
  7435. // }
  7436. //
  7437. // if res.Infcode != 0 {
  7438. // adminUser := c.GetAdminUserInfo()
  7439. // errlog := &models.HisOrderError{
  7440. // UserOrgId: adminUser.CurrentOrgId,
  7441. // Ctime: time.Now().Unix(),
  7442. // Mtime: time.Now().Unix(),
  7443. // ErrMsg: res.ErrMsg,
  7444. // Status: 1,
  7445. // PatientId: order_id,
  7446. // Stage: 10106,
  7447. // }
  7448. // service.CreateErrMsgLog(errlog)
  7449. // continue
  7450. // } else {
  7451. // hisFundSettleListResult := &models.HisFundSettleListResult{
  7452. // Number: res.Output.SetlListId,
  7453. // Status: 1,
  7454. // Ctime: time.Now().Unix(),
  7455. // Mtime: time.Now().Unix(),
  7456. // UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  7457. // IsUpload: 1,
  7458. // OrderId: order_id,
  7459. // }
  7460. // service.CreateUploadRecord(hisFundSettleListResult)
  7461. // continue
  7462. // }
  7463. // }
  7464. //}
  7465. func (c *HisApiController) GetOrgInfo() {
  7466. miConfig, _ := service.FindMedicalInsuranceInfo(4)
  7467. service.Gdyb1201("", miConfig.OrgName, "1122", miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, 1, "")
  7468. }
  7469. func (c *HisApiController) GetHisPatientInfo() {
  7470. medical_insurance_card := c.GetString("medical_insurance_card")
  7471. id_card_type, _ := c.GetInt64("id_card_type")
  7472. id_card := c.GetString("id_card")
  7473. adminInfo := c.GetAdminUserInfo()
  7474. config, _ := service.GetMedicalInsuranceConfig(adminInfo.CurrentOrgId)
  7475. miConfig, _ := service.FindMedicalInsuranceInfo(adminInfo.CurrentOrgId)
  7476. appRole, _ := service.GetAppRole(adminInfo.CurrentOrgId)
  7477. IdCardNo := ""
  7478. if id_card_type == 1 {
  7479. IdCardNo = medical_insurance_card
  7480. } else if id_card_type == 2 {
  7481. IdCardNo = id_card
  7482. }
  7483. if config.IsOpen == 1 {
  7484. 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
  7485. resp, requestErr := http.Get(api)
  7486. if requestErr != nil {
  7487. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7488. return
  7489. }
  7490. defer resp.Body.Close()
  7491. body, ioErr := ioutil.ReadAll(resp.Body)
  7492. if ioErr != nil {
  7493. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  7494. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7495. return
  7496. }
  7497. var respJSON map[string]interface{}
  7498. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  7499. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  7500. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7501. return
  7502. }
  7503. userJSON := respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  7504. userJSONBytes, _ := json.Marshal(userJSON)
  7505. var res ResultTwo
  7506. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  7507. utils.ErrorLog("解析失败:%v", err)
  7508. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7509. return
  7510. }
  7511. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  7512. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  7513. infoStr := string(Iinfos)
  7514. idetinfoStr := string(Idetinfos)
  7515. if res.Infcode == 0 {
  7516. his := models.VMHisPatient{
  7517. Status: 1,
  7518. Ctime: time.Now().Unix(),
  7519. Mtime: time.Now().Unix(),
  7520. PsnNo: res.Output.Baseinfo.PsnNo,
  7521. PsnCertType: res.Output.Baseinfo.PsnCertType,
  7522. Certno: res.Output.Baseinfo.Certno,
  7523. PsnName: res.Output.Baseinfo.PsnName,
  7524. Gend: res.Output.Baseinfo.Gend,
  7525. Naty: res.Output.Baseinfo.Naty,
  7526. Brdy: res.Output.Baseinfo.Brdy,
  7527. Age: res.Output.Baseinfo.Age,
  7528. Iinfo: infoStr,
  7529. Idetinfo: idetinfoStr,
  7530. UserOrgId: adminInfo.CurrentOrgId,
  7531. IsReturn: 1,
  7532. IdCardType: id_card_type,
  7533. }
  7534. c.ServeSuccessJSON(map[string]interface{}{
  7535. "info": his,
  7536. })
  7537. } else {
  7538. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  7539. return
  7540. }
  7541. }
  7542. }
  7543. //func GetBasBaseInfo() (jsonStr string, err error) {
  7544. //
  7545. // handle := syscall.NewLazyDLL("SSCard.dll")
  7546. // add := handle.NewProc("ReadCardBas")
  7547. // str := make([]byte, 1024)
  7548. // str1 := make([]byte, 1024)
  7549. // ret, _, _ := add.Call((uintptr)(unsafe.Pointer(&str[0])), IntPtr(1024), (uintptr)(unsafe.Pointer(&str1[0])), IntPtr(1024))
  7550. // fmt.Println(ConvertToString(string(str), "gbk", "utf-8"))
  7551. //
  7552. // fmt.Println(ConvertToString(string(str1), "gbk", "utf-8"))
  7553. //
  7554. // fmt.Println("> Add(4,5)的结果为:", ret)
  7555. // handle.Release()
  7556. //
  7557. // return "", nil
  7558. //
  7559. //}
  7560. //func GetQRBaseInfo() (jsonStr string, err error) {
  7561. // handle := syscall.LoadDLL("SSCard.dll")
  7562. // ReadCardBas := handle.FindProc("GetQRBase")
  7563. //
  7564. // str := make([]byte, 256)
  7565. // str1 := make([]byte, 256)
  7566. // r, _, _ := ReadCardBas.Call((uintptr)(unsafe.Pointer(&str[0])), IntPtr(1024), (uintptr)(unsafe.Pointer(&str1[0])), IntPtr(1024))
  7567. //
  7568. // fmt.Println(string(str))
  7569. // fmt.Println(r)
  7570. // return string(str), nil
  7571. //}
  7572. //func CardInit() int {
  7573. // DllTestDef := syscall.MustLoadDLL("SSCard.dll")
  7574. // add := DllTestDef.MustFindProc("Init")
  7575. // ret, _, err := add.Call(StrPtr("http://igb.hsa.gdgov.cn/gdyb_inf/poc/api/card/initDll"), StrPtr("440200"))
  7576. // if err != nil {
  7577. // fmt.Println("SSCard的运算结果为:", ret)
  7578. // }
  7579. // result := int(ret)
  7580. // return result
  7581. //}
  7582. //func CardInit() int {
  7583. // ret, _, err := add.Call(StrPtr("http://igb.hsa.gdgov.cn/gdyb_inf/poc/api/card/initDll"), StrPtr("440200"))
  7584. // if err != nil {
  7585. // fmt.Println("SSCard的运算结果为:", ret)
  7586. // }
  7587. // fmt.Println(err)
  7588. // result := int(ret)
  7589. // return result
  7590. //}
  7591. func IntPtr(n int) uintptr {
  7592. return uintptr(n)
  7593. }
  7594. func StrPtr(s string) uintptr {
  7595. return uintptr(unsafe.Pointer(syscall.StringBytePtr(s)))
  7596. }
  7597. type Result2001 struct {
  7598. Cainfo interface{} `json:"cainfo"`
  7599. ErrMsg string `json:"err_msg"`
  7600. InfRefmsgid string `json:"inf_refmsgid"`
  7601. Infcode int64 `json:"infcode"`
  7602. Output struct {
  7603. Trtinfo struct {
  7604. PsnNo string `json:"psn_no"`
  7605. TrtChkType string `json:"trt_chk_type"`
  7606. FundPayType string `json:"fund_pay_type"`
  7607. TrtEnjymntFlag string `json:"trt_enjymnt_flag"`
  7608. Begndate string `json:"begndate"`
  7609. Enddate string `json:"enddate"`
  7610. TrtChkRslt string `json:"trt_chk_rslt"`
  7611. } `json:"trtinfo"`
  7612. } `json:"output"`
  7613. RefmsgTime string `json:"refmsg_time"`
  7614. RespondTime string `json:"respond_time"`
  7615. Signtype interface{} `json:"signtype"`
  7616. WarnMsg interface{} `json:"warn_msg"`
  7617. }
  7618. type Result2001Org10265 struct {
  7619. Cainfo interface{} `json:"cainfo"`
  7620. ErrMsg string `json:"err_msg"`
  7621. InfRefmsgid string `json:"inf_refmsgid"`
  7622. Infcode string `json:"infcode"`
  7623. Output struct {
  7624. Trtinfo struct {
  7625. PsnNo string `json:"psn_no"`
  7626. TrtChkType string `json:"trt_chk_type"`
  7627. FundPayType string `json:"fund_pay_type"`
  7628. TrtEnjymntFlag string `json:"trt_enjymnt_flag"`
  7629. Begndate string `json:"begndate"`
  7630. Enddate string `json:"enddate"`
  7631. TrtChkRslt string `json:"trt_chk_rslt"`
  7632. } `json:"trtinfo"`
  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 ResultTwo struct {
  7640. ErrMsg string `json:"err_msg"`
  7641. InfRefmsgid string `json:"inf_refmsgid"`
  7642. Infcode int64 `json:"infcode"`
  7643. Output struct {
  7644. Baseinfo struct {
  7645. Age float64 `json:"age"`
  7646. Brdy string `json:"brdy"`
  7647. Certno string `json:"certno"`
  7648. Gend string `json:"gend"`
  7649. Naty string `json:"naty"`
  7650. PsnCertType string `json:"psn_cert_type"`
  7651. PsnName string `json:"psn_name"`
  7652. PsnNo string `json:"psn_no"`
  7653. } `json:"baseinfo"`
  7654. Idetinfo []interface{} `json:"idetinfo"`
  7655. Iinfo []struct {
  7656. Balc float64 `json:"balc"`
  7657. CvlservFlag string `json:"cvlserv_flag"`
  7658. EmpName string `json:"emp_name"`
  7659. InsuplcAdmdvs string `json:"insuplc_admdvs"`
  7660. Insutype string `json:"insutype"`
  7661. PausInsuDansuplcAdmdvs string `json:"paus_insu_dansuplc_admdvs"`
  7662. PausInsuDate string `json:"paus_insu_date"`
  7663. PsnInsuDate string `json:"psn_insu_date"`
  7664. PsnInsuStas string `json:"psn_insu_stas"`
  7665. PsnType string `json:"psn_type"`
  7666. } `json:"insuinfo"`
  7667. } `json:"output"`
  7668. RefmsgTime string `json:"refmsg_time"`
  7669. RespondTime string `json:"respond_time"`
  7670. Signtype interface{} `json:"signtype"`
  7671. WarnInfo interface{} `json:"warn_info"`
  7672. }
  7673. type ResultTwo10265 struct {
  7674. ErrMsg string `json:"err_msg"`
  7675. InfRefmsgid string `json:"inf_refmsgid"`
  7676. Infcode string `json:"infcode"`
  7677. Output struct {
  7678. Baseinfo struct {
  7679. Age float64 `json:"age"`
  7680. Brdy string `json:"brdy"`
  7681. Certno string `json:"certno"`
  7682. Gend string `json:"gend"`
  7683. Naty string `json:"naty"`
  7684. PsnCertType string `json:"psn_cert_type"`
  7685. PsnName string `json:"psn_name"`
  7686. PsnNo string `json:"psn_no"`
  7687. } `json:"baseinfo"`
  7688. Idetinfo []interface{} `json:"idetinfo"`
  7689. Iinfo []struct {
  7690. Balc float64 `json:"balc"`
  7691. CvlservFlag string `json:"cvlserv_flag"`
  7692. EmpName string `json:"emp_name"`
  7693. InsuplcAdmdvs string `json:"insuplc_admdvs"`
  7694. Insutype string `json:"insutype"`
  7695. PausInsuDansuplcAdmdvs string `json:"paus_insu_dansuplc_admdvs"`
  7696. PausInsuDate string `json:"paus_insu_date"`
  7697. PsnInsuDate string `json:"psn_insu_date"`
  7698. PsnInsuStas string `json:"psn_insu_stas"`
  7699. PsnType string `json:"psn_type"`
  7700. } `json:"insuinfo"`
  7701. } `json:"output"`
  7702. RefmsgTime string `json:"refmsg_time"`
  7703. RespondTime string `json:"respond_time"`
  7704. Signtype interface{} `json:"signtype"`
  7705. WarnInfo interface{} `json:"warn_info"`
  7706. }
  7707. type ResultThree struct {
  7708. Cainfo interface{} `json:"cainfo"`
  7709. ErrMsg string `json:"err_msg"`
  7710. InfRefmsgid string `json:"inf_refmsgid"`
  7711. Infcode int64 `json:"infcode"`
  7712. Output struct {
  7713. Data struct {
  7714. IptOtpNo string `json:"ipt_otp_no"`
  7715. MdtrtID string `json:"mdtrt_id"`
  7716. PsnNo string `json:"psn_no"`
  7717. } `json:"data"`
  7718. } `json:"output"`
  7719. RefmsgTime string `json:"refmsg_time"`
  7720. RespondTime string `json:"respond_time"`
  7721. Signtype interface{} `json:"signtype"`
  7722. WarnMsg interface{} `json:"warn_msg"`
  7723. }
  7724. type ResultThree10265 struct {
  7725. Cainfo interface{} `json:"cainfo"`
  7726. ErrMsg string `json:"err_msg"`
  7727. InfRefmsgid string `json:"inf_refmsgid"`
  7728. Infcode string `json:"infcode"`
  7729. Output struct {
  7730. Data struct {
  7731. IptOtpNo string `json:"ipt_otp_no"`
  7732. MdtrtID string `json:"mdtrt_id"`
  7733. PsnNo string `json:"psn_no"`
  7734. } `json:"data"`
  7735. } `json:"output"`
  7736. RefmsgTime string `json:"refmsg_time"`
  7737. RespondTime string `json:"respond_time"`
  7738. Signtype interface{} `json:"signtype"`
  7739. WarnMsg interface{} `json:"warn_msg"`
  7740. }
  7741. type ResultFour struct {
  7742. Cainfo string `json:"cainfo"`
  7743. ErrMsg string `json:"err_msg"`
  7744. InfRefmsgid string `json:"inf_refmsgid"`
  7745. Infcode int64 `json:"infcode"`
  7746. Output struct {
  7747. Result []struct {
  7748. BasMednFlag string `json:"bas_medn_flag"`
  7749. ChldMedcFlag string `json:"chld_medc_flag"`
  7750. ChrgitmLv string `json:"chrgitm_lv"`
  7751. Cnt float64 `json:"cnt"`
  7752. DetItemFeeSumamt float64 `json:"det_item_fee_sumamt"`
  7753. DrtReimFlag string `json:"drt_reim_flag"`
  7754. FeedetlSn string `json:"feedetl_sn"`
  7755. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  7756. HiNegoDrugFlag string `json:"hi_nego_drug_flag"`
  7757. InscpScpAmt float64 `json:"inscp_scp_amt"`
  7758. ListSpItemFlag string `json:"list_sp_item_flag"`
  7759. LmtUsedFlag string `json:"lmt_used_flag"`
  7760. MedChrgitmType string `json:"med_chrgitm_type"`
  7761. Memo string `json:"memo"`
  7762. OverlmtAmt float64 `json:"overlmt_amt"`
  7763. PreselfpayAmt float64 `json:"preselfpay_amt"`
  7764. Pric float64 `json:"pric"`
  7765. PricUplmtAmt float64 `json:"pric_uplmt_amt"`
  7766. SelfpayProp float64 `json:"selfpay_prop"`
  7767. } `json:"result"`
  7768. } `json:"output"`
  7769. RefmsgTime string `json:"refmsg_time"`
  7770. RespondTime string `json:"respond_time"`
  7771. Signtype string `json:"signtype"`
  7772. WarnMsg string `json:"warn_msg"`
  7773. }
  7774. type ResultFour10265 struct {
  7775. Cainfo string `json:"cainfo"`
  7776. ErrMsg string `json:"err_msg"`
  7777. InfRefmsgid string `json:"inf_refmsgid"`
  7778. Infcode string `json:"infcode"`
  7779. Output struct {
  7780. Result []struct {
  7781. BasMednFlag string `json:"bas_medn_flag"`
  7782. ChldMedcFlag string `json:"chld_medc_flag"`
  7783. ChrgitmLv string `json:"chrgitm_lv"`
  7784. Cnt float64 `json:"cnt"`
  7785. DetItemFeeSumamt float64 `json:"det_item_fee_sumamt"`
  7786. DrtReimFlag string `json:"drt_reim_flag"`
  7787. FeedetlSn string `json:"feedetl_sn"`
  7788. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  7789. HiNegoDrugFlag string `json:"hi_nego_drug_flag"`
  7790. InscpScpAmt float64 `json:"inscp_scp_amt"`
  7791. ListSpItemFlag string `json:"list_sp_item_flag"`
  7792. LmtUsedFlag string `json:"lmt_used_flag"`
  7793. MedChrgitmType string `json:"med_chrgitm_type"`
  7794. Memo string `json:"memo"`
  7795. OverlmtAmt float64 `json:"overlmt_amt"`
  7796. PreselfpayAmt float64 `json:"preselfpay_amt"`
  7797. Pric float64 `json:"pric"`
  7798. PricUplmtAmt float64 `json:"pric_uplmt_amt"`
  7799. SelfpayProp float64 `json:"selfpay_prop"`
  7800. } `json:"result"`
  7801. } `json:"output"`
  7802. RefmsgTime string `json:"refmsg_time"`
  7803. RespondTime string `json:"respond_time"`
  7804. Signtype string `json:"signtype"`
  7805. WarnMsg string `json:"warn_msg"`
  7806. }
  7807. type ResultMemo struct {
  7808. InsuAdmdvs string `json:"insuAdmdvs"`
  7809. }
  7810. // [{"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}]
  7811. type ResultIDInfo struct {
  7812. Begntime string `json:"begntime"`
  7813. Endtime string `json:"endtime"`
  7814. Memo string `json:"memo"`
  7815. }
  7816. type ResultFive struct {
  7817. Balc float64 `json:"balc"`
  7818. CvlservFlag string `json:"cvlserv_flag"`
  7819. EmpName string `json:"emp_name"`
  7820. InsuplcAdmdvs string `json:"insuplc_admdvs"`
  7821. Insutype string `json:"insutype"`
  7822. PausInsuDansuplcAdmdvs string `json:"paus_insu_dansuplc_admdvs"`
  7823. PausInsuDate string `json:"paus_insu_date"`
  7824. PsnInsuDate string `json:"psn_insu_date"`
  7825. PsnInsuStas string `json:"psn_insu_stas"`
  7826. PsnType string `json:"psn_type"`
  7827. }
  7828. type ResultSix struct {
  7829. Cainfo interface{} `json:"cainfo"`
  7830. ErrMsg string `json:"err_msg"`
  7831. InfRefmsgid string `json:"inf_refmsgid"`
  7832. Infcode int64 `json:"infcode"`
  7833. Output struct {
  7834. } `json:"output"`
  7835. RefmsgTime string `json:"refmsg_time"`
  7836. RespondTime string `json:"respond_time"`
  7837. Signtype interface{} `json:"signtype"`
  7838. WarnMsg interface{} `json:"warn_msg"`
  7839. }
  7840. type ResultSix10265 struct {
  7841. Cainfo interface{} `json:"cainfo"`
  7842. ErrMsg string `json:"err_msg"`
  7843. InfRefmsgid string `json:"inf_refmsgid"`
  7844. Infcode string `json:"infcode"`
  7845. Output struct {
  7846. } `json:"output"`
  7847. RefmsgTime string `json:"refmsg_time"`
  7848. RespondTime string `json:"respond_time"`
  7849. Signtype interface{} `json:"signtype"`
  7850. WarnMsg interface{} `json:"warn_msg"`
  7851. }
  7852. type ResultSeven struct {
  7853. Cainfo string `json:"cainfo"`
  7854. ErrMsg string `json:"err_msg"`
  7855. InfRefmsgid string `json:"inf_refmsgid"`
  7856. Infcode int64 `json:"infcode"`
  7857. Output struct {
  7858. Setldetail []interface{} `json:"setldetail"`
  7859. Setlinfo struct {
  7860. AcctMulaidPay float64 `json:"acct_mulaid_pay"`
  7861. AcctPay float64 `json:"acct_pay"`
  7862. ActPayDedc float64 `json:"act_pay_dedc"`
  7863. Age float64 `json:"age"`
  7864. Balc float64 `json:"balc"`
  7865. Brdy string `json:"brdy"`
  7866. Certno string `json:"certno"`
  7867. ClrOptins string `json:"clr_optins"`
  7868. ClrType string `json:"clr_type"`
  7869. ClrWay string `json:"clr_way"`
  7870. CvlservFlag string `json:"cvlserv_flag"`
  7871. CvlservPay float64 `json:"cvlserv_pay"`
  7872. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  7873. FundPaySumamt float64 `json:"fund_pay_sumamt"`
  7874. Gend string `json:"gend"`
  7875. HifesPay float64 `json:"hifes_pay"`
  7876. HifmiPay float64 `json:"hifmi_pay"`
  7877. HifpPay float64 `json:"hifp_pay"`
  7878. HospPartAmt float64 `json:"hosp_part_amt"`
  7879. InscpScpAmt float64 `json:"inscp_scp_amt"`
  7880. Insutype string `json:"insutype"`
  7881. MafPay float64 `json:"maf_pay"`
  7882. MdtrtCertType string `json:"mdtrt_cert_type"`
  7883. HifobPay float64 `json:"hifob_pay"`
  7884. MdtrtID string `json:"mdtrt_id"`
  7885. MedType string `json:"med_type"`
  7886. MedfeeSumamt float64 `json:"medfee_sumamt"`
  7887. MedinsSetlID string `json:"medins_setl_id"`
  7888. Naty string `json:"naty"`
  7889. OthPay float64 `json:"oth_pay"`
  7890. OverlmtSelfpay float64 `json:"overlmt_selfpay"`
  7891. PoolPropSelfpay float64 `json:"pool_prop_selfpay"`
  7892. PreselfpayAmt float64 `json:"preselfpay_amt"`
  7893. PsnCashPay float64 `json:"psn_cash_pay"`
  7894. PsnCertType string `json:"psn_cert_type"`
  7895. PsnName string `json:"psn_name"`
  7896. PsnNo string `json:"psn_no"`
  7897. PsnPartAmt float64 `json:"psn_part_amt"`
  7898. PsnType string `json:"psn_type"`
  7899. SetlID string `json:"setl_id"`
  7900. SetlTime string `json:"setl_time"`
  7901. } `json:"setlinfo"`
  7902. } `json:"output"`
  7903. RefmsgTime string `json:"refmsg_time"`
  7904. RespondTime string `json:"respond_time"`
  7905. Signtype interface{} `json:"signtype"`
  7906. WarnMsg interface{} `json:"warn_msg"`
  7907. }
  7908. type ResultSeven10265 struct {
  7909. Cainfo string `json:"cainfo"`
  7910. ErrMsg string `json:"err_msg"`
  7911. InfRefmsgid string `json:"inf_refmsgid"`
  7912. Infcode string `json:"infcode"`
  7913. Output struct {
  7914. Setldetail []interface{} `json:"setldetail"`
  7915. Setlinfo struct {
  7916. AcctMulaidPay float64 `json:"acct_mulaid_pay"`
  7917. AcctPay float64 `json:"acct_pay"`
  7918. ActPayDedc float64 `json:"act_pay_dedc"`
  7919. Age float64 `json:"age"`
  7920. Balc float64 `json:"balc"`
  7921. Brdy string `json:"brdy"`
  7922. Certno string `json:"certno"`
  7923. ClrOptins string `json:"clr_optins"`
  7924. ClrType string `json:"clr_type"`
  7925. ClrWay string `json:"clr_way"`
  7926. CvlservFlag string `json:"cvlserv_flag"`
  7927. CvlservPay float64 `json:"cvlserv_pay"`
  7928. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  7929. FundPaySumamt float64 `json:"fund_pay_sumamt"`
  7930. Gend string `json:"gend"`
  7931. HifesPay float64 `json:"hifes_pay"`
  7932. HifmiPay float64 `json:"hifmi_pay"`
  7933. HifpPay float64 `json:"hifp_pay"`
  7934. HospPartAmt float64 `json:"hosp_part_amt"`
  7935. InscpScpAmt float64 `json:"inscp_scp_amt"`
  7936. Insutype string `json:"insutype"`
  7937. MafPay float64 `json:"maf_pay"`
  7938. MdtrtCertType string `json:"mdtrt_cert_type"`
  7939. HifobPay float64 `json:"hifob_pay"`
  7940. MdtrtID string `json:"mdtrt_id"`
  7941. MedType string `json:"med_type"`
  7942. MedfeeSumamt float64 `json:"medfee_sumamt"`
  7943. MedinsSetlID string `json:"medins_setl_id"`
  7944. Naty string `json:"naty"`
  7945. OthPay float64 `json:"oth_pay"`
  7946. OverlmtSelfpay float64 `json:"overlmt_selfpay"`
  7947. PoolPropSelfpay float64 `json:"pool_prop_selfpay"`
  7948. PreselfpayAmt float64 `json:"preselfpay_amt"`
  7949. PsnCashPay float64 `json:"psn_cash_pay"`
  7950. PsnCertType string `json:"psn_cert_type"`
  7951. PsnName string `json:"psn_name"`
  7952. PsnNo string `json:"psn_no"`
  7953. PsnPartAmt float64 `json:"psn_part_amt"`
  7954. PsnType string `json:"psn_type"`
  7955. SetlID string `json:"setl_id"`
  7956. SetlTime string `json:"setl_time"`
  7957. } `json:"setlinfo"`
  7958. } `json:"output"`
  7959. RefmsgTime string `json:"refmsg_time"`
  7960. RespondTime string `json:"respond_time"`
  7961. Signtype interface{} `json:"signtype"`
  7962. WarnMsg interface{} `json:"warn_msg"`
  7963. }
  7964. type ResultEight struct {
  7965. Cainfo string `json:"cainfo"`
  7966. ErrMsg string `json:"err_msg"`
  7967. InfRefmsgid string `json:"inf_refmsgid"`
  7968. Infcode int64 `json:"infcode"`
  7969. Output struct {
  7970. Stmtinfo struct {
  7971. SetlOptins string `json:"setl_optins"`
  7972. StmtRslt string `json:"stmt_rslt"`
  7973. StmtRsltDscr string `json:"stmt_rslt_dscr"`
  7974. } `json:"stmtinfo"`
  7975. } `json:"output"`
  7976. RefmsgTime string `json:"refmsg_time"`
  7977. RespondTime string `json:"respond_time"`
  7978. Signtype interface{} `json:"signtype"`
  7979. WarnMsg interface{} `json:"warn_msg"`
  7980. }
  7981. type ResultEightFor10188 struct {
  7982. Cainfo string `json:"cainfo"`
  7983. ErrMsg string `json:"err_msg"`
  7984. InfRefmsgid string `json:"inf_refmsgid"`
  7985. Infcode string `json:"infcode"`
  7986. Output struct {
  7987. Stmtinfo struct {
  7988. SetlOptins string `json:"setl_optins"`
  7989. StmtRslt string `json:"stmt_rslt"`
  7990. StmtRsltDscr string `json:"stmt_rslt_dscr"`
  7991. } `json:"stmtinfo"`
  7992. } `json:"output"`
  7993. RefmsgTime string `json:"refmsg_time"`
  7994. RespondTime string `json:"respond_time"`
  7995. Signtype interface{} `json:"signtype"`
  7996. WarnMsg interface{} `json:"warn_msg"`
  7997. }
  7998. type ResultNine struct {
  7999. Cainfo string `json:"cainfo"`
  8000. ErrMsg string `json:"err_msg"`
  8001. InfRefmsgid string `json:"inf_refmsgid"`
  8002. Infcode int64 `json:"infcode"`
  8003. Output struct {
  8004. FileQuryNo string `json:"file_qury_no"`
  8005. } `json:"output"`
  8006. RefmsgTime string `json:"refmsg_time"`
  8007. RespondTime string `json:"respond_time"`
  8008. Signtype interface{} `json:"signtype"`
  8009. WarnMsg interface{} `json:"warn_msg"`
  8010. }
  8011. type ResultTen struct {
  8012. Cainfo string `json:"cainfo"`
  8013. ErrMsg string `json:"err_msg"`
  8014. InfRefmsgid string `json:"inf_refmsgid"`
  8015. Infcode int64 `json:"infcode"`
  8016. Output struct {
  8017. DldEndtime string `json:"dld_endtime"`
  8018. FileQuryNo string `json:"file_qury_no"`
  8019. Filename string `json:"filename"`
  8020. } `json:"output"`
  8021. RefmsgTime string `json:"refmsg_time"`
  8022. RespondTime string `json:"respond_time"`
  8023. Signtype interface{} `json:"signtype"`
  8024. WarnMsg interface{} `json:"warn_msg"`
  8025. }
  8026. //type Autogenerated struct {
  8027. // Output struct {
  8028. // Setlinfo struct {
  8029. // SetlTime string `json:"setl_time"`
  8030. // CvlservPay float64 `json:"cvlserv_pay"`
  8031. // Year string `json:"year"`
  8032. // MedType string `json:"med_type"`
  8033. // PsnPay float64 `json:"psn_pay"`
  8034. // OpterID string `json:"opter_id"`
  8035. // Begndate string `json:"begndate"`
  8036. // FlxempeFlag string `json:"flxempe_flag"`
  8037. // HifmiPay float64 `json:"hifmi_pay"`
  8038. // PsnNo string `json:"psn_no"`
  8039. // ActPayDedc float64 `json:"act_pay_dedc"`
  8040. // MedinsSetlID interface{} `json:"medins_setl_id"`
  8041. // AcctMulaidPay interface{} `json:"acct_mulaid_pay"`
  8042. // ClrWay string `json:"clr_way"`
  8043. // OthPay float64 `json:"oth_pay"`
  8044. // Gend string `json:"gend"`
  8045. // MdtrtID string `json:"mdtrt_id"`
  8046. // AcctPay float64 `json:"acct_pay"`
  8047. // InscpScpAmt float64 `json:"inscp_scp_amt"`
  8048. // Insutype string `json:"insutype"`
  8049. // Invono interface{} `json:"invono"`
  8050. // Enddate string `json:"enddate"`
  8051. // CashPayamt float64 `json:"cash_payamt"`
  8052. // PsnType string `json:"psn_type"`
  8053. // FixmedinsName string `json:"fixmedins_name"`
  8054. // HifpPay float64 `json:"hifp_pay"`
  8055. // NewFlag interface{} `json:"new_flag"`
  8056. // OverlmtSelfpay float64 `json:"overlmt_selfpay"`
  8057. // PreselfpayAmt float64 `json:"preselfpay_amt"`
  8058. // PayLoc string `json:"pay_loc"`
  8059. // ClrType string `json:"clr_type"`
  8060. // RefdSetlFlag string `json:"refd_setl_flag"`
  8061. // CvlservFlag string `json:"cvlserv_flag"`
  8062. // EmpName string `json:"emp_name"`
  8063. // Brdy string `json:"brdy"`
  8064. // Naty string `json:"naty"`
  8065. // Certno string `json:"certno"`
  8066. // DiseCode string `json:"dise_code"`
  8067. // FixmedinsCode string `json:"fixmedins_code"`
  8068. // DedcHospLv string `json:"dedc_hosp_lv"`
  8069. // OpterName string `json:"opter_name"`
  8070. // Balc float64 `json:"balc"`
  8071. // FixmedinsPoolarea string `json:"fixmedins_poolarea"`
  8072. // PsnCertType string `json:"psn_cert_type"`
  8073. // HifobPay float64 `json:"hifob_pay"`
  8074. // MedfeeSumamt float64 `json:"medfee_sumamt"`
  8075. // HifesPay float64 `json:"hifes_pay"`
  8076. // FundPaySumamt float64 `json:"fund_pay_sumamt"`
  8077. // OptTime string `json:"opt_time"`
  8078. // FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  8079. // SetlID string `json:"setl_id"`
  8080. // MafPay float64 `json:"maf_pay"`
  8081. // PsnName string `json:"psn_name"`
  8082. // InsuOptins interface{} `json:"insu_optins"`
  8083. // PrefFundPay interface{} `json:"pref_fund_pay"`
  8084. // ClrOptins string `json:"clr_optins"`
  8085. // PoolPropSelfpay float64 `json:"pool_prop_selfpay"`
  8086. // DiseName string `json:"dise_name"`
  8087. // LmtpricHospLv string `json:"lmtpric_hosp_lv"`
  8088. // Age float64 `json:"age"`
  8089. // DtrtCertType string `json:"dtrt_cert_type"`
  8090. // HospLv string `json:"hosp_lv"`
  8091. // } `json:"setlinfo"`
  8092. // Setldetail []struct {
  8093. // FundPayType string `json:"fund_pay_type"`
  8094. // FundPayamt float64 `json:"fund_payamt"`
  8095. // SetlProcInfo interface{} `json:"setl_proc_info"`
  8096. // CrtPaybLmtAmt interface{} `json:"crt_payb_lmt_amt"`
  8097. // InscpScpAmt interface{} `json:"inscp_scp_amt"`
  8098. // FundPayTypeName interface{} `json:"fund_pay_type_name"`
  8099. // PrefFundPay interface{} `json:"pref_fund_pay"`
  8100. // } `json:"setldetail"`
  8101. // } `json:"output"`
  8102. // Infcode int `json:"infcode"`
  8103. // WarnMsg interface{} `json:"warn_msg"`
  8104. // Cainfo interface{} `json:"cainfo"`
  8105. // ErrMsg interface{} `json:"err_msg"`
  8106. // RefmsgTime string `json:"refmsg_time"`
  8107. // Signtype interface{} `json:"signtype"`
  8108. // RespondTime string `json:"respond_time"`
  8109. // InfRefmsgid string `json:"inf_refmsgid"`
  8110. //}
  8111. type ResultEleven struct {
  8112. Cainfo string `json:"cainfo"`
  8113. ErrMsg string `json:"err_msg"`
  8114. InfRefmsgid string `json:"inf_refmsgid"`
  8115. Infcode int64 `json:"infcode"`
  8116. Output struct {
  8117. Setlinfo struct {
  8118. SetlTime string `json:"setl_time"`
  8119. CvlservPay float64 `json:"cvlserv_pay"`
  8120. Year string `json:"year"`
  8121. MedType string `json:"med_type"`
  8122. PsnPay float64 `json:"psn_pay"`
  8123. OpterID string `json:"opter_id"`
  8124. Begndate string `json:"begndate"`
  8125. FlxempeFlag string `json:"flxempe_flag"`
  8126. HifmiPay float64 `json:"hifmi_pay"`
  8127. PsnNo string `json:"psn_no"`
  8128. ActPayDedc float64 `json:"act_pay_dedc"`
  8129. MedinsSetlID interface{} `json:"medins_setl_id"`
  8130. AcctMulaidPay interface{} `json:"acct_mulaid_pay"`
  8131. ClrWay string `json:"clr_way"`
  8132. OthPay float64 `json:"oth_pay"`
  8133. Gend string `json:"gend"`
  8134. MdtrtID string `json:"mdtrt_id"`
  8135. AcctPay float64 `json:"acct_pay"`
  8136. InscpScpAmt float64 `json:"inscp_scp_amt"`
  8137. Insutype string `json:"insutype"`
  8138. Invono interface{} `json:"invono"`
  8139. Enddate string `json:"enddate"`
  8140. CashPayamt float64 `json:"cash_payamt"`
  8141. PsnType string `json:"psn_type"`
  8142. FixmedinsName string `json:"fixmedins_name"`
  8143. HifpPay float64 `json:"hifp_pay"`
  8144. NewFlag interface{} `json:"new_flag"`
  8145. OverlmtSelfpay float64 `json:"overlmt_selfpay"`
  8146. PreselfpayAmt float64 `json:"preselfpay_amt"`
  8147. PayLoc string `json:"pay_loc"`
  8148. ClrType string `json:"clr_type"`
  8149. RefdSetlFlag string `json:"refd_setl_flag"`
  8150. CvlservFlag string `json:"cvlserv_flag"`
  8151. EmpName string `json:"emp_name"`
  8152. Brdy string `json:"brdy"`
  8153. Naty string `json:"naty"`
  8154. Certno string `json:"certno"`
  8155. DiseCode string `json:"dise_code"`
  8156. FixmedinsCode string `json:"fixmedins_code"`
  8157. DedcHospLv string `json:"dedc_hosp_lv"`
  8158. OpterName string `json:"opter_name"`
  8159. Balc float64 `json:"balc"`
  8160. FixmedinsPoolarea string `json:"fixmedins_poolarea"`
  8161. PsnCertType string `json:"psn_cert_type"`
  8162. HifobPay float64 `json:"hifob_pay"`
  8163. MedfeeSumamt float64 `json:"medfee_sumamt"`
  8164. HifesPay float64 `json:"hifes_pay"`
  8165. FundPaySumamt float64 `json:"fund_pay_sumamt"`
  8166. OptTime string `json:"opt_time"`
  8167. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  8168. SetlID string `json:"setl_id"`
  8169. MafPay float64 `json:"maf_pay"`
  8170. PsnName string `json:"psn_name"`
  8171. InsuOptins interface{} `json:"insu_optins"`
  8172. PrefFundPay interface{} `json:"pref_fund_pay"`
  8173. ClrOptins string `json:"clr_optins"`
  8174. PoolPropSelfpay float64 `json:"pool_prop_selfpay"`
  8175. DiseName string `json:"dise_name"`
  8176. LmtpricHospLv string `json:"lmtpric_hosp_lv"`
  8177. Age float64 `json:"age"`
  8178. DtrtCertType string `json:"dtrt_cert_type"`
  8179. HospLv string `json:"hosp_lv"`
  8180. PsnCashPay float64
  8181. } `json:"setlinfo"`
  8182. } `json:"output"`
  8183. RefmsgTime string `json:"refmsg_time"`
  8184. RespondTime string `json:"respond_time"`
  8185. Signtype interface{} `json:"signtype"`
  8186. WarnMsg interface{} `json:"warn_msg"`
  8187. }
  8188. type ResultEleven10265 struct {
  8189. Cainfo string `json:"cainfo"`
  8190. ErrMsg string `json:"err_msg"`
  8191. InfRefmsgid string `json:"inf_refmsgid"`
  8192. Infcode string `json:"infcode"`
  8193. Output struct {
  8194. Setlinfo struct {
  8195. SetlTime string `json:"setl_time"`
  8196. CvlservPay float64 `json:"cvlserv_pay"`
  8197. Year string `json:"year"`
  8198. MedType string `json:"med_type"`
  8199. PsnPay float64 `json:"psn_pay"`
  8200. OpterID string `json:"opter_id"`
  8201. Begndate string `json:"begndate"`
  8202. FlxempeFlag string `json:"flxempe_flag"`
  8203. HifmiPay float64 `json:"hifmi_pay"`
  8204. PsnNo string `json:"psn_no"`
  8205. ActPayDedc float64 `json:"act_pay_dedc"`
  8206. MedinsSetlID interface{} `json:"medins_setl_id"`
  8207. AcctMulaidPay interface{} `json:"acct_mulaid_pay"`
  8208. ClrWay string `json:"clr_way"`
  8209. OthPay float64 `json:"oth_pay"`
  8210. Gend string `json:"gend"`
  8211. MdtrtID string `json:"mdtrt_id"`
  8212. AcctPay float64 `json:"acct_pay"`
  8213. InscpScpAmt float64 `json:"inscp_scp_amt"`
  8214. Insutype string `json:"insutype"`
  8215. Invono interface{} `json:"invono"`
  8216. Enddate string `json:"enddate"`
  8217. CashPayamt float64 `json:"cash_payamt"`
  8218. PsnType string `json:"psn_type"`
  8219. FixmedinsName string `json:"fixmedins_name"`
  8220. HifpPay float64 `json:"hifp_pay"`
  8221. NewFlag interface{} `json:"new_flag"`
  8222. OverlmtSelfpay float64 `json:"overlmt_selfpay"`
  8223. PreselfpayAmt float64 `json:"preselfpay_amt"`
  8224. PayLoc string `json:"pay_loc"`
  8225. ClrType string `json:"clr_type"`
  8226. RefdSetlFlag string `json:"refd_setl_flag"`
  8227. CvlservFlag string `json:"cvlserv_flag"`
  8228. EmpName string `json:"emp_name"`
  8229. Brdy string `json:"brdy"`
  8230. Naty string `json:"naty"`
  8231. Certno string `json:"certno"`
  8232. DiseCode string `json:"dise_code"`
  8233. FixmedinsCode string `json:"fixmedins_code"`
  8234. DedcHospLv string `json:"dedc_hosp_lv"`
  8235. OpterName string `json:"opter_name"`
  8236. Balc float64 `json:"balc"`
  8237. FixmedinsPoolarea string `json:"fixmedins_poolarea"`
  8238. PsnCertType string `json:"psn_cert_type"`
  8239. HifobPay float64 `json:"hifob_pay"`
  8240. MedfeeSumamt float64 `json:"medfee_sumamt"`
  8241. HifesPay float64 `json:"hifes_pay"`
  8242. FundPaySumamt float64 `json:"fund_pay_sumamt"`
  8243. OptTime string `json:"opt_time"`
  8244. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  8245. SetlID string `json:"setl_id"`
  8246. MafPay float64 `json:"maf_pay"`
  8247. PsnName string `json:"psn_name"`
  8248. InsuOptins interface{} `json:"insu_optins"`
  8249. PrefFundPay interface{} `json:"pref_fund_pay"`
  8250. ClrOptins string `json:"clr_optins"`
  8251. PoolPropSelfpay float64 `json:"pool_prop_selfpay"`
  8252. DiseName string `json:"dise_name"`
  8253. LmtpricHospLv string `json:"lmtpric_hosp_lv"`
  8254. Age float64 `json:"age"`
  8255. DtrtCertType string `json:"dtrt_cert_type"`
  8256. HospLv string `json:"hosp_lv"`
  8257. PsnCashPay float64
  8258. } `json:"setlinfo"`
  8259. } `json:"output"`
  8260. RefmsgTime string `json:"refmsg_time"`
  8261. RespondTime string `json:"respond_time"`
  8262. Signtype interface{} `json:"signtype"`
  8263. WarnMsg interface{} `json:"warn_msg"`
  8264. }
  8265. type ResultTwelve struct {
  8266. Cainfo string `json:"cainfo"`
  8267. ErrMsg string `json:"err_msg"`
  8268. InfRefmsgid string `json:"inf_refmsgid"`
  8269. Infcode int64 `json:"infcode"`
  8270. Output struct {
  8271. MdtrtId string `json:"mdtrt_id"`
  8272. ChrgBchno string `json:"chrg_bchno"`
  8273. PsnNo string `json:"psn_no"`
  8274. } `json:"output"`
  8275. RefmsgTime string `json:"refmsg_time"`
  8276. RespondTime string `json:"respond_time"`
  8277. Signtype interface{} `json:"signtype"`
  8278. WarnMsg interface{} `json:"warn_msg"`
  8279. }
  8280. type ResultThirteen struct {
  8281. ErrMsg string `json:"err_msg"`
  8282. InfRefmsgid string `json:"inf_refmsgid"`
  8283. Infcode int64 `json:"infcode"`
  8284. Output struct {
  8285. Result struct {
  8286. TrtDclaDetlSn string `json:"trt_dcla_detl_sn"`
  8287. } `json:"result"`
  8288. } `json:"output"`
  8289. RefmsgTime string `json:"refmsg_time"`
  8290. RespondTime string `json:"respond_time"`
  8291. Signtype interface{} `json:"signtype"`
  8292. WarnInfo interface{} `json:"warn_info"`
  8293. }
  8294. type ResultThirteen10265 struct {
  8295. ErrMsg string `json:"err_msg"`
  8296. InfRefmsgid string `json:"inf_refmsgid"`
  8297. Infcode string `json:"infcode"`
  8298. Output struct {
  8299. Result struct {
  8300. TrtDclaDetlSn string `json:"trt_dcla_detl_sn"`
  8301. } `json:"result"`
  8302. } `json:"output"`
  8303. RefmsgTime string `json:"refmsg_time"`
  8304. RespondTime string `json:"respond_time"`
  8305. Signtype interface{} `json:"signtype"`
  8306. WarnInfo interface{} `json:"warn_info"`
  8307. }
  8308. type ResultFourteen struct {
  8309. ErrMsg string `json:"err_msg"`
  8310. InfRefmsgid string `json:"inf_refmsgid"`
  8311. Infcode int64 `json:"infcode"`
  8312. Output struct {
  8313. } `json:"output"`
  8314. RefmsgTime string `json:"refmsg_time"`
  8315. RespondTime string `json:"respond_time"`
  8316. Signtype interface{} `json:"signtype"`
  8317. WarnInfo interface{} `json:"warn_info"`
  8318. }
  8319. type ResultFourteen10265 struct {
  8320. ErrMsg string `json:"err_msg"`
  8321. InfRefmsgid string `json:"inf_refmsgid"`
  8322. Infcode string `json:"infcode"`
  8323. Output struct {
  8324. } `json:"output"`
  8325. RefmsgTime string `json:"refmsg_time"`
  8326. RespondTime string `json:"respond_time"`
  8327. Signtype interface{} `json:"signtype"`
  8328. WarnInfo interface{} `json:"warn_info"`
  8329. }
  8330. type ResultSixteen struct {
  8331. Cainfo string `json:"cainfo"`
  8332. ErrMsg string `json:"err_msg"`
  8333. InfRefmsgid string `json:"inf_refmsgid"`
  8334. Infcode int64 `json:"infcode"`
  8335. Output struct {
  8336. Setldetail []interface{} `json:"setldetail"`
  8337. Setlinfo struct {
  8338. MdtrtID string `json:"mdtrt_id"`
  8339. SetlID string `json:"setl_id"`
  8340. ClrOptins string `json:"clr_optins"`
  8341. SetlTime string `json:"setl_time"`
  8342. MedfeeSumamt float64 `json:"medfee_sumamt"`
  8343. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  8344. OverlmtSelfpay float64 `json:"overlmt_selfpay"`
  8345. PreselfpayAmt float64 `json:"preselfpay_amt"`
  8346. InscpScpAmt float64 `json:"inscp_scp_amt"`
  8347. ActPayDedc float64 `json:"act_pay_dedc"`
  8348. HifpPay float64 `json:"hifp_pay"`
  8349. PoolPropSe float64 `json:"pool_prop_selfpay"`
  8350. Lfpay float64 `json:"selfpay"`
  8351. CvlservPay float64 `json:"cvlserv_pay"`
  8352. HifesPay float64 `json:"hifes_pay"`
  8353. HifmiPay float64 `json:"hifmi_pay"`
  8354. HifobPay float64 `json:"hifob_pay"`
  8355. MafPay float64 `json:"maf_pay"`
  8356. OthPay float64 `json:"oth_pay"`
  8357. FundPaySumamt float64 `json:"fund_pay_sumamt"`
  8358. PsnPartAmt float64 `json:"psn_part_amt"`
  8359. AcctPay float64 `json:"acct_pay"`
  8360. Balc float64 `json:"balc"`
  8361. AcctMulaidPay float64 `json:"acct_mulaid_pay"`
  8362. HospPartAmt float64 `json:"hosp_part_amt"`
  8363. MedinsSetlID string `json:"medins_setl_id"`
  8364. PdnCashPay string `json:"pdn_cash_pay"`
  8365. } `json:"setlinfo"`
  8366. } `json:"output"`
  8367. RefmsgTime string `json:"refmsg_time"`
  8368. RespondTime string `json:"respond_time"`
  8369. Signtype interface{} `json:"signtype"`
  8370. WarnMsg interface{} `json:"warn_msg"`
  8371. }
  8372. type ResultSixteen10265 struct {
  8373. Cainfo string `json:"cainfo"`
  8374. ErrMsg string `json:"err_msg"`
  8375. InfRefmsgid string `json:"inf_refmsgid"`
  8376. Infcode string `json:"infcode"`
  8377. Output struct {
  8378. Setldetail []interface{} `json:"setldetail"`
  8379. Setlinfo struct {
  8380. MdtrtID string `json:"mdtrt_id"`
  8381. SetlID string `json:"setl_id"`
  8382. ClrOptins string `json:"clr_optins"`
  8383. SetlTime string `json:"setl_time"`
  8384. MedfeeSumamt float64 `json:"medfee_sumamt"`
  8385. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  8386. OverlmtSelfpay float64 `json:"overlmt_selfpay"`
  8387. PreselfpayAmt float64 `json:"preselfpay_amt"`
  8388. InscpScpAmt float64 `json:"inscp_scp_amt"`
  8389. ActPayDedc float64 `json:"act_pay_dedc"`
  8390. HifpPay float64 `json:"hifp_pay"`
  8391. PoolPropSe float64 `json:"pool_prop_selfpay"`
  8392. Lfpay float64 `json:"selfpay"`
  8393. CvlservPay float64 `json:"cvlserv_pay"`
  8394. HifesPay float64 `json:"hifes_pay"`
  8395. HifmiPay float64 `json:"hifmi_pay"`
  8396. HifobPay float64 `json:"hifob_pay"`
  8397. MafPay float64 `json:"maf_pay"`
  8398. OthPay float64 `json:"oth_pay"`
  8399. FundPaySumamt float64 `json:"fund_pay_sumamt"`
  8400. PsnPartAmt float64 `json:"psn_part_amt"`
  8401. AcctPay float64 `json:"acct_pay"`
  8402. Balc float64 `json:"balc"`
  8403. AcctMulaidPay float64 `json:"acct_mulaid_pay"`
  8404. HospPartAmt float64 `json:"hosp_part_amt"`
  8405. MedinsSetlID string `json:"medins_setl_id"`
  8406. PdnCashPay string `json:"pdn_cash_pay"`
  8407. } `json:"setlinfo"`
  8408. } `json:"output"`
  8409. RefmsgTime string `json:"refmsg_time"`
  8410. RespondTime string `json:"respond_time"`
  8411. Signtype interface{} `json:"signtype"`
  8412. WarnMsg interface{} `json:"warn_msg"`
  8413. }
  8414. type ResultSeventeen struct {
  8415. ErrMsg string `json:"err_msg"`
  8416. InfRefmsgid string `json:"inf_refmsgid"`
  8417. Infcode int64 `json:"infcode"`
  8418. Output struct {
  8419. SetlListId string `json:"setl_list_id"`
  8420. } `json:"output"`
  8421. RefmsgTime string `json:"refmsg_time"`
  8422. RespondTime string `json:"respond_time"`
  8423. Signtype string `json:"signtype"`
  8424. WarnInfo string `json:"warn_info"`
  8425. }
  8426. type ResultSeventeenOther struct {
  8427. ErrMsg string `json:"err_msg"`
  8428. InfRefmsgid string `json:"inf_refmsgid"`
  8429. Infcode string `json:"infcode"`
  8430. Output struct {
  8431. SetlListId string `json:"setl_list_id"`
  8432. } `json:"output"`
  8433. RefmsgTime string `json:"refmsg_time"`
  8434. RespondTime string `json:"respond_time"`
  8435. Signtype string `json:"signtype"`
  8436. WarnInfo string `json:"warn_info"`
  8437. }
  8438. type Result90991 struct {
  8439. ErrMsg string `json:"err_msg"`
  8440. InfRefmsgid string `json:"inf_refmsgid"`
  8441. Infcode int64 `json:"infcode"`
  8442. Output struct {
  8443. Result struct {
  8444. PsnNo string `json:"psn_no"`
  8445. CardStat string `json:"card_stat"`
  8446. Certno string `json:"certno"`
  8447. PsnName string `json:"psn_name"`
  8448. CheckStat string `json:"check_stat"`
  8449. SscnoCheckStat string `json:"sscno_check_stat"`
  8450. } `json:"result"`
  8451. } `json:"output"`
  8452. RefmsgTime string `json:"refmsg_time"`
  8453. RespondTime string `json:"respond_time"`
  8454. Signtype interface{} `json:"signtype"`
  8455. WarnInfo interface{} `json:"warn_info"`
  8456. }
  8457. type Result90100 struct {
  8458. ErrMsg string `json:"err_msg"`
  8459. InfRefmsgid string `json:"inf_refmsgid"`
  8460. Infcode int64 `json:"infcode"`
  8461. Output struct {
  8462. PoolareaNo string `json:"poolarea_no"`
  8463. PoolareaNoName string `json:"poolarea_no_name"`
  8464. Insutype string `json:"insutype"`
  8465. InsutypeName string `json:"insutype_name"`
  8466. ClctType string `json:"clct_type"`
  8467. ClctTypeName string `json:"clct_type_name"`
  8468. ClctFlag string `json:"clct_flag"`
  8469. ClctFlagName string `json:"clct_flag_name"`
  8470. AccrymBegn string `json:"accrym_begn"`
  8471. AccrymEnd string `json:"accrym_end"`
  8472. ClctTime string `json:"clct_time"`
  8473. ClctstdCrtfRuleCodg string `json:"clctstd_crtf_rule_codg"`
  8474. } `json:"output"`
  8475. RefmsgTime string `json:"refmsg_time"`
  8476. RespondTime string `json:"respond_time"`
  8477. Signtype interface{} `json:"signtype"`
  8478. WarnInfo interface{} `json:"warn_info"`
  8479. }
  8480. type Custom struct {
  8481. DetItemFeeSumamt string
  8482. Cut string
  8483. FeedetlSn string
  8484. Price string
  8485. MedListCodg string
  8486. Type int64
  8487. AdviceId int64
  8488. ProjectId int64
  8489. ItemId int64
  8490. }
  8491. type Result5301 struct {
  8492. ErrMsg string `json:"err_msg"`
  8493. InfRefmsgid string `json:"inf_refmsgid"`
  8494. Infcode int64 `json:"infcode"`
  8495. Output struct {
  8496. Result []struct {
  8497. OpspDiseCode string `json:"opsp_dise_code"`
  8498. OpspDiseName string `json:"opsp_dise_name"`
  8499. Begndate string `json:"begndate"`
  8500. Enddate string `json:"enddate"`
  8501. } `json:"feedetail"`
  8502. } `json:"output"`
  8503. RefmsgTime string `json:"refmsg_time"`
  8504. RespondTime string `json:"respond_time"`
  8505. Signtype interface{} `json:"signtype"`
  8506. WarnInfo interface{} `json:"warn_info"`
  8507. }
  8508. type Result5301For10265 struct {
  8509. ErrMsg string `json:"err_msg"`
  8510. InfRefmsgid string `json:"inf_refmsgid"`
  8511. Infcode string `json:"infcode"`
  8512. Output struct {
  8513. Result []struct {
  8514. OpspDiseCode string `json:"opsp_dise_code"`
  8515. OpspDiseName string `json:"opsp_dise_name"`
  8516. Begndate string `json:"begndate"`
  8517. Enddate string `json:"enddate"`
  8518. } `json:"feedetail"`
  8519. } `json:"output"`
  8520. RefmsgTime string `json:"refmsg_time"`
  8521. RespondTime string `json:"respond_time"`
  8522. Signtype interface{} `json:"signtype"`
  8523. WarnInfo interface{} `json:"warn_info"`
  8524. }
  8525. //获取个人信息----挂号-----上传就诊信息
  8526. func (c *HisApiController) GetRegisterInfo() {
  8527. id, _ := c.GetInt64("id")
  8528. record_time := c.GetString("record_time")
  8529. settlementValue, _ := c.GetInt64("settlement_value")
  8530. medical_insurance_card := c.GetString("medical_insurance_card")
  8531. name := c.GetString("name")
  8532. id_card_type, _ := c.GetInt64("id_card_type")
  8533. certificates, _ := c.GetInt64("certificates")
  8534. medical_care, _ := c.GetInt64("medical_care")
  8535. birthday := c.GetString("birthday")
  8536. id_card := c.GetString("id_card")
  8537. register_type, _ := c.GetInt64("register")
  8538. doctor, _ := c.GetInt64("doctor")
  8539. department, _ := c.GetInt64("department")
  8540. gender, _ := c.GetInt64("sex")
  8541. registration_fee, _ := c.GetFloat("registration_fee")
  8542. medical_expenses, _ := c.GetFloat("medical_expenses")
  8543. social_type, _ := c.GetInt64("social_type")
  8544. admin_user_id, _ := c.GetInt64("admin_user_id")
  8545. insuplc_admdvs := c.GetString("insuplc_admdvs")
  8546. mdtrt_type := c.GetString("mdtrt_type")
  8547. timeLayout := "2006-01-02"
  8548. loc, _ := time.LoadLocation("Local")
  8549. birthdays, _ := time.ParseInLocation(timeLayout+" 15:04:05", birthday+" 00:00:00", loc)
  8550. birthUnix := birthdays.Unix()
  8551. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  8552. if err != nil {
  8553. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  8554. return
  8555. }
  8556. recordDateTime := theTime.Unix()
  8557. adminInfo := c.GetAdminUserInfo()
  8558. var patient service.Patients
  8559. if id == 0 {
  8560. patient, _ = service.GetPatientByIDCard(id_card, adminInfo.CurrentOrgId)
  8561. } else {
  8562. patient, _ = service.GetPatientByIDTwo(adminInfo.CurrentOrgId, id)
  8563. }
  8564. patientPrescription, _ := service.FindPatientPrescriptionInfo(adminInfo.CurrentOrgId, id, recordDateTime)
  8565. if patientPrescription.ID == 0 {
  8566. patientPrescription, _ = service.FindLastPatientPrescriptionInfo(adminInfo.CurrentOrgId, id, recordDateTime)
  8567. }
  8568. miConfig, _ := service.FindMedicalInsuranceInfo(adminInfo.CurrentOrgId)
  8569. if patient.ID == 0 {
  8570. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodePatientNoExist)
  8571. return
  8572. }
  8573. if len(patient.IdCardNo) == 0 {
  8574. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeIDCartNo)
  8575. return
  8576. }
  8577. config, _ := service.GetMedicalInsuranceConfig(adminInfo.CurrentOrgId)
  8578. roles, _ := service.GetAdminUserInfoByID(adminInfo.CurrentOrgId, admin_user_id)
  8579. doctor_info, _ := service.GetAdminUserInfoByID(adminInfo.CurrentOrgId, doctor)
  8580. //就诊结算未完成,不能进行二次挂号
  8581. his, _ := service.GetHisPatientInfoTwo(adminInfo.CurrentOrgId, patient.ID, recordDateTime)
  8582. if len(his) >= 1 {
  8583. order, _ := service.GetNewHisOrderTwo(adminInfo.CurrentOrgId, his[len(his)-1].Number, his[len(his)-1].PatientId, recordDateTime)
  8584. if len(his) >= 1 && order.ID == 0 {
  8585. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisPatientParamWrong)
  8586. return
  8587. }
  8588. }
  8589. //var register_log string
  8590. if config.IsOpen == 1 {
  8591. var res ResultTwo
  8592. var res10265 ResultTwo10265
  8593. var PsnNo string
  8594. var PsnCertType string
  8595. var Certno string
  8596. var PsnName string
  8597. var Gend string
  8598. var Naty string
  8599. var Brdy string
  8600. var Age float64
  8601. var infoStr string
  8602. var idetinfoStr string
  8603. var infocode int64
  8604. var verify_number string
  8605. fmt.Println(verify_number)
  8606. if miConfig.MdtrtareaAdmvs == "421300" {
  8607. psn_info, _ := service.GetPsnByPatientId(id)
  8608. PsnNo = psn_info.PsnNo
  8609. PsnCertType = psn_info.PsnCertType
  8610. Certno = psn_info.Certno
  8611. PsnName = psn_info.PsnName
  8612. Gend = psn_info.Gend
  8613. Naty = psn_info.Naty
  8614. Brdy = psn_info.Brdy
  8615. Age = psn_info.Age
  8616. infoStr = psn_info.Insuinfo
  8617. idetinfoStr = psn_info.Idetinfo
  8618. infocode = 0
  8619. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  8620. psn_info, _ := service.GetPsnByPatientId(id)
  8621. PsnNo = psn_info.PsnNo
  8622. PsnCertType = psn_info.PsnCertType
  8623. Certno = psn_info.Certno
  8624. PsnName = psn_info.PsnName
  8625. Gend = psn_info.Gend
  8626. Naty = psn_info.Naty
  8627. Brdy = psn_info.Brdy
  8628. Age = psn_info.Age
  8629. infoStr = psn_info.Insuinfo
  8630. idetinfoStr = psn_info.Idetinfo
  8631. infocode = 0
  8632. verify_number = psn_info.VerifyNumber
  8633. } else if miConfig.MdtrtareaAdmvs == "350500" {
  8634. if id_card_type == 1 {
  8635. psn_info, _ := service.GetPsnByPatientId(id)
  8636. PsnNo = psn_info.PsnNo
  8637. PsnCertType = psn_info.PsnCertType
  8638. Certno = psn_info.Certno
  8639. PsnName = psn_info.PsnName
  8640. Gend = psn_info.Gend
  8641. Naty = psn_info.Naty
  8642. Brdy = psn_info.Brdy
  8643. Age = psn_info.Age
  8644. infoStr = psn_info.Insuinfo
  8645. idetinfoStr = psn_info.Idetinfo
  8646. infocode = 0
  8647. verify_number = psn_info.VerifyNumber
  8648. } else if id_card_type == 2 {
  8649. 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)
  8650. fmt.Println(errMsgLog)
  8651. saveLog(result, requestLog, "1101", "人员基本信息获取")
  8652. if err := json.Unmarshal([]byte(result), &res); err != nil {
  8653. utils.ErrorLog("解析失败:%v", err)
  8654. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8655. return
  8656. }
  8657. PsnNo = res.Output.Baseinfo.PsnNo
  8658. PsnCertType = res.Output.Baseinfo.PsnCertType
  8659. Certno = res.Output.Baseinfo.Certno
  8660. PsnName = res.Output.Baseinfo.PsnName
  8661. Gend = res.Output.Baseinfo.Gend
  8662. Naty = res.Output.Baseinfo.Naty
  8663. Brdy = res.Output.Baseinfo.Brdy
  8664. Age = res.Output.Baseinfo.Age
  8665. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  8666. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  8667. infoStr = string(Iinfos)
  8668. idetinfoStr = string(Idetinfos)
  8669. infocode = res.Infcode
  8670. }
  8671. } else if miConfig.MdtrtareaAdmvs == "360399" {
  8672. if id_card_type == 1 {
  8673. psn_info, _ := service.GetPsnByPatientId(id)
  8674. PsnNo = psn_info.PsnNo
  8675. PsnCertType = psn_info.PsnCertType
  8676. Certno = psn_info.Certno
  8677. PsnName = psn_info.PsnName
  8678. Gend = psn_info.Gend
  8679. Naty = psn_info.Naty
  8680. Brdy = psn_info.Brdy
  8681. Age = psn_info.Age
  8682. infoStr = psn_info.Insuinfo
  8683. idetinfoStr = psn_info.Idetinfo
  8684. infocode = 0
  8685. verify_number = psn_info.VerifyNumber
  8686. } else if id_card_type == 2 {
  8687. 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, "")
  8688. saveLog(result, requestLog, "1101", "人员基本信息获取")
  8689. if err := json.Unmarshal([]byte(result), &res); err != nil {
  8690. utils.ErrorLog("解析失败:%v", err)
  8691. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8692. return
  8693. }
  8694. PsnNo = res.Output.Baseinfo.PsnNo
  8695. PsnCertType = res.Output.Baseinfo.PsnCertType
  8696. Certno = res.Output.Baseinfo.Certno
  8697. PsnName = res.Output.Baseinfo.PsnName
  8698. Gend = res.Output.Baseinfo.Gend
  8699. Naty = res.Output.Baseinfo.Naty
  8700. Brdy = res.Output.Baseinfo.Brdy
  8701. Age = res.Output.Baseinfo.Age
  8702. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  8703. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  8704. infoStr = string(Iinfos)
  8705. idetinfoStr = string(Idetinfos)
  8706. infocode = res.Infcode
  8707. }
  8708. } else if miConfig.MdtrtareaAdmvs == "430800" {
  8709. if id_card_type == 1 {
  8710. psn_info, _ := service.GetPsnByPatientId(id)
  8711. PsnNo = psn_info.PsnNo
  8712. PsnCertType = psn_info.PsnCertType
  8713. Certno = psn_info.Certno
  8714. PsnName = psn_info.PsnName
  8715. Gend = psn_info.Gend
  8716. Naty = psn_info.Naty
  8717. Brdy = psn_info.Brdy
  8718. Age = psn_info.Age
  8719. infoStr = psn_info.Insuinfo
  8720. idetinfoStr = psn_info.Idetinfo
  8721. infocode = 0
  8722. verify_number = psn_info.VerifyNumber
  8723. } else if id_card_type == 2 {
  8724. 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)
  8725. saveLog(result, requestLog, "1101", "人员基本信息获取")
  8726. if err := json.Unmarshal([]byte(result), &res); err != nil {
  8727. utils.ErrorLog("解析失败:%v", err)
  8728. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8729. return
  8730. }
  8731. PsnNo = res.Output.Baseinfo.PsnNo
  8732. PsnCertType = res.Output.Baseinfo.PsnCertType
  8733. Certno = res.Output.Baseinfo.Certno
  8734. PsnName = res.Output.Baseinfo.PsnName
  8735. Gend = res.Output.Baseinfo.Gend
  8736. Naty = res.Output.Baseinfo.Naty
  8737. Brdy = res.Output.Baseinfo.Brdy
  8738. Age = res.Output.Baseinfo.Age
  8739. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  8740. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  8741. infoStr = string(Iinfos)
  8742. idetinfoStr = string(Idetinfos)
  8743. infocode = res.Infcode
  8744. } else if id_card_type == 4 {
  8745. psn_info, _ := service.GetPsnByPatientId(id)
  8746. PsnNo = psn_info.PsnNo
  8747. PsnCertType = psn_info.PsnCertType
  8748. Certno = psn_info.Certno
  8749. PsnName = psn_info.PsnName
  8750. Gend = psn_info.Gend
  8751. Naty = psn_info.Naty
  8752. Brdy = psn_info.Brdy
  8753. Age = psn_info.Age
  8754. infoStr = psn_info.Insuinfo
  8755. idetinfoStr = psn_info.Idetinfo
  8756. infocode = 0
  8757. verify_number = psn_info.VerifyNumber
  8758. }
  8759. } else if miConfig.MdtrtareaAdmvs == "131023" {
  8760. var result string
  8761. var requestLog string
  8762. 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), "")
  8763. if id_card_type == 4 {
  8764. psn_info, _ := service.GetPsnByPatientId(id)
  8765. PsnNo = psn_info.PsnNo
  8766. PsnCertType = psn_info.PsnCertType
  8767. Certno = psn_info.Certno
  8768. PsnName = psn_info.PsnName
  8769. Gend = psn_info.Gend
  8770. Naty = psn_info.Naty
  8771. Brdy = psn_info.Brdy
  8772. Age = psn_info.Age
  8773. infoStr = psn_info.Insuinfo
  8774. idetinfoStr = psn_info.Idetinfo
  8775. infocode = 0
  8776. verify_number = psn_info.VerifyNumber
  8777. } else {
  8778. saveLog(result, requestLog, "1101", "人员基本信息获取")
  8779. if miConfig.Code == "H15049901371" {
  8780. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  8781. utils.ErrorLog("解析失败:%v", err)
  8782. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8783. return
  8784. }
  8785. res.ErrMsg = res10265.ErrMsg
  8786. res.Output = res10265.Output
  8787. res.InfRefmsgid = res10265.InfRefmsgid
  8788. } else {
  8789. if err := json.Unmarshal([]byte(result), &res); err != nil {
  8790. utils.ErrorLog("解析失败:%v", err)
  8791. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8792. return
  8793. }
  8794. }
  8795. PsnNo = res.Output.Baseinfo.PsnNo
  8796. PsnCertType = res.Output.Baseinfo.PsnCertType
  8797. Certno = res.Output.Baseinfo.Certno
  8798. PsnName = res.Output.Baseinfo.PsnName
  8799. Gend = res.Output.Baseinfo.Gend
  8800. Naty = res.Output.Baseinfo.Naty
  8801. Brdy = res.Output.Baseinfo.Brdy
  8802. Age = res.Output.Baseinfo.Age
  8803. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  8804. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  8805. infoStr = string(Iinfos)
  8806. idetinfoStr = string(Idetinfos)
  8807. if miConfig.Code == "H15049901371" {
  8808. infocode, _ = strconv.ParseInt(res10265.Infcode, 10, 64)
  8809. } else {
  8810. infocode = res.Infcode
  8811. }
  8812. }
  8813. } else {
  8814. var result string
  8815. var requestLog string
  8816. //if miConfig.UserOrgId == 10138 {
  8817. if id_card_type != 4 || id_card_type != 1 {
  8818. var insa string
  8819. if len(patient.InsuplcAdmdvs) > 0 {
  8820. insa = patient.InsuplcAdmdvs
  8821. } else {
  8822. insa = miConfig.InsuplcAdmdvs
  8823. }
  8824. //psn_info, _ := service.GetPsnByPatientId(id)
  8825. //result, requestLog = service.Gdyb1101ForEleCert(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, psn_info.VerifyNumber)
  8826. 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)
  8827. }
  8828. //}
  8829. //else {
  8830. // var insa string
  8831. // if len(patient.InsuplcAdmdvs) > 0 {
  8832. // insa = patient.InsuplcAdmdvs
  8833. // } else {
  8834. // insa = miConfig.InsuplcAdmdvs
  8835. // }
  8836. // 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)
  8837. //}
  8838. if id_card_type == 4 || id_card_type == 1 {
  8839. psn_info, _ := service.GetPsnByPatientId(id)
  8840. PsnNo = psn_info.PsnNo
  8841. PsnCertType = psn_info.PsnCertType
  8842. Certno = psn_info.Certno
  8843. PsnName = psn_info.PsnName
  8844. Gend = psn_info.Gend
  8845. Naty = psn_info.Naty
  8846. Brdy = psn_info.Brdy
  8847. Age = psn_info.Age
  8848. infoStr = psn_info.Insuinfo
  8849. idetinfoStr = psn_info.Idetinfo
  8850. infocode = 0
  8851. verify_number = psn_info.VerifyNumber
  8852. } else {
  8853. saveLog(result, requestLog, "1101", "人员基本信息获取")
  8854. if miConfig.Code == "H15049901371" {
  8855. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  8856. utils.ErrorLog("解析失败:%v", err)
  8857. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8858. return
  8859. }
  8860. res.ErrMsg = res10265.ErrMsg
  8861. res.Output = res10265.Output
  8862. res.InfRefmsgid = res10265.InfRefmsgid
  8863. } else {
  8864. if err := json.Unmarshal([]byte(result), &res); err != nil {
  8865. utils.ErrorLog("解析失败:%v", err)
  8866. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8867. return
  8868. }
  8869. }
  8870. PsnNo = res.Output.Baseinfo.PsnNo
  8871. PsnCertType = res.Output.Baseinfo.PsnCertType
  8872. Certno = res.Output.Baseinfo.Certno
  8873. PsnName = res.Output.Baseinfo.PsnName
  8874. Gend = res.Output.Baseinfo.Gend
  8875. Naty = res.Output.Baseinfo.Naty
  8876. Brdy = res.Output.Baseinfo.Brdy
  8877. Age = res.Output.Baseinfo.Age
  8878. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  8879. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  8880. infoStr = string(Iinfos)
  8881. idetinfoStr = string(Idetinfos)
  8882. if miConfig.Code == "H15049901371" {
  8883. infocode, _ = strconv.ParseInt(res10265.Infcode, 10, 64)
  8884. } else {
  8885. infocode = res.Infcode
  8886. }
  8887. }
  8888. }
  8889. if infocode == 0 {
  8890. his := models.VMHisPatient{
  8891. Name: name,
  8892. Gender: gender,
  8893. Birthday: birthUnix,
  8894. MedicalTreatmentType: medical_care,
  8895. IdType: certificates,
  8896. IdCardNo: id_card,
  8897. BalanceAccountsType: settlementValue,
  8898. SocialType: social_type,
  8899. MedicalInsuranceNumber: medical_insurance_card,
  8900. RegisterType: register_type,
  8901. RegisterCost: registration_fee,
  8902. TreatmentCost: medical_expenses,
  8903. Status: 1,
  8904. Ctime: time.Now().Unix(),
  8905. Mtime: time.Now().Unix(),
  8906. PsnNo: PsnNo,
  8907. PsnCertType: PsnCertType,
  8908. Certno: Certno,
  8909. PsnName: PsnName,
  8910. Gend: Gend,
  8911. Naty: Naty,
  8912. Brdy: Brdy,
  8913. Age: Age,
  8914. Iinfo: infoStr,
  8915. Idetinfo: idetinfoStr,
  8916. PatientId: patient.ID,
  8917. RecordDate: theTime.Unix(),
  8918. UserOrgId: adminInfo.CurrentOrgId,
  8919. AdminUserId: admin_user_id,
  8920. IsReturn: 1,
  8921. IdCardType: id_card_type,
  8922. Doctor: doctor,
  8923. Departments: department,
  8924. MdtrtGrpType: mdtrt_type,
  8925. }
  8926. timestamp := time.Now().Unix()
  8927. tempTime := time.Unix(timestamp, 0)
  8928. timeFormat := tempTime.Format("20060102150405")
  8929. chrgBchno := rand.Intn(100000) + 10000
  8930. ipt_otp_no := timeFormat + strconv.FormatInt(int64(chrgBchno), 10) + strconv.FormatInt(his.PatientId, 10)
  8931. his.Number = ipt_otp_no
  8932. //count, _ := service.FindHisRegisterRecord(theTime.Unix(), patient.ID, adminInfo.CurrentOrgId)
  8933. department, _ := service.GetDepartMentDetail(department)
  8934. //doctor_id := strconv.FormatInt(patientPrescription., 10)
  8935. IdCardNo := ""
  8936. if id_card_type == 1 {
  8937. // IdCardNo = medical_insurance_card
  8938. IdCardNo = patient.IdCardNo
  8939. } else {
  8940. IdCardNo = patient.IdCardNo
  8941. }
  8942. var rf []*ResultFive
  8943. json.Unmarshal([]byte(his.Iinfo), &rf)
  8944. var insutypes []*ResultFive
  8945. var insutype string
  8946. var insuplc_admdvs_temp string
  8947. var is390 int = 0
  8948. var is310 int = 0
  8949. for _, item := range rf {
  8950. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  8951. insutypes = append(insutypes, item)
  8952. }
  8953. }
  8954. if len(insutypes) == 1 {
  8955. insutype = insutypes[0].Insutype
  8956. insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  8957. } else {
  8958. for _, i := range insutypes {
  8959. if i.Insutype == "390" {
  8960. is390 = 1
  8961. }
  8962. if i.Insutype == "310" {
  8963. is310 = 1
  8964. }
  8965. }
  8966. }
  8967. if is390 == 1 {
  8968. insutype = "390"
  8969. }
  8970. if is310 == 1 {
  8971. insutype = "310"
  8972. }
  8973. fmt.Println(social_type)
  8974. if social_type > 0 {
  8975. insutype = strconv.FormatInt(social_type, 10)
  8976. }
  8977. var infocode int64
  8978. var resThree ResultThree
  8979. var resThree10265 ResultThree10265
  8980. if len(insuplc_admdvs) == 0 {
  8981. insuplc_admdvs_temp = miConfig.InsuplcAdmdvs
  8982. } else {
  8983. insuplc_admdvs_temp = insuplc_admdvs
  8984. }
  8985. if miConfig.MdtrtareaAdmvs == "421300" {
  8986. hb_doctor_info, _ := service.GetAdminUserInfoByID(adminInfo.CurrentOrgId, patientPrescription.DoctorId)
  8987. api := "http://192.168.124.4:9532/" + "hbyb/2201?psn_no=" + PsnNo + "&insutype=" + insutype + "&cert_no=" + Certno + "&ipt_otp_no=" + ipt_otp_no +
  8988. "&org_name=" + miConfig.OrgName + "&doctor=" + hb_doctor_info.UserName + "&fixmedins_code=" + miConfig.Code +
  8989. "&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
  8990. resp, requestErr := http.Get(api)
  8991. if requestErr != nil {
  8992. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8993. return
  8994. }
  8995. body, ioErr := ioutil.ReadAll(resp.Body)
  8996. if ioErr != nil {
  8997. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  8998. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8999. return
  9000. }
  9001. var respJSON map[string]interface{}
  9002. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  9003. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  9004. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9005. return
  9006. }
  9007. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  9008. result, _ := json.Marshal(respJSON)
  9009. if err := json.Unmarshal([]byte(result), &resThree); err != nil {
  9010. utils.ErrorLog("解析失败:%v", err)
  9011. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9012. return
  9013. }
  9014. infocode = resThree.Infcode
  9015. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  9016. psn_info, _ := service.GetPsnByPatientId(id)
  9017. his.PsnNo = psn_info.PsnNo
  9018. psn_info.VerifyNumber = strings.Replace(psn_info.VerifyNumber, "+", "%2B", -1)
  9019. var cert_no string
  9020. if id_card_type == 3 {
  9021. psn_info.VerifyNumber = IdCardNo + "|" + psn_info.VerifyNumber
  9022. cert_no = IdCardNo
  9023. } else if id_card_type == 4 {
  9024. cert_no = IdCardNo
  9025. psn_info.VerifyNumber = psn_info.VerifyNumber
  9026. } else {
  9027. bas := strings.Split(psn_info.CardInfo, "|")
  9028. cert_no = bas[2]
  9029. }
  9030. var hisPrescription []*models.HisPrescription
  9031. for _, item := range rf {
  9032. if item.Insutype == insutype {
  9033. //insuplc_admdvs = item.InsuplcAdmdvs
  9034. his.InsuplcAdmdvs = insuplc_admdvs
  9035. }
  9036. }
  9037. his.Insutype = insutype
  9038. res3101 := Check3101ForOne(c, patient.ID, his, admin_user_id, "1", record_time, hisPrescription)
  9039. fmt.Println(res3101)
  9040. fmt.Println(res3101.Infcode)
  9041. if res3101.Infcode == "0" {
  9042. fmt.Println("33333333")
  9043. if len(res3101.Output.Result) > 0 {
  9044. fmt.Println("222222")
  9045. for _, item := range res3101.Output.Result {
  9046. if len(res3101.ErrMsg) == 0 {
  9047. res3101.ErrMsg = item.VolaCont
  9048. } else {
  9049. res3101.ErrMsg = res3101.ErrMsg + "\n" + item.VolaCont
  9050. }
  9051. }
  9052. c.ServeSuccessJSON(map[string]interface{}{
  9053. "failed_code": -10,
  9054. "msg": res3101.ErrMsg,
  9055. })
  9056. return
  9057. } else {
  9058. fmt.Println("11111")
  9059. var api string
  9060. if miConfig.MdtrtareaAdmvs == "320921" {
  9061. api = "http://192.168.2.3:9532/" + "jsyb/2201?psn_no=" + PsnNo + "&insutype=" + insutype + "&cert_no=" + cert_no + "&ipt_otp_no=" + ipt_otp_no +
  9062. "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&doctor_name=" + doctor_info.UserName + "&fixmedins_code=" + miConfig.Code +
  9063. "&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
  9064. } else {
  9065. api = "http://192.168.5.251:9532/" + "jsyb/2201?psn_no=" + PsnNo + "&insutype=" + insutype + "&cert_no=" + cert_no + "&ipt_otp_no=" + ipt_otp_no +
  9066. "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&doctor_name=" + doctor_info.UserName + "&fixmedins_code=" + miConfig.Code +
  9067. "&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
  9068. }
  9069. resp, requestErr := http.Get(api)
  9070. if requestErr != nil {
  9071. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9072. return
  9073. }
  9074. body, ioErr := ioutil.ReadAll(resp.Body)
  9075. if ioErr != nil {
  9076. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  9077. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9078. return
  9079. }
  9080. var respJSON map[string]interface{}
  9081. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  9082. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  9083. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9084. return
  9085. }
  9086. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  9087. result, _ := json.Marshal(respJSON)
  9088. if err := json.Unmarshal([]byte(result), &resThree10265); err != nil {
  9089. utils.ErrorLog("解析失败:%v", err)
  9090. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9091. return
  9092. }
  9093. resThree.ErrMsg = resThree10265.ErrMsg
  9094. resThree.Output = resThree10265.Output
  9095. resThree.InfRefmsgid = resThree10265.InfRefmsgid
  9096. infocode, _ = strconv.ParseInt(resThree10265.Infcode, 10, 64)
  9097. }
  9098. } else if res3101.Infcode != "0" {
  9099. c.ServeSuccessJSON(map[string]interface{}{
  9100. "failed_code": -10,
  9101. "msg": res3101.ErrMsg,
  9102. })
  9103. return
  9104. }
  9105. } else if miConfig.MdtrtareaAdmvs == "350500" {
  9106. psn_info, _ := service.GetPsnByPatientId(id)
  9107. var cert_no string
  9108. if id_card_type == 1 {
  9109. cert_no = strings.Split(psn_info.CardInfo, "|")[0]
  9110. insuplc_admdvs_temp = psn_info.InsuplcAdmdvs
  9111. } else if id_card_type == 4 {
  9112. cert_no = psn_info.VerifyNumber
  9113. insuplc_admdvs_temp = psn_info.InsuplcAdmdvs
  9114. } else {
  9115. insuplc_admdvs_temp = psn_info.InsuplcAdmdvs
  9116. cert_no = psn_info.VerifyNumber
  9117. }
  9118. 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)
  9119. saveLog(result, requestLog, "2201", "挂号")
  9120. if miConfig.Code == "H15049901371" {
  9121. if err := json.Unmarshal([]byte(result), &resThree10265); err != nil {
  9122. utils.ErrorLog("解析失败:%v", err)
  9123. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9124. return
  9125. }
  9126. resThree.ErrMsg = resThree10265.ErrMsg
  9127. resThree.Output = resThree10265.Output
  9128. resThree.InfRefmsgid = resThree10265.InfRefmsgid
  9129. } else {
  9130. if err := json.Unmarshal([]byte(result), &resThree); err != nil {
  9131. utils.ErrorLog("解析失败:%v", err)
  9132. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9133. return
  9134. }
  9135. }
  9136. infocode, _ = strconv.ParseInt(resThree10265.Infcode, 10, 64)
  9137. } else if miConfig.MdtrtareaAdmvs == "360399" { //江西萍乡
  9138. psn_info, _ := service.GetPsnByPatientId(id)
  9139. var result string
  9140. var requestLog string
  9141. if id_card_type == 1 {
  9142. bas := strings.Split(psn_info.CardInfo, "|")
  9143. basNumber := bas[2]
  9144. card_sn := bas[3]
  9145. 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)
  9146. saveLog(result, requestLog, "2201A", "挂号")
  9147. } else if id_card_type == 2 {
  9148. 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, "", "")
  9149. saveLog(result, requestLog, "2201A", "挂号")
  9150. } else {
  9151. 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, "", "")
  9152. saveLog(result, requestLog, "2201A", "挂号")
  9153. }
  9154. if err := json.Unmarshal([]byte(result), &resThree); err != nil {
  9155. utils.ErrorLog("解析失败:%v", err)
  9156. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9157. return
  9158. }
  9159. infocode = resThree.Infcode
  9160. } else if miConfig.MdtrtareaAdmvs == "430800" { //江西萍乡
  9161. psn_info, _ := service.GetPsnByPatientId(id)
  9162. var result string
  9163. var requestLog string
  9164. if id_card_type == 1 {
  9165. bas := strings.Split(psn_info.CardInfo, "|")
  9166. basNumber := bas[2]
  9167. card_sn := bas[3]
  9168. 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)
  9169. saveLog(result, requestLog, "2201A", "挂号")
  9170. } else if id_card_type == 2 {
  9171. 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, "", "")
  9172. saveLog(result, requestLog, "2201A", "挂号")
  9173. } else {
  9174. 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, "", "")
  9175. saveLog(result, requestLog, "2201A", "挂号")
  9176. }
  9177. if err := json.Unmarshal([]byte(result), &resThree); err != nil {
  9178. utils.ErrorLog("解析失败:%v", err)
  9179. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9180. return
  9181. }
  9182. infocode = resThree.Infcode
  9183. } else if miConfig.MdtrtareaAdmvs == "131023" {
  9184. psn_info, _ := service.GetPsnByPatientId(id)
  9185. 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)
  9186. saveLog(result, requestLog, "2201A", "挂号")
  9187. if miConfig.Code == "H15049901371" {
  9188. if err := json.Unmarshal([]byte(result), &resThree10265); err != nil {
  9189. utils.ErrorLog("解析失败:%v", err)
  9190. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9191. return
  9192. }
  9193. resThree.ErrMsg = resThree10265.ErrMsg
  9194. resThree.Output = resThree10265.Output
  9195. resThree.InfRefmsgid = resThree10265.InfRefmsgid
  9196. } else {
  9197. if err := json.Unmarshal([]byte(result), &resThree); err != nil {
  9198. utils.ErrorLog("解析失败:%v", err)
  9199. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9200. return
  9201. }
  9202. }
  9203. if miConfig.Code == "H15049901371" {
  9204. infocode, _ = strconv.ParseInt(resThree10265.Infcode, 10, 64)
  9205. } else {
  9206. infocode = resThree.Infcode
  9207. }
  9208. } else {
  9209. psn_info, _ := service.GetPsnByPatientId(id)
  9210. if id_card_type == 4 || id_card_type == 1 {
  9211. insuplc_admdvs_temp = psn_info.InsuplcAdmdvs
  9212. }
  9213. var rf []*ResultFive
  9214. json.Unmarshal([]byte(psn_info.Insuinfo), &rf)
  9215. var insutypes []*ResultFive
  9216. var insutype string
  9217. var is390 int = 0
  9218. var is310 int = 0
  9219. for _, item := range rf {
  9220. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  9221. insutypes = append(insutypes, item)
  9222. }
  9223. }
  9224. if len(insutypes) == 1 {
  9225. insutype = insutypes[0].Insutype
  9226. insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  9227. } else {
  9228. for _, i := range insutypes {
  9229. if i.Insutype == "390" {
  9230. is390 = 1
  9231. }
  9232. if i.Insutype == "310" {
  9233. is310 = 1
  9234. }
  9235. }
  9236. }
  9237. if is390 == 1 {
  9238. insutype = "390"
  9239. }
  9240. if is310 == 1 {
  9241. insutype = "310"
  9242. }
  9243. fmt.Println(len(insutypes))
  9244. if len(insutypes) == 0 {
  9245. for index, item := range rf {
  9246. if index == 0 {
  9247. insutype = item.Insutype
  9248. insuplc_admdvs = item.InsuplcAdmdvs
  9249. }
  9250. }
  9251. fmt.Println(insutype)
  9252. fmt.Println(insuplc_admdvs)
  9253. }
  9254. if social_type > 0 {
  9255. insutype = strconv.FormatInt(social_type, 10)
  9256. }
  9257. 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)
  9258. saveLog(result, requestLog, "2201A", "挂号")
  9259. if miConfig.Code == "H15049901371" {
  9260. if err := json.Unmarshal([]byte(result), &resThree10265); err != nil {
  9261. utils.ErrorLog("解析失败:%v", err)
  9262. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9263. return
  9264. }
  9265. resThree.ErrMsg = resThree10265.ErrMsg
  9266. resThree.Output = resThree10265.Output
  9267. resThree.InfRefmsgid = resThree10265.InfRefmsgid
  9268. } else {
  9269. if err := json.Unmarshal([]byte(result), &resThree); err != nil {
  9270. utils.ErrorLog("解析失败:%v", err)
  9271. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9272. return
  9273. }
  9274. }
  9275. if miConfig.Code == "H15049901371" {
  9276. infocode, _ = strconv.ParseInt(resThree10265.Infcode, 10, 64)
  9277. } else {
  9278. infocode = resThree.Infcode
  9279. }
  9280. }
  9281. if infocode != 0 {
  9282. adminUser := c.GetAdminUserInfo()
  9283. errlog := &models.HisOrderError{
  9284. UserOrgId: adminUser.CurrentOrgId,
  9285. Ctime: time.Now().Unix(),
  9286. Mtime: time.Now().Unix(),
  9287. ErrMsg: resThree.ErrMsg,
  9288. Status: 1,
  9289. PatientId: id,
  9290. RecordTime: recordDateTime,
  9291. Stage: 2,
  9292. }
  9293. service.CreateErrMsgLog(errlog)
  9294. c.ServeSuccessJSON(map[string]interface{}{
  9295. "failed_code": -10,
  9296. "msg": resThree.ErrMsg,
  9297. })
  9298. return
  9299. }
  9300. his.Number = resThree.Output.Data.MdtrtID
  9301. his.PsnNo = resThree.Output.Data.PsnNo
  9302. his.IptOtpNo = resThree.Output.Data.IptOtpNo
  9303. his.IdCardNo = patient.IdCardNo
  9304. his.PhoneNumber = patient.Phone
  9305. his.UserOrgId = adminInfo.CurrentOrgId
  9306. his.Insutype = insutype
  9307. his.Ctime = time.Now().Unix()
  9308. his.Mtime = time.Now().Unix()
  9309. his.InsuplcAdmdvs = insuplc_admdvs_temp
  9310. his.Status = 1
  9311. his.MdtrtGrpType = mdtrt_type
  9312. service.UpdateHisPatientStatus(&his)
  9313. service.UpdateHisPrescriptionHisID(his.ID, patient.ID, recordDateTime, adminInfo.CurrentOrgId)
  9314. c.ServeSuccessJSON(map[string]interface{}{
  9315. "his_info": his,
  9316. })
  9317. } else {
  9318. adminUser := c.GetAdminUserInfo()
  9319. errlog := &models.HisOrderError{
  9320. UserOrgId: adminUser.CurrentOrgId,
  9321. Ctime: time.Now().Unix(),
  9322. Mtime: time.Now().Unix(),
  9323. ErrMsg: res.ErrMsg,
  9324. Status: 1,
  9325. PatientId: id,
  9326. RecordTime: recordDateTime,
  9327. Stage: 1,
  9328. }
  9329. service.CreateErrMsgLog(errlog)
  9330. c.ServeSuccessJSON(map[string]interface{}{
  9331. "failed_code": -10,
  9332. "msg": res.ErrMsg,
  9333. })
  9334. return
  9335. //c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeGdybOneException)
  9336. }
  9337. }
  9338. }
  9339. func (c *HisApiController) GetUploadInfo() {
  9340. id, _ := c.GetInt64("id")
  9341. record_time := c.GetString("record_time")
  9342. his_patient_id, _ := c.GetInt64("his_patient_id")
  9343. order_id, _ := c.GetInt64("order_id")
  9344. pay_way, _ := c.GetInt64("pay_way")
  9345. pay_ways := c.GetString("pay_ways")
  9346. oth_desc := c.GetString("oth_desc")
  9347. pay_price, _ := c.GetFloat("pay_price")
  9348. pay_card_no := c.GetString("pay_card_no")
  9349. discount_price, _ := c.GetFloat("discount_price")
  9350. preferential_price, _ := c.GetFloat("preferential_price")
  9351. reality_price, _ := c.GetFloat("reality_price")
  9352. found_price, _ := c.GetFloat("found_price")
  9353. medical_insurance_price, _ := c.GetFloat("medical_insurance_price")
  9354. private_price, _ := c.GetFloat("private_price")
  9355. settle_accounts_type, _ := c.GetInt64("settle_accounts_type")
  9356. admin_user_id, _ := c.GetInt64("admin_user_id")
  9357. fapiao_code := c.GetString("fapiao_code")
  9358. fapiao_number := c.GetString("fapiao_number")
  9359. diagnosis_id := c.GetString("diagnosis")
  9360. sick_type, _ := c.GetInt64("sick_type")
  9361. reg_type, _ := c.GetInt64("p_type")
  9362. begin_time := c.GetString("begin_time")
  9363. acct_used_flag_num, _ := c.GetInt64("acct_used_flag")
  9364. cash_pay := c.GetString("cash_pay")
  9365. band_card_pay := c.GetString("band_card_pay")
  9366. wechat_pay := c.GetString("wechat_pay")
  9367. ali_pay := c.GetString("ali_pay")
  9368. jifen_pay := c.GetString("jifen_pay")
  9369. acct_used_flag := strconv.FormatInt(acct_used_flag_num, 10)
  9370. fmt.Println(acct_used_flag)
  9371. id_str := c.GetString("ids")
  9372. ids_arr := strings.Split(id_str, ",")
  9373. timeLayout := "2006-01-02"
  9374. loc, _ := time.LoadLocation("Local")
  9375. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  9376. if err != nil {
  9377. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  9378. return
  9379. }
  9380. recordDateTime := theTime.Unix()
  9381. adminUser := c.GetAdminUserInfo()
  9382. var tempOrder models.HisOrder
  9383. tempOrder, _ = service.GetHisOrderByID(order_id)
  9384. var prescriptions []*models.HisPrescription
  9385. var start_time int64
  9386. var end_time int64
  9387. //押金模块
  9388. dec_way := c.GetString("dec_way") //是否使用押金支付bool类型
  9389. tmp_decimal := c.GetString("tmp_decimal")
  9390. var decimal float64 //本次使用的押金
  9391. var errmsg error
  9392. if dec_way == "true" && tmp_decimal == "0" || dec_way == "true" && tmp_decimal == "" {
  9393. c.ServeFailJsonSend(enums.ErrorCodeParamWrong, "押金不能为0")
  9394. return
  9395. }
  9396. if len(tmp_decimal) > 0 {
  9397. if tmp_decimal[0] == 45 {
  9398. c.ServeFailJsonSend(enums.ErrorCodeParamWrong, "押金不能为负数")
  9399. return
  9400. }
  9401. }
  9402. tt, errs := strconv.ParseFloat(tmp_decimal, 64)
  9403. fmt.Println(errs)
  9404. decimal = tt
  9405. //if adminUser.CurrentOrgId == 10106{
  9406. // if len(fapiao_code) == 0{
  9407. // fapiao_code = "144072080589"
  9408. // }
  9409. // if len(fapiao_number) == 0{
  9410. // order, _ := service.GetLastHisOrder(adminUser.CurrentOrgId)
  9411. // if order.ID == 0{
  9412. // fapiao_number = "00001520"
  9413. // }else{
  9414. // //fapiao_code = "00001520"
  9415. // fpNumber, _ := strconv.Atoi(order.FaPiaoNumber)
  9416. // var zero string
  9417. // if fpNumber >= 1000{
  9418. // zero = "0000" + strconv.Itoa(fpNumber)
  9419. // }else if fpNumber >= 10000{
  9420. // zero = "000" + strconv.Itoa(fpNumber)
  9421. // } else if fpNumber >= 100000{
  9422. // zero = "00" + strconv.Itoa(fpNumber)
  9423. // } else if fpNumber >= 1000000{
  9424. // zero = "0" + strconv.Itoa(fpNumber)
  9425. // }else {
  9426. // zero = strconv.Itoa(fpNumber)
  9427. // }
  9428. // fapiao_number = zero
  9429. // }
  9430. // }
  9431. //}
  9432. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  9433. his, _ := service.GetNewHisPatientInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  9434. var patientPrescription models.HisPrescriptionInfo
  9435. patientPrescription, _ = service.FindHisPatientPrescriptionInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  9436. if patientPrescription.ID == 0 {
  9437. patientPrescription, _ = service.FindLastPatientPrescriptionInfo(adminUser.CurrentOrgId, id, recordDateTime)
  9438. }
  9439. //if patientPrescription.Do
  9440. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  9441. department, _ := service.GetDepartMentDetail(patientPrescription.Departments)
  9442. doctor_info, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, patientPrescription.DoctorId)
  9443. diagnosis_ids := strings.Split(diagnosis_id, ",")
  9444. var config []*models.HisXtDiagnoseConfig
  9445. for _, item := range diagnosis_ids {
  9446. id, _ := strconv.ParseInt(item, 10, 64)
  9447. diagnosisConfig, _ := service.FindDiagnoseById(id)
  9448. config = append(config, &diagnosisConfig)
  9449. }
  9450. sickConfig, _ := service.FindSickById(sick_type)
  9451. //if tempOrder.ID == 0 {
  9452. // tempOrder, _ = service.GetTodayHisOrder(adminUser.CurrentOrgId, id, recordDateTime, his.Number)
  9453. //}
  9454. if tempOrder.ID == 0 {
  9455. var result string
  9456. var requestLog string
  9457. var res2 ResultSix
  9458. var ressix10265 ResultSix10265
  9459. if miConfig.MdtrtareaAdmvs == "421300" {
  9460. data := make(map[string]interface{})
  9461. client := &http.Client{}
  9462. data["psn_no"] = his.PsnNo
  9463. data["mdtrt_id"] = his.Number
  9464. data["opter"] = roles.UserName
  9465. data["org_name"] = miConfig.OrgName
  9466. data["med_type"] = strconv.FormatInt(reg_type, 10)
  9467. data["doctor_id"] = doctor_info.DoctorNumber
  9468. data["doctor_name"] = doctor_info.UserName
  9469. data["department"] = department.Name
  9470. data["fixmedins_code"] = miConfig.Code
  9471. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  9472. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  9473. data["secret_key"] = miConfig.SecretKey
  9474. data["sick_code"] = sickConfig.CountryCode
  9475. data["sick_name"] = sickConfig.ClassName
  9476. data["dept"] = strconv.FormatInt(department.ID, 10)
  9477. data["config"] = config
  9478. data["begin_time"] = begin_time
  9479. bytesData, _ := json.Marshal(data)
  9480. req, _ := http.NewRequest("POST", "http://192.168.124.4:9532/"+"hbyb/2203", bytes.NewReader(bytesData))
  9481. resp, _ := client.Do(req)
  9482. defer resp.Body.Close()
  9483. body, ioErr := ioutil.ReadAll(resp.Body)
  9484. if ioErr != nil {
  9485. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  9486. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9487. return
  9488. }
  9489. var respJSON map[string]interface{}
  9490. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  9491. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  9492. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9493. return
  9494. }
  9495. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  9496. userJSONBytes, _ := json.Marshal(respJSON)
  9497. fmt.Println("log")
  9498. fmt.Println(string(userJSONBytes))
  9499. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  9500. utils.ErrorLog("解析失败:%v", err)
  9501. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9502. return
  9503. }
  9504. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  9505. data := make(map[string]interface{})
  9506. client := &http.Client{}
  9507. data["psn_no"] = his.PsnNo
  9508. data["mdtrt_id"] = his.Number
  9509. data["doctor"] = roles.UserName
  9510. data["department"] = department.Name
  9511. data["org_name"] = miConfig.OrgName
  9512. data["med_type"] = strconv.FormatInt(reg_type, 10)
  9513. data["doctor_id"] = doctor_info.DoctorNumber
  9514. data["new_doctor_name"] = doctor_info.UserName
  9515. data["fixmedins_code"] = miConfig.Code
  9516. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  9517. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  9518. data["secret_key"] = miConfig.SecretKey
  9519. data["sick_code"] = sickConfig.CountryCode
  9520. data["sick_name"] = sickConfig.ClassName
  9521. data["url"] = miConfig.Url
  9522. data["ak"] = miConfig.AccessKey
  9523. data["begin_time"] = begin_time
  9524. data["cainfo"] = miConfig.Cainfo
  9525. data["dept"] = strconv.FormatInt(department.ID, 10)
  9526. data["config"] = config
  9527. bytesData, _ := json.Marshal(data)
  9528. var req *http.Request
  9529. if miConfig.MdtrtareaAdmvs == "320921" {
  9530. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/2203", bytes.NewReader(bytesData))
  9531. //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 +
  9532. // "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&cainfo=" + miConfig.Cainfo
  9533. } else {
  9534. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2203", bytes.NewReader(bytesData))
  9535. }
  9536. resp, _ := client.Do(req)
  9537. defer resp.Body.Close()
  9538. body, ioErr := ioutil.ReadAll(resp.Body)
  9539. if ioErr != nil {
  9540. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  9541. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9542. return
  9543. }
  9544. var respJSON map[string]interface{}
  9545. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  9546. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  9547. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9548. return
  9549. }
  9550. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  9551. userJSONBytes, _ := json.Marshal(respJSON)
  9552. fmt.Println("log")
  9553. fmt.Println(string(userJSONBytes))
  9554. if err := json.Unmarshal(userJSONBytes, &ressix10265); err != nil {
  9555. utils.ErrorLog("解析失败:%v", err)
  9556. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9557. return
  9558. }
  9559. res2.InfRefmsgid = ressix10265.InfRefmsgid
  9560. res2.Output = ressix10265.Output
  9561. res2.ErrMsg = ressix10265.ErrMsg
  9562. res2.Cainfo = ressix10265.Cainfo
  9563. res2.WarnMsg = ressix10265.WarnMsg
  9564. infocode, _ := strconv.ParseInt(ressix10265.Infcode, 10, 64)
  9565. res2.Infcode = infocode
  9566. } else if miConfig.MdtrtareaAdmvs == "350500" {
  9567. 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)
  9568. saveLog(result, requestLog, "2203", "上传就诊信息")
  9569. var respJSON2 map[string]interface{}
  9570. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  9571. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  9572. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9573. return
  9574. }
  9575. userJSONBytes2, _ := json.Marshal(respJSON2)
  9576. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  9577. utils.ErrorLog("解析失败:%v", err)
  9578. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9579. return
  9580. }
  9581. 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)
  9582. fmt.Println(result2)
  9583. fmt.Println(src_request)
  9584. } else {
  9585. if miConfig.MdtrtareaAdmvs == "440781" { //
  9586. 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)
  9587. } else {
  9588. if miConfig.Code == "H15049901371" {
  9589. //赤峰地区国家医保医疗类别
  9590. //职工透析:医疗类别选特殊情况门诊990502
  9591. //居民定额血透门慢: 医疗类别选门诊慢病140104
  9592. var med_type string
  9593. if his.Insutype == "390" {
  9594. if reg_type == 14 {
  9595. med_type = "9933"
  9596. } else if reg_type == 11 {
  9597. med_type = "11"
  9598. }
  9599. } else if his.Insutype == "310" {
  9600. if reg_type == 14 {
  9601. med_type = "990502"
  9602. } else if reg_type == 11 {
  9603. med_type = "11"
  9604. }
  9605. }
  9606. 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)
  9607. } else {
  9608. 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)
  9609. }
  9610. }
  9611. saveLog(result, requestLog, "2203", "上传就诊信息")
  9612. var respJSON2 map[string]interface{}
  9613. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  9614. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  9615. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9616. return
  9617. }
  9618. userJSONBytes2, _ := json.Marshal(respJSON2)
  9619. if miConfig.Code == "H15049901371" {
  9620. if err := json.Unmarshal(userJSONBytes2, &ressix10265); err != nil {
  9621. utils.ErrorLog("解析失败:%v", err)
  9622. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9623. return
  9624. }
  9625. res2.InfRefmsgid = ressix10265.InfRefmsgid
  9626. res2.Output = ressix10265.Output
  9627. res2.ErrMsg = ressix10265.ErrMsg
  9628. res2.Cainfo = ressix10265.Cainfo
  9629. res2.WarnMsg = ressix10265.WarnMsg
  9630. infocode, _ := strconv.ParseInt(ressix10265.Infcode, 10, 64)
  9631. res2.Infcode = infocode
  9632. } else {
  9633. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  9634. utils.ErrorLog("解析失败:%v", err)
  9635. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9636. return
  9637. }
  9638. }
  9639. }
  9640. if res2.Infcode != 0 {
  9641. adminUser := c.GetAdminUserInfo()
  9642. errlog := &models.HisOrderError{
  9643. UserOrgId: adminUser.CurrentOrgId,
  9644. Ctime: time.Now().Unix(),
  9645. Mtime: time.Now().Unix(),
  9646. ErrMsg: res2.ErrMsg,
  9647. Status: 1,
  9648. PatientId: id,
  9649. RecordTime: recordDateTime,
  9650. Stage: 3,
  9651. }
  9652. service.CreateErrMsgLog(errlog)
  9653. c.ServeSuccessJSON(map[string]interface{}{
  9654. "failed_code": -10,
  9655. "msg": res2.ErrMsg,
  9656. })
  9657. return
  9658. } else {
  9659. his.Diagnosis = diagnosis_id
  9660. his.SickType = sickConfig.ID
  9661. //var p_type int64
  9662. //if reg_type == 1111 || reg_type == 1112 {
  9663. // p_type = 11
  9664. //
  9665. //}
  9666. his.PType = fmt.Sprintf("%d", reg_type)
  9667. service.UpdateHisPatientThree(&his)
  9668. data := make(map[string]interface{})
  9669. if settle_accounts_type == 1 { //日结
  9670. if reg_type == 11 || reg_type == 1111 || reg_type == 1112 {
  9671. prescriptions, _ = service.GetPrescriptionByIds(ids_arr, adminUser.CurrentOrgId)
  9672. } else {
  9673. prescriptions, _ = service.GetNewHisPrescription(adminUser.CurrentOrgId, his_patient_id, recordDateTime, strconv.Itoa(int(reg_type)))
  9674. }
  9675. //prescriptions, _ = service.GetNewHisPrescriptionTwo(adminUser.CurrentOrgId, his_patient_id, recordDateTime, reg_type)
  9676. data["pre"] = prescriptions
  9677. } else { //月结
  9678. start_time_str := c.GetString("start_time")
  9679. end_time_str := c.GetString("end_time")
  9680. timeLayout := "2006-01-02"
  9681. loc, _ := time.LoadLocation("Local")
  9682. theStartTime, err := time.ParseInLocation(timeLayout+" 15:04:05", start_time_str+" 00:00:00", loc)
  9683. if err != nil {
  9684. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  9685. return
  9686. }
  9687. recordStartTime := theStartTime.Unix()
  9688. start_time = recordStartTime
  9689. theEndTime, err := time.ParseInLocation(timeLayout+" 15:04:05", end_time_str+" 00:00:00", loc)
  9690. if err != nil {
  9691. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  9692. return
  9693. }
  9694. recordEndTime := theEndTime.Unix()
  9695. end_time = recordEndTime
  9696. prescriptions, _ = service.GetMonthHisPrescriptionTwo(adminUser.CurrentOrgId, id, recordStartTime, recordEndTime, reg_type)
  9697. data["pre"] = prescriptions
  9698. }
  9699. timestamp := time.Now().Unix()
  9700. tempTime := time.Unix(timestamp, 0)
  9701. timeFormat := tempTime.Format("20060102150405")
  9702. chrgBchno := rand.Intn(100000) + 10000
  9703. chrg_bchno := timeFormat + strconv.FormatInt(int64(chrgBchno), 10) + strconv.FormatInt(his.PatientId, 10)
  9704. strconv.FormatInt(his.PatientId, 10)
  9705. client := &http.Client{}
  9706. data["psn_no"] = his.PsnNo
  9707. data["mdtrt_id"] = his.Number
  9708. data["chrg_bchno"] = chrg_bchno
  9709. data["org_name"] = miConfig.OrgName
  9710. data["doctor"] = doctor_info.UserName
  9711. data["doctor_id"] = doctor_info.DoctorNumber
  9712. data["dept"] = strconv.FormatInt(patientPrescription.Departments, 10)
  9713. data["fixmedins_code"] = miConfig.Code
  9714. data["opter"] = roles.UserName
  9715. data["dept_code"] = department.Number
  9716. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  9717. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  9718. data["secret_key"] = miConfig.SecretKey
  9719. data["balance_accounts_type"] = strconv.FormatInt(his.BalanceAccountsType, 10)
  9720. data["url"] = miConfig.Url
  9721. data["ak"] = miConfig.AccessKey
  9722. data["new_doctor_name"] = patientPrescription.Doctor
  9723. data["diag_code"] = sickConfig.CountryCode
  9724. data["cainfo"] = miConfig.Cainfo
  9725. data["opter"] = roles.UserName
  9726. var ids []int64
  9727. for _, item := range prescriptions {
  9728. ids = append(ids, item.ID)
  9729. }
  9730. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  9731. if config.IsOpen == 1 { //对接了医保,走医保流程
  9732. var res ResultFour
  9733. var resFour10265 ResultFour10265
  9734. if miConfig.MdtrtareaAdmvs == "421300" {
  9735. bytesData, _ := json.Marshal(data)
  9736. req, _ := http.NewRequest("POST", "http://192.168.124.4:9532/"+"hbyb/2204", bytes.NewReader(bytesData))
  9737. resp, _ := client.Do(req)
  9738. defer resp.Body.Close()
  9739. body, ioErr := ioutil.ReadAll(resp.Body)
  9740. if ioErr != nil {
  9741. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  9742. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9743. return
  9744. }
  9745. var respJSON map[string]interface{}
  9746. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  9747. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  9748. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9749. return
  9750. }
  9751. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  9752. userJSONBytes, _ := json.Marshal(respJSON)
  9753. fmt.Println("log")
  9754. fmt.Println(string(userJSONBytes))
  9755. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  9756. utils.ErrorLog("解析失败:%v", err)
  9757. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9758. return
  9759. }
  9760. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  9761. result3101 := Check3101(c, id, his_patient_id, admin_user_id, "2", record_time, prescriptions)
  9762. if result3101.Infcode == "0" {
  9763. if len(result3101.Output.Result) > 0 {
  9764. var errMsgs []string
  9765. for _, item := range result3101.Output.Result {
  9766. errMsgs = append(errMsgs, item.VolaCont)
  9767. }
  9768. c.ServeSuccessJSON(map[string]interface{}{
  9769. "failed_code": -10,
  9770. "msg": errMsgs,
  9771. })
  9772. return
  9773. }
  9774. }
  9775. if miConfig.MdtrtareaAdmvs == "320921" {
  9776. data["doctor_id"] = "D320923012139"
  9777. } else {
  9778. data["doctor_id"] = "D371621008686"
  9779. }
  9780. bytesData, _ := json.Marshal(data)
  9781. var req *http.Request
  9782. if miConfig.MdtrtareaAdmvs == "320921" {
  9783. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  9784. } else {
  9785. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  9786. }
  9787. resp, _ := client.Do(req)
  9788. defer resp.Body.Close()
  9789. body, ioErr := ioutil.ReadAll(resp.Body)
  9790. if ioErr != nil {
  9791. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  9792. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9793. return
  9794. }
  9795. var respJSON map[string]interface{}
  9796. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  9797. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  9798. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9799. return
  9800. }
  9801. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  9802. userJSONBytes, _ := json.Marshal(respJSON)
  9803. fmt.Println("log")
  9804. fmt.Println(string(userJSONBytes))
  9805. if err := json.Unmarshal(userJSONBytes, &resFour10265); err != nil {
  9806. utils.ErrorLog("解析失败:%v", err)
  9807. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9808. return
  9809. }
  9810. res.InfRefmsgid = resFour10265.InfRefmsgid
  9811. res.Output = resFour10265.Output
  9812. res.ErrMsg = resFour10265.ErrMsg
  9813. res.Cainfo = resFour10265.Cainfo
  9814. res.WarnMsg = resFour10265.WarnMsg
  9815. infocode, _ := strconv.ParseInt(resFour10265.Infcode, 10, 64)
  9816. res.Infcode = infocode
  9817. } else if miConfig.MdtrtareaAdmvs == "350500" {
  9818. 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)
  9819. var dat map[string]interface{}
  9820. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  9821. fmt.Println(dat)
  9822. } else {
  9823. fmt.Println(err)
  9824. }
  9825. saveLog(result, request_log, "2204", "上传费用明细")
  9826. userJSONBytes, _ := json.Marshal(dat)
  9827. if err := json.Unmarshal(userJSONBytes, &resFour10265); err != nil {
  9828. utils.ErrorLog("解析失败:%v", err)
  9829. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9830. return
  9831. }
  9832. res.InfRefmsgid = resFour10265.InfRefmsgid
  9833. res.Output = resFour10265.Output
  9834. res.ErrMsg = resFour10265.ErrMsg
  9835. res.Cainfo = resFour10265.Cainfo
  9836. res.WarnMsg = resFour10265.WarnMsg
  9837. infocode, _ := strconv.ParseInt(resFour10265.Infcode, 10, 64)
  9838. res.Infcode = infocode
  9839. } else {
  9840. if miConfig.Code == "H15049901371" {
  9841. 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)
  9842. var dat map[string]interface{}
  9843. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  9844. fmt.Println(dat)
  9845. } else {
  9846. fmt.Println(err)
  9847. }
  9848. saveLog(result, request_log, "2204", "上传费用明细")
  9849. userJSONBytes, _ := json.Marshal(dat)
  9850. if err := json.Unmarshal(userJSONBytes, &resFour10265); err != nil {
  9851. utils.ErrorLog("解析失败:%v", err)
  9852. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9853. return
  9854. }
  9855. res.InfRefmsgid = resFour10265.InfRefmsgid
  9856. res.Output = resFour10265.Output
  9857. res.ErrMsg = resFour10265.ErrMsg
  9858. res.Cainfo = resFour10265.Cainfo
  9859. res.WarnMsg = resFour10265.WarnMsg
  9860. infocode, _ := strconv.ParseInt(resFour10265.Infcode, 10, 64)
  9861. res.Infcode = infocode
  9862. } else {
  9863. 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)
  9864. var dat map[string]interface{}
  9865. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  9866. fmt.Println(dat)
  9867. } else {
  9868. fmt.Println(err)
  9869. }
  9870. saveLog(result, request_log, "2204", "上传费用明细")
  9871. userJSONBytes, _ := json.Marshal(dat)
  9872. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  9873. utils.ErrorLog("解析失败:%v", err)
  9874. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9875. return
  9876. }
  9877. }
  9878. }
  9879. if res.Infcode == 0 {
  9880. order := &models.HisOrder{
  9881. UserOrgId: adminUser.CurrentOrgId,
  9882. HisPatientId: his.ID,
  9883. PatientId: his.PatientId,
  9884. SettleAccountsDate: recordDateTime,
  9885. MdtrtId: his.Number,
  9886. PsnNo: his.PsnNo,
  9887. MedType: strconv.FormatInt(reg_type, 10),
  9888. Ctime: time.Now().Unix(),
  9889. Mtime: time.Now().Unix(),
  9890. Status: 1,
  9891. Number: chrg_bchno,
  9892. Infcode: res.Infcode,
  9893. WarnMsg: res.WarnMsg,
  9894. Cainfo: res.Cainfo,
  9895. ErrMsg: res.ErrMsg,
  9896. RespondTime: res.RefmsgTime,
  9897. InfRefmsgid: res.InfRefmsgid,
  9898. OrderStatus: 1,
  9899. PayWay: pay_way,
  9900. PayWays: pay_ways,
  9901. OthDesc: oth_desc,
  9902. PayPrice: pay_price,
  9903. PayCardNo: pay_card_no,
  9904. DiscountPrice: discount_price,
  9905. PreferentialPrice: preferential_price,
  9906. RealityPrice: reality_price,
  9907. FoundPrice: found_price,
  9908. MedicalInsurancePrice: medical_insurance_price,
  9909. PrivatePrice: private_price,
  9910. IsMedicineInsurance: 1,
  9911. SettleType: settle_accounts_type,
  9912. SettleStartTime: start_time,
  9913. SettleEndTime: end_time,
  9914. Creator: roles.AdminUserId,
  9915. Modify: roles.AdminUserId,
  9916. FaPiaoNumber: fapiao_number,
  9917. FaPiaoCode: fapiao_code,
  9918. PType: 2,
  9919. Diagnosis: diagnosis_id,
  9920. CashPay: cash_pay,
  9921. WechatPay: wechat_pay,
  9922. AliPay: ali_pay,
  9923. JifenPay: jifen_pay,
  9924. BandCardPay: band_card_pay,
  9925. }
  9926. err = service.CreateOrder(order)
  9927. if err != nil {
  9928. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCreatePreOrderException)
  9929. return
  9930. }
  9931. for _, item := range res.Output.Result {
  9932. temp := strings.Split(item.FeedetlSn, "-")
  9933. var advice_id int64 = 0
  9934. var project_id int64 = 0
  9935. var types int64 = 0
  9936. id, _ := strconv.ParseInt(temp[2], 10, 64)
  9937. types, _ = strconv.ParseInt(temp[1], 10, 64)
  9938. if temp[1] == "1" {
  9939. advice_id = id
  9940. project_id = 0
  9941. } else if temp[1] == "2" {
  9942. advice_id = 0
  9943. project_id = id
  9944. }
  9945. if item.MedChrgitmType == "9" {
  9946. item.MedChrgitmType = "09"
  9947. }
  9948. info := &models.HisOrderInfo{
  9949. OrderNumber: order.Number,
  9950. FeedetlSn: item.FeedetlSn,
  9951. UploadDate: time.Now().Unix(),
  9952. AdviceId: advice_id,
  9953. DetItemFeeSumamt: item.DetItemFeeSumamt,
  9954. Cnt: item.Cnt,
  9955. Pric: float64(item.Pric),
  9956. PatientId: his.PatientId,
  9957. PricUplmtAmt: item.PricUplmtAmt,
  9958. SelfpayProp: item.SelfpayProp,
  9959. FulamtOwnpayAmt: item.FulamtOwnpayAmt,
  9960. OverlmtAmt: item.OverlmtAmt,
  9961. PreselfpayAmt: item.PreselfpayAmt,
  9962. BasMednFlag: item.BasMednFlag,
  9963. MedChrgitmType: item.MedChrgitmType,
  9964. HiNegoDrugFlag: item.HiNegoDrugFlag,
  9965. Status: 1,
  9966. Memo: item.Memo,
  9967. Mtime: time.Now().Unix(),
  9968. InscpScpAmt: item.InscpScpAmt,
  9969. DrtReimFlag: item.DrtReimFlag,
  9970. Ctime: time.Now().Unix(),
  9971. ListSpItemFlag: item.ListSpItemFlag,
  9972. ChldMedcFlag: item.ChldMedcFlag,
  9973. LmtUsedFlag: item.LmtUsedFlag,
  9974. ChrgitmLv: item.ChrgitmLv,
  9975. UserOrgId: adminUser.CurrentOrgId,
  9976. HisPatientId: his.ID,
  9977. OrderId: order.ID,
  9978. ProjectId: project_id,
  9979. Type: types,
  9980. }
  9981. service.CreateOrderInfo(info)
  9982. }
  9983. service.UpDatePrescriptionNumber(adminUser.CurrentOrgId, ids, chrg_bchno)
  9984. service.UpDateHisPrescriptionInfoNumber(adminUser.CurrentOrgId, his_patient_id, chrg_bchno, recordDateTime)
  9985. var total float64
  9986. for _, item := range prescriptions {
  9987. if item.Type == 1 { //药品
  9988. for _, subItem := range item.HisDoctorAdviceInfo {
  9989. price, _ := strconv.ParseFloat(fmt.Sprintf("%.2f", subItem.Price), 64)
  9990. total_one := price * subItem.PrescribingNumber
  9991. total = total + total_one
  9992. }
  9993. }
  9994. if item.Type == 2 { //项目
  9995. for _, subItem := range item.HisPrescriptionProject {
  9996. cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  9997. price, _ := strconv.ParseFloat(fmt.Sprintf("%.2f", subItem.Price), 64)
  9998. total_one := price * cnt
  9999. total = total + total_one
  10000. }
  10001. }
  10002. }
  10003. allTotal := fmt.Sprintf("%f", total)
  10004. //if adminUser.CurrentOrgId == 9919 {
  10005. //
  10006. // allTotal = fmt.Sprintf("%.2f", total)
  10007. //
  10008. //} else {
  10009. //
  10010. // allTotal = fmt.Sprintf("%.2f", total)
  10011. //
  10012. //}
  10013. if res.Infcode == 0 {
  10014. var rf []*ResultFive
  10015. json.Unmarshal([]byte(his.Iinfo), &rf)
  10016. chrg_bchno := chrg_bchno
  10017. cert_no := his.Certno
  10018. var insutypes []string
  10019. var insutype string
  10020. var is390 int = 0
  10021. var is310 int = 0
  10022. for _, item := range rf {
  10023. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  10024. insutypes = append(insutypes, item.Insutype)
  10025. }
  10026. }
  10027. if len(insutypes) == 1 {
  10028. insutype = insutypes[0]
  10029. } else {
  10030. for _, i := range insutypes {
  10031. if i == "390" {
  10032. is390 = 1
  10033. }
  10034. if i == "310" {
  10035. is310 = 1
  10036. }
  10037. }
  10038. }
  10039. if is390 == 1 {
  10040. insutype = "390"
  10041. }
  10042. if is310 == 1 {
  10043. insutype = "310"
  10044. }
  10045. if len(insutypes) == 0 {
  10046. insutype = "310"
  10047. }
  10048. if len(insutypes) == 2 {
  10049. insutype = strconv.FormatInt(his.SocialType, 10)
  10050. }
  10051. insutype = strconv.FormatInt(his.SocialType, 10)
  10052. //insutype = "390"
  10053. if his.IdCardType == 1 {
  10054. // cert_no = his.MedicalInsuranceNumber
  10055. cert_no = his.Certno
  10056. } else {
  10057. cert_no = his.Certno
  10058. }
  10059. var res ResultSeven
  10060. var resSeven10265 ResultSeven10265
  10061. var src_resquest string
  10062. var result2 string
  10063. if miConfig.MdtrtareaAdmvs == "421300" {
  10064. api := "http://192.168.124.4:9532/" + "hbyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  10065. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  10066. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  10067. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  10068. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  10069. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  10070. "&insutype=" + insutype + "&total=" + allTotal + "&med_type=" + strconv.FormatInt(reg_type, 10) + "&acct_used_flag=" + acct_used_flag
  10071. resp, requestErr := http.Get(api)
  10072. if requestErr != nil {
  10073. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10074. return
  10075. }
  10076. body, ioErr := ioutil.ReadAll(resp.Body)
  10077. if ioErr != nil {
  10078. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  10079. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10080. return
  10081. }
  10082. var respJSON map[string]interface{}
  10083. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  10084. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  10085. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10086. return
  10087. }
  10088. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  10089. result, _ := json.Marshal(respJSON)
  10090. if miConfig.Code == "H15049901371" {
  10091. if err := json.Unmarshal([]byte(result), &resSeven10265); err != nil {
  10092. utils.ErrorLog("解析失败:%v", err)
  10093. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10094. return
  10095. }
  10096. res.InfRefmsgid = resSeven10265.InfRefmsgid
  10097. res.Output = resSeven10265.Output
  10098. res.ErrMsg = resSeven10265.ErrMsg
  10099. res.Cainfo = resSeven10265.Cainfo
  10100. res.WarnMsg = resSeven10265.WarnMsg
  10101. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  10102. res.Infcode = infocode
  10103. } else {
  10104. if err := json.Unmarshal([]byte(result), &res); err != nil {
  10105. utils.ErrorLog("解析失败:%v", err)
  10106. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10107. return
  10108. }
  10109. }
  10110. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  10111. result3101 := Check3102(c, id, his_patient_id, admin_user_id, "7", order.ID)
  10112. if result3101.Infcode == "0" {
  10113. if len(result3101.Output.Result) > 0 {
  10114. var errMsgs []string
  10115. for _, item := range result3101.Output.Result {
  10116. errMsgs = append(errMsgs, item.VolaCont)
  10117. }
  10118. c.ServeSuccessJSON(map[string]interface{}{
  10119. "failed_code": -10,
  10120. "msg": errMsgs,
  10121. })
  10122. return
  10123. } else {
  10124. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  10125. psn_info.VerifyNumber = strings.Replace(psn_info.VerifyNumber, "+", "%2B", -1)
  10126. bas := strings.Split(psn_info.CardInfo, "|")
  10127. if his.IdCardType == 1 {
  10128. cert_no = bas[2]
  10129. } else if his.IdCardType == 3 {
  10130. cert_no = his.Certno
  10131. psn_info.VerifyNumber = his.Certno + "|" + psn_info.VerifyNumber
  10132. } else if his.IdCardType == 4 {
  10133. cert_no = his.Certno
  10134. psn_info.VerifyNumber = psn_info.VerifyNumber
  10135. }
  10136. var api string
  10137. if miConfig.MdtrtareaAdmvs == "320921" {
  10138. api = "http://192.168.2.3:9532/" + "jsyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  10139. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  10140. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  10141. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  10142. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  10143. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  10144. "&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
  10145. } else {
  10146. api = "http://192.168.5.251:9532/" + "jsyb/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 + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&verify_number=" + psn_info.VerifyNumber + "&cainfo=" + miConfig.Cainfo + "&mdtrt_grp_type=" + his.MdtrtGrpType
  10153. }
  10154. resp, requestErr := http.Get(api)
  10155. if requestErr != nil {
  10156. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10157. return
  10158. }
  10159. body, ioErr := ioutil.ReadAll(resp.Body)
  10160. if ioErr != nil {
  10161. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  10162. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10163. return
  10164. }
  10165. var respJSON map[string]interface{}
  10166. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  10167. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  10168. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10169. return
  10170. }
  10171. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  10172. result, _ := json.Marshal(respJSON)
  10173. if err := json.Unmarshal([]byte(result), &resSeven10265); err != nil {
  10174. utils.ErrorLog("解析失败:%v", err)
  10175. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10176. return
  10177. }
  10178. res.InfRefmsgid = resSeven10265.InfRefmsgid
  10179. res.Output = resSeven10265.Output
  10180. res.ErrMsg = resSeven10265.ErrMsg
  10181. res.Cainfo = resSeven10265.Cainfo
  10182. res.WarnMsg = resSeven10265.WarnMsg
  10183. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  10184. res.Infcode = infocode
  10185. }
  10186. }
  10187. } else if miConfig.MdtrtareaAdmvs == "350500" {
  10188. var cert_no string
  10189. if his.IdCardType == 4 {
  10190. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  10191. cert_no = psn_info.VerifyNumber
  10192. 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)
  10193. } else if his.IdCardType == 1 {
  10194. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  10195. cert_no = strings.Split(psn_info.CardInfo, "|")[0]
  10196. 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)
  10197. }
  10198. //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)
  10199. var dat map[string]interface{}
  10200. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  10201. fmt.Println(dat)
  10202. } else {
  10203. fmt.Println(err)
  10204. }
  10205. saveLog(result2, src_resquest, "2207", "结算")
  10206. userJSONBytes, _ := json.Marshal(dat)
  10207. if err := json.Unmarshal(userJSONBytes, &resSeven10265); err != nil {
  10208. utils.ErrorLog("解析失败:%v", err)
  10209. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10210. return
  10211. }
  10212. res.InfRefmsgid = resSeven10265.InfRefmsgid
  10213. res.Output = resSeven10265.Output
  10214. res.ErrMsg = resSeven10265.ErrMsg
  10215. res.Cainfo = resSeven10265.Cainfo
  10216. res.WarnMsg = resSeven10265.WarnMsg
  10217. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  10218. res.Infcode = infocode
  10219. } else {
  10220. if miConfig.Code == "H15049901371" {
  10221. //赤峰地区国家医保医疗类别
  10222. //职工透析:医疗类别选特殊情况门诊990502
  10223. //居民定额血透门慢: 医疗类别选门诊慢病140104
  10224. var med_type string
  10225. if his.Insutype == "390" {
  10226. if reg_type == 14 {
  10227. med_type = "9933"
  10228. } else if reg_type == 11 {
  10229. med_type = "11"
  10230. }
  10231. } else if his.Insutype == "310" {
  10232. if reg_type == 14 {
  10233. med_type = "990502"
  10234. } else if reg_type == 11 {
  10235. med_type = "11"
  10236. }
  10237. }
  10238. 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, "")
  10239. } else {
  10240. if his.IdCardType == 4 {
  10241. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  10242. var token string
  10243. token = psn_info.VerifyNumber
  10244. 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)
  10245. } else {
  10246. 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, "")
  10247. }
  10248. }
  10249. //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)
  10250. var dat map[string]interface{}
  10251. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  10252. fmt.Println(dat)
  10253. } else {
  10254. fmt.Println(err)
  10255. }
  10256. saveLog(result2, src_resquest, "2207", "结算")
  10257. userJSONBytes, _ := json.Marshal(dat)
  10258. if miConfig.Code == "H15049901371" {
  10259. if err := json.Unmarshal(userJSONBytes, &resSeven10265); err != nil {
  10260. utils.ErrorLog("解析失败:%v", err)
  10261. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10262. return
  10263. }
  10264. res.InfRefmsgid = resSeven10265.InfRefmsgid
  10265. res.Output = resSeven10265.Output
  10266. res.ErrMsg = resSeven10265.ErrMsg
  10267. res.Cainfo = resSeven10265.Cainfo
  10268. res.WarnMsg = resSeven10265.WarnMsg
  10269. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  10270. res.Infcode = infocode
  10271. } else {
  10272. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  10273. utils.ErrorLog("解析失败:%v", err)
  10274. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10275. return
  10276. }
  10277. }
  10278. }
  10279. if res.Infcode != 0 {
  10280. errlog := &models.HisOrderError{
  10281. UserOrgId: adminUser.CurrentOrgId,
  10282. Ctime: time.Now().Unix(),
  10283. Mtime: time.Now().Unix(),
  10284. Number: chrg_bchno,
  10285. ErrMsg: res.ErrMsg,
  10286. Status: 1,
  10287. PatientId: id,
  10288. RecordTime: recordDateTime,
  10289. Stage: 6,
  10290. }
  10291. service.CreateErrMsgLog(errlog)
  10292. c.ServeSuccessJSON(map[string]interface{}{
  10293. "failed_code": -10,
  10294. "msg": res.ErrMsg,
  10295. })
  10296. return
  10297. } else {
  10298. order, _ := service.GetHisOrderTwo(adminUser.CurrentOrgId, chrg_bchno, id)
  10299. order.OrderStatus = 2
  10300. order.Status = 1
  10301. order.MdtrtId = res.Output.Setlinfo.MdtrtID
  10302. order.SetlId = res.Output.Setlinfo.SetlID
  10303. order.PsnNo = res.Output.Setlinfo.PsnNo
  10304. order.PsnName = res.Output.Setlinfo.PsnName
  10305. order.PsnCertType = res.Output.Setlinfo.PsnCertType
  10306. order.Certno = res.Output.Setlinfo.Certno
  10307. order.Gend = res.Output.Setlinfo.Gend
  10308. order.Naty = res.Output.Setlinfo.Naty
  10309. order.Age = res.Output.Setlinfo.Age
  10310. order.Insutype = res.Output.Setlinfo.Insutype
  10311. order.PsnType = res.Output.Setlinfo.PsnType
  10312. order.CvlservFlag = res.Output.Setlinfo.CvlservFlag
  10313. order.SetlTime = res.Output.Setlinfo.SetlTime
  10314. order.MdtrtCertType = res.Output.Setlinfo.MdtrtCertType
  10315. if res.Output.Setlinfo.MedType == "140101" {
  10316. order.MedType = "14"
  10317. } else {
  10318. order.MedType = res.Output.Setlinfo.MedType
  10319. }
  10320. if reg_type == 1112 {
  10321. order.MedType = "1112"
  10322. }
  10323. if reg_type == 1111 {
  10324. order.MedType = "1111"
  10325. }
  10326. order.MedfeeSumamt = res.Output.Setlinfo.MedfeeSumamt
  10327. order.FulamtOwnpayAmt = res.Output.Setlinfo.FulamtOwnpayAmt
  10328. order.OverlmtSelfPay = res.Output.Setlinfo.OverlmtSelfpay
  10329. order.PreselfpayAmt = res.Output.Setlinfo.PreselfpayAmt
  10330. order.InscpScpAmt = res.Output.Setlinfo.InscpScpAmt
  10331. order.ActPayDedc = res.Output.Setlinfo.ActPayDedc
  10332. order.HifpPay = res.Output.Setlinfo.HifpPay
  10333. order.CvlservPay = res.Output.Setlinfo.CvlservPay
  10334. order.PoolPropSelfpay = res.Output.Setlinfo.PoolPropSelfpay
  10335. order.HifesPay = res.Output.Setlinfo.HifesPay
  10336. order.HifobPay = res.Output.Setlinfo.HifobPay
  10337. order.MafPay = res.Output.Setlinfo.MafPay
  10338. order.HifmiPay = res.Output.Setlinfo.HifmiPay
  10339. order.OthPay = res.Output.Setlinfo.OthPay
  10340. order.FundPaySumamt = res.Output.Setlinfo.FundPaySumamt
  10341. order.PsnPartAmt = res.Output.Setlinfo.PsnPartAmt
  10342. order.AcctPay = res.Output.Setlinfo.AcctPay
  10343. order.PsnCashPay = res.Output.Setlinfo.PsnCashPay
  10344. order.HospPartAmt = res.Output.Setlinfo.HospPartAmt
  10345. order.Balc = res.Output.Setlinfo.Balc
  10346. order.AcctMulaidPay = res.Output.Setlinfo.AcctMulaidPay
  10347. order.MedinsSetlId = res.Output.Setlinfo.MedinsSetlID
  10348. order.ClrOptins = res.Output.Setlinfo.ClrOptins
  10349. order.ClrType = res.Output.Setlinfo.ClrType
  10350. order.ClrWay = res.Output.Setlinfo.ClrWay
  10351. order.Creator = order.Creator
  10352. order.Modify = roles.AdminUserId
  10353. order.RequestLog = src_resquest
  10354. setlDetail, _ := json.Marshal(res.Output.Setldetail)
  10355. detailStr := string(setlDetail)
  10356. order.SetlDetail = detailStr
  10357. err := service.UpdataOrderStatusTwo(chrg_bchno, adminUser.CurrentOrgId)
  10358. err = service.UpDateOrder(order)
  10359. if err == nil {
  10360. //判断是否使用了押金
  10361. if dec_way == "true" {
  10362. tmpstring := strconv.FormatInt(order.ID, 10)
  10363. order.Decimal = decimal
  10364. service.UpDateOrder(order)
  10365. //扣押金
  10366. errmsg = service.SpendDeposit(c.GetAdminUserInfo().CurrentOrgId, id, c.GetAdminUserInfo().AdminUser.Id, tmpstring, decimal)
  10367. if errmsg != nil {
  10368. c.ServeFailJsonSend(enums.ErrorCodeParamWrong, errmsg.Error())
  10369. return
  10370. }
  10371. }
  10372. c.ServeSuccessJSON(map[string]interface{}{
  10373. "msg": "结算成功",
  10374. })
  10375. } else {
  10376. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeAmountAccountException)
  10377. return
  10378. }
  10379. }
  10380. } else {
  10381. adminUser := c.GetAdminUserInfo()
  10382. errlog := &models.HisOrderError{
  10383. UserOrgId: adminUser.CurrentOrgId,
  10384. Ctime: time.Now().Unix(),
  10385. Mtime: time.Now().Unix(),
  10386. ErrMsg: res.ErrMsg,
  10387. Status: 1,
  10388. PatientId: id,
  10389. RecordTime: recordDateTime,
  10390. Stage: 4,
  10391. }
  10392. service.CreateErrMsgLog(errlog)
  10393. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeRegisterRepeatException)
  10394. return
  10395. }
  10396. } else {
  10397. adminUser := c.GetAdminUserInfo()
  10398. errlog := &models.HisOrderError{
  10399. UserOrgId: adminUser.CurrentOrgId,
  10400. Ctime: time.Now().Unix(),
  10401. Mtime: time.Now().Unix(),
  10402. ErrMsg: res.ErrMsg,
  10403. Status: 1,
  10404. PatientId: id,
  10405. RecordTime: recordDateTime,
  10406. Stage: 4,
  10407. }
  10408. service.CreateErrMsgLog(errlog)
  10409. c.ServeSuccessJSON(map[string]interface{}{
  10410. "failed_code": -10,
  10411. "msg": res.ErrMsg,
  10412. })
  10413. return
  10414. //c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCalOrderException)
  10415. //return
  10416. }
  10417. }
  10418. }
  10419. } else if tempOrder.ID > 0 {
  10420. if tempOrder.IsPre == 1 {
  10421. allTotal := fmt.Sprintf("%.2f", tempOrder.MedfeeSumamt)
  10422. var rf []*ResultFive
  10423. json.Unmarshal([]byte(his.Iinfo), &rf)
  10424. chrg_bchno := tempOrder.Number
  10425. cert_no := his.Certno
  10426. var insutypes []string
  10427. var insutype string
  10428. var is390 int = 0
  10429. var is310 int = 0
  10430. for _, item := range rf {
  10431. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  10432. insutypes = append(insutypes, item.Insutype)
  10433. }
  10434. }
  10435. if len(insutypes) == 1 {
  10436. insutype = insutypes[0]
  10437. } else {
  10438. for _, i := range insutypes {
  10439. if i == "390" {
  10440. is390 = 1
  10441. }
  10442. if i == "310" {
  10443. is310 = 1
  10444. }
  10445. }
  10446. }
  10447. if is390 == 1 {
  10448. insutype = "390"
  10449. }
  10450. if is310 == 1 {
  10451. insutype = "310"
  10452. }
  10453. if len(insutypes) == 0 {
  10454. insutype = "310"
  10455. }
  10456. if len(insutypes) == 2 {
  10457. insutype = strconv.FormatInt(his.SocialType, 10)
  10458. }
  10459. //insutype = "390"
  10460. if his.IdCardType == 1 {
  10461. // cert_no = his.MedicalInsuranceNumber
  10462. cert_no = his.Certno
  10463. } else {
  10464. cert_no = his.Certno
  10465. }
  10466. var res ResultSeven
  10467. var resSeven10265 ResultSeven10265
  10468. var src_resquest string
  10469. var result2 string
  10470. if miConfig.MdtrtareaAdmvs == "421300" {
  10471. api := "http://192.168.124.4:9532/" + "hbyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  10472. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  10473. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  10474. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  10475. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  10476. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  10477. "&insutype=" + insutype + "&total=" + allTotal + "&med_type=" + strconv.FormatInt(reg_type, 10) + "&acct_used_flag=" + acct_used_flag
  10478. resp, requestErr := http.Get(api)
  10479. if requestErr != nil {
  10480. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10481. return
  10482. }
  10483. body, ioErr := ioutil.ReadAll(resp.Body)
  10484. if ioErr != nil {
  10485. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  10486. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10487. return
  10488. }
  10489. var respJSON map[string]interface{}
  10490. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  10491. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  10492. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10493. return
  10494. }
  10495. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  10496. result, _ := json.Marshal(respJSON)
  10497. fmt.Println("log")
  10498. fmt.Println(string(result))
  10499. if err := json.Unmarshal([]byte(result), &res); err != nil {
  10500. utils.ErrorLog("解析失败:%v", err)
  10501. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10502. return
  10503. }
  10504. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  10505. result3101 := Check3102(c, id, his_patient_id, admin_user_id, "7", tempOrder.ID)
  10506. if result3101.Infcode == "0" {
  10507. if len(result3101.Output.Result) > 0 {
  10508. var errMsgs []string
  10509. for _, item := range result3101.Output.Result {
  10510. errMsgs = append(errMsgs, item.VolaCont)
  10511. }
  10512. c.ServeSuccessJSON(map[string]interface{}{
  10513. "failed_code": -10,
  10514. "msg": errMsgs,
  10515. })
  10516. return
  10517. } else {
  10518. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  10519. psn_info.VerifyNumber = strings.Replace(psn_info.VerifyNumber, "+", "%2B", -1)
  10520. bas := strings.Split(psn_info.CardInfo, "|")
  10521. if his.IdCardType == 1 {
  10522. cert_no = bas[2]
  10523. } else if his.IdCardType == 3 {
  10524. cert_no = his.Certno
  10525. psn_info.VerifyNumber = his.Certno + "|" + psn_info.VerifyNumber
  10526. } else if his.IdCardType == 4 {
  10527. cert_no = his.Certno
  10528. psn_info.VerifyNumber = psn_info.VerifyNumber
  10529. }
  10530. //江苏地区国家医保医疗类别
  10531. //职工透析:医疗类别选特殊情况门诊9933
  10532. //居民血透门慢: 医疗类别选门诊慢病1402
  10533. //var med_type string
  10534. //if his.Insutype == "310" {
  10535. // if reg_type == 14 {
  10536. // med_type = "9933"
  10537. // } else if reg_type == 11 {
  10538. // med_type = "11"
  10539. //
  10540. // }
  10541. //} else if his.Insutype == "390" {
  10542. // if reg_type == 14 {
  10543. // med_type = "1402"
  10544. // } else if reg_type == 11 {
  10545. // med_type = "11"
  10546. // }
  10547. //}
  10548. var api string
  10549. if miConfig.MdtrtareaAdmvs == "320921" {
  10550. api = "http://192.168.2.3:9532/" + "jsyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  10551. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  10552. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  10553. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  10554. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  10555. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  10556. "&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
  10557. //req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  10558. } else {
  10559. //req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  10560. api = "http://192.168.5.251:9532/" + "jsyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  10561. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  10562. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  10563. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  10564. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  10565. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  10566. "&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
  10567. }
  10568. resp, requestErr := http.Get(api)
  10569. if requestErr != nil {
  10570. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10571. return
  10572. }
  10573. body, ioErr := ioutil.ReadAll(resp.Body)
  10574. if ioErr != nil {
  10575. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  10576. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10577. return
  10578. }
  10579. var respJSON map[string]interface{}
  10580. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  10581. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  10582. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10583. return
  10584. }
  10585. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  10586. result, _ := json.Marshal(respJSON)
  10587. fmt.Println("log")
  10588. fmt.Println(string(result))
  10589. if err := json.Unmarshal([]byte(result), &resSeven10265); err != nil {
  10590. utils.ErrorLog("解析失败:%v", err)
  10591. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10592. return
  10593. }
  10594. res.InfRefmsgid = resSeven10265.InfRefmsgid
  10595. res.Output = resSeven10265.Output
  10596. res.ErrMsg = resSeven10265.ErrMsg
  10597. res.Cainfo = resSeven10265.Cainfo
  10598. res.WarnMsg = resSeven10265.WarnMsg
  10599. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  10600. res.Infcode = infocode
  10601. }
  10602. }
  10603. } else if miConfig.MdtrtareaAdmvs == "350500" {
  10604. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  10605. var cert_no string
  10606. if his.IdCardType == 1 {
  10607. cert_no = strings.Split(psn_info.CardInfo, "|")[0]
  10608. } else {
  10609. cert_no = psn_info.VerifyNumber
  10610. }
  10611. 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)
  10612. var dat map[string]interface{}
  10613. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  10614. fmt.Println(dat)
  10615. } else {
  10616. fmt.Println(err)
  10617. }
  10618. saveLog(result2, src_resquest, "2207", "结算")
  10619. userJSONBytes, _ := json.Marshal(dat)
  10620. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  10621. utils.ErrorLog("解析失败:%v", err)
  10622. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10623. return
  10624. }
  10625. } else if miConfig.MdtrtareaAdmvs == "360399" {
  10626. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  10627. var cert_no string
  10628. if his.IdCardType == 1 {
  10629. cert_no = strings.Split(psn_info.CardInfo, "|")[0]
  10630. } else if his.IdCardType == 2 {
  10631. cert_no = his.IdCardNo
  10632. } else {
  10633. cert_no = psn_info.VerifyNumber
  10634. }
  10635. 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, "")
  10636. var dat map[string]interface{}
  10637. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  10638. fmt.Println(dat)
  10639. } else {
  10640. fmt.Println(err)
  10641. }
  10642. saveLog(result2, src_resquest, "2207", "结算")
  10643. userJSONBytes, _ := json.Marshal(dat)
  10644. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  10645. utils.ErrorLog("解析失败:%v", err)
  10646. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10647. return
  10648. }
  10649. } else if miConfig.MdtrtareaAdmvs == "430800" {
  10650. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  10651. var cert_no string
  10652. if his.IdCardType == 1 {
  10653. cert_no = strings.Split(psn_info.CardInfo, "|")[0]
  10654. } else if his.IdCardType == 2 {
  10655. cert_no = his.IdCardNo
  10656. } else {
  10657. cert_no = psn_info.VerifyNumber
  10658. }
  10659. 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, "")
  10660. var dat map[string]interface{}
  10661. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  10662. fmt.Println(dat)
  10663. } else {
  10664. fmt.Println(err)
  10665. }
  10666. saveLog(result2, src_resquest, "2207", "结算")
  10667. userJSONBytes, _ := json.Marshal(dat)
  10668. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  10669. utils.ErrorLog("解析失败:%v", err)
  10670. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10671. return
  10672. }
  10673. } else {
  10674. var src_resquest string
  10675. if miConfig.Code == "H15049901371" {
  10676. //赤峰地区国家医保医疗类别
  10677. //职工透析:医疗类别选特殊情况门诊990502
  10678. //居民定额血透门慢: 医疗类别选门诊慢病140104
  10679. var med_type string
  10680. if his.Insutype == "390" {
  10681. if reg_type == 14 {
  10682. med_type = "9933"
  10683. } else if reg_type == 11 {
  10684. med_type = "11"
  10685. }
  10686. } else if his.Insutype == "310" {
  10687. if reg_type == 14 {
  10688. med_type = "990502"
  10689. } else if reg_type == 11 {
  10690. med_type = "11"
  10691. }
  10692. }
  10693. 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, "")
  10694. } else {
  10695. if his.IdCardType == 4 {
  10696. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  10697. token := psn_info.VerifyNumber
  10698. 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)
  10699. } else {
  10700. 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, "")
  10701. }
  10702. }
  10703. var dat map[string]interface{}
  10704. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  10705. fmt.Println(dat)
  10706. } else {
  10707. fmt.Println(err)
  10708. }
  10709. saveLog(result2, src_resquest, "2207", "结算")
  10710. userJSONBytes, _ := json.Marshal(dat)
  10711. if miConfig.Code == "H15049901371" {
  10712. if err := json.Unmarshal(userJSONBytes, &resSeven10265); err != nil {
  10713. utils.ErrorLog("解析失败:%v", err)
  10714. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10715. return
  10716. }
  10717. res.InfRefmsgid = resSeven10265.InfRefmsgid
  10718. res.Output = resSeven10265.Output
  10719. res.ErrMsg = resSeven10265.ErrMsg
  10720. res.Cainfo = resSeven10265.Cainfo
  10721. res.WarnMsg = resSeven10265.WarnMsg
  10722. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  10723. res.Infcode = infocode
  10724. } else {
  10725. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  10726. utils.ErrorLog("解析失败:%v", err)
  10727. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10728. return
  10729. }
  10730. }
  10731. }
  10732. if res.Infcode != 0 {
  10733. errlog := &models.HisOrderError{
  10734. UserOrgId: adminUser.CurrentOrgId,
  10735. Ctime: time.Now().Unix(),
  10736. Mtime: time.Now().Unix(),
  10737. Number: chrg_bchno,
  10738. ErrMsg: res.ErrMsg,
  10739. Status: 1,
  10740. PatientId: id,
  10741. RecordTime: recordDateTime,
  10742. Stage: 6,
  10743. }
  10744. service.CreateErrMsgLog(errlog)
  10745. c.ServeSuccessJSON(map[string]interface{}{
  10746. "failed_code": -10,
  10747. "msg": res.ErrMsg,
  10748. })
  10749. return
  10750. } else {
  10751. order, _ := service.GetHisOrderTwo(adminUser.CurrentOrgId, chrg_bchno, id)
  10752. order.OrderStatus = 2
  10753. order.MdtrtId = res.Output.Setlinfo.MdtrtID
  10754. order.SetlId = res.Output.Setlinfo.SetlID
  10755. order.PsnNo = res.Output.Setlinfo.PsnNo
  10756. order.PsnName = res.Output.Setlinfo.PsnName
  10757. order.PsnCertType = res.Output.Setlinfo.PsnCertType
  10758. order.Certno = res.Output.Setlinfo.Certno
  10759. order.Gend = res.Output.Setlinfo.Gend
  10760. order.Naty = res.Output.Setlinfo.Naty
  10761. order.Age = res.Output.Setlinfo.Age
  10762. order.Insutype = res.Output.Setlinfo.Insutype
  10763. order.PsnType = res.Output.Setlinfo.PsnType
  10764. order.CvlservFlag = res.Output.Setlinfo.CvlservFlag
  10765. order.SetlTime = res.Output.Setlinfo.SetlTime
  10766. order.MdtrtCertType = res.Output.Setlinfo.MdtrtCertType
  10767. order.PayWays = pay_ways
  10768. order.AcctUsedFlag = acct_used_flag
  10769. order.WechatPay = wechat_pay
  10770. order.AliPay = ali_pay
  10771. order.JifenPay = jifen_pay
  10772. order.BandCardPay = band_card_pay
  10773. order.CashPay = cash_pay
  10774. order.OthDesc = oth_desc
  10775. //order.MedType = res.Output.Setlinfo.MedType
  10776. if reg_type == 1112 {
  10777. order.MedType = "1112"
  10778. }
  10779. if reg_type == 1111 {
  10780. order.MedType = "1111"
  10781. }
  10782. order.MedfeeSumamt = res.Output.Setlinfo.MedfeeSumamt
  10783. order.FulamtOwnpayAmt = res.Output.Setlinfo.FulamtOwnpayAmt
  10784. order.OverlmtSelfPay = res.Output.Setlinfo.OverlmtSelfpay
  10785. order.PreselfpayAmt = res.Output.Setlinfo.PreselfpayAmt
  10786. order.InscpScpAmt = res.Output.Setlinfo.InscpScpAmt
  10787. order.ActPayDedc = res.Output.Setlinfo.ActPayDedc
  10788. order.HifpPay = res.Output.Setlinfo.HifpPay
  10789. order.CvlservPay = res.Output.Setlinfo.CvlservPay
  10790. order.PoolPropSelfpay = res.Output.Setlinfo.PoolPropSelfpay
  10791. order.HifesPay = res.Output.Setlinfo.HifesPay
  10792. order.HifobPay = res.Output.Setlinfo.HifobPay
  10793. order.MafPay = res.Output.Setlinfo.MafPay
  10794. order.HifmiPay = res.Output.Setlinfo.HifmiPay
  10795. order.OthPay = res.Output.Setlinfo.OthPay
  10796. order.FundPaySumamt = res.Output.Setlinfo.FundPaySumamt
  10797. order.PsnPartAmt = res.Output.Setlinfo.PsnPartAmt
  10798. order.AcctPay = res.Output.Setlinfo.AcctPay
  10799. order.PsnCashPay = res.Output.Setlinfo.PsnCashPay
  10800. order.HospPartAmt = res.Output.Setlinfo.HospPartAmt
  10801. order.Balc = res.Output.Setlinfo.Balc
  10802. order.AcctMulaidPay = res.Output.Setlinfo.AcctMulaidPay
  10803. order.MedinsSetlId = res.Output.Setlinfo.MedinsSetlID
  10804. order.ClrOptins = res.Output.Setlinfo.ClrOptins
  10805. order.ClrWay = res.Output.Setlinfo.ClrWay
  10806. order.Creator = order.Creator
  10807. order.Modify = roles.AdminUserId
  10808. order.RequestLog = src_resquest
  10809. order.Diagnosis = diagnosis_id
  10810. setlDetail, _ := json.Marshal(res.Output.Setldetail)
  10811. detailStr := string(setlDetail)
  10812. order.SetlDetail = detailStr
  10813. err := service.UpdataOrderStatusTwo(chrg_bchno, adminUser.CurrentOrgId)
  10814. err = service.UpDateOrder(order)
  10815. if err == nil {
  10816. //判断是否使用了押金
  10817. if dec_way == "true" {
  10818. tmpstring := strconv.FormatInt(order.ID, 10)
  10819. //扣押金
  10820. order.Decimal = decimal
  10821. service.UpDateOrder(order)
  10822. errmsg = service.SpendDeposit(c.GetAdminUserInfo().CurrentOrgId, id, c.GetAdminUserInfo().AdminUser.Id, tmpstring, decimal)
  10823. if errmsg != nil {
  10824. c.ServeFailJsonSend(enums.ErrorCodeParamWrong, errmsg.Error())
  10825. return
  10826. }
  10827. }
  10828. c.ServeSuccessJSON(map[string]interface{}{
  10829. "msg": "结算成功",
  10830. })
  10831. } else {
  10832. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeAmountAccountException)
  10833. return
  10834. }
  10835. }
  10836. }
  10837. }
  10838. }
  10839. //func (c *HisApiController) GetPreUploadInfo() {
  10840. // id, _ := c.GetInt64("id")
  10841. // record_time := c.GetString("record_time")
  10842. // settle_accounts_type, _ := c.GetInt64("settle_accounts_type")
  10843. // admin_user_id, _ := c.GetInt64("admin_user_id")
  10844. //
  10845. // timeLayout := "2006-01-02"
  10846. // loc, _ := time.LoadLocation("Local")
  10847. // theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  10848. // if err != nil {
  10849. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  10850. // return
  10851. // }
  10852. // recordDateTime := theTime.Unix()
  10853. // adminUser := c.GetAdminUserInfo()
  10854. //
  10855. // var prescriptions []*models.HisPrescription
  10856. //
  10857. // var start_time int64
  10858. // var end_time int64
  10859. //
  10860. // data := make(map[string]interface{})
  10861. // if settle_accounts_type == 1 { //日结
  10862. // prescriptions, _ = service.GetHisPrescription(adminUser.CurrentOrgId, id, recordDateTime)
  10863. // data["pre"] = prescriptions
  10864. //
  10865. // } else { //月结
  10866. // start_time_str := c.GetString("start_time")
  10867. // end_time_str := c.GetString("end_time")
  10868. // timeLayout := "2006-01-02"
  10869. // loc, _ := time.LoadLocation("Local")
  10870. // theStartTime, err := time.ParseInLocation(timeLayout+" 15:04:05", start_time_str+" 00:00:00", loc)
  10871. // if err != nil {
  10872. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  10873. // return
  10874. // }
  10875. // recordStartTime := theStartTime.Unix()
  10876. // start_time = recordStartTime
  10877. // theEndTime, err := time.ParseInLocation(timeLayout+" 15:04:05", end_time_str+" 00:00:00", loc)
  10878. // if err != nil {
  10879. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  10880. // return
  10881. // }
  10882. // recordEndTime := theEndTime.Unix()
  10883. // end_time = recordEndTime
  10884. // prescriptions, _ = service.GetMonthHisPrescription(adminUser.CurrentOrgId, id, recordStartTime, recordEndTime)
  10885. // data["pre"] = prescriptions
  10886. //
  10887. // }
  10888. //
  10889. // roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  10890. //
  10891. // his, _ := service.GetVMHisPatientInfo(adminUser.CurrentOrgId, id, recordDateTime)
  10892. // timestamp := time.Now().Unix()
  10893. // tempTime := time.Unix(timestamp, 0)
  10894. // timeFormat := tempTime.Format("20060102150405")
  10895. // chrgBchno := rand.Intn(100000) + 10000
  10896. // chrg_bchno := timeFormat + strconv.FormatInt(int64(chrgBchno), 10) + strconv.FormatInt(his.PatientId, 10)
  10897. // miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  10898. // patientPrescription, _ := service.FindPatientPrescriptionInfo(adminUser.CurrentOrgId, id, recordDateTime)
  10899. // department, _ := service.GetDepartMentDetail(patientPrescription.Departments)
  10900. // strconv.FormatInt(his.PatientId, 10)
  10901. // client := &http.Client{}
  10902. // data["psn_no"] = his.PsnNo
  10903. // data["mdtrt_id"] = his.Number
  10904. // data["chrg_bchno"] = chrg_bchno
  10905. // data["org_name"] = miConfig.OrgName
  10906. // data["doctor"] = roles.UserName
  10907. // data["doctor_id"] = strconv.FormatInt(roles.AdminUserId, 10)
  10908. // data["dept"] = strconv.FormatInt(patientPrescription.Departments, 10)
  10909. // data["fixmedins_code"] = miConfig.Code
  10910. // data["dept_code"] = department.Number
  10911. // data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  10912. // data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  10913. // data["secret_key"] = miConfig.SecretKey
  10914. // var ids []int64
  10915. //
  10916. // for _, item := range prescriptions {
  10917. // ids = append(ids, item.ID)
  10918. // }
  10919. // config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  10920. // if config.IsOpen == 1 { //对接了医保,走医保流程
  10921. // bytesData, _ := json.Marshal(data)
  10922. // req, _ := http.NewRequest("POST", "http://127.0.0.1:9532/"+"gdyb/five", bytes.NewReader(bytesData))
  10923. // resp, _ := client.Do(req)
  10924. // defer resp.Body.Close()
  10925. // body, ioErr := ioutil.ReadAll(resp.Body)
  10926. // if ioErr != nil {
  10927. // utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  10928. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10929. // return
  10930. // }
  10931. // var respJSON map[string]interface{}
  10932. // if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  10933. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  10934. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10935. // return
  10936. // }
  10937. //
  10938. // respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  10939. // userJSONBytes, _ := json.Marshal(respJSON)
  10940. // var res ResultFour
  10941. // if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  10942. // utils.ErrorLog("解析失败:%v", err)
  10943. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10944. // return
  10945. // }
  10946. //
  10947. // if res.Infcode == 0 {
  10948. // order := &models.HisOrder{
  10949. // UserOrgId: adminUser.CurrentOrgId,
  10950. // HisPatientId: his.ID,
  10951. // PatientId: his.PatientId,
  10952. // SettleAccountsDate: recordDateTime,
  10953. // Ctime: time.Now().Unix(),
  10954. // Mtime: time.Now().Unix(),
  10955. // Status: 1,
  10956. // Number: chrg_bchno,
  10957. // Infcode: res.Infcode,
  10958. // WarnMsg: res.WarnMsg,
  10959. // Cainfo: res.Cainfo,
  10960. // ErrMsg: res.ErrMsg,
  10961. // RespondTime: res.RefmsgTime,
  10962. // InfRefmsgid: res.InfRefmsgid,
  10963. // OrderStatus: 1,
  10964. // IsMedicineInsurance: 1,
  10965. // SettleType: settle_accounts_type,
  10966. // SettleStartTime: start_time,
  10967. // SettleEndTime: end_time,
  10968. // Creator: roles.ID,
  10969. // Modify: roles.ID,
  10970. // PType: 2,
  10971. // }
  10972. // err = service.CreateOrder(order)
  10973. // if err != nil {
  10974. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCreatePreOrderException)
  10975. // return
  10976. // }
  10977. //
  10978. // for _, item := range res.Output.Result {
  10979. // temp := strings.Split(item.FeedetlSn, "-")
  10980. // var advice_id int64 = 0
  10981. // var project_id int64 = 0
  10982. // var types int64 = 0
  10983. //
  10984. // id, _ := strconv.ParseInt(temp[2], 10, 64)
  10985. // types, _ = strconv.ParseInt(temp[1], 10, 64)
  10986. //
  10987. // if temp[1] == "1" {
  10988. // advice_id = id
  10989. // project_id = 0
  10990. // } else if temp[1] == "2" {
  10991. // advice_id = 0
  10992. // project_id = id
  10993. // }
  10994. //
  10995. // info := &models.HisOrderInfo{
  10996. // OrderNumber: order.Number,
  10997. // FeedetlSn: item.FeedetlSn,
  10998. // UploadDate: time.Now().Unix(),
  10999. // AdviceId: advice_id,
  11000. // DetItemFeeSumamt: item.DetItemFeeSumamt,
  11001. // Cnt: item.Cnt,
  11002. // Pric: float64(item.Pric),
  11003. // PatientId: his.PatientId,
  11004. // PricUplmtAmt: item.PricUplmtAmt,
  11005. // SelfpayProp: item.SelfpayProp,
  11006. // FulamtOwnpayAmt: item.FulamtOwnpayAmt,
  11007. // OverlmtAmt: item.OverlmtAmt,
  11008. // PreselfpayAmt: item.PreselfpayAmt,
  11009. // BasMednFlag: item.BasMednFlag,
  11010. // MedChrgitmType: item.MedChrgitmType,
  11011. // HiNegoDrugFlag: item.HiNegoDrugFlag,
  11012. // Status: 1,
  11013. // Memo: item.Memo,
  11014. // Mtime: time.Now().Unix(),
  11015. // InscpScpAmt: item.InscpScpAmt,
  11016. // DrtReimFlag: item.DrtReimFlag,
  11017. // Ctime: time.Now().Unix(),
  11018. // ListSpItemFlag: item.ListSpItemFlag,
  11019. // ChldMedcFlag: item.ChldMedcFlag,
  11020. // LmtUsedFlag: item.LmtUsedFlag,
  11021. // ChrgitmLv: item.ChrgitmLv,
  11022. // UserOrgId: adminUser.CurrentOrgId,
  11023. // HisPatientId: his.ID,
  11024. // OrderId: order.ID,
  11025. // ProjectId: project_id,
  11026. // Type: types,
  11027. // }
  11028. // service.CreateOrderInfo(info)
  11029. //
  11030. // }
  11031. // service.UpDatePrescriptionNumber(adminUser.CurrentOrgId, ids, chrg_bchno)
  11032. // service.UpDatePrescriptionInfoNumber(adminUser.CurrentOrgId, patientPrescription.PatientId, chrg_bchno, recordDateTime)
  11033. //
  11034. // var total float64
  11035. // for _, item := range prescriptions {
  11036. // if item.Type == 1 { //药品
  11037. // for _, subItem := range item.HisDoctorAdviceInfo {
  11038. // total = total + (subItem.Price * subItem.PrescribingNumber)
  11039. // }
  11040. // }
  11041. // if item.Type == 2 { //项目
  11042. // for _, subItem := range item.HisPrescriptionProject {
  11043. // total = total + (subItem.Price * float64(subItem.Count))
  11044. // }
  11045. // }
  11046. // }
  11047. //
  11048. // for _, item := range prescriptions {
  11049. // for _, subItem := range item.HisAdditionalCharge {
  11050. // total = total + (subItem.Price * float64(subItem.Count))
  11051. // }
  11052. // }
  11053. //
  11054. // allTotal := fmt.Sprintf("%.2f", total)
  11055. // if res.Infcode == 0 {
  11056. // var rf []*ResultFive
  11057. // json.Unmarshal([]byte(his.Iinfo), &rf)
  11058. // psn_no := his.PsnNo
  11059. // mdtrt_id := his.Number
  11060. // chrg_bchno := chrg_bchno
  11061. // cert_no := his.Certno
  11062. // insutype := rf[0].Insutype
  11063. //
  11064. // if his.IdCardType == 1 {
  11065. // cert_no = his.MedicalInsuranceNumber
  11066. //
  11067. // } else {
  11068. //
  11069. // cert_no = his.Certno
  11070. //
  11071. // }
  11072. //
  11073. // api := "http://127.0.0.1:9532/" + "gdyb/seven?cert_no=" + cert_no + "&insutype=" +
  11074. // insutype + "&psn_no=" + psn_no + "&chrg_bchno=" + chrg_bchno + "&mdtrt_id=" + mdtrt_id +
  11075. // "&total=" + allTotal + "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code + "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" +
  11076. // miConfig.SecretKey + "&med_type=" + strconv.FormatInt(patientPrescription.RegisterType, 10) + "&id_card_type=" + strconv.FormatInt(int64(his.IdCardType), 10)
  11077. // resp, requestErr := http.Get(api)
  11078. // if requestErr != nil {
  11079. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11080. // return
  11081. // }
  11082. // defer resp.Body.Close()
  11083. // body, ioErr := ioutil.ReadAll(resp.Body)
  11084. // if ioErr != nil {
  11085. // utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  11086. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11087. // return
  11088. // }
  11089. // var respJSON map[string]interface{}
  11090. // if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  11091. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  11092. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11093. // return
  11094. // }
  11095. // fmt.Println(respJSON)
  11096. // respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  11097. // userJSONBytes, _ := json.Marshal(respJSON)
  11098. // var res ResultSeven
  11099. // if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  11100. // utils.ErrorLog("解析失败:%v", err)
  11101. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11102. // return
  11103. // }
  11104. // if res.Infcode != 0 {
  11105. // errlog := &models.HisOrderError{
  11106. // UserOrgId: adminUser.CurrentOrgId,
  11107. // Ctime: time.Now().Unix(),
  11108. // Mtime: time.Now().Unix(),
  11109. // Number: chrg_bchno,
  11110. // ErrMsg: res.ErrMsg,
  11111. // Status: 1,
  11112. // PatientId: id,
  11113. // RecordTime: recordDateTime,
  11114. // Stage: 7,
  11115. // }
  11116. // service.CreateErrMsgLog(errlog)
  11117. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeRegisterRepeatException)
  11118. // return
  11119. // } else {
  11120. // order, _ := service.GetHisOrderTwo(adminUser.CurrentOrgId, chrg_bchno, id)
  11121. // order.OrderStatus = 1
  11122. // order.MdtrtId = res.Output.Setlinfo.MdtrtID
  11123. // order.SetlId = res.Output.Setlinfo.SetlID
  11124. // order.PsnNo = res.Output.Setlinfo.PsnNo
  11125. // order.PsnName = res.Output.Setlinfo.PsnName
  11126. // order.PsnCertType = res.Output.Setlinfo.PsnCertType
  11127. // order.Certno = res.Output.Setlinfo.Certno
  11128. // order.Gend = res.Output.Setlinfo.Gend
  11129. // order.Naty = res.Output.Setlinfo.Naty
  11130. // order.Age = res.Output.Setlinfo.Age
  11131. // order.Insutype = res.Output.Setlinfo.Insutype
  11132. // order.PsnType = res.Output.Setlinfo.PsnType
  11133. // order.CvlservFlag = res.Output.Setlinfo.CvlservFlag
  11134. // order.SetlTime = res.Output.Setlinfo.SetlTime
  11135. // order.MdtrtCertType = res.Output.Setlinfo.MdtrtCertType
  11136. // order.MedType = res.Output.Setlinfo.MedType
  11137. // order.MedfeeSumamt = res.Output.Setlinfo.MedfeeSumamt
  11138. // order.FulamtOwnpayAmt = res.Output.Setlinfo.FulamtOwnpayAmt
  11139. // order.OverlmtSelfPay = res.Output.Setlinfo.OverlmtSelfpay
  11140. // order.PreselfpayAmt = res.Output.Setlinfo.PreselfpayAmt
  11141. // order.InscpScpAmt = res.Output.Setlinfo.InscpScpAmt
  11142. // order.ActPayDedc = res.Output.Setlinfo.ActPayDedc
  11143. // order.HifpPay = res.Output.Setlinfo.HifpPay
  11144. // order.CvlservPay = res.Output.Setlinfo.CvlservPay
  11145. // order.PoolPropSelfpay = res.Output.Setlinfo.PoolPropSelfpay
  11146. // order.HifesPay = res.Output.Setlinfo.HifesPay
  11147. // order.HifobPay = res.Output.Setlinfo.HifobPay
  11148. // order.MafPay = res.Output.Setlinfo.MafPay
  11149. // order.OthPay = res.Output.Setlinfo.OthPay
  11150. // order.FundPaySumamt = res.Output.Setlinfo.FundPaySumamt
  11151. // order.PsnPartAmt = res.Output.Setlinfo.PsnPartAmt
  11152. // order.AcctPay = res.Output.Setlinfo.AcctPay
  11153. // order.PsnCashPay = res.Output.Setlinfo.PsnCashPay
  11154. // order.HospPartAmt = res.Output.Setlinfo.HospPartAmt
  11155. // order.Balc = res.Output.Setlinfo.Balc
  11156. // order.AcctMulaidPay = res.Output.Setlinfo.AcctMulaidPay
  11157. // order.MedinsSetlId = res.Output.Setlinfo.MedinsSetlID
  11158. // order.ClrOptins = res.Output.Setlinfo.ClrOptins
  11159. // order.ClrWay = res.Output.Setlinfo.ClrWay
  11160. // order.Creator = order.Creator
  11161. // order.Modify = roles.ID
  11162. // setlDetail, _ := json.Marshal(res.Output.Setldetail)
  11163. // detailStr := string(setlDetail)
  11164. // order.SetlDetail = detailStr
  11165. // //err := service.UpdataOrderStatusTwo(chrg_bchno, adminUser.CurrentOrgId)
  11166. // err = service.UpDateOrder(order)
  11167. // if err == nil {
  11168. // c.ServeSuccessJSON(map[string]interface{}{
  11169. // "msg": "预结算成功",
  11170. // })
  11171. // } else {
  11172. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeAmountAccountException)
  11173. // return
  11174. // }
  11175. // }
  11176. // } else {
  11177. // adminUser := c.GetAdminUserInfo()
  11178. // errlog := &models.HisOrderError{
  11179. // UserOrgId: adminUser.CurrentOrgId,
  11180. // Ctime: time.Now().Unix(),
  11181. // Mtime: time.Now().Unix(),
  11182. // ErrMsg: res.ErrMsg,
  11183. // Status: 1,
  11184. // PatientId: id,
  11185. // RecordTime: recordDateTime,
  11186. // Stage: 4,
  11187. // }
  11188. // service.CreateErrMsgLog(errlog)
  11189. //
  11190. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeRegisterRepeatException)
  11191. // return
  11192. // }
  11193. // } else {
  11194. // adminUser := c.GetAdminUserInfo()
  11195. // errlog := &models.HisOrderError{
  11196. // UserOrgId: adminUser.CurrentOrgId,
  11197. // Ctime: time.Now().Unix(),
  11198. // Mtime: time.Now().Unix(),
  11199. // ErrMsg: res.ErrMsg,
  11200. // Status: 1,
  11201. // PatientId: id,
  11202. // RecordTime: recordDateTime,
  11203. // Stage: 4,
  11204. // }
  11205. // service.CreateErrMsgLog(errlog)
  11206. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCalOrderException)
  11207. // return
  11208. // }
  11209. //
  11210. // } else {
  11211. // var total float64
  11212. // for _, item := range prescriptions {
  11213. // if item.Type == 1 { //药品
  11214. // for _, subItem := range item.HisDoctorAdviceInfo {
  11215. // total = total + (subItem.Price * subItem.PrescribingNumber)
  11216. // }
  11217. // }
  11218. // if item.Type == 2 { //项目
  11219. // for _, subItem := range item.HisPrescriptionProject {
  11220. // total = total + (subItem.Price * float64(subItem.Count))
  11221. // }
  11222. // }
  11223. //
  11224. // for _, subItem := range item.HisAdditionalCharge {
  11225. // total = total + (subItem.Price * float64(subItem.Count))
  11226. // }
  11227. // }
  11228. //
  11229. // allTotal := fmt.Sprintf("%.2f", total)
  11230. // totals, _ := strconv.ParseFloat(allTotal, 64)
  11231. // order := &models.HisOrder{
  11232. // UserOrgId: adminUser.CurrentOrgId,
  11233. // HisPatientId: his.ID,
  11234. // PatientId: id,
  11235. // SettleAccountsDate: recordDateTime,
  11236. // Ctime: time.Now().Unix(),
  11237. // Mtime: time.Now().Unix(),
  11238. // Status: 1,
  11239. // OrderStatus: 2,
  11240. // Number: chrg_bchno,
  11241. // MedfeeSumamt: totals,
  11242. // }
  11243. // err = service.CreateOrder(order)
  11244. // if err != nil {
  11245. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCreatePreOrderException)
  11246. // return
  11247. // }
  11248. //
  11249. // var customs []*Custom
  11250. // for _, item := range prescriptions {
  11251. //
  11252. // if item.Type == 1 { //药品
  11253. // for _, subItem := range item.HisDoctorAdviceInfo {
  11254. // cus := &Custom{
  11255. // AdviceId: subItem.ID,
  11256. // ProjectId: 0,
  11257. // DetItemFeeSumamt: fmt.Sprintf("%.2f", subItem.Price*subItem.PrescribingNumber),
  11258. // Cut: fmt.Sprintf("%.2f", subItem.PrescribingNumber),
  11259. // FeedetlSn: subItem.FeedetlSn,
  11260. // Price: fmt.Sprintf("%.2f", subItem.Price),
  11261. // MedListCodg: subItem.MedListCodg,
  11262. // Type: 1,
  11263. // }
  11264. // customs = append(customs, cus)
  11265. // }
  11266. // }
  11267. //
  11268. // if item.Type == 2 { //项目
  11269. // for _, subItem := range item.HisPrescriptionProject {
  11270. //
  11271. // cus := &Custom{
  11272. // AdviceId: 0,
  11273. // ProjectId: subItem.ID,
  11274. // DetItemFeeSumamt: fmt.Sprintf("%.2f", subItem.Price*float64(subItem.Count)),
  11275. // Cut: fmt.Sprintf("%.2f", float64(subItem.Count)),
  11276. // FeedetlSn: subItem.FeedetlSn,
  11277. // Price: fmt.Sprintf("%.2f", float64(subItem.Price)),
  11278. // MedListCodg: subItem.MedListCodg,
  11279. // Type: 2,
  11280. // }
  11281. //
  11282. // customs = append(customs, cus)
  11283. // }
  11284. // }
  11285. //
  11286. // for _, item := range item.HisAdditionalCharge {
  11287. // cus := &Custom{
  11288. // ItemId: item.ID,
  11289. // AdviceId: 0,
  11290. // ProjectId: 0,
  11291. // DetItemFeeSumamt: fmt.Sprintf("%.2f", item.Price),
  11292. // Cut: fmt.Sprintf("%.2f", float64(item.Count)),
  11293. // FeedetlSn: item.FeedetlSn,
  11294. // Price: fmt.Sprintf("%.2f", float64(item.Price)),
  11295. // MedListCodg: item.XtHisAddtionConfig.Code,
  11296. // Type: 3,
  11297. // }
  11298. //
  11299. // customs = append(customs, cus)
  11300. // }
  11301. //
  11302. // }
  11303. //
  11304. // for _, item := range customs {
  11305. // var advice_id int64 = 0
  11306. // var project_id int64 = 0
  11307. // var item_id int64 = 0
  11308. //
  11309. // var types int64 = 0
  11310. //
  11311. // if item.Type == 1 {
  11312. // advice_id = item.AdviceId
  11313. // project_id = 0
  11314. // item_id = 0
  11315. // } else if item.Type == 2 {
  11316. // advice_id = 0
  11317. // item_id = 0
  11318. //
  11319. // project_id = item.ProjectId
  11320. // } else if item.Type == 3 {
  11321. // advice_id = 0
  11322. // item_id = item.ItemId
  11323. // project_id = 0
  11324. // }
  11325. //
  11326. // detItemFeeSumamt, _ := strconv.ParseFloat(item.DetItemFeeSumamt, 32)
  11327. // cut, _ := strconv.ParseFloat(item.Cut, 32)
  11328. // pric, _ := strconv.ParseFloat(item.Price, 32)
  11329. //
  11330. // info := &models.HisOrderInfo{
  11331. // OrderNumber: order.Number,
  11332. // UploadDate: time.Now().Unix(),
  11333. // AdviceId: advice_id,
  11334. // DetItemFeeSumamt: detItemFeeSumamt,
  11335. // Cnt: cut,
  11336. // Pric: pric,
  11337. // PatientId: id,
  11338. // Status: 1,
  11339. // Mtime: time.Now().Unix(),
  11340. // Ctime: time.Now().Unix(),
  11341. // UserOrgId: adminUser.CurrentOrgId,
  11342. // HisPatientId: his.ID,
  11343. // OrderId: order.ID,
  11344. // ProjectId: project_id,
  11345. // Type: types,
  11346. // ItemId: item_id,
  11347. // }
  11348. // service.CreateOrderInfo(info)
  11349. // }
  11350. // //err := service.UpDateAddtionNumber(adminUser.CurrentOrgId, ids, chrg_bchno)
  11351. // err = service.UpDatePrescriptionNumber(adminUser.CurrentOrgId, ids, chrg_bchno)
  11352. // err = service.UpDatePrescriptionInfoNumber(adminUser.CurrentOrgId, id, chrg_bchno, recordDateTime)
  11353. // err = service.UpdataOrderStatusTwo(chrg_bchno, adminUser.CurrentOrgId)
  11354. // if err == nil {
  11355. // c.ServeSuccessJSON(map[string]interface{}{
  11356. // "msg": "结算成功",
  11357. // })
  11358. // } else {
  11359. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeAmountAccountException)
  11360. // return
  11361. // }
  11362. // }
  11363. //}
  11364. // 上传明细-预结算-
  11365. func (c *HisApiController) GetPreUploadInfo() {
  11366. id, _ := c.GetInt64("id")
  11367. record_time := c.GetString("record_time")
  11368. his_patient_id, _ := c.GetInt64("his_patient_id")
  11369. settle_accounts_type, _ := c.GetInt64("settle_accounts_type")
  11370. admin_user_id, _ := c.GetInt64("admin_user_id")
  11371. diagnosis_id := c.GetString("diagnosis")
  11372. sick_type, _ := c.GetInt64("sick_type")
  11373. reg_type, _ := c.GetInt64("p_type")
  11374. begin_time := c.GetString("begin_time")
  11375. acct_used_flag := c.GetString("acct_used_flag")
  11376. id_str := c.GetString("ids")
  11377. ids_arr := strings.Split(id_str, ",")
  11378. timeLayout := "2006-01-02"
  11379. loc, _ := time.LoadLocation("Local")
  11380. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  11381. if err != nil {
  11382. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  11383. return
  11384. }
  11385. recordDateTime := theTime.Unix()
  11386. adminUser := c.GetAdminUserInfo()
  11387. diagnosis_ids := strings.Split(diagnosis_id, ",")
  11388. var config []*models.HisXtDiagnoseConfig
  11389. for _, item := range diagnosis_ids {
  11390. id, _ := strconv.ParseInt(item, 10, 64)
  11391. diagnosisConfig, _ := service.FindDiagnoseById(id)
  11392. config = append(config, &diagnosisConfig)
  11393. }
  11394. //diagnosisConfig, _ := service.FindDiagnoseById(diagnosis_id)
  11395. sickConfig, _ := service.FindSickById(sick_type)
  11396. var prescriptions []*models.HisPrescription
  11397. var start_time int64
  11398. var end_time int64
  11399. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  11400. fmt.Println(his_patient_id)
  11401. his, _ := service.GetNewHisPatientInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  11402. timestamp := time.Now().Unix()
  11403. tempTime := time.Unix(timestamp, 0)
  11404. timeFormat := tempTime.Format("20060102150405")
  11405. chrgBchno := rand.Intn(100000) + 10000
  11406. chrg_bchno := timeFormat + strconv.FormatInt(int64(chrgBchno), 10) + strconv.FormatInt(his.PatientId, 10)
  11407. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  11408. var patientPrescription models.HisPrescriptionInfo
  11409. patientPrescription, _ = service.FindHisPatientPrescriptionInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  11410. if patientPrescription.ID == 0 {
  11411. patientPrescription, _ = service.FindLastPatientPrescriptionInfo(adminUser.CurrentOrgId, id, recordDateTime)
  11412. }
  11413. //miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  11414. department, _ := service.GetDepartMentDetail(patientPrescription.Departments)
  11415. doctor_info, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, patientPrescription.DoctorId)
  11416. strconv.FormatInt(his.PatientId, 10)
  11417. var res2 ResultSix
  11418. var resSix10265 ResultSix10265
  11419. //var time_stamp string
  11420. if miConfig.MdtrtareaAdmvs == "421300" {
  11421. data := make(map[string]interface{})
  11422. client := &http.Client{}
  11423. data["psn_no"] = his.PsnNo
  11424. data["mdtrt_id"] = his.Number
  11425. data["department"] = department.Name
  11426. data["org_name"] = miConfig.OrgName
  11427. data["med_type"] = strconv.FormatInt(reg_type, 10)
  11428. data["doctor_id"] = doctor_info.DoctorNumber
  11429. data["doctor_name"] = roles.UserName
  11430. data["fixmedins_code"] = miConfig.Code
  11431. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  11432. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  11433. data["secret_key"] = miConfig.SecretKey
  11434. data["sick_code"] = sickConfig.CountryCode
  11435. data["sick_name"] = sickConfig.ClassName
  11436. data["begin_time"] = begin_time
  11437. data["dept"] = strconv.FormatInt(department.ID, 10)
  11438. data["config"] = config
  11439. data["opter"] = roles.UserName
  11440. fmt.Println(data)
  11441. bytesData, _ := json.Marshal(data)
  11442. req, _ := http.NewRequest("POST", "http://192.168.124.4:9532/"+"hbyb/2203", bytes.NewReader(bytesData))
  11443. resp, _ := client.Do(req)
  11444. defer resp.Body.Close()
  11445. body, ioErr := ioutil.ReadAll(resp.Body)
  11446. if ioErr != nil {
  11447. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  11448. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11449. return
  11450. }
  11451. var respJSON map[string]interface{}
  11452. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  11453. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  11454. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11455. return
  11456. }
  11457. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  11458. userJSONBytes, _ := json.Marshal(respJSON)
  11459. fmt.Println("log")
  11460. fmt.Println(string(userJSONBytes))
  11461. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  11462. utils.ErrorLog("解析失败:%v", err)
  11463. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11464. return
  11465. }
  11466. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  11467. data := make(map[string]interface{})
  11468. client := &http.Client{}
  11469. data["psn_no"] = his.PsnNo
  11470. data["mdtrt_id"] = his.Number
  11471. data["doctor"] = roles.UserName
  11472. data["department"] = department.Name
  11473. data["org_name"] = miConfig.OrgName
  11474. data["med_type"] = strconv.FormatInt(reg_type, 10)
  11475. data["doctor_id"] = strconv.FormatInt(doctor_info.AdminUserId, 10)
  11476. data["fixmedins_code"] = miConfig.Code
  11477. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  11478. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  11479. data["secret_key"] = miConfig.SecretKey
  11480. data["sick_code"] = sickConfig.CountryCode
  11481. data["sick_name"] = sickConfig.ClassName
  11482. data["begin_time"] = begin_time
  11483. data["dept"] = strconv.FormatInt(department.ID, 10)
  11484. data["config"] = config
  11485. data["url"] = miConfig.Url
  11486. data["ak"] = miConfig.AccessKey
  11487. data["cainfo"] = miConfig.Cainfo
  11488. bytesData, _ := json.Marshal(data)
  11489. var req *http.Request
  11490. if miConfig.MdtrtareaAdmvs == "320921" {
  11491. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/2203", bytes.NewReader(bytesData))
  11492. } else {
  11493. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2203", bytes.NewReader(bytesData))
  11494. }
  11495. resp, _ := client.Do(req)
  11496. defer resp.Body.Close()
  11497. body, ioErr := ioutil.ReadAll(resp.Body)
  11498. if ioErr != nil {
  11499. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  11500. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11501. return
  11502. }
  11503. var respJSON map[string]interface{}
  11504. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  11505. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  11506. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11507. return
  11508. }
  11509. //time_stamp := strconv.FormatInt(int64(respJSON["data"].(map[string]interface{})["time_stamp"].(float64)), 10)
  11510. //fmt.Println(respJSON["data"].(map[string]interface{})["time_stamp"].(string))
  11511. //time_stamp = respJSON["data"].(map[string]interface{})["time_stamp"].(string)
  11512. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  11513. userJSONBytes, _ := json.Marshal(respJSON)
  11514. fmt.Println("log")
  11515. fmt.Println(string(userJSONBytes))
  11516. if err := json.Unmarshal(userJSONBytes, &resSix10265); err != nil {
  11517. utils.ErrorLog("解析失败:%v", err)
  11518. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11519. return
  11520. }
  11521. res2.InfRefmsgid = resSix10265.InfRefmsgid
  11522. res2.Output = resSix10265.Output
  11523. res2.ErrMsg = resSix10265.ErrMsg
  11524. res2.Cainfo = resSix10265.Cainfo
  11525. res2.WarnMsg = resSix10265.WarnMsg
  11526. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  11527. res2.Infcode = infocode
  11528. } else if miConfig.MdtrtareaAdmvs == "350500" {
  11529. 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)
  11530. saveLog(result, requestLog, "2203", "上传就诊信息")
  11531. var respJSON2 map[string]interface{}
  11532. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  11533. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  11534. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11535. return
  11536. }
  11537. userJSONBytes2, _ := json.Marshal(respJSON2)
  11538. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  11539. utils.ErrorLog("解析失败:%v", err)
  11540. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11541. return
  11542. }
  11543. } else if miConfig.MdtrtareaAdmvs == "360399" {
  11544. var result string
  11545. var requestLog string
  11546. 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, "")
  11547. saveLog(result, requestLog, "2203", "上传就诊信息")
  11548. var respJSON2 map[string]interface{}
  11549. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  11550. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  11551. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11552. return
  11553. }
  11554. userJSONBytes2, _ := json.Marshal(respJSON2)
  11555. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  11556. utils.ErrorLog("解析失败:%v", err)
  11557. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11558. return
  11559. }
  11560. } else if miConfig.MdtrtareaAdmvs == "430800" {
  11561. var result string
  11562. var requestLog string
  11563. 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, "")
  11564. saveLog(result, requestLog, "2203", "上传就诊信息")
  11565. var respJSON2 map[string]interface{}
  11566. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  11567. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  11568. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11569. return
  11570. }
  11571. userJSONBytes2, _ := json.Marshal(respJSON2)
  11572. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  11573. utils.ErrorLog("解析失败:%v", err)
  11574. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11575. return
  11576. }
  11577. } else {
  11578. var result string
  11579. var requestLog string
  11580. if miConfig.MdtrtareaAdmvs == "440781" { //
  11581. 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)
  11582. } else {
  11583. if miConfig.Code == "H15049901371" {
  11584. //赤峰地区国家医保医疗类别
  11585. //职工透析:医疗类别选特殊情况门诊990502
  11586. //居民定额血透门慢: 医疗类别选门诊慢病140104
  11587. var med_type string
  11588. if his.Insutype == "390" {
  11589. if reg_type == 14 {
  11590. med_type = "9933"
  11591. } else if reg_type == 11 {
  11592. med_type = "11"
  11593. }
  11594. } else if his.Insutype == "310" {
  11595. if reg_type == 14 {
  11596. med_type = "990502"
  11597. } else if reg_type == 11 {
  11598. med_type = "11"
  11599. }
  11600. }
  11601. 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)
  11602. } else {
  11603. 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)
  11604. }
  11605. saveLog(result, requestLog, "2203", "上传就诊信息")
  11606. var respJSON2 map[string]interface{}
  11607. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  11608. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  11609. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11610. return
  11611. }
  11612. userJSONBytes2, _ := json.Marshal(respJSON2)
  11613. if miConfig.Code == "H15049901371" {
  11614. if err := json.Unmarshal(userJSONBytes2, &resSix10265); err != nil {
  11615. utils.ErrorLog("解析失败:%v", err)
  11616. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11617. return
  11618. }
  11619. res2.InfRefmsgid = resSix10265.InfRefmsgid
  11620. res2.Output = resSix10265.Output
  11621. res2.ErrMsg = resSix10265.ErrMsg
  11622. res2.Cainfo = resSix10265.Cainfo
  11623. res2.WarnMsg = resSix10265.WarnMsg
  11624. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  11625. res2.Infcode = infocode
  11626. } else {
  11627. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  11628. utils.ErrorLog("解析失败:%v", err)
  11629. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11630. return
  11631. }
  11632. }
  11633. }
  11634. }
  11635. if res2.Infcode != 0 {
  11636. adminUser := c.GetAdminUserInfo()
  11637. errlog := &models.HisOrderError{
  11638. UserOrgId: adminUser.CurrentOrgId,
  11639. Ctime: time.Now().Unix(),
  11640. Mtime: time.Now().Unix(),
  11641. ErrMsg: res2.ErrMsg,
  11642. Status: 1,
  11643. PatientId: id,
  11644. RecordTime: recordDateTime,
  11645. Stage: 3,
  11646. }
  11647. service.CreateErrMsgLog(errlog)
  11648. c.ServeSuccessJSON(map[string]interface{}{
  11649. "failed_code": -10,
  11650. "msg": res2.ErrMsg,
  11651. })
  11652. return
  11653. } else {
  11654. his.Diagnosis = diagnosis_id
  11655. his.SickType = sickConfig.ID
  11656. his.PType = fmt.Sprintf("%d", reg_type)
  11657. service.UpdateHisPatientThree(&his)
  11658. data := make(map[string]interface{})
  11659. if settle_accounts_type == 1 { //日结
  11660. if reg_type == 11 || reg_type == 1111 || reg_type == 1112 {
  11661. prescriptions, _ = service.GetPrescriptionByIds(ids_arr, adminUser.CurrentOrgId)
  11662. } else {
  11663. prescriptions, _ = service.GetNewHisPrescription(adminUser.CurrentOrgId, his_patient_id, recordDateTime, strconv.Itoa(int(reg_type)))
  11664. }
  11665. data["pre"] = prescriptions
  11666. } else { //月结
  11667. start_time_str := c.GetString("start_time")
  11668. end_time_str := c.GetString("end_time")
  11669. timeLayout := "2006-01-02"
  11670. loc, _ := time.LoadLocation("Local")
  11671. theStartTime, err := time.ParseInLocation(timeLayout+" 15:04:05", start_time_str+" 00:00:00", loc)
  11672. if err != nil {
  11673. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  11674. return
  11675. }
  11676. recordStartTime := theStartTime.Unix()
  11677. start_time = recordStartTime
  11678. theEndTime, err := time.ParseInLocation(timeLayout+" 15:04:05", end_time_str+" 00:00:00", loc)
  11679. if err != nil {
  11680. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  11681. return
  11682. }
  11683. recordEndTime := theEndTime.Unix()
  11684. end_time = recordEndTime
  11685. prescriptions, _ = service.GetMonthHisPrescriptionTwo(adminUser.CurrentOrgId, id, recordStartTime, recordEndTime, reg_type)
  11686. data["pre"] = prescriptions
  11687. }
  11688. client := &http.Client{}
  11689. data["psn_no"] = his.PsnNo
  11690. data["mdtrt_id"] = his.Number
  11691. data["chrg_bchno"] = chrg_bchno
  11692. data["org_name"] = miConfig.OrgName
  11693. data["doctor"] = doctor_info.UserName
  11694. data["doctor_id"] = doctor_info.DoctorNumber
  11695. data["dept"] = department.Name
  11696. data["fixmedins_code"] = miConfig.Code
  11697. data["opter"] = roles.UserName
  11698. data["dept_code"] = department.Number
  11699. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  11700. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  11701. data["secret_key"] = miConfig.SecretKey
  11702. data["balance_accounts_type"] = strconv.FormatInt(his.BalanceAccountsType, 10)
  11703. data["url"] = miConfig.Url
  11704. data["ak"] = miConfig.AccessKey
  11705. data["new_doctor_name"] = patientPrescription.Doctor
  11706. data["diag_code"] = sickConfig.CountryCode
  11707. data["cainfo"] = miConfig.Cainfo
  11708. data["opter"] = roles.UserName
  11709. var ids []int64
  11710. for _, item := range prescriptions {
  11711. ids = append(ids, item.ID)
  11712. }
  11713. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  11714. if config.IsOpen == 1 { //对接了医保,走医保流程
  11715. var res ResultFour
  11716. var resFour10265 ResultFour10265
  11717. if miConfig.MdtrtareaAdmvs == "421300" {
  11718. bytesData, _ := json.Marshal(data)
  11719. req, _ := http.NewRequest("POST", "http://192.168.124.4:9532/"+"hbyb/2204", bytes.NewReader(bytesData))
  11720. resp, _ := client.Do(req)
  11721. defer resp.Body.Close()
  11722. body, ioErr := ioutil.ReadAll(resp.Body)
  11723. if ioErr != nil {
  11724. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  11725. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11726. return
  11727. }
  11728. var respJSON map[string]interface{}
  11729. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  11730. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  11731. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11732. return
  11733. }
  11734. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  11735. userJSONBytes, _ := json.Marshal(respJSON)
  11736. fmt.Println("log")
  11737. fmt.Println(string(userJSONBytes))
  11738. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  11739. utils.ErrorLog("解析失败:%v", err)
  11740. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11741. return
  11742. }
  11743. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  11744. result3101 := Check3101(c, id, his_patient_id, admin_user_id, "2", record_time, prescriptions)
  11745. if result3101.Infcode == "0" {
  11746. if len(result3101.Output.Result) > 0 {
  11747. var errMsgs []string
  11748. for _, item := range result3101.Output.Result {
  11749. errMsgs = append(errMsgs, item.VolaCont)
  11750. }
  11751. c.ServeSuccessJSON(map[string]interface{}{
  11752. "failed_code": -10,
  11753. "msg": errMsgs,
  11754. })
  11755. return
  11756. } else {
  11757. if miConfig.MdtrtareaAdmvs == "320921" {
  11758. data["doctor_id"] = "D320923012139"
  11759. } else {
  11760. data["doctor_id"] = "D371621008686"
  11761. }
  11762. bytesData, _ := json.Marshal(data)
  11763. var req *http.Request
  11764. if miConfig.MdtrtareaAdmvs == "320921" {
  11765. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  11766. } else {
  11767. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  11768. }
  11769. resp, _ := client.Do(req)
  11770. defer resp.Body.Close()
  11771. body, ioErr := ioutil.ReadAll(resp.Body)
  11772. if ioErr != nil {
  11773. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  11774. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11775. return
  11776. }
  11777. var respJSON map[string]interface{}
  11778. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  11779. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  11780. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11781. return
  11782. }
  11783. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  11784. userJSONBytes, _ := json.Marshal(respJSON)
  11785. fmt.Println("log")
  11786. fmt.Println(string(userJSONBytes))
  11787. if err := json.Unmarshal(userJSONBytes, &resFour10265); err != nil {
  11788. utils.ErrorLog("解析失败:%v", err)
  11789. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11790. return
  11791. }
  11792. res.InfRefmsgid = resFour10265.InfRefmsgid
  11793. res.Output = resFour10265.Output
  11794. res.ErrMsg = resFour10265.ErrMsg
  11795. res.Cainfo = resFour10265.Cainfo
  11796. res.WarnMsg = resFour10265.WarnMsg
  11797. infocode, _ := strconv.ParseInt(resFour10265.Infcode, 10, 64)
  11798. res.Infcode = infocode
  11799. }
  11800. }
  11801. } else if miConfig.MdtrtareaAdmvs == "350500" {
  11802. 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)
  11803. var dat map[string]interface{}
  11804. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  11805. fmt.Println(dat)
  11806. } else {
  11807. fmt.Println(err)
  11808. }
  11809. saveLog(result, request_log, "2204", "上传费用明细")
  11810. userJSONBytes, _ := json.Marshal(dat)
  11811. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  11812. utils.ErrorLog("解析失败:%v", err)
  11813. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11814. return
  11815. }
  11816. } else if miConfig.MdtrtareaAdmvs == "360399" {
  11817. 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, "", "")
  11818. var dat map[string]interface{}
  11819. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  11820. fmt.Println(dat)
  11821. } else {
  11822. fmt.Println(err)
  11823. }
  11824. saveLog(result, request_log, "2204", "上传费用明细")
  11825. userJSONBytes, _ := json.Marshal(dat)
  11826. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  11827. utils.ErrorLog("解析失败:%v", err)
  11828. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11829. return
  11830. }
  11831. } else if miConfig.MdtrtareaAdmvs == "430800" {
  11832. 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, "", "")
  11833. var dat map[string]interface{}
  11834. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  11835. fmt.Println(dat)
  11836. } else {
  11837. fmt.Println(err)
  11838. }
  11839. saveLog(result, request_log, "2204", "上传费用明细")
  11840. userJSONBytes, _ := json.Marshal(dat)
  11841. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  11842. utils.ErrorLog("解析失败:%v", err)
  11843. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11844. return
  11845. }
  11846. } else {
  11847. if miConfig.Code == "H15049901371" {
  11848. 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)
  11849. var dat map[string]interface{}
  11850. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  11851. fmt.Println(dat)
  11852. } else {
  11853. fmt.Println(err)
  11854. }
  11855. saveLog(result, request_log, "2204", "上传费用明细")
  11856. userJSONBytes, _ := json.Marshal(dat)
  11857. if err := json.Unmarshal(userJSONBytes, &resFour10265); err != nil {
  11858. utils.ErrorLog("解析失败:%v", err)
  11859. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11860. return
  11861. }
  11862. res.InfRefmsgid = resFour10265.InfRefmsgid
  11863. res.Output = resFour10265.Output
  11864. res.ErrMsg = resFour10265.ErrMsg
  11865. res.Cainfo = resFour10265.Cainfo
  11866. res.WarnMsg = resFour10265.WarnMsg
  11867. infocode, _ := strconv.ParseInt(resFour10265.Infcode, 10, 64)
  11868. res.Infcode = infocode
  11869. } else {
  11870. 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)
  11871. var dat map[string]interface{}
  11872. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  11873. fmt.Println(dat)
  11874. } else {
  11875. fmt.Println(err)
  11876. }
  11877. saveLog(result, request_log, "2204", "上传费用明细")
  11878. userJSONBytes, _ := json.Marshal(dat)
  11879. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  11880. utils.ErrorLog("解析失败:%v", err)
  11881. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11882. return
  11883. }
  11884. }
  11885. }
  11886. var total_two float64
  11887. if res.Infcode == 0 {
  11888. order := &models.HisOrder{
  11889. UserOrgId: adminUser.CurrentOrgId,
  11890. HisPatientId: his.ID,
  11891. PatientId: his.PatientId,
  11892. SettleAccountsDate: recordDateTime,
  11893. Ctime: time.Now().Unix(),
  11894. Mtime: time.Now().Unix(),
  11895. MdtrtId: his.Number,
  11896. PsnNo: his.PsnNo,
  11897. MedType: strconv.FormatInt(reg_type, 10),
  11898. Status: 1,
  11899. Number: chrg_bchno,
  11900. Infcode: res.Infcode,
  11901. WarnMsg: res.WarnMsg,
  11902. Cainfo: res.Cainfo,
  11903. ErrMsg: res.ErrMsg,
  11904. RespondTime: res.RefmsgTime,
  11905. InfRefmsgid: res.InfRefmsgid,
  11906. OrderStatus: 1,
  11907. IsMedicineInsurance: 1,
  11908. SettleType: settle_accounts_type,
  11909. SettleStartTime: start_time,
  11910. SettleEndTime: end_time,
  11911. Creator: roles.AdminUserId,
  11912. Modify: roles.AdminUserId,
  11913. PType: 2,
  11914. Diagnosis: diagnosis_id,
  11915. }
  11916. err = service.CreateOrder(order)
  11917. if err != nil {
  11918. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCreatePreOrderException)
  11919. return
  11920. }
  11921. for _, item := range res.Output.Result {
  11922. temp := strings.Split(item.FeedetlSn, "-")
  11923. var advice_id int64 = 0
  11924. var project_id int64 = 0
  11925. var types int64 = 0
  11926. id, _ := strconv.ParseInt(temp[2], 10, 64)
  11927. types, _ = strconv.ParseInt(temp[1], 10, 64)
  11928. if temp[1] == "1" {
  11929. advice_id = id
  11930. project_id = 0
  11931. } else if temp[1] == "2" {
  11932. advice_id = 0
  11933. project_id = id
  11934. }
  11935. total_two = total_two + item.DetItemFeeSumamt
  11936. info := &models.HisOrderInfo{
  11937. OrderNumber: order.Number,
  11938. FeedetlSn: item.FeedetlSn,
  11939. UploadDate: time.Now().Unix(),
  11940. AdviceId: advice_id,
  11941. DetItemFeeSumamt: item.DetItemFeeSumamt,
  11942. Cnt: item.Cnt,
  11943. Pric: float64(item.Pric),
  11944. PatientId: his.PatientId,
  11945. PricUplmtAmt: item.PricUplmtAmt,
  11946. SelfpayProp: item.SelfpayProp,
  11947. FulamtOwnpayAmt: item.FulamtOwnpayAmt,
  11948. OverlmtAmt: item.OverlmtAmt,
  11949. PreselfpayAmt: item.PreselfpayAmt,
  11950. BasMednFlag: item.BasMednFlag,
  11951. MedChrgitmType: item.MedChrgitmType,
  11952. HiNegoDrugFlag: item.HiNegoDrugFlag,
  11953. Status: 1,
  11954. Memo: item.Memo,
  11955. Mtime: time.Now().Unix(),
  11956. InscpScpAmt: item.InscpScpAmt,
  11957. DrtReimFlag: item.DrtReimFlag,
  11958. Ctime: time.Now().Unix(),
  11959. ListSpItemFlag: item.ListSpItemFlag,
  11960. ChldMedcFlag: item.ChldMedcFlag,
  11961. LmtUsedFlag: item.LmtUsedFlag,
  11962. ChrgitmLv: item.ChrgitmLv,
  11963. UserOrgId: adminUser.CurrentOrgId,
  11964. HisPatientId: his.ID,
  11965. OrderId: order.ID,
  11966. ProjectId: project_id,
  11967. Type: types,
  11968. }
  11969. service.CreateOrderInfo(info)
  11970. }
  11971. service.UpDatePrescriptionNumber(adminUser.CurrentOrgId, ids, chrg_bchno)
  11972. service.UpDateHisPrescriptionInfoNumber(adminUser.CurrentOrgId, his_patient_id, chrg_bchno, recordDateTime)
  11973. var total float64
  11974. for _, item := range prescriptions {
  11975. if item.Type == 1 { //药品
  11976. for _, subItem := range item.HisDoctorAdviceInfo {
  11977. price, _ := strconv.ParseFloat(fmt.Sprintf("%.2f", subItem.Price), 64)
  11978. total_one := price * subItem.PrescribingNumber
  11979. fmt.Println("subItem")
  11980. fmt.Println(subItem.Price)
  11981. fmt.Println("price")
  11982. fmt.Println(price)
  11983. fmt.Println("total_one")
  11984. fmt.Println(total_one)
  11985. total = total + total_one
  11986. fmt.Println(total)
  11987. }
  11988. }
  11989. if item.Type == 2 { //项目
  11990. for _, subItem := range item.HisPrescriptionProject {
  11991. cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  11992. price, _ := strconv.ParseFloat(fmt.Sprintf("%.2f", subItem.Price), 64)
  11993. total_one := price * cnt
  11994. total = total + total_one
  11995. }
  11996. }
  11997. }
  11998. allTotal := fmt.Sprintf("%2f", total)
  11999. if res.Infcode == 0 {
  12000. var rf []*ResultFive
  12001. json.Unmarshal([]byte(his.Iinfo), &rf)
  12002. chrg_bchno := chrg_bchno
  12003. cert_no := his.Certno
  12004. var insutypes []string
  12005. var insutype string
  12006. var is390 int = 0
  12007. var is310 int = 0
  12008. for _, item := range rf {
  12009. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  12010. insutypes = append(insutypes, item.Insutype)
  12011. }
  12012. }
  12013. if len(insutypes) == 1 {
  12014. insutype = insutypes[0]
  12015. } else {
  12016. for _, i := range insutypes {
  12017. if i == "390" {
  12018. is390 = 1
  12019. }
  12020. if i == "310" {
  12021. is310 = 1
  12022. }
  12023. }
  12024. }
  12025. if is390 == 1 {
  12026. insutype = "390"
  12027. }
  12028. if is310 == 1 {
  12029. insutype = "310"
  12030. }
  12031. if len(insutypes) == 0 {
  12032. insutype = "390"
  12033. }
  12034. if len(insutypes) == 2 {
  12035. insutype = strconv.FormatInt(his.SocialType, 10)
  12036. }
  12037. //insutype = "390"
  12038. if his.IdCardType == 1 {
  12039. cert_no = his.MedicalInsuranceNumber
  12040. } else {
  12041. cert_no = his.Certno
  12042. }
  12043. var res ResultSeven
  12044. var resSeven10265 ResultSeven10265
  12045. if miConfig.MdtrtareaAdmvs == "421300" {
  12046. api := "http://192.168.124.4:9532/" + "hbyb/2206?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  12047. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  12048. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  12049. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  12050. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  12051. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  12052. "&insutype=" + insutype + "&total=" + allTotal + "&med_type=" + strconv.FormatInt(reg_type, 10)
  12053. resp, requestErr := http.Get(api)
  12054. if requestErr != nil {
  12055. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12056. return
  12057. }
  12058. body, ioErr := ioutil.ReadAll(resp.Body)
  12059. if ioErr != nil {
  12060. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  12061. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12062. return
  12063. }
  12064. var respJSON map[string]interface{}
  12065. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  12066. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  12067. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12068. return
  12069. }
  12070. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  12071. result, _ := json.Marshal(respJSON)
  12072. fmt.Println("log")
  12073. fmt.Println(string(result))
  12074. if err := json.Unmarshal([]byte(result), &res); err != nil {
  12075. utils.ErrorLog("解析失败:%v", err)
  12076. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12077. return
  12078. }
  12079. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  12080. result3101 := Check3102(c, id, his_patient_id, admin_user_id, "6", order.ID)
  12081. if result3101.Infcode == "0" {
  12082. if len(result3101.Output.Result) > 0 {
  12083. var errMsgs []string
  12084. for _, item := range result3101.Output.Result {
  12085. errMsgs = append(errMsgs, item.VolaCont)
  12086. }
  12087. c.ServeSuccessJSON(map[string]interface{}{
  12088. "failed_code": -10,
  12089. "msg": errMsgs,
  12090. })
  12091. return
  12092. } else {
  12093. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  12094. if his.IdCardType != 4 {
  12095. psn_info.VerifyNumber = strings.Replace(psn_info.VerifyNumber, "+", "%2B", -1)
  12096. bas := strings.Split(psn_info.CardInfo, "|")
  12097. if his.IdCardType == 1 {
  12098. cert_no = bas[2]
  12099. } else {
  12100. cert_no = bas[1]
  12101. }
  12102. } else {
  12103. cert_no = his.Certno
  12104. }
  12105. //江苏地区国家医保医疗类别
  12106. //职工透析:医疗类别选特殊情况门诊9933
  12107. //居民血透门慢: 医疗类别选门诊慢病1402
  12108. //var med_type string
  12109. //if his.Insutype == "310" {
  12110. // if reg_type == 14 {
  12111. // med_type = "9933"
  12112. // } else if reg_type == 11 {
  12113. // med_type = "11"
  12114. //
  12115. // }
  12116. //} else if his.Insutype == "390" {
  12117. // if reg_type == 14 {
  12118. // med_type = "1402"
  12119. // } else if reg_type == 11 {
  12120. // med_type = "11"
  12121. // }
  12122. //}
  12123. var api string
  12124. if miConfig.MdtrtareaAdmvs == "320921" {
  12125. api = "http://192.168.2.3:9532/" + "jsyb/2206?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  12126. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  12127. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  12128. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  12129. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  12130. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  12131. "&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
  12132. //req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  12133. } else {
  12134. //req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  12135. api = "http://192.168.5.251:9532/" + "jsyb/2206?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  12136. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  12137. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  12138. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  12139. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  12140. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  12141. "&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
  12142. }
  12143. resp, requestErr := http.Get(api)
  12144. if requestErr != nil {
  12145. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12146. return
  12147. }
  12148. body, ioErr := ioutil.ReadAll(resp.Body)
  12149. if ioErr != nil {
  12150. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  12151. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12152. return
  12153. }
  12154. var respJSON map[string]interface{}
  12155. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  12156. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  12157. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12158. return
  12159. }
  12160. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  12161. result, _ := json.Marshal(respJSON)
  12162. fmt.Println("log")
  12163. fmt.Println(string(result))
  12164. if err := json.Unmarshal([]byte(result), &resSeven10265); err != nil {
  12165. utils.ErrorLog("解析失败:%v", err)
  12166. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12167. return
  12168. }
  12169. res.InfRefmsgid = resSeven10265.InfRefmsgid
  12170. res.Output = resSeven10265.Output
  12171. res.ErrMsg = resSeven10265.ErrMsg
  12172. res.Cainfo = resSeven10265.Cainfo
  12173. res.WarnMsg = resSeven10265.WarnMsg
  12174. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  12175. res.Infcode = infocode
  12176. }
  12177. }
  12178. } else if miConfig.MdtrtareaAdmvs == "350500" {
  12179. acct_used_flag := "1"
  12180. psn_info, _ := service.GetPsnByPatientIdTwo(his.PatientId)
  12181. var result string
  12182. var request_log string
  12183. if his.IdCardType == 4 && len(psn_info.VerifyNumber) > 0 {
  12184. 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)
  12185. } else {
  12186. 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)
  12187. }
  12188. var dat map[string]interface{}
  12189. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  12190. fmt.Println(dat)
  12191. } else {
  12192. fmt.Println(err)
  12193. }
  12194. saveLog(result, request_log, "2206", "预结算")
  12195. userJSONBytes, _ := json.Marshal(dat)
  12196. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  12197. utils.ErrorLog("解析失败:%v", err)
  12198. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12199. return
  12200. }
  12201. } else if miConfig.MdtrtareaAdmvs == "360399" {
  12202. var result string
  12203. var request_log string
  12204. if his.IdCardType == 2 {
  12205. 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, "")
  12206. } else if his.IdCardType == 1 {
  12207. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  12208. bas := strings.Split(psn_info.CardInfo, "|")
  12209. basNumber := bas[2]
  12210. card_sn := bas[3]
  12211. 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)
  12212. } else {
  12213. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  12214. 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, "")
  12215. }
  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, request_log, "2206", "预结算")
  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. var result string
  12231. var request_log string
  12232. if his.IdCardType == 2 {
  12233. 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")
  12234. } else if his.IdCardType == 1 {
  12235. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  12236. bas := strings.Split(psn_info.CardInfo, "|")
  12237. basNumber := bas[2]
  12238. card_sn := bas[3]
  12239. 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")
  12240. } else {
  12241. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  12242. 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")
  12243. }
  12244. var dat map[string]interface{}
  12245. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  12246. fmt.Println(dat)
  12247. } else {
  12248. fmt.Println(err)
  12249. }
  12250. saveLog(result, request_log, "2206", "预结算")
  12251. userJSONBytes, _ := json.Marshal(dat)
  12252. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  12253. utils.ErrorLog("解析失败:%v", err)
  12254. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12255. return
  12256. }
  12257. } else {
  12258. var result string
  12259. var request_log string
  12260. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  12261. allTotal = fmt.Sprintf("%2f", total_two)
  12262. if his.IdCardType == 4 {
  12263. 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)
  12264. } else {
  12265. 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)
  12266. }
  12267. var dat map[string]interface{}
  12268. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  12269. fmt.Println(dat)
  12270. } else {
  12271. fmt.Println(err)
  12272. }
  12273. saveLog(result, request_log, "2206", "预结算")
  12274. //userJSONBytes, _ := json.Marshal(dat)
  12275. //
  12276. //if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  12277. // utils.ErrorLog("解析失败:%v", err)
  12278. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12279. // return
  12280. //}
  12281. userJSONBytes, _ := json.Marshal(dat)
  12282. if miConfig.Code == "H15049901371" {
  12283. if err := json.Unmarshal(userJSONBytes, &resSeven10265); err != nil {
  12284. utils.ErrorLog("解析失败:%v", err)
  12285. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12286. return
  12287. }
  12288. res.InfRefmsgid = resSeven10265.InfRefmsgid
  12289. res.Output = resSeven10265.Output
  12290. res.ErrMsg = resSeven10265.ErrMsg
  12291. res.Cainfo = resSeven10265.Cainfo
  12292. res.WarnMsg = resSeven10265.WarnMsg
  12293. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  12294. res.Infcode = infocode
  12295. } else {
  12296. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  12297. utils.ErrorLog("解析失败:%v", err)
  12298. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12299. return
  12300. }
  12301. }
  12302. }
  12303. if res.Infcode != 0 {
  12304. errlog := &models.HisOrderError{
  12305. UserOrgId: adminUser.CurrentOrgId,
  12306. Ctime: time.Now().Unix(),
  12307. Mtime: time.Now().Unix(),
  12308. Number: chrg_bchno,
  12309. ErrMsg: res.ErrMsg,
  12310. Status: 1,
  12311. PatientId: id,
  12312. RecordTime: recordDateTime,
  12313. Stage: 20,
  12314. }
  12315. service.CreateErrMsgLog(errlog)
  12316. c.ServeSuccessJSON(map[string]interface{}{
  12317. "failed_code": -10,
  12318. "msg": res.ErrMsg,
  12319. })
  12320. return
  12321. } else {
  12322. order, _ := service.GetHisOrderTwo(adminUser.CurrentOrgId, chrg_bchno, id)
  12323. order.OrderStatus = 1
  12324. order.IsPre = 1
  12325. order.Status = 1
  12326. order.MdtrtId = res.Output.Setlinfo.MdtrtID
  12327. order.SetlId = res.Output.Setlinfo.SetlID
  12328. order.PsnNo = res.Output.Setlinfo.PsnNo
  12329. order.PsnName = res.Output.Setlinfo.PsnName
  12330. order.PsnCertType = res.Output.Setlinfo.PsnCertType
  12331. order.Certno = res.Output.Setlinfo.Certno
  12332. order.Gend = res.Output.Setlinfo.Gend
  12333. order.Naty = res.Output.Setlinfo.Naty
  12334. order.Age = res.Output.Setlinfo.Age
  12335. order.Insutype = res.Output.Setlinfo.Insutype
  12336. order.PsnType = res.Output.Setlinfo.PsnType
  12337. order.CvlservFlag = res.Output.Setlinfo.CvlservFlag
  12338. order.SetlTime = res.Output.Setlinfo.SetlTime
  12339. order.AcctUsedFlag = acct_used_flag
  12340. order.MdtrtCertType = res.Output.Setlinfo.MdtrtCertType
  12341. if res.Output.Setlinfo.MedType == "140101" {
  12342. order.MedType = "14"
  12343. } else {
  12344. order.MedType = res.Output.Setlinfo.MedType
  12345. }
  12346. if reg_type == 1112 {
  12347. order.MedType = "1112"
  12348. }
  12349. if reg_type == 1111 {
  12350. order.MedType = "1111"
  12351. }
  12352. order.MedfeeSumamt = res.Output.Setlinfo.MedfeeSumamt
  12353. order.FulamtOwnpayAmt = res.Output.Setlinfo.FulamtOwnpayAmt
  12354. order.OverlmtSelfPay = res.Output.Setlinfo.OverlmtSelfpay
  12355. order.PreselfpayAmt = res.Output.Setlinfo.PreselfpayAmt
  12356. order.InscpScpAmt = res.Output.Setlinfo.InscpScpAmt
  12357. order.ActPayDedc = res.Output.Setlinfo.ActPayDedc
  12358. order.HifpPay = res.Output.Setlinfo.HifpPay
  12359. order.CvlservPay = res.Output.Setlinfo.CvlservPay
  12360. order.PoolPropSelfpay = res.Output.Setlinfo.PoolPropSelfpay
  12361. order.HifesPay = res.Output.Setlinfo.HifesPay
  12362. order.HifobPay = res.Output.Setlinfo.HifobPay
  12363. order.MafPay = res.Output.Setlinfo.MafPay
  12364. order.HifmiPay = res.Output.Setlinfo.HifmiPay
  12365. order.OthPay = res.Output.Setlinfo.OthPay
  12366. order.FundPaySumamt = res.Output.Setlinfo.FundPaySumamt
  12367. order.PsnPartAmt = res.Output.Setlinfo.PsnPartAmt
  12368. order.AcctPay = res.Output.Setlinfo.AcctPay
  12369. order.PsnCashPay = res.Output.Setlinfo.PsnCashPay
  12370. order.HospPartAmt = res.Output.Setlinfo.HospPartAmt
  12371. order.Balc = res.Output.Setlinfo.Balc
  12372. order.AcctMulaidPay = res.Output.Setlinfo.AcctMulaidPay
  12373. order.MedinsSetlId = res.Output.Setlinfo.MedinsSetlID
  12374. order.ClrOptins = res.Output.Setlinfo.ClrOptins
  12375. order.ClrWay = res.Output.Setlinfo.ClrWay
  12376. order.Creator = order.Creator
  12377. order.Modify = roles.AdminUserId
  12378. setlDetail, _ := json.Marshal(res.Output.Setldetail)
  12379. detailStr := string(setlDetail)
  12380. order.SetlDetail = detailStr
  12381. //err := service.UpdataOrderStatusTwo(chrg_bchno, adminUser.CurrentOrgId)
  12382. err = service.UpDateOrder(order)
  12383. if err == nil {
  12384. c.ServeSuccessJSON(map[string]interface{}{
  12385. "msg": "预结算成功",
  12386. })
  12387. } else {
  12388. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeAmountAccountException)
  12389. return
  12390. }
  12391. }
  12392. } else {
  12393. adminUser := c.GetAdminUserInfo()
  12394. errlog := &models.HisOrderError{
  12395. UserOrgId: adminUser.CurrentOrgId,
  12396. Ctime: time.Now().Unix(),
  12397. Mtime: time.Now().Unix(),
  12398. ErrMsg: res.ErrMsg,
  12399. Status: 1,
  12400. PatientId: id,
  12401. RecordTime: recordDateTime,
  12402. Stage: 4,
  12403. }
  12404. service.CreateErrMsgLog(errlog)
  12405. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeRegisterRepeatException)
  12406. return
  12407. }
  12408. } else {
  12409. adminUser := c.GetAdminUserInfo()
  12410. errlog := &models.HisOrderError{
  12411. UserOrgId: adminUser.CurrentOrgId,
  12412. Ctime: time.Now().Unix(),
  12413. Mtime: time.Now().Unix(),
  12414. ErrMsg: res.ErrMsg,
  12415. Status: 1,
  12416. PatientId: id,
  12417. RecordTime: recordDateTime,
  12418. Stage: 4,
  12419. }
  12420. service.CreateErrMsgLog(errlog)
  12421. c.ServeSuccessJSON(map[string]interface{}{
  12422. "failed_code": -10,
  12423. "msg": res.ErrMsg,
  12424. })
  12425. return
  12426. }
  12427. }
  12428. }
  12429. }
  12430. // 退款
  12431. func (c *HisApiController) Refund() {
  12432. order_id, _ := c.GetInt64("order_id")
  12433. admin_user_id, _ := c.GetInt64("admin_user_id")
  12434. adminUser := c.GetAdminUserInfo()
  12435. var order models.HisOrder
  12436. order, _ = service.GetHisOrderByID(order_id)
  12437. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  12438. if order.ID == 0 {
  12439. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  12440. return
  12441. }
  12442. his, _ := service.GetHisPatientByNumber(order.MdtrtId)
  12443. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  12444. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  12445. if config.IsOpen == 1 { //对接了医保,走医保流程
  12446. var res ResultSixteen
  12447. var resSixteen10265 ResultSixteen10265
  12448. var src_resquest string
  12449. var result string
  12450. if miConfig.MdtrtareaAdmvs == "421300" {
  12451. api3 := "http://192.168.124.4:9532/" + "hbyb/2208?psn_no=" + order.PsnNo +
  12452. "&mdtrt_id=" + order.MdtrtId + "&setl_id=" + order.SetlId + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  12453. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  12454. resp3, requestErr3 := http.Get(api3)
  12455. if requestErr3 != nil {
  12456. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12457. return
  12458. }
  12459. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  12460. if ioErr3 != nil {
  12461. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  12462. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12463. return
  12464. }
  12465. var respJSON3 map[string]interface{}
  12466. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  12467. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  12468. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12469. return
  12470. }
  12471. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  12472. userJSONBytes3, _ := json.Marshal(respJSON3)
  12473. fmt.Println("log")
  12474. fmt.Println(string(userJSONBytes3))
  12475. if err := json.Unmarshal(userJSONBytes3, &res); err != nil {
  12476. utils.ErrorLog("解析失败:%v", err)
  12477. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12478. return
  12479. }
  12480. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  12481. var api3 string
  12482. if miConfig.MdtrtareaAdmvs == "320921" {
  12483. api3 = "http://192.168.2.3:9532/" + "jsyb/2208?psn_no=" + order.PsnNo +
  12484. "&mdtrt_id=" + order.MdtrtId + "&setl_id=" + order.SetlId + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  12485. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  12486. //req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  12487. } else {
  12488. //req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  12489. api3 = "http://192.168.5.251:9532/" + "jsyb/2208?psn_no=" + order.PsnNo +
  12490. "&mdtrt_id=" + order.MdtrtId + "&setl_id=" + order.SetlId + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  12491. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  12492. }
  12493. resp3, requestErr3 := http.Get(api3)
  12494. if requestErr3 != nil {
  12495. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12496. return
  12497. }
  12498. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  12499. if ioErr3 != nil {
  12500. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  12501. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12502. return
  12503. }
  12504. var respJSON3 map[string]interface{}
  12505. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  12506. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  12507. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12508. return
  12509. }
  12510. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  12511. userJSONBytes3, _ := json.Marshal(respJSON3)
  12512. if err := json.Unmarshal(userJSONBytes3, &resSixteen10265); err != nil {
  12513. utils.ErrorLog("解析失败:%v", err)
  12514. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12515. return
  12516. }
  12517. res.InfRefmsgid = resSixteen10265.InfRefmsgid
  12518. res.Output = resSixteen10265.Output
  12519. res.ErrMsg = resSixteen10265.ErrMsg
  12520. res.Cainfo = resSixteen10265.Cainfo
  12521. res.WarnMsg = resSixteen10265.WarnMsg
  12522. infocode, _ := strconv.ParseInt(resSixteen10265.Infcode, 10, 64)
  12523. res.Infcode = infocode
  12524. } else if miConfig.MdtrtareaAdmvs == "350500" {
  12525. 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)
  12526. var dat map[string]interface{}
  12527. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  12528. fmt.Println(dat)
  12529. } else {
  12530. fmt.Println(err)
  12531. }
  12532. saveLog(result, src_resquest, "2208", "退费")
  12533. userJSONBytes, _ := json.Marshal(dat)
  12534. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  12535. utils.ErrorLog("解析失败:%v", err)
  12536. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12537. return
  12538. }
  12539. } else if miConfig.MdtrtareaAdmvs == "360399" {
  12540. 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, "")
  12541. var dat map[string]interface{}
  12542. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  12543. fmt.Println(dat)
  12544. } else {
  12545. fmt.Println(err)
  12546. }
  12547. saveLog(result, src_resquest, "2208", "退费")
  12548. userJSONBytes, _ := json.Marshal(dat)
  12549. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  12550. utils.ErrorLog("解析失败:%v", err)
  12551. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12552. return
  12553. }
  12554. } else if miConfig.MdtrtareaAdmvs == "430800" {
  12555. 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, "")
  12556. var dat map[string]interface{}
  12557. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  12558. fmt.Println(dat)
  12559. } else {
  12560. fmt.Println(err)
  12561. }
  12562. saveLog(result, src_resquest, "2208", "退费")
  12563. userJSONBytes, _ := json.Marshal(dat)
  12564. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  12565. utils.ErrorLog("解析失败:%v", err)
  12566. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12567. return
  12568. }
  12569. } else {
  12570. if miConfig.Code == "H15049901371" {
  12571. result, src_resquest = service.Gdyb2208(order.PsnNo, order.MdtrtId, order.SetlId, miConfig.OrgName, roles.UserName, miConfig.SecretKey, miConfig.Code, his.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs)
  12572. var dat map[string]interface{}
  12573. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  12574. fmt.Println(dat)
  12575. } else {
  12576. fmt.Println(err)
  12577. }
  12578. saveLog(result, src_resquest, "2208", "退费")
  12579. userJSONBytes, _ := json.Marshal(dat)
  12580. if err := json.Unmarshal(userJSONBytes, &resSixteen10265); err != nil {
  12581. utils.ErrorLog("解析失败:%v", err)
  12582. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12583. return
  12584. }
  12585. res.InfRefmsgid = resSixteen10265.InfRefmsgid
  12586. res.Output = resSixteen10265.Output
  12587. res.ErrMsg = resSixteen10265.ErrMsg
  12588. res.Cainfo = resSixteen10265.Cainfo
  12589. res.WarnMsg = resSixteen10265.WarnMsg
  12590. infocode, _ := strconv.ParseInt(resSixteen10265.Infcode, 10, 64)
  12591. res.Infcode = infocode
  12592. } else {
  12593. result, src_resquest = service.Gdyb2208(order.PsnNo, order.MdtrtId, order.SetlId, miConfig.OrgName, roles.UserName, miConfig.SecretKey, miConfig.Code, his.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs)
  12594. var dat map[string]interface{}
  12595. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  12596. fmt.Println(dat)
  12597. } else {
  12598. fmt.Println(err)
  12599. }
  12600. saveLog(result, src_resquest, "2208", "退费")
  12601. userJSONBytes, _ := json.Marshal(dat)
  12602. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  12603. utils.ErrorLog("解析失败:%v", err)
  12604. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12605. return
  12606. }
  12607. }
  12608. }
  12609. if res.Infcode == 0 {
  12610. var res2 ResultSix
  12611. var resSix10265 ResultSix10265
  12612. if miConfig.MdtrtareaAdmvs == "421300" {
  12613. api3 := "http://192.168.124.4:9532/" + "hbyb/2205?psn_no=" + order.PsnNo +
  12614. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  12615. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  12616. resp3, requestErr3 := http.Get(api3)
  12617. if requestErr3 != nil {
  12618. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12619. return
  12620. }
  12621. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  12622. if ioErr3 != nil {
  12623. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  12624. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12625. return
  12626. }
  12627. var respJSON3 map[string]interface{}
  12628. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  12629. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  12630. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12631. return
  12632. }
  12633. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  12634. userJSONBytes3, _ := json.Marshal(respJSON3)
  12635. fmt.Println("log")
  12636. fmt.Println(string(userJSONBytes3))
  12637. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  12638. utils.ErrorLog("解析失败:%v", err)
  12639. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12640. return
  12641. }
  12642. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  12643. var api3 string
  12644. if miConfig.MdtrtareaAdmvs == "320921" {
  12645. api3 = "http://192.168.2.3:9532/" + "jsyb/2205?psn_no=" + order.PsnNo +
  12646. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  12647. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  12648. //req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  12649. } else {
  12650. //req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  12651. api3 = "http://192.168.5.251:9532/" + "jsyb/2205?psn_no=" + order.PsnNo +
  12652. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  12653. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  12654. }
  12655. resp3, requestErr3 := http.Get(api3)
  12656. if requestErr3 != nil {
  12657. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12658. return
  12659. }
  12660. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  12661. if ioErr3 != nil {
  12662. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  12663. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12664. return
  12665. }
  12666. var respJSON3 map[string]interface{}
  12667. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  12668. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  12669. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12670. return
  12671. }
  12672. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  12673. userJSONBytes3, _ := json.Marshal(respJSON3)
  12674. fmt.Println("log")
  12675. fmt.Println(string(userJSONBytes3))
  12676. if err := json.Unmarshal(userJSONBytes3, &resSix10265); err != nil {
  12677. utils.ErrorLog("解析失败:%v", err)
  12678. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12679. return
  12680. }
  12681. res2.InfRefmsgid = resSix10265.InfRefmsgid
  12682. res2.Output = resSix10265.Output
  12683. res2.ErrMsg = resSix10265.ErrMsg
  12684. res2.Cainfo = resSix10265.Cainfo
  12685. res2.WarnMsg = resSix10265.WarnMsg
  12686. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  12687. res2.Infcode = infocode
  12688. } else if miConfig.MdtrtareaAdmvs == "350500" {
  12689. 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)
  12690. var dat map[string]interface{}
  12691. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  12692. fmt.Println(dat)
  12693. } else {
  12694. fmt.Println(err)
  12695. }
  12696. saveLog(result2, src_request, "2205", "撤销明细")
  12697. userJSONBytes, _ := json.Marshal(dat)
  12698. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  12699. utils.ErrorLog("解析失败:%v", err)
  12700. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12701. return
  12702. }
  12703. } else if miConfig.MdtrtareaAdmvs == "360399" {
  12704. 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, "")
  12705. var dat map[string]interface{}
  12706. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  12707. fmt.Println(dat)
  12708. } else {
  12709. fmt.Println(err)
  12710. }
  12711. saveLog(result2, src_request, "2205", "撤销明细")
  12712. userJSONBytes, _ := json.Marshal(dat)
  12713. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  12714. utils.ErrorLog("解析失败:%v", err)
  12715. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12716. return
  12717. }
  12718. } else if miConfig.MdtrtareaAdmvs == "430800" {
  12719. 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, "")
  12720. var dat map[string]interface{}
  12721. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  12722. fmt.Println(dat)
  12723. } else {
  12724. fmt.Println(err)
  12725. }
  12726. saveLog(result2, src_request, "2205", "撤销明细")
  12727. userJSONBytes, _ := json.Marshal(dat)
  12728. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  12729. utils.ErrorLog("解析失败:%v", err)
  12730. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12731. return
  12732. }
  12733. } else {
  12734. if miConfig.Code == "H15049901371" {
  12735. result2, src_request := service.Gdyb2205(order.PsnNo, order.MdtrtId, order.Number, miConfig.OrgName, roles.UserName, his.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, miConfig.Code)
  12736. var dat map[string]interface{}
  12737. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  12738. fmt.Println(dat)
  12739. } else {
  12740. fmt.Println(err)
  12741. }
  12742. saveLog(result2, src_request, "2205", "撤销明细")
  12743. userJSONBytes, _ := json.Marshal(dat)
  12744. if err := json.Unmarshal(userJSONBytes, &resSix10265); err != nil {
  12745. utils.ErrorLog("解析失败:%v", err)
  12746. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12747. return
  12748. }
  12749. res2.InfRefmsgid = resSix10265.InfRefmsgid
  12750. res2.Output = resSix10265.Output
  12751. res2.ErrMsg = resSix10265.ErrMsg
  12752. res2.Cainfo = resSix10265.Cainfo
  12753. res2.WarnMsg = resSix10265.WarnMsg
  12754. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  12755. res2.Infcode = infocode
  12756. } else {
  12757. result2, src_request := service.Gdyb2205(order.PsnNo, order.MdtrtId, order.Number, miConfig.OrgName, roles.UserName, his.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, miConfig.Code)
  12758. var dat map[string]interface{}
  12759. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  12760. fmt.Println(dat)
  12761. } else {
  12762. fmt.Println(err)
  12763. }
  12764. saveLog(result2, src_request, "2205", "撤销明细")
  12765. userJSONBytes, _ := json.Marshal(dat)
  12766. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  12767. utils.ErrorLog("解析失败:%v", err)
  12768. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12769. return
  12770. }
  12771. }
  12772. }
  12773. if res2.Infcode == 0 {
  12774. err := service.UpdataOrderStatus(order_id, order.Number, adminUser.CurrentOrgId, src_resquest, result)
  12775. if err == nil {
  12776. //当押金不为零时产生退费记录
  12777. if order.Decimal != 0 {
  12778. tmp := strconv.FormatInt(order.ID, 10)
  12779. err = service.MoneyIncrease(adminUser.CurrentOrgId, order.PatientId, tmp, order.Decimal)
  12780. if err != nil {
  12781. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12782. return
  12783. }
  12784. }
  12785. c.ServeSuccessJSON(map[string]interface{}{
  12786. "msg": "退费成功",
  12787. })
  12788. } else {
  12789. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12790. return
  12791. }
  12792. } else {
  12793. c.ServeSuccessJSON(map[string]interface{}{
  12794. "code": -10,
  12795. "msg": res2.ErrMsg,
  12796. })
  12797. }
  12798. } else {
  12799. c.ServeSuccessJSON(map[string]interface{}{
  12800. "code": -10,
  12801. "msg": res.ErrMsg,
  12802. })
  12803. }
  12804. }
  12805. }
  12806. func (c *HisApiController) RefundNumber() {
  12807. record_time := c.GetString("record_time")
  12808. //patient_id, _ := c.GetInt64("patient_id")
  12809. admin_user_id, _ := c.GetInt64("admin_user_id")
  12810. his_patient_id, _ := c.GetInt64("id")
  12811. timeLayout := "2006-01-02"
  12812. loc, _ := time.LoadLocation("Local")
  12813. adminUser := c.GetAdminUserInfo()
  12814. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  12815. fmt.Println(err)
  12816. if err != nil {
  12817. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  12818. return
  12819. }
  12820. recordDateTime := theTime.Unix()
  12821. //his, _ := service.GetVMHisPatientInfo(adminUser.CurrentOrgId, patient_id, recordDateTime)
  12822. his, _ := service.GetHisPatientRecord(adminUser.CurrentOrgId, his_patient_id)
  12823. //patientPrescription, _ := service.FindPatientPrescriptionInfo(adminUser.CurrentOrgId, patient_id, recordDateTime)
  12824. //order, _ := service.GetHisOrderByID(order_id)
  12825. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  12826. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  12827. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  12828. count, _ := service.GetOrderCountByNumber(adminUser.CurrentOrgId, his.PatientId, recordDateTime, his.Number)
  12829. if count > 0 {
  12830. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeOrderParamWrong)
  12831. return
  12832. }
  12833. if config.IsOpen == 1 { //对接了医保,走医保流程
  12834. var res2 ResultSix
  12835. var resSix10265 ResultSix10265
  12836. if miConfig.MdtrtareaAdmvs == "421300" {
  12837. api3 := "http://192.168.124.4:9532/" + "hbyb/2202?psn_no=" + his.PsnNo +
  12838. "&mdtrt_id=" + his.Number + "&ipt_otp_no=" + his.IptOtpNo + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  12839. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  12840. resp3, requestErr3 := http.Get(api3)
  12841. if requestErr3 != nil {
  12842. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12843. return
  12844. }
  12845. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  12846. if ioErr3 != nil {
  12847. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  12848. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12849. return
  12850. }
  12851. var respJSON3 map[string]interface{}
  12852. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  12853. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  12854. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12855. return
  12856. }
  12857. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  12858. userJSONBytes3, _ := json.Marshal(respJSON3)
  12859. fmt.Println("log")
  12860. fmt.Println(string(userJSONBytes3))
  12861. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  12862. utils.ErrorLog("解析失败:%v", err)
  12863. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12864. return
  12865. }
  12866. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  12867. var api3 string
  12868. if miConfig.MdtrtareaAdmvs == "320921" {
  12869. api3 = "http://192.168.2.3:9532/" + "jsyb/2202?psn_no=" + his.PsnNo +
  12870. "&mdtrt_id=" + his.Number + "&ipt_otp_no=" + his.IptOtpNo + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  12871. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  12872. //req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  12873. } else {
  12874. //req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  12875. api3 = "http://192.168.5.251:9532/" + "jsyb/2202?psn_no=" + his.PsnNo +
  12876. "&mdtrt_id=" + his.Number + "&ipt_otp_no=" + his.IptOtpNo + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  12877. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  12878. }
  12879. resp3, requestErr3 := http.Get(api3)
  12880. if requestErr3 != nil {
  12881. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12882. return
  12883. }
  12884. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  12885. if ioErr3 != nil {
  12886. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  12887. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12888. return
  12889. }
  12890. var respJSON3 map[string]interface{}
  12891. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  12892. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  12893. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12894. return
  12895. }
  12896. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  12897. userJSONBytes3, _ := json.Marshal(respJSON3)
  12898. if err := json.Unmarshal(userJSONBytes3, &resSix10265); err != nil {
  12899. utils.ErrorLog("解析失败:%v", err)
  12900. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12901. return
  12902. }
  12903. res2.InfRefmsgid = resSix10265.InfRefmsgid
  12904. res2.Output = resSix10265.Output
  12905. res2.ErrMsg = resSix10265.ErrMsg
  12906. res2.Cainfo = resSix10265.Cainfo
  12907. res2.WarnMsg = resSix10265.WarnMsg
  12908. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  12909. res2.Infcode = infocode
  12910. } else if miConfig.MdtrtareaAdmvs == "350500" {
  12911. 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)
  12912. var dat map[string]interface{}
  12913. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  12914. fmt.Println(dat)
  12915. } else {
  12916. fmt.Println(err)
  12917. }
  12918. saveLog(result, request, "2202", "退号")
  12919. userJSONBytes, _ := json.Marshal(dat)
  12920. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  12921. utils.ErrorLog("解析失败:%v", err)
  12922. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12923. return
  12924. }
  12925. } else if miConfig.MdtrtareaAdmvs == "360399" {
  12926. 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, "")
  12927. var dat map[string]interface{}
  12928. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  12929. fmt.Println(dat)
  12930. } else {
  12931. fmt.Println(err)
  12932. }
  12933. saveLog(result, request, "2202", "退号")
  12934. userJSONBytes, _ := json.Marshal(dat)
  12935. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  12936. utils.ErrorLog("解析失败:%v", err)
  12937. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12938. return
  12939. }
  12940. } else if miConfig.MdtrtareaAdmvs == "430800" {
  12941. 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, "")
  12942. var dat map[string]interface{}
  12943. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  12944. fmt.Println(dat)
  12945. } else {
  12946. fmt.Println(err)
  12947. }
  12948. saveLog(result, request, "2202", "退号")
  12949. userJSONBytes, _ := json.Marshal(dat)
  12950. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  12951. utils.ErrorLog("解析失败:%v", err)
  12952. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12953. return
  12954. }
  12955. } else {
  12956. var api3 string
  12957. if miConfig.Code == "H15049901371" {
  12958. api3 = "http://127.0.0.1:9532/" + "gdyb/three?psn_no=" + his.PsnNo +
  12959. "&mdtrt_id=" + his.Number + "&ipt_otp_no=" + his.IptOtpNo + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  12960. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  12961. } else {
  12962. api3 = "http://127.0.0.1:9532/" + "gdyb/three?psn_no=" + his.PsnNo +
  12963. "&mdtrt_id=" + his.Number + "&ipt_otp_no=" + his.IptOtpNo + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  12964. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  12965. }
  12966. resp3, requestErr3 := http.Get(api3)
  12967. if requestErr3 != nil {
  12968. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12969. return
  12970. }
  12971. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  12972. if ioErr3 != nil {
  12973. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  12974. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12975. return
  12976. }
  12977. var respJSON3 map[string]interface{}
  12978. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  12979. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  12980. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12981. return
  12982. }
  12983. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  12984. userJSONBytes3, _ := json.Marshal(respJSON3)
  12985. if miConfig.Code == "H15049901371" {
  12986. if err := json.Unmarshal(userJSONBytes3, &resSix10265); err != nil {
  12987. utils.ErrorLog("解析失败:%v", err)
  12988. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12989. return
  12990. }
  12991. res2.InfRefmsgid = resSix10265.InfRefmsgid
  12992. res2.Output = resSix10265.Output
  12993. res2.ErrMsg = resSix10265.ErrMsg
  12994. res2.Cainfo = resSix10265.Cainfo
  12995. res2.WarnMsg = resSix10265.WarnMsg
  12996. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  12997. res2.Infcode = infocode
  12998. } else {
  12999. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  13000. utils.ErrorLog("解析失败:%v", err)
  13001. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13002. return
  13003. }
  13004. }
  13005. }
  13006. if res2.Infcode == 0 {
  13007. if err == nil {
  13008. c.ServeSuccessJSON(map[string]interface{}{
  13009. "msg": "退号成功",
  13010. })
  13011. service.UpdataRegStatusTwo(his_patient_id, recordDateTime, adminUser.CurrentOrgId)
  13012. } else {
  13013. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13014. return
  13015. }
  13016. } else {
  13017. c.ServeSuccessJSON(map[string]interface{}{
  13018. "code": -10,
  13019. "msg": res2.ErrMsg,
  13020. })
  13021. }
  13022. } else {
  13023. //err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId)
  13024. //if err == nil {
  13025. // c.ServeSuccessJSON(map[string]interface{}{
  13026. // "msg": "退费成功",
  13027. // })
  13028. //} else {
  13029. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13030. // return
  13031. //}
  13032. }
  13033. }
  13034. func (c *HisApiController) RefundDetail() {
  13035. order_id, _ := c.GetInt64("order_id")
  13036. admin_user_id, _ := c.GetInt64("admin_user_id")
  13037. //his_patient_id, _ := c.GetInt64("his_patient_id")
  13038. number := c.GetString("number")
  13039. record_time := c.GetString("record_time")
  13040. patient_id, _ := c.GetInt64("patient_id")
  13041. //med_type, _ := c.GetInt64("med_type")
  13042. timeLayout := "2006-01-02"
  13043. loc, _ := time.LoadLocation("Local")
  13044. adminUser := c.GetAdminUserInfo()
  13045. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  13046. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  13047. fmt.Println(err)
  13048. if err != nil {
  13049. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  13050. return
  13051. }
  13052. recordDateTime := theTime.Unix()
  13053. //his, _ := service.GetNewVMHisPatientInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  13054. patientPrescription, _ := service.FindPatientPrescriptionInfo(adminUser.CurrentOrgId, patient_id, recordDateTime)
  13055. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  13056. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  13057. var order models.HisOrder
  13058. order, _ = service.GetHisOrderByID(order_id)
  13059. his, _ := service.GetHisPatientByNumber(order.MdtrtId)
  13060. if config.IsOpen == 1 { //对接了医保,走医保流程
  13061. var res2 ResultSix
  13062. if miConfig.MdtrtareaAdmvs == "421300" {
  13063. api3 := "http://192.168.124.4:9532/" + "hbyb/2205?psn_no=" + order.PsnNo +
  13064. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + patientPrescription.Doctor + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  13065. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  13066. resp3, requestErr3 := http.Get(api3)
  13067. if requestErr3 != nil {
  13068. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13069. return
  13070. }
  13071. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  13072. if ioErr3 != nil {
  13073. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  13074. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13075. return
  13076. }
  13077. var respJSON3 map[string]interface{}
  13078. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  13079. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  13080. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13081. return
  13082. }
  13083. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  13084. userJSONBytes3, _ := json.Marshal(respJSON3)
  13085. fmt.Println("log")
  13086. fmt.Println(string(userJSONBytes3))
  13087. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  13088. utils.ErrorLog("解析失败:%v", err)
  13089. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13090. return
  13091. }
  13092. err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId, "", "")
  13093. if err == nil {
  13094. c.ServeSuccessJSON(map[string]interface{}{
  13095. "msg": "撤销明细成功",
  13096. })
  13097. return
  13098. } else {
  13099. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13100. return
  13101. }
  13102. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  13103. var resSix10265 ResultSix10265
  13104. var api3 string
  13105. if miConfig.MdtrtareaAdmvs == "320921" {
  13106. api3 = "http://192.168.2.3:9532/" + "jsyb/2205?psn_no=" + order.PsnNo +
  13107. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + patientPrescription.Doctor + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  13108. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  13109. //req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  13110. } else {
  13111. //req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  13112. api3 = "http://192.168.5.251:9532/" + "jsyb/2205?psn_no=" + order.PsnNo +
  13113. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + patientPrescription.Doctor + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  13114. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  13115. }
  13116. resp3, requestErr3 := http.Get(api3)
  13117. if requestErr3 != nil {
  13118. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13119. return
  13120. }
  13121. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  13122. if ioErr3 != nil {
  13123. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  13124. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13125. return
  13126. }
  13127. var respJSON3 map[string]interface{}
  13128. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  13129. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  13130. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13131. return
  13132. }
  13133. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  13134. userJSONBytes3, _ := json.Marshal(respJSON3)
  13135. fmt.Println("log")
  13136. fmt.Println(string(userJSONBytes3))
  13137. if err := json.Unmarshal(userJSONBytes3, &resSix10265); err != nil {
  13138. utils.ErrorLog("解析失败:%v", err)
  13139. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13140. return
  13141. }
  13142. res2.InfRefmsgid = resSix10265.InfRefmsgid
  13143. res2.Output = resSix10265.Output
  13144. res2.ErrMsg = resSix10265.ErrMsg
  13145. res2.Cainfo = resSix10265.Cainfo
  13146. res2.WarnMsg = resSix10265.WarnMsg
  13147. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  13148. res2.Infcode = infocode
  13149. err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId, "", "")
  13150. if err == nil {
  13151. c.ServeSuccessJSON(map[string]interface{}{
  13152. "msg": "撤销明细成功",
  13153. })
  13154. return
  13155. } else {
  13156. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13157. return
  13158. }
  13159. } else if miConfig.MdtrtareaAdmvs == "350500" {
  13160. 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)
  13161. var dat map[string]interface{}
  13162. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  13163. fmt.Println(dat)
  13164. } else {
  13165. fmt.Println(err)
  13166. }
  13167. saveLog(result2, src_request, "2205", "撤销明细")
  13168. userJSONBytes, _ := json.Marshal(dat)
  13169. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  13170. utils.ErrorLog("解析失败:%v", err)
  13171. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13172. return
  13173. }
  13174. if res2.Infcode == 0 {
  13175. err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId, "", "")
  13176. if err == nil {
  13177. c.ServeSuccessJSON(map[string]interface{}{
  13178. "msg": "撤销明细成功",
  13179. })
  13180. return
  13181. } else {
  13182. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13183. return
  13184. }
  13185. } else {
  13186. c.ServeSuccessJSON(map[string]interface{}{
  13187. "code": -10,
  13188. "msg": res2.ErrMsg,
  13189. })
  13190. }
  13191. } else if miConfig.MdtrtareaAdmvs == "360399" {
  13192. 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, "")
  13193. var dat map[string]interface{}
  13194. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  13195. fmt.Println(dat)
  13196. } else {
  13197. fmt.Println(err)
  13198. }
  13199. saveLog(result2, src_request, "2205", "撤销明细")
  13200. userJSONBytes, _ := json.Marshal(dat)
  13201. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  13202. utils.ErrorLog("解析失败:%v", err)
  13203. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13204. return
  13205. }
  13206. if res2.Infcode == 0 {
  13207. err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId, "", "")
  13208. if err == nil {
  13209. c.ServeSuccessJSON(map[string]interface{}{
  13210. "msg": "撤销明细成功",
  13211. })
  13212. return
  13213. } else {
  13214. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13215. return
  13216. }
  13217. } else {
  13218. c.ServeSuccessJSON(map[string]interface{}{
  13219. "code": -10,
  13220. "msg": res2.ErrMsg,
  13221. })
  13222. }
  13223. } else if miConfig.MdtrtareaAdmvs == "430800" {
  13224. 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, "")
  13225. var dat map[string]interface{}
  13226. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  13227. fmt.Println(dat)
  13228. } else {
  13229. fmt.Println(err)
  13230. }
  13231. saveLog(result2, src_request, "2205", "撤销明细")
  13232. userJSONBytes, _ := json.Marshal(dat)
  13233. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  13234. utils.ErrorLog("解析失败:%v", err)
  13235. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13236. return
  13237. }
  13238. if res2.Infcode == 0 {
  13239. err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId, "", "")
  13240. if err == nil {
  13241. c.ServeSuccessJSON(map[string]interface{}{
  13242. "msg": "撤销明细成功",
  13243. })
  13244. return
  13245. } else {
  13246. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13247. return
  13248. }
  13249. } else {
  13250. c.ServeSuccessJSON(map[string]interface{}{
  13251. "code": -10,
  13252. "msg": res2.ErrMsg,
  13253. })
  13254. }
  13255. } else {
  13256. api2 := "http://127.0.0.1:9532/" + "gdyb/six?psn_no=" + his.PsnNo +
  13257. "&mdtrt_id=" + his.Number + "&chrg_bchno=" + order.Number + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  13258. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  13259. resp2, requestErr2 := http.Get(api2)
  13260. if requestErr2 != nil {
  13261. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13262. return
  13263. }
  13264. body2, ioErr2 := ioutil.ReadAll(resp2.Body)
  13265. if ioErr2 != nil {
  13266. utils.ErrorLog("接口返回数据读取失败: %v", ioErr2)
  13267. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13268. return
  13269. }
  13270. var respJSON2 map[string]interface{}
  13271. if err := json.Unmarshal([]byte(string(body2)), &respJSON2); err != nil {
  13272. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  13273. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13274. return
  13275. }
  13276. err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId, "", "")
  13277. if err == nil {
  13278. c.ServeSuccessJSON(map[string]interface{}{
  13279. "msg": "撤销明细成功",
  13280. })
  13281. return
  13282. } else {
  13283. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13284. return
  13285. }
  13286. }
  13287. } else {
  13288. err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId, "", "")
  13289. if err == nil {
  13290. c.ServeSuccessJSON(map[string]interface{}{
  13291. "msg": "退费成功",
  13292. })
  13293. } else {
  13294. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13295. return
  13296. }
  13297. }
  13298. }
  13299. // 对账
  13300. func (c *HisApiController) GetCheckAccount() {
  13301. start_time := c.GetString("start_time")
  13302. end_time := c.GetString("end_time")
  13303. insutype := c.GetString("insutype")
  13304. clr_type := c.GetString("clr_type")
  13305. clr_org := c.GetString("clr_optins")
  13306. admin_user_id, _ := c.GetInt64("admin_user_id")
  13307. adminUser := c.GetAdminUserInfo()
  13308. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  13309. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  13310. if len(clr_org) == 0 {
  13311. clr_org = miConfig.MdtrtareaAdmvs
  13312. }
  13313. timeLayout := "2006-01-02"
  13314. loc, _ := time.LoadLocation("Local")
  13315. startime, _ := time.ParseInLocation(timeLayout+" 15:04:05", start_time+" 00:00:00", loc)
  13316. endtime, _ := time.ParseInLocation(timeLayout+" 15:04:05", end_time+" 23:59:59", loc)
  13317. orders, _ := service.GetOrderByTime(startime.Unix(), endtime.Unix(), adminUser.CurrentOrgId, insutype, "", clr_type, miConfig.MdtrtareaAdmvs)
  13318. orders_two, _ := service.GetOrderByTimeFive(startime.Unix(), endtime.Unix(), adminUser.CurrentOrgId, insutype, "", clr_type, miConfig.MdtrtareaAdmvs)
  13319. fixmedins_setl_cnt := int64(len(orders))
  13320. var medfee_sumamt float64
  13321. var acct_pay float64
  13322. var fund_pay_sumamt float64
  13323. for _, item := range orders {
  13324. medfee_sumamt = medfee_sumamt + item.MedfeeSumamt
  13325. acct_pay = acct_pay + item.AcctPay
  13326. fund_pay_sumamt = fund_pay_sumamt + item.FundPaySumamt
  13327. }
  13328. var user_name string
  13329. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  13330. if role.ID == 0 {
  13331. user_name = "xxx"
  13332. } else {
  13333. user_name = role.UserName
  13334. }
  13335. var res ResultEight
  13336. var res10188 ResultEightFor10188
  13337. if config.IsOpen == 1 {
  13338. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  13339. api := "http://192.168.2.3:9532/" + "jsyb/3201?" +
  13340. "insutype=" + insutype +
  13341. "&clr_type=" + clr_type +
  13342. "&setl_optins=" + clr_org +
  13343. "&stmt_begndate=" + start_time +
  13344. "&stm_enddate=" + end_time +
  13345. "&medfee_sumamt=" + fmt.Sprintf("%.4f", medfee_sumamt) +
  13346. "&fund_pay_sumamt=" + fmt.Sprintf("%.4f", fund_pay_sumamt) +
  13347. "&acct_pay=" + fmt.Sprintf("%.4f", acct_pay) +
  13348. "&fixmedins_setl_cnt=" + strconv.FormatInt(fixmedins_setl_cnt+int64(len(orders_two)*2), 10) +
  13349. "&fixmedins_code=" + miConfig.Code +
  13350. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs +
  13351. "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  13352. "&secret_key=" + miConfig.SecretKey +
  13353. "&org_name=" + miConfig.OrgName +
  13354. "&doctor=" + user_name +
  13355. "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  13356. fmt.Println(api)
  13357. resp, requestErr := http.Get(api)
  13358. if requestErr != nil {
  13359. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13360. return
  13361. }
  13362. body, ioErr := ioutil.ReadAll(resp.Body)
  13363. fmt.Println(body)
  13364. if ioErr != nil {
  13365. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  13366. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13367. return
  13368. }
  13369. var respJSON map[string]interface{}
  13370. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  13371. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  13372. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13373. return
  13374. }
  13375. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  13376. userJSONBytes, _ := json.Marshal(respJSON)
  13377. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  13378. utils.ErrorLog("解析失败:%v", err)
  13379. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13380. return
  13381. }
  13382. res.InfRefmsgid = res10188.InfRefmsgid
  13383. res.Output = res10188.Output
  13384. res.ErrMsg = res10188.ErrMsg
  13385. res.Cainfo = res10188.Cainfo
  13386. res.WarnMsg = res10188.WarnMsg
  13387. infocode, _ := strconv.ParseInt(res10188.Infcode, 10, 64)
  13388. res.Infcode = infocode
  13389. } else if miConfig.MdtrtareaAdmvs == "150499" {
  13390. if clr_type == "11" {
  13391. fixmedins_setl_cnt = 0
  13392. }
  13393. //if clr_type == "21" {
  13394. // clr_type = "22"
  13395. //}
  13396. api := "http://172.16.13.254:9532/" + "nmyb/3201?" +
  13397. "insutype=" + insutype +
  13398. "&clr_type=" + clr_type +
  13399. "&setl_optins=" + clr_org +
  13400. "&stmt_begndate=" + start_time +
  13401. "&stm_enddate=" + end_time +
  13402. "&medfee_sumamt=" + fmt.Sprintf("%.4f", medfee_sumamt) +
  13403. "&fund_pay_sumamt=" + fmt.Sprintf("%.4f", fund_pay_sumamt) +
  13404. "&acct_pay=" + fmt.Sprintf("%.4f", acct_pay) +
  13405. "&fixmedins_setl_cnt=" + strconv.FormatInt(fixmedins_setl_cnt+int64(len(orders_two)*2), 10) +
  13406. "&fixmedins_code=" + miConfig.Code +
  13407. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs +
  13408. "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  13409. "&secret_key=" + miConfig.SecretKey +
  13410. "&org_name=" + miConfig.OrgName +
  13411. "&doctor=" + user_name
  13412. resp, requestErr := http.Get(api)
  13413. if requestErr != nil {
  13414. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13415. return
  13416. }
  13417. body, ioErr := ioutil.ReadAll(resp.Body)
  13418. if ioErr != nil {
  13419. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  13420. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13421. return
  13422. }
  13423. var respJSON map[string]interface{}
  13424. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  13425. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  13426. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13427. return
  13428. }
  13429. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  13430. result, _ := json.Marshal(respJSON)
  13431. fmt.Println("log")
  13432. fmt.Println(string(result))
  13433. if err := json.Unmarshal([]byte(result), &res10188); err != nil {
  13434. utils.ErrorLog("解析失败:%v", err)
  13435. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13436. return
  13437. }
  13438. res.InfRefmsgid = res10188.InfRefmsgid
  13439. res.Output = res10188.Output
  13440. res.ErrMsg = res10188.ErrMsg
  13441. res.Cainfo = res10188.Cainfo
  13442. res.WarnMsg = res10188.WarnMsg
  13443. infocode, _ := strconv.ParseInt(res10188.Infcode, 10, 64)
  13444. res.Infcode = infocode
  13445. } else if miConfig.MdtrtareaAdmvs == "350500" {
  13446. var baseParams models.BaseParams
  13447. baseParams.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  13448. baseParams.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  13449. baseParams.SecretKey = miConfig.SecretKey
  13450. baseParams.OrgName = miConfig.OrgName
  13451. baseParams.FixmedinsCode = miConfig.Code
  13452. baseParams.EncKey = miConfig.EncKey
  13453. baseParams.AppSecret = miConfig.AppSecret
  13454. baseParams.SignKey = miConfig.SignKey
  13455. baseParams.AppID = miConfig.Code
  13456. baseParams.Doctor = role.UserName
  13457. baseParams.RequestUrl = miConfig.Url
  13458. businessParams := models.BusinessParams{
  13459. Insutype: insutype,
  13460. ClrType: clr_type,
  13461. SetlOptins: clr_org,
  13462. StmtBegndate: start_time,
  13463. StmtEnddate: end_time,
  13464. MedfeeSumamt: medfee_sumamt,
  13465. FundPaySumamt: fund_pay_sumamt,
  13466. AcctPay: acct_pay,
  13467. FixmedinsSetlCnt: fixmedins_setl_cnt,
  13468. }
  13469. result, requestLog, err_msg := service.FJyb3201(baseParams, businessParams, fmt.Sprintf("%.4f", medfee_sumamt), fmt.Sprintf("%.4f", fund_pay_sumamt))
  13470. fmt.Println(requestLog)
  13471. fmt.Println(result)
  13472. fmt.Println(err_msg)
  13473. var dat map[string]interface{}
  13474. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  13475. fmt.Println(dat)
  13476. } else {
  13477. fmt.Println(err)
  13478. }
  13479. userJSONBytes, _ := json.Marshal(dat)
  13480. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  13481. utils.ErrorLog("解析失败:%v", err)
  13482. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13483. return
  13484. }
  13485. } else if miConfig.MdtrtareaAdmvs == "430800" {
  13486. var baseParams models.BaseParams
  13487. baseParams.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  13488. baseParams.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  13489. baseParams.SecretKey = miConfig.SecretKey
  13490. baseParams.OrgName = miConfig.OrgName
  13491. baseParams.FixmedinsCode = miConfig.Code
  13492. baseParams.EncKey = miConfig.EncKey
  13493. baseParams.AppSecret = miConfig.AppSecret
  13494. baseParams.SignKey = miConfig.SignKey
  13495. baseParams.AppID = miConfig.Code
  13496. baseParams.Doctor = role.UserName
  13497. baseParams.RequestUrl = miConfig.Url
  13498. baseParams.AccessKey = miConfig.AccessKey
  13499. businessParams := models.BusinessParams{
  13500. Insutype: insutype,
  13501. ClrType: clr_type,
  13502. SetlOptins: "430822",
  13503. StmtBegndate: start_time,
  13504. StmtEnddate: end_time,
  13505. MedfeeSumamt: medfee_sumamt,
  13506. FundPaySumamt: fund_pay_sumamt,
  13507. AcctPay: acct_pay,
  13508. FixmedinsSetlCnt: fixmedins_setl_cnt,
  13509. }
  13510. 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)
  13511. fmt.Println(requestLog)
  13512. fmt.Println(result)
  13513. var dat map[string]interface{}
  13514. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  13515. fmt.Println(dat)
  13516. } else {
  13517. fmt.Println(err)
  13518. }
  13519. userJSONBytes, _ := json.Marshal(dat)
  13520. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  13521. utils.ErrorLog("解析失败:%v", err)
  13522. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13523. return
  13524. }
  13525. } else if miConfig.MdtrtareaAdmvs == "350500" {
  13526. var baseParams models.BaseParams
  13527. baseParams.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  13528. baseParams.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  13529. baseParams.SecretKey = miConfig.SecretKey
  13530. baseParams.OrgName = miConfig.OrgName
  13531. baseParams.FixmedinsCode = miConfig.Code
  13532. baseParams.EncKey = miConfig.EncKey
  13533. baseParams.AppSecret = miConfig.AppSecret
  13534. baseParams.SignKey = miConfig.SignKey
  13535. baseParams.AppID = miConfig.Code
  13536. baseParams.Doctor = role.UserName
  13537. baseParams.RequestUrl = miConfig.Url
  13538. businessParams := models.BusinessParams{
  13539. Insutype: insutype,
  13540. ClrType: clr_type,
  13541. SetlOptins: clr_org,
  13542. StmtBegndate: start_time,
  13543. StmtEnddate: end_time,
  13544. MedfeeSumamt: medfee_sumamt,
  13545. FundPaySumamt: fund_pay_sumamt,
  13546. AcctPay: acct_pay,
  13547. FixmedinsSetlCnt: fixmedins_setl_cnt,
  13548. }
  13549. result, requestLog, err_msg := service.FJyb3201(baseParams, businessParams, fmt.Sprintf("%.4f", medfee_sumamt), fmt.Sprintf("%.4f", fund_pay_sumamt))
  13550. fmt.Println(requestLog)
  13551. fmt.Println(result)
  13552. fmt.Println(err_msg)
  13553. var dat map[string]interface{}
  13554. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  13555. fmt.Println(dat)
  13556. } else {
  13557. fmt.Println(err)
  13558. }
  13559. userJSONBytes, _ := json.Marshal(dat)
  13560. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  13561. utils.ErrorLog("解析失败:%v", err)
  13562. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13563. return
  13564. }
  13565. } else {
  13566. if len(clr_type) == 0 {
  13567. clr_type = "11"
  13568. }
  13569. api := "http://127.0.0.1:9532/" + "gdyb/ten?" +
  13570. "insutype=" + insutype +
  13571. "&clr_type=" + clr_type +
  13572. "&setl_optins=" + clr_org +
  13573. "&stmt_begndate=" + start_time +
  13574. "&stm_enddate=" + end_time +
  13575. "&medfee_sumamt=" + fmt.Sprintf("%.4f", medfee_sumamt) +
  13576. "&fund_pay_sumamt=" + fmt.Sprintf("%.4f", fund_pay_sumamt) +
  13577. "&acct_pay=" + fmt.Sprintf("%.4f", acct_pay) +
  13578. "&fixmedins_setl_cnt=" + strconv.FormatInt(fixmedins_setl_cnt, 10) +
  13579. "&fixmedins_code=" + miConfig.Code +
  13580. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs +
  13581. "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  13582. "&secret_key=" + miConfig.SecretKey +
  13583. "&org_name=" + miConfig.OrgName +
  13584. "&doctor=" + user_name
  13585. fmt.Println(api)
  13586. resp, requestErr := http.Get(api)
  13587. if requestErr != nil {
  13588. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13589. return
  13590. }
  13591. body, ioErr := ioutil.ReadAll(resp.Body)
  13592. fmt.Println(body)
  13593. if ioErr != nil {
  13594. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  13595. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13596. return
  13597. }
  13598. var respJSON map[string]interface{}
  13599. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  13600. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  13601. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13602. return
  13603. }
  13604. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  13605. userJSONBytes, _ := json.Marshal(respJSON)
  13606. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  13607. utils.ErrorLog("解析失败:%v", err)
  13608. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13609. return
  13610. }
  13611. }
  13612. if res.Infcode == 0 {
  13613. if res.Output.Stmtinfo.StmtRslt == "0" {
  13614. micc := &models.MedicalInsuranceCostCompare{
  13615. StartTime: startime.Unix(),
  13616. EndTime: endtime.Unix(),
  13617. Insutype: insutype,
  13618. CheckType: 1,
  13619. Num: fixmedins_setl_cnt,
  13620. Mtime: time.Now().Unix(),
  13621. Status: 1,
  13622. UserOrgId: adminUser.CurrentOrgId,
  13623. CostTotal: medfee_sumamt,
  13624. FuncTotal: fund_pay_sumamt,
  13625. PsnPay: acct_pay,
  13626. Creator: admin_user_id,
  13627. Ctime: time.Now().Unix(),
  13628. ClrType: clr_type,
  13629. }
  13630. err := service.CreateMedicalInsuranceCostCompareRecord(micc)
  13631. if err == nil {
  13632. c.ServeSuccessJSON(map[string]interface{}{
  13633. "stmt_rslt": res.Output.Stmtinfo.StmtRslt,
  13634. "stmt_rslt_dscr": res.Output.Stmtinfo.StmtRsltDscr,
  13635. })
  13636. } else {
  13637. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13638. }
  13639. } else {
  13640. c.ServeSuccessJSON(map[string]interface{}{
  13641. "stmt_rslt": res.Output.Stmtinfo.StmtRslt,
  13642. "stmt_rslt_dscr": res.Output.Stmtinfo.StmtRsltDscr,
  13643. })
  13644. }
  13645. } else {
  13646. c.ServeSuccessJSON(map[string]interface{}{
  13647. "code": -10,
  13648. "msg": res.ErrMsg,
  13649. })
  13650. }
  13651. }
  13652. }
  13653. func (c *HisApiController) Check310() {
  13654. adminUser := c.GetAdminUserInfo()
  13655. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  13656. var user_name string
  13657. user_name = "高慧裕"
  13658. api := "http://127.0.0.1:9532/" + "gdyb/ten?" +
  13659. "insutype=" + "310" +
  13660. "&clr_type=" + "" +
  13661. "&setl_optins=" + "441202" +
  13662. "&stmt_begndate=" + "2022-03-01" +
  13663. "&stm_enddate=" + "2022-03-31" +
  13664. "&medfee_sumamt=" + "194930.12" +
  13665. "&fund_pay_sumamt=" + "188741.46" +
  13666. "&acct_pay=" + "0" +
  13667. "&fixmedins_setl_cnt=" + "452" +
  13668. "&fixmedins_code=" + miConfig.Code +
  13669. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs +
  13670. "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  13671. "&secret_key=" + miConfig.SecretKey +
  13672. "&org_name=" + miConfig.OrgName +
  13673. "&doctor=" + user_name
  13674. fmt.Println(api)
  13675. resp, requestErr := http.Get(api)
  13676. if requestErr != nil {
  13677. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13678. return
  13679. }
  13680. body, ioErr := ioutil.ReadAll(resp.Body)
  13681. fmt.Println(body)
  13682. if ioErr != nil {
  13683. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  13684. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13685. return
  13686. }
  13687. var respJSON map[string]interface{}
  13688. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  13689. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  13690. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13691. return
  13692. }
  13693. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  13694. userJSONBytes, _ := json.Marshal(respJSON)
  13695. var res ResultEight
  13696. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  13697. utils.ErrorLog("解析失败:%v", err)
  13698. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13699. return
  13700. }
  13701. }
  13702. func (c *HisApiController) Check390() {
  13703. adminUser := c.GetAdminUserInfo()
  13704. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  13705. var user_name string
  13706. user_name = "高慧裕"
  13707. api := "http://127.0.0.1:9532/" + "gdyb/ten?" +
  13708. "insutype=" + "390" +
  13709. "&clr_type=" + "" +
  13710. "&setl_optins=" + "441202" +
  13711. "&stmt_begndate=" + "2022-03-01" +
  13712. "&stm_enddate=" + "2022-03-31" +
  13713. "&medfee_sumamt=" + "1068448.89" +
  13714. "&fund_pay_sumamt=" + "1014677.62" +
  13715. "&acct_pay=" + "0" +
  13716. "&fixmedins_setl_cnt=" + "1950" +
  13717. "&fixmedins_code=" + miConfig.Code +
  13718. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs +
  13719. "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  13720. "&secret_key=" + miConfig.SecretKey +
  13721. "&org_name=" + miConfig.OrgName +
  13722. "&doctor=" + user_name
  13723. fmt.Println(api)
  13724. resp, requestErr := http.Get(api)
  13725. if requestErr != nil {
  13726. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13727. return
  13728. }
  13729. body, ioErr := ioutil.ReadAll(resp.Body)
  13730. fmt.Println(body)
  13731. if ioErr != nil {
  13732. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  13733. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13734. return
  13735. }
  13736. var respJSON map[string]interface{}
  13737. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  13738. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  13739. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13740. return
  13741. }
  13742. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  13743. userJSONBytes, _ := json.Marshal(respJSON)
  13744. var res ResultEight
  13745. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  13746. utils.ErrorLog("解析失败:%v", err)
  13747. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13748. return
  13749. }
  13750. }
  13751. // 对账明细
  13752. func (c *HisApiController) GetCheckDetailAccount() {
  13753. start_time := c.GetString("start_time")
  13754. end_time := c.GetString("end_time")
  13755. admin_user_id, _ := c.GetInt64("admin_user_id")
  13756. adminUser := c.GetAdminUserInfo()
  13757. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  13758. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  13759. timeLayout := "2006-01-02"
  13760. loc, _ := time.LoadLocation("Local")
  13761. startime, _ := time.ParseInLocation(timeLayout+" 15:04:05", start_time+" 00:00:00", loc)
  13762. endtime, _ := time.ParseInLocation(timeLayout+" 15:04:05", end_time+" 23:59:59", loc)
  13763. orders, _ := service.GetOrderByTimeTwo(startime.Unix(), endtime.Unix(), adminUser.CurrentOrgId)
  13764. rand.Seed(time.Now().UnixNano())
  13765. num := rand.Intn(30000)
  13766. Mkdir(miConfig.OrgName)
  13767. file := strconv.FormatInt(int64(num), 10)
  13768. file_name := file + ".txt"
  13769. zip_name := file + ".zip"
  13770. zip_path := miConfig.OrgName + "/" + zip_name
  13771. file_path := miConfig.OrgName + "/" + file_name
  13772. decimal.DivisionPrecision = 2
  13773. var medfee_sumamt float64
  13774. var psn_cash_pay float64
  13775. var fund_pay_sumamt float64
  13776. fixmedins_setl_cnt := int64(len(orders))
  13777. for _, item := range orders {
  13778. medfee_sumamt = medfee_sumamt + item.MedfeeSumamt
  13779. psn_cash_pay = psn_cash_pay + item.PsnCashPay
  13780. fund_pay_sumamt = fund_pay_sumamt + item.FundPaySumamt
  13781. }
  13782. f, err := os.Create(miConfig.OrgName + "/" + file_name)
  13783. defer f.Close()
  13784. if err != nil {
  13785. fmt.Println(err.Error())
  13786. } else {
  13787. for _, item := range orders {
  13788. var refd_setl_flag string
  13789. if item.OrderStatus == 2 {
  13790. refd_setl_flag = "0"
  13791. var str string
  13792. str = item.SetlId + " " +
  13793. item.MdtrtId + " " +
  13794. item.PsnNo + " " +
  13795. fmt.Sprintf("%.4f", item.MedfeeSumamt) + " " +
  13796. fmt.Sprintf("%.4f", item.FundPaySumamt) + " " +
  13797. fmt.Sprintf("%.4f", item.AcctPay) + " " + refd_setl_flag + "\r\n"
  13798. _, err = f.Write([]byte(str))
  13799. }
  13800. if item.OrderStatus == 3 {
  13801. var str string
  13802. str = item.SetlId + " " +
  13803. item.MdtrtId + " " +
  13804. item.PsnNo + " " +
  13805. fmt.Sprintf("%.4f", item.MedfeeSumamt) + " " +
  13806. fmt.Sprintf("%.4f", item.FundPaySumamt) + " " +
  13807. fmt.Sprintf("%.4f", item.AcctPay) + " " + "1" + "\r\n"
  13808. _, err = f.Write([]byte(str))
  13809. var str2 string
  13810. str2 = item.SetlId + " " +
  13811. item.MdtrtId + " " +
  13812. item.PsnNo + " " +
  13813. fmt.Sprintf("%.4f", 0-item.MedfeeSumamt) + " " +
  13814. fmt.Sprintf("%.4f", 0-item.FundPaySumamt) + " " +
  13815. fmt.Sprintf("%.4f", 0-item.AcctPay) + " " + "1" + "\r\n"
  13816. _, err = f.Write([]byte(str2))
  13817. }
  13818. }
  13819. }
  13820. Zip(file_path, zip_path)
  13821. fmt.Println(ReadFile(zip_path))
  13822. fmt.Println(string(ReadFile(zip_path)))
  13823. if config.IsOpen == 1 {
  13824. var user_name string
  13825. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  13826. if role.ID == 0 {
  13827. user_name = "管理员"
  13828. } else {
  13829. user_name = role.UserName
  13830. }
  13831. baseParams := models.BaseParams{
  13832. SecretKey: miConfig.SecretKey,
  13833. FixmedinsCode: miConfig.Code,
  13834. InsuplcAdmdvs: miConfig.InsuplcAdmdvs,
  13835. MdtrtareaAdmvs: miConfig.MdtrtareaAdmvs,
  13836. OrgName: miConfig.OrgName,
  13837. Doctor: user_name,
  13838. }
  13839. result := service.Gdyb9101(baseParams, file_name, ReadFile(file_path))
  13840. var dat map[string]interface{}
  13841. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  13842. fmt.Println(dat)
  13843. } else {
  13844. fmt.Println(err)
  13845. }
  13846. userJSONBytes, _ := json.Marshal(dat)
  13847. var res ResultNine
  13848. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  13849. utils.ErrorLog("解析失败:%v", err)
  13850. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13851. return
  13852. }
  13853. if res.Infcode == 0 {
  13854. fileNo := res.Output.FileQuryNo
  13855. api := "http://127.0.0.1:9532/" + "gdyb/twelve?" +
  13856. "file_qury_no=" + fileNo +
  13857. "&setl_optins=" + "定点医保中心" +
  13858. "&stmt_begndate=" + start_time +
  13859. "&stm_enddate=" + end_time +
  13860. "&medfee_sumamt=" + fmt.Sprintf("%.4f", medfee_sumamt) +
  13861. "&fund_pay_sumamt=" + fmt.Sprintf("%.4f", fund_pay_sumamt) +
  13862. "&cash_payamt=" + fmt.Sprintf("%.4f", psn_cash_pay) +
  13863. "&fixmedins_setl_cnt=" + strconv.FormatInt(fixmedins_setl_cnt, 10) +
  13864. "&fixmedins_code=" + miConfig.Code +
  13865. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs +
  13866. "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  13867. "&secret_key=" + miConfig.SecretKey +
  13868. "&org_name=" + miConfig.OrgName +
  13869. "&doctor=" + user_name
  13870. resp, requestErr := http.Get(api)
  13871. if requestErr != nil {
  13872. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13873. return
  13874. }
  13875. body, ioErr := ioutil.ReadAll(resp.Body)
  13876. if ioErr != nil {
  13877. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  13878. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13879. return
  13880. }
  13881. var respJSON map[string]interface{}
  13882. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  13883. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  13884. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13885. return
  13886. }
  13887. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  13888. userJSONBytes, _ := json.Marshal(respJSON)
  13889. var res ResultTen
  13890. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  13891. utils.ErrorLog("解析失败:%v", err)
  13892. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13893. return
  13894. }
  13895. if res.Infcode == 0 {
  13896. service.Gdyb9102(baseParams, zip_name, fileNo)
  13897. micc := &models.MedicalInsuranceCostCompare{
  13898. StartTime: startime.Unix(),
  13899. EndTime: endtime.Unix(),
  13900. Insutype: "0",
  13901. CheckType: 2,
  13902. Num: fixmedins_setl_cnt,
  13903. Mtime: time.Now().Unix(),
  13904. Status: 1,
  13905. UserOrgId: adminUser.CurrentOrgId,
  13906. CostTotal: medfee_sumamt,
  13907. FuncTotal: fund_pay_sumamt,
  13908. PsnPay: psn_cash_pay,
  13909. Creator: admin_user_id,
  13910. Ctime: time.Now().Unix(),
  13911. }
  13912. service.CreateMedicalInsuranceCostCompareRecord(micc)
  13913. c.ServeSuccessJSON(map[string]interface{}{
  13914. "msg": "明细对账成功",
  13915. })
  13916. }
  13917. } else {
  13918. }
  13919. }
  13920. }
  13921. type CustomOrderInfo struct {
  13922. Name string
  13923. Spec string
  13924. Unit string
  13925. Count float64
  13926. Price float64
  13927. Total float64
  13928. }
  13929. func (c *HisApiController) GetBatchSettleAccounts() {
  13930. admin_user_id, _ := c.GetInt64("admin_user_id")
  13931. order_ids := c.GetString("order_ids")
  13932. order_ids_arr := strings.Split(order_ids, ",")
  13933. data3 := []map[string]interface{}{}
  13934. for _, item := range order_ids_arr {
  13935. id, _ := strconv.ParseInt(item, 10, 64)
  13936. order_id := id
  13937. adminUser := c.GetAdminUserInfo()
  13938. order, _ := service.GetHisOrderByID(order_id)
  13939. his, _ := service.GetHisPatientByNumber(order.MdtrtId)
  13940. orderInfos, _ := service.GetHisOrderInfoByNumber(order.Number)
  13941. orderInfos_two, _ := service.GetHisOrderInfoByNumberTwo(order.Number)
  13942. orderInfos = append(orderInfos, orderInfos_two...)
  13943. his_hospital, _ := service.GetInHospitalRecordByNumber(order.MdtrtId)
  13944. //diagnosisConfig, _ := service.FindDiagnoseById(his.Diagnosis)
  13945. var diagnosis_ids []string
  13946. if his.ID > 0 {
  13947. diagnosis_ids = strings.Split(his.Diagnosis, ",")
  13948. } else {
  13949. diagnosis_ids = strings.Split(his_hospital.Diagnosis, ",")
  13950. }
  13951. patient, _ := service.GetPatientByIDTwo(adminUser.CurrentOrgId, order.PatientId)
  13952. var dia_config []*models.HisXtDiagnoseConfig
  13953. var name string
  13954. for _, item := range diagnosis_ids {
  13955. id, _ := strconv.ParseInt(item, 10, 64)
  13956. diagnosisConfig, _ := service.FindDiagnoseById(id)
  13957. dia_config = append(dia_config, &diagnosisConfig)
  13958. if len(name) == 0 {
  13959. name = diagnosisConfig.ClassName
  13960. } else {
  13961. name = name + "," + diagnosisConfig.ClassName
  13962. }
  13963. }
  13964. var bedCostTotal float64 = 0 //床位总费
  13965. var bedCostSelfTotal float64 = 0 //床位自费
  13966. var bedCostPartSelfTotal float64 = 0 //床位部分项目自费
  13967. var bedSelfTotal float64 = 0 //床位部分项目自费
  13968. var bedInscpTotal float64 = 0 //床位部分项目自费
  13969. var operationCostTotal float64 = 0 //手术费
  13970. var operationCostSelfTotal float64 = 0 //手术费
  13971. var operationCostPartSelfTotal float64 = 0 //手术费
  13972. var operationSelfTotal float64 = 0 //床位部分项目自费
  13973. var operationInscpTotal float64 = 0 //床位部分项目自费
  13974. var otherCostTotal float64 = 0 //其他费用
  13975. var otherCostSelfTotal float64 = 0 //其他费用
  13976. var otherCostPartSelfTotal float64 = 0 //其他费用
  13977. var otherSelfTotal float64 = 0 //床位部分项目自费
  13978. var otherInscpTotal float64 = 0 //床位部分项目自费
  13979. var materialCostTotal float64 = 0 //材料费
  13980. var materialCostSelfTotal float64 = 0 //材料费
  13981. var materialCostPartSelfTotal float64 = 0 //材料费
  13982. var materialSelfTotal float64 = 0 //床位部分项目自费
  13983. var materialInscpTotal float64 = 0 //床位部分项目自费
  13984. var westernMedicineCostTotal float64 = 0 //西药费
  13985. var westernMedicineCostSelfTotal float64 = 0 //西药费
  13986. var westernMedicineCostPartSelfTotal float64 = 0 //西药费
  13987. var westernMedicineSelfTotal float64 = 0 //床位部分项目自费
  13988. var westernMedicineInscpTotal float64 = 0 //床位部分项目自费
  13989. var chineseTraditionalMedicineCostTotal float64 = 0 //中成药
  13990. var chineseTraditionalMedicineCostSelfTotal float64 = 0 //中成药
  13991. var chineseTraditionalMedicineCostPartSelfTotal float64 = 0 //中成药
  13992. var chineseTraditionalSelfTotal float64 = 0 //床位部分项目自费
  13993. var chineseTraditionalInscpTotal float64 = 0 //床位部分项目自费
  13994. var checkCostTotal float64 = 0 //检查费
  13995. var checkCostSelfTotal float64 = 0 //检查费
  13996. var checkCostPartSelfTotal float64 = 0 //检查费
  13997. var checkSelfTotal float64 = 0 //床位部分项目自费
  13998. var checkInscpTotal float64 = 0 //床位部分项目自费
  13999. var laboratoryCostTotal float64 = 0 //化验费
  14000. var laboratoryCostSelfTotal float64 = 0 //化验费
  14001. var laboratoryCostPartSelfTotal float64 = 0 //化验费
  14002. var laboratorySelfTotal float64 = 0 //床位部分项目自费
  14003. var laboratoryInscpTotal float64 = 0 //床位部分项目自费
  14004. var treatCostTotal float64 = 0 //治疗费用
  14005. var treatCostSelfTotal float64 = 0 //治疗费用
  14006. var treatCostPartSelfTotal float64 = 0 //治疗费用
  14007. var treatSelfTotal float64 = 0 //床位部分项目自费
  14008. var treatInscpTotal float64 = 0 //床位部分项目自费
  14009. decimal.DivisionPrecision = 2
  14010. for _, item := range orderInfos {
  14011. if item.MedChrgitmType == "01" { //床位费
  14012. bedCostTotal, _ = decimal.NewFromFloat(bedCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  14013. bedCostSelfTotal, _ = decimal.NewFromFloat(bedCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  14014. bedCostPartSelfTotal, _ = decimal.NewFromFloat(bedCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  14015. bedSelfTotal, _ = decimal.NewFromFloat(bedSelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  14016. bedInscpTotal, _ = decimal.NewFromFloat(bedInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
  14017. }
  14018. if c.GetAdminUserInfo().CurrentOrgId == 10188 || c.GetAdminUserInfo().CurrentOrgId == 10217 {
  14019. if item.MedChrgitmType == "03" { //检查费
  14020. laboratoryCostTotal, _ = decimal.NewFromFloat(laboratoryCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  14021. laboratoryCostSelfTotal, _ = decimal.NewFromFloat(laboratoryCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  14022. laboratoryCostPartSelfTotal, _ = decimal.NewFromFloat(laboratoryCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  14023. laboratorySelfTotal, _ = decimal.NewFromFloat(laboratorySelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  14024. laboratoryInscpTotal, _ = decimal.NewFromFloat(laboratoryInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
  14025. }
  14026. } else {
  14027. if item.MedChrgitmType == "03" { //检查费
  14028. checkCostTotal, _ = decimal.NewFromFloat(checkCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  14029. checkCostSelfTotal, _ = decimal.NewFromFloat(checkCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  14030. checkCostPartSelfTotal, _ = decimal.NewFromFloat(checkCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  14031. checkSelfTotal, _ = decimal.NewFromFloat(checkSelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  14032. checkInscpTotal, _ = decimal.NewFromFloat(checkInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
  14033. }
  14034. }
  14035. if item.MedChrgitmType == "04" { //化验费
  14036. laboratoryCostTotal, _ = decimal.NewFromFloat(laboratoryCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  14037. laboratoryCostSelfTotal, _ = decimal.NewFromFloat(laboratoryCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  14038. laboratoryCostPartSelfTotal, _ = decimal.NewFromFloat(laboratoryCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  14039. laboratorySelfTotal, _ = decimal.NewFromFloat(laboratorySelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  14040. laboratoryInscpTotal, _ = decimal.NewFromFloat(laboratoryInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
  14041. }
  14042. if item.MedChrgitmType == "05" || item.MedChrgitmType == "1402" || item.MedChrgitmType == "1403" { //治疗费
  14043. treatCostTotal, _ = decimal.NewFromFloat(treatCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  14044. treatCostSelfTotal, _ = decimal.NewFromFloat(treatCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  14045. treatCostPartSelfTotal, _ = decimal.NewFromFloat(treatCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  14046. treatSelfTotal, _ = decimal.NewFromFloat(treatSelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  14047. treatInscpTotal, _ = decimal.NewFromFloat(treatInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
  14048. }
  14049. if item.MedChrgitmType == "06" { //手术费
  14050. operationCostTotal, _ = decimal.NewFromFloat(operationCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  14051. operationCostSelfTotal, _ = decimal.NewFromFloat(operationCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  14052. operationCostPartSelfTotal, _ = decimal.NewFromFloat(operationCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  14053. operationSelfTotal, _ = decimal.NewFromFloat(operationSelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  14054. operationInscpTotal, _ = decimal.NewFromFloat(operationInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
  14055. }
  14056. if item.MedChrgitmType == "08" { //材料费
  14057. materialCostTotal, _ = decimal.NewFromFloat(materialCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  14058. materialCostSelfTotal, _ = decimal.NewFromFloat(materialCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  14059. materialCostPartSelfTotal, _ = decimal.NewFromFloat(materialCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  14060. materialSelfTotal, _ = decimal.NewFromFloat(materialSelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  14061. materialInscpTotal, _ = decimal.NewFromFloat(materialInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
  14062. }
  14063. if item.MedChrgitmType == "09" { //西药费
  14064. westernMedicineCostTotal, _ = decimal.NewFromFloat(westernMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  14065. westernMedicineCostSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  14066. westernMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  14067. westernMedicineSelfTotal, _ = decimal.NewFromFloat(westernMedicineSelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  14068. westernMedicineInscpTotal, _ = decimal.NewFromFloat(westernMedicineInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
  14069. }
  14070. if item.MedChrgitmType == "11" { //中成费
  14071. chineseTraditionalMedicineCostTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  14072. chineseTraditionalMedicineCostSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  14073. chineseTraditionalMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  14074. chineseTraditionalSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalSelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  14075. chineseTraditionalInscpTotal, _ = decimal.NewFromFloat(chineseTraditionalInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
  14076. }
  14077. if item.MedChrgitmType == "14" || item.MedChrgitmType == "0" || item.MedChrgitmType == "12" || item.MedChrgitmType == "02" { //其他费
  14078. otherCostTotal, _ = decimal.NewFromFloat(otherCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  14079. otherCostSelfTotal, _ = decimal.NewFromFloat(otherCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  14080. otherCostPartSelfTotal, _ = decimal.NewFromFloat(otherCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  14081. otherSelfTotal, _ = decimal.NewFromFloat(otherSelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  14082. otherInscpTotal, _ = decimal.NewFromFloat(otherInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
  14083. }
  14084. }
  14085. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  14086. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  14087. var user_name string
  14088. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  14089. if role.ID == 0 {
  14090. user_name = "管理员"
  14091. } else {
  14092. user_name = role.UserName
  14093. }
  14094. baseParams := models.BaseParams{
  14095. SecretKey: miConfig.SecretKey,
  14096. FixmedinsCode: miConfig.Code,
  14097. InsuplcAdmdvs: miConfig.InsuplcAdmdvs,
  14098. MdtrtareaAdmvs: miConfig.MdtrtareaAdmvs,
  14099. OrgName: miConfig.OrgName,
  14100. Doctor: user_name,
  14101. RequestUrl: miConfig.Url,
  14102. AccessKey: miConfig.AccessKey,
  14103. }
  14104. businessParams := models.BusinessParams{
  14105. PsnNo: order.PsnNo,
  14106. MdtrtId: order.MdtrtId,
  14107. SetlId: order.SetlId,
  14108. }
  14109. var res ResultEleven
  14110. var resEleven10265 ResultEleven10265
  14111. if config.IsOpen == 1 {
  14112. baseParams.InsuplcAdmdvs = his.InsuplcAdmdvs
  14113. result := service.Gdyb5203(baseParams, businessParams)
  14114. //service.Gdyb5204(baseParams, businessParams)
  14115. //service.Gdyb5302(businessParams.PsnNo, baseParams.OrgName, baseParams.Doctor, baseParams.FixmedinsCode, baseParams.InsuplcAdmdvs, baseParams.MdtrtareaAdmvs, baseParams.SecretKey)
  14116. var dat map[string]interface{}
  14117. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  14118. fmt.Println(dat)
  14119. } else {
  14120. fmt.Println(err)
  14121. }
  14122. userJSONBytes, _ := json.Marshal(dat)
  14123. if miConfig.Code == "H15049901371" {
  14124. if err := json.Unmarshal(userJSONBytes, &resEleven10265); err != nil {
  14125. utils.ErrorLog("解析失败:%v", err)
  14126. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14127. return
  14128. }
  14129. res.InfRefmsgid = resEleven10265.InfRefmsgid
  14130. res.Output = resEleven10265.Output
  14131. res.ErrMsg = resEleven10265.ErrMsg
  14132. res.Cainfo = resEleven10265.Cainfo
  14133. res.WarnMsg = resEleven10265.WarnMsg
  14134. infocode, _ := strconv.ParseInt(resEleven10265.Infcode, 10, 64)
  14135. res.Infcode = infocode
  14136. } else {
  14137. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  14138. utils.ErrorLog("解析失败:%v", err)
  14139. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14140. return
  14141. }
  14142. }
  14143. printor_admin, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  14144. charge_admin, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, order.Creator)
  14145. patientPrescription, _ := service.FindPatientPrescriptionInfo(adminUser.CurrentOrgId, order.PatientId, order.SettleAccountsDate)
  14146. adminRole_two, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, patientPrescription.DoctorId)
  14147. doctor_info, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, his_hospital.Doctor)
  14148. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  14149. var doctor_name string
  14150. if roles.ID == 0 {
  14151. doctor_name = "管理员"
  14152. } else {
  14153. doctor_name = roles.UserName
  14154. }
  14155. yiliao_leibie := ""
  14156. switch order.MedType {
  14157. case "11":
  14158. yiliao_leibie = "普通门诊"
  14159. break
  14160. case "12":
  14161. yiliao_leibie = "门诊挂号"
  14162. break
  14163. case "13":
  14164. yiliao_leibie = "急诊"
  14165. break
  14166. case "14":
  14167. yiliao_leibie = "门诊特殊病"
  14168. break
  14169. case "15":
  14170. yiliao_leibie = "门诊统筹"
  14171. break
  14172. case "16":
  14173. yiliao_leibie = "门诊慢性病"
  14174. break
  14175. case "21":
  14176. yiliao_leibie = "普通住院"
  14177. break
  14178. }
  14179. departments, _ := service.GetDepartMentDetail(patientPrescription.Departments)
  14180. res.Output.Setlinfo.PsnCashPay = res.Output.Setlinfo.CashPayamt
  14181. if res.Infcode == 0 {
  14182. data2 := map[string]interface{}{
  14183. "diagnosis": name,
  14184. "order_infos": orderInfos,
  14185. "number": order.MdtrtId,
  14186. "date": order.SettleAccountsDate,
  14187. "charge_admin": charge_admin,
  14188. "printor_admin": printor_admin,
  14189. "info": res.Output.Setlinfo,
  14190. "order": order,
  14191. "bedCostTotal": bedCostTotal,
  14192. "bedCostSelfTotal": bedCostSelfTotal,
  14193. "bedCostPartSelfTotal": bedCostPartSelfTotal,
  14194. "bedSelfTotal": bedSelfTotal,
  14195. "bedInscpTotal": bedInscpTotal,
  14196. "operationCostTotal": operationCostTotal,
  14197. "operationCostSelfTotal": operationCostSelfTotal,
  14198. "operationCostPartSelfTotal": operationCostPartSelfTotal,
  14199. "operationSelfTotal": operationSelfTotal,
  14200. "operationInscpTotal": operationInscpTotal,
  14201. "otherCostTotal": otherCostTotal,
  14202. "otherCostSelfTotal": otherCostSelfTotal,
  14203. "otherCostPartSelfTotal": otherCostPartSelfTotal,
  14204. "otherSelfTotal": otherSelfTotal,
  14205. "otherInscpTotal": otherInscpTotal,
  14206. "materialCostTotal": materialCostTotal,
  14207. "materialCostSelfTotal": materialCostSelfTotal,
  14208. "materialCostPartSelfTotal": materialCostPartSelfTotal,
  14209. "materialSelfTotal": materialSelfTotal,
  14210. "materialInscpTotal": materialInscpTotal,
  14211. "westernMedicineCostTotal": westernMedicineCostTotal,
  14212. "westernMedicineCostSelfTotal": westernMedicineCostSelfTotal,
  14213. "westernMedicineCostPartSelfTotal": westernMedicineCostPartSelfTotal,
  14214. "westernMedicineSelfTotal": westernMedicineSelfTotal,
  14215. "westernMedicineInscpTotal": westernMedicineInscpTotal,
  14216. "chineseTraditionalMedicineCostTotal": chineseTraditionalMedicineCostTotal,
  14217. "chineseTraditionalMedicineCostSelfTotal": chineseTraditionalMedicineCostSelfTotal,
  14218. "chineseTraditionalMedicineCostPartSelfTotal": chineseTraditionalMedicineCostPartSelfTotal,
  14219. "chineseTraditionalSelfTotal": chineseTraditionalSelfTotal,
  14220. "chineseTraditionalInscpTotal": chineseTraditionalInscpTotal,
  14221. "checkCostTotal": checkCostTotal,
  14222. "checkCostSelfTotal": checkCostSelfTotal,
  14223. "checkCostPartSelfTotal": checkCostPartSelfTotal,
  14224. "checkSelfTotal": checkSelfTotal,
  14225. "checkInscpTotal": checkInscpTotal,
  14226. "laboratoryCostTotal": laboratoryCostTotal,
  14227. "laboratoryCostSelfTotal": laboratoryCostSelfTotal,
  14228. "laboratoryCostPartSelfTotal": laboratoryCostPartSelfTotal,
  14229. "laboratorySelfTotal": laboratorySelfTotal,
  14230. "laboratoryInscpTotal": laboratoryInscpTotal,
  14231. "treatCostTotal": treatCostTotal,
  14232. "treatCostSelfTotal": treatCostSelfTotal,
  14233. "treatCostPartSelfTotal": treatCostPartSelfTotal,
  14234. "treatSelfTotal": treatSelfTotal,
  14235. "treatInscpTotal": treatInscpTotal,
  14236. "doctor_info": doctor_info,
  14237. "doctor_code": adminRole_two.DoctorCode,
  14238. "doctor_name": doctor_name,
  14239. "health_card_no": order.PsnNo,
  14240. "department": departments.Name,
  14241. "yiliao_leibie": yiliao_leibie,
  14242. "after_money": order.AccountPrice,
  14243. "patient": patient,
  14244. "org_name": miConfig.OrgName,
  14245. "org_code": miConfig.Code,
  14246. "order_number": order.Number,
  14247. "his_hospital": his_hospital,
  14248. "his": his,
  14249. "dia_config": dia_config,
  14250. "psn_cash_pay": order.PsnCashPay,
  14251. //"check_order_info": cus_slice,
  14252. }
  14253. data3 = append(data3, data2)
  14254. }
  14255. }
  14256. }
  14257. c.ServeSuccessJSON(map[string]interface{}{
  14258. "infos": data3,
  14259. })
  14260. }
  14261. func (c *HisApiController) GetSettleAccounts() {
  14262. //id, _ := c.GetInt64("id")
  14263. //record_time := c.GetString("record_time")
  14264. order_id, _ := c.GetInt64("order_id")
  14265. admin_user_id, _ := c.GetInt64("admin_user_id")
  14266. //timeLayout := "2006-01-02"
  14267. //loc, _ := time.LoadLocation("Local")
  14268. //
  14269. //theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  14270. //if err != nil {
  14271. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  14272. // return
  14273. //}
  14274. //recordDateTime := theTime.Unix()
  14275. adminUser := c.GetAdminUserInfo()
  14276. order, _ := service.GetHisOrderByID(order_id)
  14277. his, _ := service.GetHisPatientByNumber(order.MdtrtId)
  14278. orderInfos, _ := service.GetHisOrderInfoByNumber(order.Number)
  14279. orderInfos_two, _ := service.GetHisOrderInfoByNumberTwo(order.Number)
  14280. orderInfos = append(orderInfos, orderInfos_two...)
  14281. his_hospital, _ := service.GetInHospitalRecordByNumber(order.MdtrtId)
  14282. //diagnosisConfig, _ := service.FindDiagnoseById(his.Diagnosis)
  14283. var diagnosis_ids []string
  14284. if his.ID > 0 {
  14285. diagnosis_ids = strings.Split(his.Diagnosis, ",")
  14286. } else {
  14287. diagnosis_ids = strings.Split(his_hospital.Diagnosis, ",")
  14288. }
  14289. patient, _ := service.GetPatientByIDTwo(adminUser.CurrentOrgId, order.PatientId)
  14290. var dia_config []*models.HisXtDiagnoseConfig
  14291. var name string
  14292. for _, item := range diagnosis_ids {
  14293. id, _ := strconv.ParseInt(item, 10, 64)
  14294. diagnosisConfig, _ := service.FindDiagnoseById(id)
  14295. dia_config = append(dia_config, &diagnosisConfig)
  14296. if len(name) == 0 {
  14297. name = diagnosisConfig.ClassName
  14298. } else {
  14299. name = name + "," + diagnosisConfig.ClassName
  14300. }
  14301. }
  14302. var bedCostTotal float64 = 0 //床位总费
  14303. var bedCostSelfTotal float64 = 0 //床位自费
  14304. var bedCostPartSelfTotal float64 = 0 //床位部分项目自费
  14305. var bedSelfTotal float64 = 0 //床位部分项目自费
  14306. var bedInscpTotal float64 = 0 //床位部分项目自费
  14307. var operationCostTotal float64 = 0 //手术费
  14308. var operationCostSelfTotal float64 = 0 //手术费
  14309. var operationCostPartSelfTotal float64 = 0 //手术费
  14310. var operationSelfTotal float64 = 0 //床位部分项目自费
  14311. var operationInscpTotal float64 = 0 //床位部分项目自费
  14312. var otherCostTotal float64 = 0 //其他费用
  14313. var otherCostSelfTotal float64 = 0 //其他费用
  14314. var otherCostPartSelfTotal float64 = 0 //其他费用
  14315. var otherSelfTotal float64 = 0 //床位部分项目自费
  14316. var otherInscpTotal float64 = 0 //床位部分项目自费
  14317. var materialCostTotal float64 = 0 //材料费
  14318. var materialCostSelfTotal float64 = 0 //材料费
  14319. var materialCostPartSelfTotal float64 = 0 //材料费
  14320. var materialSelfTotal float64 = 0 //床位部分项目自费
  14321. var materialInscpTotal float64 = 0 //床位部分项目自费
  14322. var westernMedicineCostTotal float64 = 0 //西药费
  14323. var westernMedicineCostSelfTotal float64 = 0 //西药费
  14324. var westernMedicineCostPartSelfTotal float64 = 0 //西药费
  14325. var westernMedicineSelfTotal float64 = 0 //床位部分项目自费
  14326. var westernMedicineInscpTotal float64 = 0 //床位部分项目自费
  14327. var chineseTraditionalMedicineCostTotal float64 = 0 //中成药
  14328. var chineseTraditionalMedicineCostSelfTotal float64 = 0 //中成药
  14329. var chineseTraditionalMedicineCostPartSelfTotal float64 = 0 //中成药
  14330. var chineseTraditionalSelfTotal float64 = 0 //床位部分项目自费
  14331. var chineseTraditionalInscpTotal float64 = 0 //床位部分项目自费
  14332. var checkCostTotal float64 = 0 //检查费
  14333. var checkCostSelfTotal float64 = 0 //检查费
  14334. var checkCostPartSelfTotal float64 = 0 //检查费
  14335. var checkSelfTotal float64 = 0 //床位部分项目自费
  14336. var checkInscpTotal float64 = 0 //床位部分项目自费
  14337. var laboratoryCostTotal float64 = 0 //化验费
  14338. var laboratoryCostSelfTotal float64 = 0 //化验费
  14339. var laboratoryCostPartSelfTotal float64 = 0 //化验费
  14340. var laboratorySelfTotal float64 = 0 //床位部分项目自费
  14341. var laboratoryInscpTotal float64 = 0 //床位部分项目自费
  14342. var treatCostTotal float64 = 0 //治疗费用
  14343. var treatCostSelfTotal float64 = 0 //治疗费用
  14344. var treatCostPartSelfTotal float64 = 0 //治疗费用
  14345. var treatSelfTotal float64 = 0 //床位部分项目自费
  14346. var treatInscpTotal float64 = 0 //床位部分项目自费
  14347. decimal.DivisionPrecision = 2
  14348. for _, item := range orderInfos {
  14349. if item.MedChrgitmType == "01" { //床位费
  14350. bedCostTotal, _ = decimal.NewFromFloat(bedCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  14351. bedCostSelfTotal, _ = decimal.NewFromFloat(bedCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  14352. bedCostPartSelfTotal, _ = decimal.NewFromFloat(bedCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  14353. bedSelfTotal, _ = decimal.NewFromFloat(bedSelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  14354. bedInscpTotal, _ = decimal.NewFromFloat(bedInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
  14355. }
  14356. if c.GetAdminUserInfo().CurrentOrgId == 10188 || c.GetAdminUserInfo().CurrentOrgId == 10217 {
  14357. if item.MedChrgitmType == "03" { //检查费
  14358. laboratoryCostTotal, _ = decimal.NewFromFloat(laboratoryCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  14359. laboratoryCostSelfTotal, _ = decimal.NewFromFloat(laboratoryCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  14360. laboratoryCostPartSelfTotal, _ = decimal.NewFromFloat(laboratoryCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  14361. laboratorySelfTotal, _ = decimal.NewFromFloat(laboratorySelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  14362. laboratoryInscpTotal, _ = decimal.NewFromFloat(laboratoryInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
  14363. }
  14364. } else {
  14365. if item.MedChrgitmType == "03" { //检查费
  14366. checkCostTotal, _ = decimal.NewFromFloat(checkCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  14367. checkCostSelfTotal, _ = decimal.NewFromFloat(checkCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  14368. checkCostPartSelfTotal, _ = decimal.NewFromFloat(checkCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  14369. checkSelfTotal, _ = decimal.NewFromFloat(checkSelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  14370. checkInscpTotal, _ = decimal.NewFromFloat(checkInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
  14371. }
  14372. }
  14373. if item.MedChrgitmType == "04" { //化验费
  14374. laboratoryCostTotal, _ = decimal.NewFromFloat(laboratoryCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  14375. laboratoryCostSelfTotal, _ = decimal.NewFromFloat(laboratoryCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  14376. laboratoryCostPartSelfTotal, _ = decimal.NewFromFloat(laboratoryCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  14377. laboratorySelfTotal, _ = decimal.NewFromFloat(laboratorySelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  14378. laboratoryInscpTotal, _ = decimal.NewFromFloat(laboratoryInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
  14379. }
  14380. if item.MedChrgitmType == "05" || item.MedChrgitmType == "1402" || item.MedChrgitmType == "1403" { //治疗费
  14381. treatCostTotal, _ = decimal.NewFromFloat(treatCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  14382. treatCostSelfTotal, _ = decimal.NewFromFloat(treatCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  14383. treatCostPartSelfTotal, _ = decimal.NewFromFloat(treatCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  14384. treatSelfTotal, _ = decimal.NewFromFloat(treatSelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  14385. treatInscpTotal, _ = decimal.NewFromFloat(treatInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
  14386. }
  14387. if item.MedChrgitmType == "06" { //手术费
  14388. operationCostTotal, _ = decimal.NewFromFloat(operationCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  14389. operationCostSelfTotal, _ = decimal.NewFromFloat(operationCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  14390. operationCostPartSelfTotal, _ = decimal.NewFromFloat(operationCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  14391. operationSelfTotal, _ = decimal.NewFromFloat(operationSelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  14392. operationInscpTotal, _ = decimal.NewFromFloat(operationInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
  14393. }
  14394. if item.MedChrgitmType == "08" { //材料费
  14395. materialCostTotal, _ = decimal.NewFromFloat(materialCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  14396. materialCostSelfTotal, _ = decimal.NewFromFloat(materialCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  14397. materialCostPartSelfTotal, _ = decimal.NewFromFloat(materialCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  14398. materialSelfTotal, _ = decimal.NewFromFloat(materialSelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  14399. materialInscpTotal, _ = decimal.NewFromFloat(materialInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
  14400. }
  14401. if item.MedChrgitmType == "09" { //西药费
  14402. westernMedicineCostTotal, _ = decimal.NewFromFloat(westernMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  14403. westernMedicineCostSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  14404. westernMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  14405. westernMedicineSelfTotal, _ = decimal.NewFromFloat(westernMedicineSelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  14406. westernMedicineInscpTotal, _ = decimal.NewFromFloat(westernMedicineInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
  14407. }
  14408. if item.MedChrgitmType == "11" { //中成费
  14409. chineseTraditionalMedicineCostTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  14410. chineseTraditionalMedicineCostSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  14411. chineseTraditionalMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  14412. chineseTraditionalSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalSelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  14413. chineseTraditionalInscpTotal, _ = decimal.NewFromFloat(chineseTraditionalInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
  14414. }
  14415. if item.MedChrgitmType == "14" || item.MedChrgitmType == "0" || item.MedChrgitmType == "12" || item.MedChrgitmType == "02" { //其他费
  14416. otherCostTotal, _ = decimal.NewFromFloat(otherCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  14417. otherCostSelfTotal, _ = decimal.NewFromFloat(otherCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  14418. otherCostPartSelfTotal, _ = decimal.NewFromFloat(otherCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  14419. otherSelfTotal, _ = decimal.NewFromFloat(otherSelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  14420. otherInscpTotal, _ = decimal.NewFromFloat(otherInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
  14421. }
  14422. }
  14423. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  14424. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  14425. var user_name string
  14426. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  14427. if role.ID == 0 {
  14428. user_name = "管理员"
  14429. } else {
  14430. user_name = role.UserName
  14431. }
  14432. baseParams := models.BaseParams{
  14433. SecretKey: miConfig.SecretKey,
  14434. FixmedinsCode: miConfig.Code,
  14435. InsuplcAdmdvs: miConfig.InsuplcAdmdvs,
  14436. MdtrtareaAdmvs: miConfig.MdtrtareaAdmvs,
  14437. OrgName: miConfig.OrgName,
  14438. Doctor: user_name,
  14439. RequestUrl: miConfig.Url,
  14440. AccessKey: miConfig.AccessKey,
  14441. }
  14442. businessParams := models.BusinessParams{
  14443. PsnNo: order.PsnNo,
  14444. MdtrtId: order.MdtrtId,
  14445. SetlId: order.SetlId,
  14446. }
  14447. var res ResultEleven
  14448. var resEleven10265 ResultEleven10265
  14449. if config.IsOpen == 1 {
  14450. if miConfig.MdtrtareaAdmvs == "421300" {
  14451. api := "http://192.168.124.4:9532/" + "hbyb/5203?psn_no=" + businessParams.PsnNo + "&mdtrt_id=" + businessParams.MdtrtId + "&setl_id=" + businessParams.SetlId +
  14452. "&org_name=" + miConfig.OrgName + "&doctor=" + baseParams.Doctor + "&fixmedins_code=" + miConfig.Code +
  14453. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  14454. resp, requestErr := http.Get(api)
  14455. if requestErr != nil {
  14456. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14457. return
  14458. }
  14459. body, ioErr := ioutil.ReadAll(resp.Body)
  14460. if ioErr != nil {
  14461. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  14462. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14463. return
  14464. }
  14465. var respJSON map[string]interface{}
  14466. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  14467. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  14468. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14469. return
  14470. }
  14471. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  14472. result, _ := json.Marshal(respJSON)
  14473. fmt.Println("log")
  14474. fmt.Println(string(result))
  14475. if err := json.Unmarshal([]byte(result), &res); err != nil {
  14476. utils.ErrorLog("解析失败:%v", err)
  14477. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14478. return
  14479. }
  14480. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  14481. var api string
  14482. if miConfig.MdtrtareaAdmvs == "320921" {
  14483. api = "http://192.168.2.3:9532/" + "jsyb/5203?psn_no=" + businessParams.PsnNo + "&mdtrt_id=" + businessParams.MdtrtId + "&setl_id=" + businessParams.SetlId +
  14484. "&org_name=" + miConfig.OrgName + "&doctor=" + baseParams.Doctor + "&fixmedins_code=" + miConfig.Code +
  14485. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  14486. //req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  14487. } else {
  14488. //req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  14489. api = "http://192.168.5.251:9532/" + "jsyb/5203?psn_no=" + businessParams.PsnNo + "&mdtrt_id=" + businessParams.MdtrtId + "&setl_id=" + businessParams.SetlId +
  14490. "&org_name=" + miConfig.OrgName + "&doctor=" + baseParams.Doctor + "&fixmedins_code=" + miConfig.Code +
  14491. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  14492. }
  14493. resp, requestErr := http.Get(api)
  14494. if requestErr != nil {
  14495. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14496. return
  14497. }
  14498. body, ioErr := ioutil.ReadAll(resp.Body)
  14499. if ioErr != nil {
  14500. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  14501. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14502. return
  14503. }
  14504. var respJSON map[string]interface{}
  14505. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  14506. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  14507. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14508. return
  14509. }
  14510. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  14511. result, _ := json.Marshal(respJSON)
  14512. fmt.Println("log")
  14513. fmt.Println(string(result))
  14514. if err := json.Unmarshal([]byte(result), &resEleven10265); err != nil {
  14515. utils.ErrorLog("解析失败:%v", err)
  14516. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14517. return
  14518. }
  14519. res.InfRefmsgid = resEleven10265.InfRefmsgid
  14520. res.Output = resEleven10265.Output
  14521. res.ErrMsg = resEleven10265.ErrMsg
  14522. res.Cainfo = resEleven10265.Cainfo
  14523. res.WarnMsg = resEleven10265.WarnMsg
  14524. infocode, _ := strconv.ParseInt(resEleven10265.Infcode, 10, 64)
  14525. res.Infcode = infocode
  14526. } else if miConfig.MdtrtareaAdmvs == "350500" {
  14527. result, requestLog, _ := service.FJyb5203(baseParams, businessParams, miConfig.Url, miConfig.Code, miConfig.AppSecret, miConfig.SignKey, miConfig.EncKey)
  14528. saveLog(result, requestLog, "5203", "结算单")
  14529. var dat map[string]interface{}
  14530. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  14531. fmt.Println(dat)
  14532. } else {
  14533. fmt.Println(err)
  14534. }
  14535. userJSONBytes, _ := json.Marshal(dat)
  14536. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  14537. utils.ErrorLog("解析失败:%v", err)
  14538. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14539. return
  14540. }
  14541. } else if miConfig.MdtrtareaAdmvs == "360399" {
  14542. result, requestLog := service.Jxyb5203(baseParams, businessParams)
  14543. saveLog(result, requestLog, "5203", "结算单")
  14544. var dat map[string]interface{}
  14545. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  14546. fmt.Println(dat)
  14547. } else {
  14548. fmt.Println(err)
  14549. }
  14550. userJSONBytes, _ := json.Marshal(dat)
  14551. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  14552. utils.ErrorLog("解析失败:%v", err)
  14553. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14554. return
  14555. }
  14556. } else if miConfig.MdtrtareaAdmvs == "430800" {
  14557. result, requestLog := service.Hnyb5203(baseParams, businessParams)
  14558. saveLog(result, requestLog, "5203", "结算单")
  14559. var dat map[string]interface{}
  14560. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  14561. fmt.Println(dat)
  14562. } else {
  14563. fmt.Println(err)
  14564. }
  14565. userJSONBytes, _ := json.Marshal(dat)
  14566. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  14567. utils.ErrorLog("解析失败:%v", err)
  14568. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14569. return
  14570. }
  14571. } else if miConfig.MdtrtareaAdmvs == "150499" {
  14572. api := "http://172.16.13.254:9532/" + "nmyb/5203?psn_no=" + businessParams.PsnNo + "&mdtrt_id=" + businessParams.MdtrtId + "&setl_id=" + businessParams.SetlId +
  14573. "&org_name=" + miConfig.OrgName + "&doctor=" + baseParams.Doctor + "&fixmedins_code=" + miConfig.Code +
  14574. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  14575. resp, requestErr := http.Get(api)
  14576. if requestErr != nil {
  14577. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14578. return
  14579. }
  14580. body, ioErr := ioutil.ReadAll(resp.Body)
  14581. if ioErr != nil {
  14582. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  14583. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14584. return
  14585. }
  14586. var respJSON map[string]interface{}
  14587. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  14588. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  14589. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14590. return
  14591. }
  14592. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  14593. result, _ := json.Marshal(respJSON)
  14594. fmt.Println("log")
  14595. fmt.Println(string(result))
  14596. if err := json.Unmarshal([]byte(result), &resEleven10265); err != nil {
  14597. utils.ErrorLog("解析失败:%v", err)
  14598. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14599. return
  14600. }
  14601. res.InfRefmsgid = resEleven10265.InfRefmsgid
  14602. res.Output = resEleven10265.Output
  14603. res.ErrMsg = resEleven10265.ErrMsg
  14604. res.Cainfo = resEleven10265.Cainfo
  14605. res.WarnMsg = resEleven10265.WarnMsg
  14606. infocode, _ := strconv.ParseInt(resEleven10265.Infcode, 10, 64)
  14607. res.Infcode = infocode
  14608. } else {
  14609. baseParams.InsuplcAdmdvs = his.InsuplcAdmdvs
  14610. result := service.Gdyb5203(baseParams, businessParams)
  14611. //service.Gdyb5204(baseParams, businessParams)
  14612. //service.Gdyb5302(businessParams.PsnNo, baseParams.OrgName, baseParams.Doctor, baseParams.FixmedinsCode, baseParams.InsuplcAdmdvs, baseParams.MdtrtareaAdmvs, baseParams.SecretKey)
  14613. var dat map[string]interface{}
  14614. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  14615. fmt.Println(dat)
  14616. } else {
  14617. fmt.Println(err)
  14618. }
  14619. userJSONBytes, _ := json.Marshal(dat)
  14620. if miConfig.Code == "H15049901371" {
  14621. if err := json.Unmarshal(userJSONBytes, &resEleven10265); err != nil {
  14622. utils.ErrorLog("解析失败:%v", err)
  14623. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14624. return
  14625. }
  14626. res.InfRefmsgid = resEleven10265.InfRefmsgid
  14627. res.Output = resEleven10265.Output
  14628. res.ErrMsg = resEleven10265.ErrMsg
  14629. res.Cainfo = resEleven10265.Cainfo
  14630. res.WarnMsg = resEleven10265.WarnMsg
  14631. infocode, _ := strconv.ParseInt(resEleven10265.Infcode, 10, 64)
  14632. res.Infcode = infocode
  14633. } else {
  14634. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  14635. utils.ErrorLog("解析失败:%v", err)
  14636. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14637. return
  14638. }
  14639. }
  14640. }
  14641. printor_admin, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  14642. charge_admin, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, order.Creator)
  14643. patientPrescription, _ := service.FindPatientPrescriptionInfo(adminUser.CurrentOrgId, order.PatientId, order.SettleAccountsDate)
  14644. adminRole_two, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, patientPrescription.DoctorId)
  14645. doctor_info, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, his_hospital.Doctor)
  14646. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  14647. var doctor_name string
  14648. if roles.ID == 0 {
  14649. doctor_name = "管理员"
  14650. } else {
  14651. doctor_name = roles.UserName
  14652. }
  14653. yiliao_leibie := ""
  14654. switch order.MedType {
  14655. case "11":
  14656. yiliao_leibie = "普通门诊"
  14657. break
  14658. case "12":
  14659. yiliao_leibie = "门诊挂号"
  14660. break
  14661. case "13":
  14662. yiliao_leibie = "急诊"
  14663. break
  14664. case "14":
  14665. yiliao_leibie = "门诊特殊病"
  14666. break
  14667. case "15":
  14668. yiliao_leibie = "门诊统筹"
  14669. break
  14670. case "16":
  14671. yiliao_leibie = "门诊慢性病"
  14672. break
  14673. case "21":
  14674. yiliao_leibie = "普通住院"
  14675. break
  14676. }
  14677. departments, _ := service.GetDepartMentDetail(patientPrescription.Departments)
  14678. res.Output.Setlinfo.PsnCashPay = res.Output.Setlinfo.CashPayamt
  14679. if res.Infcode == 0 {
  14680. c.ServeSuccessJSON(map[string]interface{}{
  14681. "diagnosis": name,
  14682. "order_infos": orderInfos,
  14683. "number": order.MdtrtId,
  14684. "date": order.SettleAccountsDate,
  14685. "charge_admin": charge_admin,
  14686. "printor_admin": printor_admin,
  14687. "info": res.Output.Setlinfo,
  14688. "order": order,
  14689. "bedCostTotal": bedCostTotal,
  14690. "bedCostSelfTotal": bedCostSelfTotal,
  14691. "bedCostPartSelfTotal": bedCostPartSelfTotal,
  14692. "bedSelfTotal": bedSelfTotal,
  14693. "bedInscpTotal": bedInscpTotal,
  14694. "operationCostTotal": operationCostTotal,
  14695. "operationCostSelfTotal": operationCostSelfTotal,
  14696. "operationCostPartSelfTotal": operationCostPartSelfTotal,
  14697. "operationSelfTotal": operationSelfTotal,
  14698. "operationInscpTotal": operationInscpTotal,
  14699. "otherCostTotal": otherCostTotal,
  14700. "otherCostSelfTotal": otherCostSelfTotal,
  14701. "otherCostPartSelfTotal": otherCostPartSelfTotal,
  14702. "otherSelfTotal": otherSelfTotal,
  14703. "otherInscpTotal": otherInscpTotal,
  14704. "materialCostTotal": materialCostTotal,
  14705. "materialCostSelfTotal": materialCostSelfTotal,
  14706. "materialCostPartSelfTotal": materialCostPartSelfTotal,
  14707. "materialSelfTotal": materialSelfTotal,
  14708. "materialInscpTotal": materialInscpTotal,
  14709. "westernMedicineCostTotal": westernMedicineCostTotal,
  14710. "westernMedicineCostSelfTotal": westernMedicineCostSelfTotal,
  14711. "westernMedicineCostPartSelfTotal": westernMedicineCostPartSelfTotal,
  14712. "westernMedicineSelfTotal": westernMedicineSelfTotal,
  14713. "westernMedicineInscpTotal": westernMedicineInscpTotal,
  14714. "chineseTraditionalMedicineCostTotal": chineseTraditionalMedicineCostTotal,
  14715. "chineseTraditionalMedicineCostSelfTotal": chineseTraditionalMedicineCostSelfTotal,
  14716. "chineseTraditionalMedicineCostPartSelfTotal": chineseTraditionalMedicineCostPartSelfTotal,
  14717. "chineseTraditionalSelfTotal": chineseTraditionalSelfTotal,
  14718. "chineseTraditionalInscpTotal": chineseTraditionalInscpTotal,
  14719. "checkCostTotal": checkCostTotal,
  14720. "checkCostSelfTotal": checkCostSelfTotal,
  14721. "checkCostPartSelfTotal": checkCostPartSelfTotal,
  14722. "checkSelfTotal": checkSelfTotal,
  14723. "checkInscpTotal": checkInscpTotal,
  14724. "laboratoryCostTotal": laboratoryCostTotal,
  14725. "laboratoryCostSelfTotal": laboratoryCostSelfTotal,
  14726. "laboratoryCostPartSelfTotal": laboratoryCostPartSelfTotal,
  14727. "laboratorySelfTotal": laboratorySelfTotal,
  14728. "laboratoryInscpTotal": laboratoryInscpTotal,
  14729. "treatCostTotal": treatCostTotal,
  14730. "treatCostSelfTotal": treatCostSelfTotal,
  14731. "treatCostPartSelfTotal": treatCostPartSelfTotal,
  14732. "treatSelfTotal": treatSelfTotal,
  14733. "treatInscpTotal": treatInscpTotal,
  14734. "doctor_info": doctor_info,
  14735. "doctor_code": adminRole_two.DoctorCode,
  14736. "doctor_name": doctor_name,
  14737. "health_card_no": order.PsnNo,
  14738. "department": departments.Name,
  14739. "yiliao_leibie": yiliao_leibie,
  14740. "after_money": order.AccountPrice,
  14741. "patient": patient,
  14742. "org_name": miConfig.OrgName,
  14743. "org_code": miConfig.Code,
  14744. "order_number": order.Number,
  14745. "his_hospital": his_hospital,
  14746. "his": his,
  14747. "dia_config": dia_config,
  14748. "psn_cash_pay": order.PsnCashPay,
  14749. //"check_order_info": cus_slice,
  14750. })
  14751. }
  14752. }
  14753. }
  14754. func (c *HisApiController) CheckTreatment() {
  14755. patient_id, _ := c.GetInt64("patient_id")
  14756. id_card_no := c.GetString("id_card_no")
  14757. insutype := c.GetString("insutype")
  14758. med_type := c.GetString("med_type")
  14759. admin_user_id, _ := c.GetInt64("admin_user_id")
  14760. adminUser := c.GetAdminUserInfo()
  14761. patient, _ := service.GetPatientByID(adminUser.CurrentOrgId, patient_id)
  14762. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  14763. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  14764. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  14765. if miConfig.MdtrtareaAdmvs == "421300" {
  14766. var res ResultTwo
  14767. api := "http://192.168.124.4:9532/" + "hbyb/1101?cert_no=" + "" +
  14768. "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  14769. "&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)
  14770. resp, requestErr := http.Get(api)
  14771. if requestErr != nil {
  14772. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14773. return
  14774. }
  14775. body, ioErr := ioutil.ReadAll(resp.Body)
  14776. if ioErr != nil {
  14777. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  14778. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14779. return
  14780. }
  14781. var respJSON map[string]interface{}
  14782. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  14783. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  14784. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14785. return
  14786. }
  14787. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  14788. result, _ := json.Marshal(respJSON)
  14789. if err := json.Unmarshal([]byte(result), &res); err != nil {
  14790. utils.ErrorLog("解析失败:%v", err)
  14791. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14792. return
  14793. }
  14794. if res.Infcode == 0 {
  14795. api := "http://192.168.124.4:9532/" + "hbyb/2001?cert_no=" + "" +
  14796. "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  14797. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&psn_no=" + res.Output.Baseinfo.PsnNo + "&insutype=" + insutype + "&med_type=" + med_type
  14798. resp, requestErr := http.Get(api)
  14799. if requestErr != nil {
  14800. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14801. return
  14802. }
  14803. body, ioErr := ioutil.ReadAll(resp.Body)
  14804. if ioErr != nil {
  14805. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  14806. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14807. return
  14808. }
  14809. var respJSON map[string]interface{}
  14810. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  14811. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  14812. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14813. return
  14814. }
  14815. var res Result2001
  14816. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  14817. result2, _ := json.Marshal(respJSON)
  14818. if err := json.Unmarshal([]byte(result2), &res); err != nil {
  14819. utils.ErrorLog("解析失败:%v", err)
  14820. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14821. return
  14822. }
  14823. if res.Infcode == 0 {
  14824. c.ServeSuccessJSON(map[string]interface{}{
  14825. "msg": res.Output.Trtinfo,
  14826. })
  14827. }
  14828. } else {
  14829. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  14830. return
  14831. }
  14832. } else {
  14833. result := service.Gdyb1101A(id_card_no, miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, patient.Name)
  14834. var dat map[string]interface{}
  14835. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  14836. fmt.Println(dat)
  14837. } else {
  14838. fmt.Println(err)
  14839. }
  14840. userJSONBytes, _ := json.Marshal(dat)
  14841. var res ResultTwo
  14842. var res10265 ResultTwo10265
  14843. if miConfig.Code == "H15049901371" {
  14844. if err := json.Unmarshal(userJSONBytes, &res10265); err != nil {
  14845. utils.ErrorLog("解析失败:%v", err)
  14846. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14847. return
  14848. }
  14849. res.ErrMsg = res10265.ErrMsg
  14850. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  14851. res.Infcode = infocode
  14852. res.Output = res10265.Output
  14853. res.InfRefmsgid = res10265.InfRefmsgid
  14854. } else {
  14855. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  14856. utils.ErrorLog("解析失败:%v", err)
  14857. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14858. return
  14859. }
  14860. }
  14861. var user_name string
  14862. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, adminUser.AdminUser.Id)
  14863. if role.ID == 0 {
  14864. user_name = "xxx"
  14865. } else {
  14866. user_name = role.UserName
  14867. }
  14868. baseParams := models.BaseParams{
  14869. SecretKey: miConfig.SecretKey,
  14870. FixmedinsCode: miConfig.Code,
  14871. InsuplcAdmdvs: miConfig.InsuplcAdmdvs,
  14872. MdtrtareaAdmvs: miConfig.MdtrtareaAdmvs,
  14873. OrgName: miConfig.OrgName,
  14874. Doctor: user_name,
  14875. }
  14876. if config.IsOpen == 1 {
  14877. if miConfig.Code == "H15049901371" {
  14878. if med_type == "14" {
  14879. if insutype == "390" {
  14880. med_type = "9933"
  14881. } else if insutype == "310" {
  14882. med_type = "990502"
  14883. }
  14884. } else if med_type == "11" {
  14885. med_type = "11"
  14886. }
  14887. }
  14888. result := service.Gdyb2001(baseParams, res.Output.Baseinfo.PsnNo, insutype, med_type)
  14889. var dat map[string]interface{}
  14890. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  14891. fmt.Println(dat)
  14892. } else {
  14893. fmt.Println(err)
  14894. }
  14895. var res Result2001
  14896. var res10265 Result2001Org10265
  14897. if miConfig.Code == "H15049901371" {
  14898. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  14899. utils.ErrorLog("解析失败:%v", err)
  14900. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14901. return
  14902. }
  14903. res.ErrMsg = res10265.ErrMsg
  14904. res.Output = res10265.Output
  14905. res.InfRefmsgid = res10265.InfRefmsgid
  14906. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  14907. res.Infcode = infocode
  14908. } else {
  14909. if err := json.Unmarshal([]byte(result), &res); err != nil {
  14910. utils.ErrorLog("解析失败:%v", err)
  14911. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14912. return
  14913. }
  14914. }
  14915. if res.Infcode == 0 {
  14916. c.ServeSuccessJSON(map[string]interface{}{
  14917. "msg": res.Output.Trtinfo,
  14918. })
  14919. }
  14920. }
  14921. }
  14922. }
  14923. //func (c *HisApiController) PutRecord() {
  14924. // id, _ := c.GetInt64("id")
  14925. // record_time := c.GetString("record_time")
  14926. // timeLayout := "2006-01-02"
  14927. // loc, _ := time.LoadLocation("Local")
  14928. // theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  14929. // if err != nil {
  14930. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  14931. // return
  14932. // }
  14933. // recordDateTime := theTime.Unix()
  14934. //
  14935. // adminInfo := c.GetAdminUserInfo()
  14936. // patient, _ := service.GetPatientByID(adminInfo.CurrentOrgId, id)
  14937. // patientPrescription, _ := service.FindPatientPrescriptionInfo(adminInfo.CurrentOrgId, id, recordDateTime)
  14938. //
  14939. // miConfig, _ := service.FindMedicalInsuranceInfo(adminInfo.CurrentOrgId)
  14940. //
  14941. // fmt.Println(miConfig.SecretKey)
  14942. //
  14943. // if patient == nil {
  14944. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodePatientNoExist)
  14945. // return
  14946. // }
  14947. // if len(patient.IdCardNo) == 0 {
  14948. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeIDCartNo)
  14949. // return
  14950. // }
  14951. // config, _ := service.GetMedicalInsuranceConfig(adminInfo.CurrentOrgId)
  14952. // if config.IsOpen == 1 {
  14953. // 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
  14954. // resp, requestErr := http.Get(api)
  14955. // if requestErr != nil {
  14956. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14957. // return
  14958. // }
  14959. // defer resp.Body.Close()
  14960. // body, ioErr := ioutil.ReadAll(resp.Body)
  14961. // if ioErr != nil {
  14962. // utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  14963. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14964. // return
  14965. // }
  14966. // var respJSON map[string]interface{}
  14967. //
  14968. // if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  14969. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  14970. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14971. // return
  14972. // }
  14973. //
  14974. // userJSON := respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  14975. // userJSONBytes, _ := json.Marshal(userJSON)
  14976. // var res ResultTwo
  14977. // if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  14978. // utils.ErrorLog("解析失败:%v", err)
  14979. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14980. // return
  14981. // }
  14982. // Iinfos, _ := json.Marshal(res.Output.Iinfo)
  14983. // Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  14984. // infoStr := string(Iinfos)
  14985. // idetinfoStr := string(Idetinfos)
  14986. //
  14987. // if res.Infcode == 0 {
  14988. // his := models.VMHisPatient{
  14989. // Status: 1,
  14990. // Ctime: time.Now().Unix(),
  14991. // Mtime: time.Now().Unix(),
  14992. // PsnNo: res.Output.Baseinfo.PsnNo,
  14993. // PsnCertType: res.Output.Baseinfo.PsnCertType,
  14994. // Certno: res.Output.Baseinfo.Certno,
  14995. // PsnName: res.Output.Baseinfo.PsnName,
  14996. // Gend: res.Output.Baseinfo.Gend,
  14997. // Naty: res.Output.Baseinfo.Naty,
  14998. // Brdy: res.Output.Baseinfo.Brdy,
  14999. // Age: res.Output.Baseinfo.Age,
  15000. // Iinfo: infoStr,
  15001. // Idetinfo: idetinfoStr,
  15002. // PatientId: patient.ID,
  15003. // RecordDate: theTime.Unix(),
  15004. // UserOrgId: adminInfo.CurrentOrgId,
  15005. // AdminUserId: adminInfo.AdminUser.Id,
  15006. // IsReturn: 1,
  15007. // }
  15008. //
  15009. // //doctor_id := strconv.FormatInt(patientPrescription.DoctorId, 10)
  15010. // //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")
  15011. // //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")
  15012. //
  15013. // //var dat map[string]interface{}
  15014. // //if err := json.Unmarshal([]byte(result), &dat); err == nil {
  15015. // // fmt.Println(dat)
  15016. // //} else {
  15017. // // fmt.Println(err)
  15018. // //}
  15019. //
  15020. // var dat2 map[string]interface{}
  15021. // if err := json.Unmarshal([]byte(result2), &dat2); err == nil {
  15022. // fmt.Println(dat2)
  15023. // } else {
  15024. // fmt.Println(err)
  15025. // }
  15026. //
  15027. // } else {
  15028. // adminUser := c.GetAdminUserInfo()
  15029. // errlog := &models.HisOrderError{
  15030. // UserOrgId: adminUser.CurrentOrgId,
  15031. // Ctime: time.Now().Unix(),
  15032. // Mtime: time.Now().Unix(),
  15033. // ErrMsg: res.ErrMsg,
  15034. // Status: 1,
  15035. // PatientId: id,
  15036. // RecordTime: recordDateTime,
  15037. // Stage: 1,
  15038. // }
  15039. // service.CreateErrMsgLog(errlog)
  15040. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeGdybOneException)
  15041. // return
  15042. // }
  15043. // }
  15044. //
  15045. //}
  15046. //func (c *HisApiController) GetUploadDiag() {
  15047. // id, _ := c.GetInt64("id")
  15048. // record_time := c.GetString("record_time")
  15049. //
  15050. // diagnosis_id, _ := c.GetInt64("diagnosis")
  15051. // sick_type, _ := c.GetInt64("sick_type")
  15052. // reg_type, _ := c.GetInt64("reg_type")
  15053. //
  15054. // timeLayout := "2006-01-02"
  15055. // loc, _ := time.LoadLocation("Local")
  15056. // theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  15057. // if err != nil {
  15058. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  15059. // return
  15060. // }
  15061. //
  15062. // var patientPrescription models.HisPrescriptionInfo
  15063. // recordDateTime := theTime.Unix()
  15064. // adminInfo := c.GetAdminUserInfo()
  15065. // patientPrescription, _ = service.FindPatientPrescriptionInfo(adminInfo.CurrentOrgId, id, recordDateTime)
  15066. //
  15067. // if patientPrescription.ID == 0 {
  15068. // patientPrescription, _ = service.FindLastPatientPrescriptionInfo(adminInfo.CurrentOrgId, id, recordDateTime)
  15069. // }
  15070. //
  15071. // miConfig, _ := service.FindMedicalInsuranceInfo(adminInfo.CurrentOrgId)
  15072. // diagnosisConfig, _ := service.FindDiagnoseById(diagnosis_id)
  15073. // his, _ := service.GetVMHisPatientInfo(adminInfo.CurrentOrgId, id, recordDateTime)
  15074. // sickConfig, _ := service.FindSickById(sick_type)
  15075. // department, _ := service.GetDepartMentDetail(patientPrescription.Departments)
  15076. //
  15077. // api2 := "http://127.0.0.1:9532/" + "gdyb/four?psn_no=" + his.PsnNo +
  15078. // "&mdtrt_id=" + his.Number + "&doctor=" + patientPrescription.Doctor + "&department=" + department.Name +
  15079. // "&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 +
  15080. // "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&sick_code=" + sickConfig.ContentCode + "&sick_name=" + sickConfig.ClassName
  15081. // resp2, requestErr2 := http.Get(api2)
  15082. // if requestErr2 != nil {
  15083. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  15084. // return
  15085. // }
  15086. // body2, ioErr2 := ioutil.ReadAll(resp2.Body)
  15087. // if ioErr2 != nil {
  15088. // utils.ErrorLog("接口返回数据读取失败: %v", ioErr2)
  15089. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  15090. // return
  15091. // }
  15092. // var respJSON2 map[string]interface{}
  15093. // if err := json.Unmarshal([]byte(string(body2)), &respJSON2); err != nil {
  15094. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  15095. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  15096. // return
  15097. // }
  15098. // respJSON2 = respJSON2["data"].(map[string]interface{})["pre"].(map[string]interface{})
  15099. // userJSONBytes2, _ := json.Marshal(respJSON2)
  15100. //
  15101. // var res2 ResultSix
  15102. // if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  15103. // utils.ErrorLog("解析失败:%v", err)
  15104. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  15105. // return
  15106. // }
  15107. // if res2.Infcode != 0 {
  15108. // adminUser := c.GetAdminUserInfo()
  15109. // errlog := &models.HisOrderError{
  15110. // UserOrgId: adminUser.CurrentOrgId,
  15111. // Ctime: time.Now().Unix(),
  15112. // Mtime: time.Now().Unix(),
  15113. // ErrMsg: res2.ErrMsg,
  15114. // Status: 1,
  15115. // PatientId: id,
  15116. // RecordTime: recordDateTime,
  15117. // Stage: 3,
  15118. // }
  15119. // service.CreateErrMsgLog(errlog)
  15120. //
  15121. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeRegisterThreeException)
  15122. // return
  15123. // }
  15124. //
  15125. // c.ServeSuccessJSON(map[string]interface{}{
  15126. // "msg": "上传成功",
  15127. // })
  15128. //
  15129. //}
  15130. type QueryResult struct {
  15131. ID int64
  15132. Name string
  15133. Code string
  15134. List_type_code string
  15135. }
  15136. func (c *HisApiController) GetCheckCode() {
  15137. ids_str := c.GetString("ids")
  15138. record_type, _ := c.GetInt64("record_type") //1.药品 2.耗材 3.项目
  15139. ids_arr := strings.Split(ids_str, ",")
  15140. var queryResult []QueryResult
  15141. ids := make([]int64, 0)
  15142. for _, item := range ids_arr {
  15143. id, _ := strconv.ParseInt(item, 10, 64)
  15144. ids = append(ids, id)
  15145. }
  15146. if record_type == 1 {
  15147. drugs, _ := service.GetBatchDrugList(ids)
  15148. for _, item := range drugs {
  15149. result := QueryResult{
  15150. ID: item.ID,
  15151. Name: item.DrugName,
  15152. Code: item.MedicalInsuranceNumber,
  15153. List_type_code: "101",
  15154. }
  15155. queryResult = append(queryResult, result)
  15156. }
  15157. } else if record_type == 2 {
  15158. goods, _ := service.GetBatchGoodInformationList(ids)
  15159. for _, item := range goods {
  15160. result := QueryResult{
  15161. ID: item.ID,
  15162. Name: item.GoodName,
  15163. Code: item.MedicalInsuranceNumber,
  15164. List_type_code: "301",
  15165. }
  15166. queryResult = append(queryResult, result)
  15167. }
  15168. } else if record_type == 3 {
  15169. projects, _ := service.GetBathchMyPorjecgList(ids)
  15170. for _, item := range projects {
  15171. result := QueryResult{
  15172. ID: item.ID,
  15173. Name: item.ProjectName,
  15174. Code: item.MedicalCode,
  15175. List_type_code: "201",
  15176. }
  15177. queryResult = append(queryResult, result)
  15178. }
  15179. }
  15180. admin_user_id, _ := c.GetInt64("admin_user_id")
  15181. adminUser := c.GetAdminUserInfo()
  15182. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  15183. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  15184. var user_name string
  15185. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  15186. if role.ID == 0 {
  15187. user_name = "xxx"
  15188. } else {
  15189. user_name = role.UserName
  15190. }
  15191. baseParams := &models.BaseParams{
  15192. SecretKey: miConfig.SecretKey,
  15193. FixmedinsCode: miConfig.Code,
  15194. InsuplcAdmdvs: miConfig.InsuplcAdmdvs,
  15195. MdtrtareaAdmvs: miConfig.MdtrtareaAdmvs,
  15196. OrgName: miConfig.OrgName,
  15197. Doctor: user_name,
  15198. }
  15199. if config.IsOpen == 1 {
  15200. for _, item := range queryResult {
  15201. var result string
  15202. if record_type == 1 {
  15203. result = service.Gdyb3301(baseParams, item.Name, item.Code, item.List_type_code, "2021-04-26", "", item.List_type_code)
  15204. } else if record_type == 2 {
  15205. result = service.Gdyb3301(baseParams, item.Name, item.Code, item.List_type_code, "2021-04-26", "", item.List_type_code)
  15206. } else if record_type == 3 {
  15207. result = service.Gdyb3301(baseParams, item.Name, item.Code, item.List_type_code, "2021-04-26", "", item.List_type_code)
  15208. }
  15209. var dat map[string]interface{}
  15210. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  15211. fmt.Println(dat)
  15212. } else {
  15213. fmt.Println(err)
  15214. }
  15215. userJSONBytes, _ := json.Marshal(dat)
  15216. var res ResultSix
  15217. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  15218. utils.ErrorLog("解析失败:%v", err)
  15219. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  15220. return
  15221. }
  15222. if res.Infcode == 0 {
  15223. if record_type == 1 {
  15224. service.UpdateBaseDrugById(item.ID)
  15225. } else if record_type == 2 {
  15226. service.UpdateGoodInformaitonByDetail(item.ID)
  15227. } else if record_type == 3 {
  15228. service.UpdateProjectById(item.ID)
  15229. }
  15230. c.ServeSuccessJSON(map[string]interface{}{
  15231. "failed_code": 0,
  15232. "msg": "目录对照成功",
  15233. })
  15234. } else {
  15235. c.ServeSuccessJSON(map[string]interface{}{
  15236. "failed_code": -10,
  15237. "msg": res.ErrMsg,
  15238. })
  15239. }
  15240. }
  15241. }
  15242. }
  15243. func (c *HisApiController) UnCheckCode() {
  15244. ids_str := c.GetString("ids")
  15245. record_type, _ := c.GetInt64("record_type") //1.药品 2.耗材 3.项目
  15246. admin_user_id, _ := c.GetInt64("admin_user_id")
  15247. ids_arr := strings.Split(ids_str, ",")
  15248. var queryResult []QueryResult
  15249. ids := make([]int64, 0)
  15250. for _, item := range ids_arr {
  15251. id, _ := strconv.ParseInt(item, 10, 64)
  15252. ids = append(ids, id)
  15253. }
  15254. if record_type == 1 {
  15255. drugs, _ := service.GetBatchDrugList(ids)
  15256. for _, item := range drugs {
  15257. result := QueryResult{
  15258. ID: item.ID,
  15259. Name: item.DrugName,
  15260. Code: item.MedicalInsuranceNumber,
  15261. List_type_code: "101",
  15262. }
  15263. queryResult = append(queryResult, result)
  15264. }
  15265. } else if record_type == 2 {
  15266. goods, _ := service.GetBatchGoodInformationList(ids)
  15267. for _, item := range goods {
  15268. result := QueryResult{
  15269. ID: item.ID,
  15270. Name: item.GoodName,
  15271. Code: item.MedicalInsuranceNumber,
  15272. List_type_code: "301",
  15273. }
  15274. queryResult = append(queryResult, result)
  15275. }
  15276. } else if record_type == 3 {
  15277. projects, _ := service.GetBathchMyPorjecgList(ids)
  15278. for _, item := range projects {
  15279. result := QueryResult{
  15280. ID: item.ID,
  15281. Name: item.ProjectName,
  15282. Code: item.MedicalCode,
  15283. List_type_code: "201",
  15284. }
  15285. queryResult = append(queryResult, result)
  15286. }
  15287. }
  15288. adminUser := c.GetAdminUserInfo()
  15289. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  15290. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  15291. var user_name string
  15292. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  15293. if role.ID == 0 {
  15294. user_name = "xxx"
  15295. } else {
  15296. user_name = role.UserName
  15297. }
  15298. baseParams := &models.BaseParams{
  15299. SecretKey: miConfig.SecretKey,
  15300. FixmedinsCode: miConfig.Code,
  15301. InsuplcAdmdvs: miConfig.InsuplcAdmdvs,
  15302. MdtrtareaAdmvs: miConfig.MdtrtareaAdmvs,
  15303. OrgName: miConfig.OrgName,
  15304. Doctor: user_name,
  15305. }
  15306. if config.IsOpen == 1 {
  15307. for _, item := range queryResult {
  15308. var result string
  15309. if record_type == 1 {
  15310. result = service.Gdyb3302(baseParams, item.Name, item.Code, item.List_type_code)
  15311. } else if record_type == 2 {
  15312. result = service.Gdyb3302(baseParams, item.Name, item.Code, item.List_type_code)
  15313. } else if record_type == 3 {
  15314. result = service.Gdyb3302(baseParams, item.Name, item.Code, item.List_type_code)
  15315. }
  15316. var dat2 map[string]interface{}
  15317. if err := json.Unmarshal([]byte(result), &dat2); err == nil {
  15318. fmt.Println(dat2)
  15319. } else {
  15320. fmt.Println(err)
  15321. }
  15322. userJSONBytes, _ := json.Marshal(dat2)
  15323. var res ResultSix
  15324. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  15325. utils.ErrorLog("解析失败:%v", err)
  15326. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  15327. return
  15328. }
  15329. if res.Infcode == 0 {
  15330. if record_type == 1 {
  15331. service.UpdateDrugByIdDetail(item.ID)
  15332. } else if record_type == 2 {
  15333. service.UpdateGoodInfoById(item.ID)
  15334. } else if record_type == 3 {
  15335. service.UpdateMyProjectById(item.ID)
  15336. }
  15337. c.ServeSuccessJSON(map[string]interface{}{
  15338. "failed_code": 0,
  15339. "msg": "撤销目录对照成功",
  15340. })
  15341. } else {
  15342. c.ServeSuccessJSON(map[string]interface{}{
  15343. "failed_code": -10,
  15344. "msg": res.ErrMsg,
  15345. })
  15346. }
  15347. }
  15348. }
  15349. }
  15350. func (c *HisApiController) GetPatientInfo() {
  15351. id_card_no := c.GetString("id_card_no")
  15352. admin_user_id, _ := c.GetInt64("admin_user_id")
  15353. patient, _ := service.GetPatientByIDCard(id_card_no, c.GetAdminUserInfo().CurrentOrgId)
  15354. if patient.ID == 0 {
  15355. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodePatientNoExist)
  15356. return
  15357. }
  15358. role, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  15359. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  15360. config, _ := service.GetMedicalInsuranceConfig(c.GetAdminUserInfo().CurrentOrgId)
  15361. if config.IsOpen == 1 {
  15362. result := service.Gdyb1101A(id_card_no, miConfig.OrgName, role.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, patient.Name)
  15363. var dat map[string]interface{}
  15364. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  15365. fmt.Println(dat)
  15366. } else {
  15367. fmt.Println(err)
  15368. }
  15369. userJSONBytes, _ := json.Marshal(dat)
  15370. var res ResultTwo
  15371. var res10265 ResultTwo10265
  15372. if miConfig.Code == "H15049901371" {
  15373. if err := json.Unmarshal(userJSONBytes, &res10265); err != nil {
  15374. utils.ErrorLog("解析失败:%v", err)
  15375. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  15376. return
  15377. }
  15378. res.ErrMsg = res10265.ErrMsg
  15379. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  15380. res.Infcode = infocode
  15381. res.Output = res10265.Output
  15382. res.InfRefmsgid = res10265.InfRefmsgid
  15383. } else {
  15384. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  15385. utils.ErrorLog("解析失败:%v", err)
  15386. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  15387. return
  15388. }
  15389. }
  15390. //if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  15391. // utils.ErrorLog("解析失败:%v", err)
  15392. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  15393. // return
  15394. //}
  15395. for index, item := range res.Output.Iinfo {
  15396. if item.PsnInsuStas == "2" {
  15397. fmt.Println("--------")
  15398. res.Output.Iinfo[index].Insutype = "300"
  15399. res.Output.Iinfo[index].PsnInsuStas = "1"
  15400. }
  15401. }
  15402. fmt.Println(res.Output.Iinfo)
  15403. if res.Infcode != 0 {
  15404. c.ServeSuccessJSON(map[string]interface{}{
  15405. "failed_code": -10,
  15406. "msg": res.ErrMsg,
  15407. })
  15408. } else {
  15409. c.ServeSuccessJSON(map[string]interface{}{
  15410. "failed_code": 0,
  15411. "info": res,
  15412. })
  15413. }
  15414. }
  15415. }
  15416. func (c *HisApiController) PsnPutOnRecord() {
  15417. record_type, _ := c.GetInt64("type")
  15418. patient_id, _ := c.GetInt64("patient_id")
  15419. admin_user_id, _ := c.GetInt64("admin_user_id")
  15420. start_time := c.GetString("start_time")
  15421. end_time := c.GetString("end_time")
  15422. adminUser := c.GetAdminUserInfo()
  15423. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  15424. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  15425. var patients []*models.Patients
  15426. if record_type == 1 { //全部备案
  15427. patient, _ := service.GetAllPatient(adminUser.CurrentOrgId)
  15428. patients = append(patients, patient...)
  15429. } else { //单个备案
  15430. patient, _ := service.GetPatientByID(adminUser.CurrentOrgId, patient_id)
  15431. patients = append(patients, patient)
  15432. }
  15433. var user_name string
  15434. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  15435. if role.ID == 0 {
  15436. user_name = "xxx"
  15437. } else {
  15438. user_name = role.UserName
  15439. }
  15440. if config.IsOpen == 1 {
  15441. for _, item := range patients {
  15442. 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
  15443. resp, requestErr := http.Get(api)
  15444. if requestErr != nil {
  15445. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  15446. return
  15447. }
  15448. defer resp.Body.Close()
  15449. body, ioErr := ioutil.ReadAll(resp.Body)
  15450. if ioErr != nil {
  15451. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  15452. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  15453. return
  15454. }
  15455. var respJSON map[string]interface{}
  15456. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  15457. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  15458. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  15459. return
  15460. }
  15461. userJSON := respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  15462. userJSONBytes, _ := json.Marshal(userJSON)
  15463. var res ResultTwo
  15464. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  15465. utils.ErrorLog("解析失败:%v", err)
  15466. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  15467. return
  15468. }
  15469. if res.Infcode == 0 {
  15470. result := service.Gdyb2505(res.Output.Baseinfo.PsnNo, user_name, miConfig.OrgName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, start_time, end_time)
  15471. var dat map[string]interface{}
  15472. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  15473. fmt.Println(dat)
  15474. } else {
  15475. fmt.Println(err)
  15476. }
  15477. userJSONBytes, _ := json.Marshal(dat)
  15478. var res2 ResultThirteen
  15479. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  15480. utils.ErrorLog("解析失败:%v", err)
  15481. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  15482. return
  15483. }
  15484. if res2.Infcode == 0 {
  15485. psnResult := &models.GdybPsnRecord{
  15486. UserOrgId: adminUser.CurrentOrgId,
  15487. PatientId: item.ID,
  15488. PsnNo: res.Output.Baseinfo.PsnNo,
  15489. Ctime: time.Now().Unix(),
  15490. Mtime: time.Now().Unix(),
  15491. Status: 1,
  15492. IsCancel: 1,
  15493. TrtDclaDetlSn: res2.Output.Result.TrtDclaDetlSn,
  15494. }
  15495. service.CreatePsnRecord(psnResult)
  15496. } else {
  15497. c.ServeSuccessJSON(map[string]interface{}{
  15498. "failed_code": -10,
  15499. "msg": res2.ErrMsg,
  15500. })
  15501. return
  15502. }
  15503. }
  15504. }
  15505. }
  15506. }
  15507. func (c *HisApiController) PsnUnPutOnRecord() {
  15508. id, _ := c.GetInt64("id")
  15509. //record_type, _ := c.GetInt64("type")
  15510. admin_user_id, _ := c.GetInt64("admin_user_id")
  15511. adminUser := c.GetAdminUserInfo()
  15512. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  15513. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  15514. var user_name string
  15515. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  15516. if role.ID == 0 {
  15517. user_name = "xxx"
  15518. } else {
  15519. user_name = role.UserName
  15520. }
  15521. psn_record, _ := service.GetPsnRecordById(id)
  15522. if psn_record.ID == 0 {
  15523. c.ServeFailJSONWithSGJErrorCode(enums.ErrorPsnRecordNoExistWrong)
  15524. return
  15525. }
  15526. if config.IsOpen == 1 {
  15527. result := service.Gdyb2506(psn_record.PsnNo, user_name, miConfig.OrgName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, psn_record.TrtDclaDetlSn)
  15528. var dat map[string]interface{}
  15529. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  15530. fmt.Println(dat)
  15531. } else {
  15532. fmt.Println(err)
  15533. }
  15534. userJSONBytes, _ := json.Marshal(dat)
  15535. var res ResultFourteen
  15536. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  15537. utils.ErrorLog("解析失败:%v", err)
  15538. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  15539. return
  15540. }
  15541. if res.Infcode == 0 {
  15542. psn_record.IsCancel = 2
  15543. service.CreatePsnRecord(&psn_record)
  15544. } else {
  15545. c.ServeSuccessJSON(map[string]interface{}{
  15546. "failed_code": -10,
  15547. "msg": res.ErrMsg,
  15548. })
  15549. return
  15550. }
  15551. }
  15552. }
  15553. func (c *HisApiController) PsnPutNCDSOnRecord() {
  15554. patient_id, _ := c.GetInt64("patient_id")
  15555. insutype_two := c.GetString("insutype")
  15556. psn_no := c.GetString("psn_no")
  15557. doctor_id, _ := c.GetInt64("doctor_id")
  15558. sick_id, _ := c.GetInt64("sick_id")
  15559. department_id, _ := c.GetInt64("department_id")
  15560. start_time := c.GetString("start_time")
  15561. end_time := c.GetString("end_time")
  15562. check_time := c.GetString("check_time")
  15563. hospital_code := c.GetString("hospital_code")
  15564. hospital_name := c.GetString("hospital_name")
  15565. adminUser := c.GetAdminUserInfo()
  15566. patient, _ := service.GetPatientByID(adminUser.CurrentOrgId, patient_id)
  15567. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  15568. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  15569. sick, _ := service.FindSickById(sick_id)
  15570. doctor, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, doctor_id)
  15571. if len(hospital_code) == 0 {
  15572. hospital_code = miConfig.Code
  15573. }
  15574. if len(hospital_name) == 0 {
  15575. hospital_name = miConfig.OrgName
  15576. }
  15577. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, doctor_id)
  15578. var res ResultTwo
  15579. var res10265 ResultTwo10265
  15580. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  15581. psn_info, _ := service.GetPsnByPatientId(patient.ID)
  15582. api := "http://192.168.2.3:9532/" + "hbyb/1101?cert_no=" + "" +
  15583. "&org_name=" + miConfig.OrgName + "&doctor=" + role.UserName + "&fixmedins_code=" + miConfig.Code +
  15584. "&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
  15585. resp, requestErr := http.Get(api)
  15586. if requestErr != nil {
  15587. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  15588. return
  15589. }
  15590. body, ioErr := ioutil.ReadAll(resp.Body)
  15591. if ioErr != nil {
  15592. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  15593. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  15594. return
  15595. }
  15596. var respJSON map[string]interface{}
  15597. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  15598. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  15599. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  15600. return
  15601. }
  15602. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  15603. result, _ := json.Marshal(respJSON)
  15604. fmt.Println("log")
  15605. fmt.Println(string(result))
  15606. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  15607. utils.ErrorLog("解析失败:%v", err)
  15608. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  15609. return
  15610. }
  15611. res.ErrMsg = res10265.ErrMsg
  15612. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  15613. res.Infcode = infocode
  15614. res.Output = res10265.Output
  15615. res.InfRefmsgid = res10265.InfRefmsgid
  15616. } else {
  15617. result, _ := service.Gdyb1101(patient.IdCardNo, miConfig.OrgName, role.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, 2, "", "0", patient.Name)
  15618. if miConfig.Code == "H15049901371" {
  15619. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  15620. utils.ErrorLog("解析失败:%v", err)
  15621. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  15622. return
  15623. }
  15624. res.ErrMsg = res10265.ErrMsg
  15625. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  15626. res.Infcode = infocode
  15627. res.Output = res10265.Output
  15628. res.InfRefmsgid = res10265.InfRefmsgid
  15629. } else {
  15630. if err := json.Unmarshal([]byte(result), &res); err != nil {
  15631. utils.ErrorLog("解析失败:%v", err)
  15632. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  15633. return
  15634. }
  15635. }
  15636. }
  15637. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  15638. infoStr := string(Iinfos)
  15639. var rf []*ResultFive
  15640. json.Unmarshal([]byte(infoStr), &rf)
  15641. var insuplc_admdvs string
  15642. var insutype string
  15643. var is390 int = 0
  15644. var is310 int = 0
  15645. var insutypes []*ResultFive
  15646. for _, item := range rf {
  15647. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  15648. insutypes = append(insutypes, item)
  15649. }
  15650. }
  15651. if len(insutypes) == 1 {
  15652. insutype = insutypes[0].Insutype
  15653. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  15654. } else {
  15655. for _, i := range insutypes {
  15656. if i.Insutype == "390" {
  15657. is390 = 1
  15658. }
  15659. if i.Insutype == "310" {
  15660. is310 = 1
  15661. }
  15662. }
  15663. }
  15664. if is390 == 1 {
  15665. insutype = "390"
  15666. }
  15667. if is310 == 1 {
  15668. insutype = "310"
  15669. }
  15670. if len(insutypes) == 2 {
  15671. insutype = insutype_two
  15672. }
  15673. if len(insutypes) == 0 {
  15674. insutype = "310"
  15675. }
  15676. insutype = insutype_two
  15677. fmt.Println(insutype)
  15678. for _, item := range rf {
  15679. fmt.Println(item.Insutype)
  15680. fmt.Println(insutype)
  15681. if item.Insutype == insutype {
  15682. fmt.Println(item.Insutype)
  15683. fmt.Println(insutype)
  15684. insuplc_admdvs = item.InsuplcAdmdvs
  15685. }
  15686. }
  15687. fmt.Println(insuplc_admdvs)
  15688. var res2 ResultThirteen
  15689. var res10265_2 ResultThirteen10265
  15690. if config.IsOpen == 1 {
  15691. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  15692. } else {
  15693. 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)
  15694. var dat map[string]interface{}
  15695. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  15696. fmt.Println(dat)
  15697. } else {
  15698. fmt.Println(err)
  15699. }
  15700. userJSONBytes, _ := json.Marshal(dat)
  15701. if miConfig.Code == "H15049901371" {
  15702. if err := json.Unmarshal(userJSONBytes, &res10265_2); err != nil {
  15703. utils.ErrorLog("解析失败:%v", err)
  15704. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  15705. return
  15706. }
  15707. res2.ErrMsg = res10265_2.ErrMsg
  15708. infocode, _ := strconv.ParseInt(res10265_2.Infcode, 10, 64)
  15709. res2.Infcode = infocode
  15710. res2.Output = res10265_2.Output
  15711. res2.InfRefmsgid = res10265_2.InfRefmsgid
  15712. } else {
  15713. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  15714. utils.ErrorLog("解析失败:%v", err)
  15715. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  15716. return
  15717. }
  15718. }
  15719. }
  15720. if res2.Infcode == 0 {
  15721. psnResult := &models.GdybPsnNcdsRecord{
  15722. UserOrgId: adminUser.CurrentOrgId,
  15723. PatientId: patient.ID,
  15724. PsnNo: psn_no,
  15725. DoctorId: doctor.AdminUserId,
  15726. DepartmentId: department_id,
  15727. SickType: sick_id,
  15728. Insutype: insutype,
  15729. Ctime: time.Now().Unix(),
  15730. Mtime: time.Now().Unix(),
  15731. Status: 1,
  15732. IsCancel: 1,
  15733. TrtDclaDetlSn: res2.Output.Result.TrtDclaDetlSn,
  15734. }
  15735. service.CreatePsnNCDSRecord(psnResult)
  15736. c.ServeSuccessJSON(map[string]interface{}{
  15737. "failed_code": 0,
  15738. "msg": "备案成功",
  15739. "result": psnResult,
  15740. })
  15741. } else {
  15742. c.ServeSuccessJSON(map[string]interface{}{
  15743. "failed_code": -10,
  15744. "msg": res2.ErrMsg,
  15745. })
  15746. return
  15747. }
  15748. }
  15749. }
  15750. func (c *HisApiController) PsnPutUnNCDSOnRecord() {
  15751. id, _ := c.GetInt64("id")
  15752. admin_user_id, _ := c.GetInt64("admin_user_id")
  15753. adminUser := c.GetAdminUserInfo()
  15754. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  15755. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  15756. //config, _ := service.Ge(adminUser.CurrentOrgId)
  15757. patient, _ := service.GetPatientByID(c.GetAdminUserInfo().CurrentOrgId, id)
  15758. //role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  15759. //var user_name string
  15760. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  15761. //if role.ID == 0 {
  15762. // user_name = "xxx"
  15763. //} else {
  15764. // user_name = role.UserName
  15765. //}
  15766. psn_record, _ := service.GetPsnNCDSRecordById(id)
  15767. if psn_record.ID == 0 {
  15768. c.ServeFailJSONWithSGJErrorCode(enums.ErrorPsnRecordNoExistWrong)
  15769. return
  15770. }
  15771. result, _ := service.Gdyb1101(patient.IdCardNo, miConfig.OrgName, role.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, 2, "", "0", patient.Name)
  15772. var res ResultTwo
  15773. var res10265 ResultTwo10265
  15774. if miConfig.Code == "H15049901371" {
  15775. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  15776. utils.ErrorLog("解析失败:%v", err)
  15777. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  15778. return
  15779. }
  15780. res.ErrMsg = res10265.ErrMsg
  15781. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  15782. res.Infcode = infocode
  15783. res.Output = res10265.Output
  15784. res.InfRefmsgid = res10265.InfRefmsgid
  15785. } else {
  15786. if err := json.Unmarshal([]byte(result), &res); err != nil {
  15787. utils.ErrorLog("解析失败:%v", err)
  15788. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  15789. return
  15790. }
  15791. }
  15792. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  15793. infoStr := string(Iinfos)
  15794. var rf []*ResultFive
  15795. json.Unmarshal([]byte(infoStr), &rf)
  15796. var insuplc_admdvs string
  15797. var insutype string
  15798. var is390 int = 0
  15799. var is310 int = 0
  15800. var insutypes []*ResultFive
  15801. for _, item := range rf {
  15802. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  15803. insutypes = append(insutypes, item)
  15804. }
  15805. }
  15806. if len(insutypes) == 1 {
  15807. insutype = insutypes[0].Insutype
  15808. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  15809. } else {
  15810. for _, i := range insutypes {
  15811. if i.Insutype == "390" {
  15812. is390 = 1
  15813. }
  15814. if i.Insutype == "310" {
  15815. is310 = 1
  15816. }
  15817. }
  15818. }
  15819. if is390 == 1 {
  15820. insutype = "390"
  15821. }
  15822. if is310 == 1 {
  15823. insutype = "310"
  15824. }
  15825. if len(insutypes) == 0 {
  15826. insutype = "310"
  15827. }
  15828. insutype = psn_record.Insutype
  15829. for _, item := range rf {
  15830. if item.Insutype == insutype {
  15831. insuplc_admdvs = item.InsuplcAdmdvs
  15832. }
  15833. }
  15834. if config.IsOpen == 1 {
  15835. result := service.Gdyb2504(psn_record.PsnNo, miConfig.OrgName, role.UserName, miConfig.Code, insuplc_admdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, psn_record.TrtDclaDetlSn)
  15836. var dat map[string]interface{}
  15837. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  15838. fmt.Println(dat)
  15839. } else {
  15840. fmt.Println(err)
  15841. }
  15842. userJSONBytes, _ := json.Marshal(dat)
  15843. var res ResultFourteen
  15844. var res10265 ResultFourteen10265
  15845. if miConfig.Code == "H15049901371" {
  15846. if err := json.Unmarshal(userJSONBytes, &res10265); err != nil {
  15847. utils.ErrorLog("解析失败:%v", err)
  15848. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  15849. return
  15850. }
  15851. res.ErrMsg = res10265.ErrMsg
  15852. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  15853. res.Infcode = infocode
  15854. res.Output = res10265.Output
  15855. res.InfRefmsgid = res10265.InfRefmsgid
  15856. } else {
  15857. if err := json.Unmarshal([]byte(result), &res); err != nil {
  15858. utils.ErrorLog("解析失败:%v", err)
  15859. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  15860. return
  15861. }
  15862. }
  15863. //if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  15864. // utils.ErrorLog("解析失败:%v", err)
  15865. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  15866. // return
  15867. //}
  15868. if res.Infcode == 0 {
  15869. psn_record.IsCancel = 2
  15870. service.CreatePsnNCDSRecord(&psn_record)
  15871. c.ServeSuccessJSON(map[string]interface{}{
  15872. "failed_code": 0,
  15873. "msg": "撤销备案成功",
  15874. })
  15875. } else {
  15876. c.ServeSuccessJSON(map[string]interface{}{
  15877. "failed_code": -10,
  15878. "msg": res.ErrMsg,
  15879. })
  15880. return
  15881. }
  15882. }
  15883. }
  15884. func (c *HisApiController) TestTest() {
  15885. patient, _ := service.GetHisPatientInfo(4, 456, 1619712000)
  15886. fmt.Println(patient.Iinfo)
  15887. }
  15888. type CustomData struct {
  15889. MsgId string
  15890. PsnNo string
  15891. Info string
  15892. }
  15893. func (c *HisApiController) ReversalData() {
  15894. var customData []*CustomData
  15895. custom := &CustomData{
  15896. MsgId: "H44022900158202103301714472004",
  15897. PsnNo: "44020000001101329945",
  15898. Info: "2207",
  15899. }
  15900. customData = append(customData, custom)
  15901. custom1 := &CustomData{
  15902. MsgId: "H4402290015820210330172057803",
  15903. PsnNo: "44020000001101161813",
  15904. Info: "2207",
  15905. }
  15906. customData = append(customData, custom1)
  15907. custom2 := &CustomData{
  15908. MsgId: "H44022900158202103301705198813",
  15909. PsnNo: "44190000133097375417",
  15910. Info: "2207",
  15911. }
  15912. customData = append(customData, custom2)
  15913. custom3 := &CustomData{
  15914. MsgId: "H44022900158202103301715524756",
  15915. PsnNo: "44020000001100187221",
  15916. Info: "2207",
  15917. }
  15918. customData = append(customData, custom3)
  15919. custom4 := &CustomData{
  15920. MsgId: "H44022900158202103301730376224",
  15921. PsnNo: "44020000001101959155",
  15922. Info: "2207",
  15923. }
  15924. customData = append(customData, custom4)
  15925. custom5 := &CustomData{
  15926. MsgId: "H44022900158202103301748008725",
  15927. PsnNo: "44020000001104246641",
  15928. Info: "2207",
  15929. }
  15930. customData = append(customData, custom5)
  15931. custom6 := &CustomData{
  15932. MsgId: "H44022900158202103301718096755",
  15933. PsnNo: "44020000001102211860",
  15934. Info: "2207",
  15935. }
  15936. customData = append(customData, custom6)
  15937. custom7 := &CustomData{
  15938. MsgId: "H44022900158202103301736551640",
  15939. PsnNo: "44020000001102687718",
  15940. Info: "2207",
  15941. }
  15942. customData = append(customData, custom7)
  15943. custom8 := &CustomData{
  15944. MsgId: "H44022900158202103301743097676",
  15945. PsnNo: "44020000001102127785",
  15946. Info: "2207",
  15947. }
  15948. customData = append(customData, custom8)
  15949. custom9 := &CustomData{
  15950. MsgId: "H44022900158202103301712304203",
  15951. PsnNo: "44020000001101518097",
  15952. Info: "2207",
  15953. }
  15954. customData = append(customData, custom9)
  15955. custom10 := &CustomData{
  15956. MsgId: "H44022900158202103301738448785",
  15957. PsnNo: "44020000001100500813",
  15958. Info: "2207",
  15959. }
  15960. customData = append(customData, custom10)
  15961. custom11 := &CustomData{
  15962. MsgId: "H44022900158202103301732455843",
  15963. PsnNo: "44020000001102690557",
  15964. Info: "2207",
  15965. }
  15966. customData = append(customData, custom11)
  15967. custom12 := &CustomData{
  15968. MsgId: "H44022900158202103301745421708",
  15969. PsnNo: "44020000001102211928",
  15970. Info: "2207",
  15971. }
  15972. customData = append(customData, custom12)
  15973. custom1212 := &CustomData{
  15974. MsgId: "H440229001582021033017351627",
  15975. PsnNo: "44020000001102481733",
  15976. Info: "2207",
  15977. }
  15978. customData = append(customData, custom1212)
  15979. custom13 := &CustomData{
  15980. MsgId: "H44022900158202103301740327951",
  15981. PsnNo: "44020000001103174866",
  15982. Info: "2207",
  15983. }
  15984. customData = append(customData, custom13)
  15985. custom14 := &CustomData{
  15986. MsgId: "H4402290015820210330174922668",
  15987. PsnNo: "44020000001102927272",
  15988. Info: "2207",
  15989. }
  15990. customData = append(customData, custom14)
  15991. custom15 := &CustomData{
  15992. MsgId: "H44022900158202103301752362273",
  15993. PsnNo: "44020000001102942890",
  15994. Info: "2207",
  15995. }
  15996. customData = append(customData, custom15)
  15997. custom16 := &CustomData{
  15998. MsgId: "H44022900158202103301751082917",
  15999. PsnNo: "44020000001101662162",
  16000. Info: "2207",
  16001. }
  16002. customData = append(customData, custom16)
  16003. custom17 := &CustomData{
  16004. MsgId: "H44022900158202103301754147728",
  16005. PsnNo: "44020000000229014511",
  16006. Info: "2207",
  16007. }
  16008. customData = append(customData, custom17)
  16009. adminUser := c.GetAdminUserInfo()
  16010. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  16011. for _, item := range customData {
  16012. result := service.Gdyb2601(item.PsnNo, item.MsgId, item.Info, miConfig.OrgName, "张俊杰", miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey)
  16013. fmt.Println(result)
  16014. }
  16015. }
  16016. func (c *HisApiController) GetAllopatry() {
  16017. year := c.GetString("year")
  16018. month := c.GetString("month")
  16019. admin_user_id, _ := c.GetInt64("admin_user_id")
  16020. adminUser := c.GetAdminUserInfo()
  16021. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  16022. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  16023. result, _ := service.Gdyb9001Two(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, admin_user_id)
  16024. var dat map[string]interface{}
  16025. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  16026. fmt.Println(dat)
  16027. } else {
  16028. fmt.Println(err)
  16029. }
  16030. userJSONBytes, _ := json.Marshal(dat)
  16031. var res models.Result9001
  16032. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  16033. utils.ErrorLog("解析失败:%v", err)
  16034. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  16035. return
  16036. }
  16037. fmt.Println(res.Output.Signinoutb)
  16038. fmt.Println(res.Output.Signinoutb.SignNo)
  16039. fmt.Println(string(userJSONBytes))
  16040. result3, _ := service.Gdyb3260(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, year, month, res.Output.Signinoutb.SignNo, 0)
  16041. var dat3 map[string]interface{}
  16042. if err := json.Unmarshal([]byte(result3), &dat3); err == nil {
  16043. fmt.Println(dat3)
  16044. } else {
  16045. fmt.Println(err)
  16046. }
  16047. userJSONBytes3, _ := json.Marshal(dat3)
  16048. var res3 models.Result3260
  16049. if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  16050. utils.ErrorLog("解析失败:%v", err)
  16051. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  16052. return
  16053. }
  16054. var curpage int
  16055. var pagesize int = 100
  16056. var start int = 1
  16057. //var stop int
  16058. //pagecount := 10
  16059. pagecount := int(math.Ceil(float64(res3.Output.Totalrow) / float64(pagesize)))
  16060. for curpage = 1; curpage <= pagecount; curpage++ {
  16061. if curpage == 1 {
  16062. start = 0
  16063. } else {
  16064. start = (curpage-1)*pagesize + 1
  16065. }
  16066. //stop = curpage * pagesize
  16067. //if stop > int(res3.Output.Totalrow) {
  16068. // stop =int(res3.Output.Totalrow)
  16069. //}
  16070. result2, _ := service.Gdyb3260(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, year, month, res.Output.Signinoutb.SignNo, start)
  16071. var dat2 map[string]interface{}
  16072. if err := json.Unmarshal([]byte(result2), &dat2); err == nil {
  16073. fmt.Println(dat)
  16074. } else {
  16075. fmt.Println(err)
  16076. }
  16077. userJSONBytes2, _ := json.Marshal(dat2)
  16078. var res2 models.Result3260
  16079. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  16080. utils.ErrorLog("解析失败:%v", err)
  16081. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  16082. return
  16083. }
  16084. //if res2.Infcode == 0 {
  16085. // service.Gdyb3261(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, year, month, res2, res.Output.Signinoutb.SignNo)
  16086. // //var dat2 map[string]interface{}
  16087. // //if err := json.Unmarshal([]byte(result3), &dat2); err == nil {
  16088. // // fmt.Println(dat)
  16089. // //} else {
  16090. // // fmt.Println(err)
  16091. // //}
  16092. // //c.ServeSuccessJSON(map[string]interface{}{
  16093. // // "list": res2.Output.Data,
  16094. // //})
  16095. // //return
  16096. //}
  16097. }
  16098. }
  16099. func (c *HisApiController) ComfirmAllopatry() {
  16100. year := c.GetString("year")
  16101. month := c.GetString("month")
  16102. admin_user_id, _ := c.GetInt64("admin_user_id")
  16103. adminUser := c.GetAdminUserInfo()
  16104. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  16105. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  16106. result, _ := service.Gdyb9001Two(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, admin_user_id)
  16107. var dat map[string]interface{}
  16108. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  16109. fmt.Println(dat)
  16110. } else {
  16111. fmt.Println(err)
  16112. }
  16113. userJSONBytes, _ := json.Marshal(dat)
  16114. var res models.Result9001
  16115. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  16116. utils.ErrorLog("解析失败:%v", err)
  16117. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  16118. return
  16119. }
  16120. result2, _ := service.Gdyb3260(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, year, month, res.Output.Signinoutb.SignNo, 0)
  16121. var dat2 map[string]interface{}
  16122. if err := json.Unmarshal([]byte(result2), &dat2); err == nil {
  16123. fmt.Println(dat)
  16124. } else {
  16125. fmt.Println(err)
  16126. }
  16127. userJSONBytes2, _ := json.Marshal(dat2)
  16128. var res2 models.Result3260
  16129. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  16130. utils.ErrorLog("解析失败:%v", err)
  16131. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  16132. return
  16133. }
  16134. //if res2.Infcode == 0 {
  16135. // result, _, msgId := service.Gdyb3261(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, year, month, res2, res.Output.Signinoutb.SignNo)
  16136. // var dat map[string]interface{}
  16137. // if err := json.Unmarshal([]byte(result), &dat); err == nil {
  16138. // fmt.Println(dat)
  16139. // } else {
  16140. // fmt.Println(err)
  16141. // }
  16142. // userJSONBytes, _ := json.Marshal(dat)
  16143. // var res3 models.Result3261
  16144. // if err := json.Unmarshal(userJSONBytes, &res3); err != nil {
  16145. // utils.ErrorLog("解析失败:%v", err)
  16146. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  16147. // return
  16148. // }
  16149. //
  16150. // if res3.Infcode == 0 {
  16151. // record := &models.HisYidiClearRecord{
  16152. // UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  16153. // Ctime: time.Now().Unix(),
  16154. // Mtime: time.Now().Unix(),
  16155. // Status: 1,
  16156. // MsgId: msgId,
  16157. // }
  16158. // service.SaveClearRecord(record)
  16159. // c.ServeSuccessJSON(map[string]interface{}{
  16160. // "msg": "提取成功",
  16161. // })
  16162. // }
  16163. //}
  16164. }
  16165. func (c *HisApiController) RefundAllopatry() {
  16166. year := c.GetString("year")
  16167. month := c.GetString("month")
  16168. //id, _ := c.GetInt64("id")
  16169. admin_user_id, _ := c.GetInt64("admin_user_id")
  16170. adminUser := c.GetAdminUserInfo()
  16171. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  16172. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  16173. //record, _ := service.GetClearRecordById(id)
  16174. result2, _ := service.Gdyb9001Two(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, admin_user_id)
  16175. var dat map[string]interface{}
  16176. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  16177. fmt.Println(dat)
  16178. } else {
  16179. fmt.Println(err)
  16180. }
  16181. userJSONBytes, _ := json.Marshal(dat)
  16182. var res models.Result9001
  16183. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  16184. utils.ErrorLog("解析失败:%v", err)
  16185. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  16186. return
  16187. }
  16188. result, _ := service.Gdyb3262(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, year, month, "", res.Output.Signinoutb.SignNo)
  16189. var dat2 map[string]interface{}
  16190. if err := json.Unmarshal([]byte(result), &dat2); err == nil {
  16191. fmt.Println(dat)
  16192. } else {
  16193. fmt.Println(err)
  16194. }
  16195. userJSONBytes2, _ := json.Marshal(dat2)
  16196. var empty ResultFourteen
  16197. if err := json.Unmarshal(userJSONBytes2, &empty); err != nil {
  16198. utils.ErrorLog("解析失败:%v", err)
  16199. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  16200. return
  16201. }
  16202. if empty.Infcode == 0 {
  16203. c.ServeSuccessJSON(map[string]interface{}{
  16204. "msg": "撤销成功",
  16205. })
  16206. return
  16207. }
  16208. }
  16209. func (c *HisApiController) ReversalOtherData() {
  16210. var customData []*CustomData
  16211. custom := &CustomData{
  16212. MsgId: "H44022900158202103301714472004",
  16213. PsnNo: "44020000001101329945",
  16214. Info: "2208",
  16215. }
  16216. customData = append(customData, custom)
  16217. custom1 := &CustomData{
  16218. MsgId: "H4402290015820210330172057803",
  16219. PsnNo: "44020000001101161813",
  16220. Info: "2208",
  16221. }
  16222. customData = append(customData, custom1)
  16223. custom2 := &CustomData{
  16224. MsgId: "H44022900158202103301705198813",
  16225. PsnNo: "44190000133097375417",
  16226. Info: "2208",
  16227. }
  16228. customData = append(customData, custom2)
  16229. custom3 := &CustomData{
  16230. MsgId: "H44022900158202103301715524756",
  16231. PsnNo: "44020000001100187221",
  16232. Info: "2208",
  16233. }
  16234. customData = append(customData, custom3)
  16235. custom4 := &CustomData{
  16236. MsgId: "H44022900158202103301730376224",
  16237. PsnNo: "44020000001101959155",
  16238. Info: "2208",
  16239. }
  16240. customData = append(customData, custom4)
  16241. custom5 := &CustomData{
  16242. MsgId: "H44022900158202103301748008725",
  16243. PsnNo: "44020000001104246641",
  16244. Info: "2208",
  16245. }
  16246. customData = append(customData, custom5)
  16247. custom6 := &CustomData{
  16248. MsgId: "H44022900158202103301718096755",
  16249. PsnNo: "44020000001102211860",
  16250. Info: "2208",
  16251. }
  16252. customData = append(customData, custom6)
  16253. custom7 := &CustomData{
  16254. MsgId: "H44022900158202103301736551640",
  16255. PsnNo: "44020000001102687718",
  16256. Info: "2208",
  16257. }
  16258. customData = append(customData, custom7)
  16259. custom8 := &CustomData{
  16260. MsgId: "H44022900158202103301743097676",
  16261. PsnNo: "44020000001102127785",
  16262. Info: "2208",
  16263. }
  16264. customData = append(customData, custom8)
  16265. custom9 := &CustomData{
  16266. MsgId: "H44022900158202103301712304203",
  16267. PsnNo: "44020000001101518097",
  16268. Info: "2208",
  16269. }
  16270. customData = append(customData, custom9)
  16271. custom10 := &CustomData{
  16272. MsgId: "H44022900158202103301738448785",
  16273. PsnNo: "44020000001100500813",
  16274. Info: "2208",
  16275. }
  16276. customData = append(customData, custom10)
  16277. custom11 := &CustomData{
  16278. MsgId: "H44022900158202103301732455843",
  16279. PsnNo: "44020000001102690557",
  16280. Info: "2208",
  16281. }
  16282. customData = append(customData, custom11)
  16283. custom12 := &CustomData{
  16284. MsgId: "H44022900158202103301745421708",
  16285. PsnNo: "44020000001102211928",
  16286. Info: "2208",
  16287. }
  16288. customData = append(customData, custom12)
  16289. custom1212 := &CustomData{
  16290. MsgId: "H440229001582021033017351627",
  16291. PsnNo: "44020000001102481733",
  16292. Info: "2208",
  16293. }
  16294. customData = append(customData, custom1212)
  16295. custom13 := &CustomData{
  16296. MsgId: "H44022900158202103301740327951",
  16297. PsnNo: "44020000001103174866",
  16298. Info: "2208",
  16299. }
  16300. customData = append(customData, custom13)
  16301. custom14 := &CustomData{
  16302. MsgId: "H4402290015820210330174922668",
  16303. PsnNo: "44020000001102927272",
  16304. Info: "2208",
  16305. }
  16306. customData = append(customData, custom14)
  16307. custom15 := &CustomData{
  16308. MsgId: "H44022900158202103301752362273",
  16309. PsnNo: "44020000001102942890",
  16310. Info: "2208",
  16311. }
  16312. customData = append(customData, custom15)
  16313. custom16 := &CustomData{
  16314. MsgId: "H44022900158202103301751082917",
  16315. PsnNo: "44020000001101662162",
  16316. Info: "2208",
  16317. }
  16318. customData = append(customData, custom16)
  16319. custom17 := &CustomData{
  16320. MsgId: "H44022900158202103301754147728",
  16321. PsnNo: "44020000000229014511",
  16322. Info: "2208",
  16323. }
  16324. customData = append(customData, custom17)
  16325. adminUser := c.GetAdminUserInfo()
  16326. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  16327. for _, item := range customData {
  16328. result := service.Gdyb2601(item.PsnNo, item.MsgId, item.Info, miConfig.OrgName, "张俊杰", miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey)
  16329. fmt.Println(result)
  16330. }
  16331. }
  16332. func PathExists(path string) (bool, error) {
  16333. _, err := os.Stat(path)
  16334. if err == nil {
  16335. return true, nil
  16336. }
  16337. if os.IsNotExist(err) {
  16338. return false, nil
  16339. }
  16340. return false, err
  16341. }
  16342. // 创建文件夹
  16343. func Mkdir(dir string) {
  16344. // 创建文件夹
  16345. exist, err := PathExists(dir)
  16346. if err != nil {
  16347. fmt.Println(err.Error())
  16348. } else {
  16349. if exist {
  16350. fmt.Println(dir + "文件夹已存在!")
  16351. } else {
  16352. // 文件夹名称,权限
  16353. err := os.Mkdir(dir, os.ModePerm)
  16354. if err != nil {
  16355. fmt.Println(dir+"文件夹创建失败:", err.Error())
  16356. } else {
  16357. fmt.Println(dir + "文件夹创建成功!")
  16358. }
  16359. }
  16360. }
  16361. }
  16362. // 压缩文件
  16363. func Zip(srcFile string, destZip string) error {
  16364. zipfile, err := os.Create(destZip)
  16365. if err != nil {
  16366. return err
  16367. }
  16368. defer zipfile.Close()
  16369. archive := zip.NewWriter(zipfile)
  16370. defer archive.Close()
  16371. filepath.Walk(srcFile, func(path string, info os.FileInfo, err error) error {
  16372. if err != nil {
  16373. return err
  16374. }
  16375. header, err := zip.FileInfoHeader(info)
  16376. if err != nil {
  16377. return err
  16378. }
  16379. header.Name = strings.TrimPrefix(path, filepath.Dir(srcFile)+"/")
  16380. // header.Name = path
  16381. if info.IsDir() {
  16382. header.Name += "/"
  16383. } else {
  16384. header.Method = zip.Deflate
  16385. }
  16386. writer, err := archive.CreateHeader(header)
  16387. if err != nil {
  16388. return err
  16389. }
  16390. if !info.IsDir() {
  16391. file, err := os.Open(path)
  16392. if err != nil {
  16393. return err
  16394. }
  16395. defer file.Close()
  16396. _, err = io.Copy(writer, file)
  16397. }
  16398. return err
  16399. })
  16400. return err
  16401. }
  16402. func ReadFile(filePath string) []byte {
  16403. f, err := os.Open(filePath)
  16404. if err != nil {
  16405. fmt.Println("read file fail", err)
  16406. return nil
  16407. }
  16408. defer f.Close()
  16409. fd, err := ioutil.ReadAll(f)
  16410. if err != nil {
  16411. fmt.Println("read to fd fail", err)
  16412. return nil
  16413. }
  16414. return fd
  16415. }
  16416. func saveLog(result string, request string, infno string, desc string) {
  16417. org_id, _ := beego.AppConfig.Int64("org_id")
  16418. miConfig, _ := service.FindMedicalInsuranceInfo(org_id)
  16419. dir := miConfig.OrgName + "日志"
  16420. utils.Mkdir(dir)
  16421. month := time.Unix(1557042972, 0).Format("1")
  16422. year := time.Now().Format("2006")
  16423. month = time.Now().Format("01")
  16424. day := time.Now().Format("02")
  16425. hour := time.Now().Format("15")
  16426. min := time.Now().Format("04")
  16427. sec := time.Now().Format("05")
  16428. result_time := year + "-" + month + "-" + day + " " + hour + ":" + min + ":" + sec
  16429. file := strconv.FormatInt(org_id, 10) + "_" + year + month + day + "_log"
  16430. file_name := file + ".txt"
  16431. file_path := miConfig.OrgName + "日志" + "/" + file_name
  16432. exist, _ := utils.PathExists(file_path)
  16433. if exist { //存在
  16434. fmt.Println("存在")
  16435. f, err := os.OpenFile(file_path, os.O_WRONLY, 0644)
  16436. if err != nil {
  16437. fmt.Println("read fail")
  16438. }
  16439. content := "\r\n" + "\r\n" + "\r\n" + result_time + " " + "【 " + desc + infno + "入参" + " 】:" + "\r\n" + request + "\r\n" + result_time + " " + "【 " + desc + infno + "出参" + " 】:" + "\r\n" + result
  16440. n, _ := f.Seek(0, 2)
  16441. _, err = f.WriteAt([]byte(content), n)
  16442. } else { //不存在
  16443. fmt.Println("文件不存在,创建文件")
  16444. f, err := os.Create(miConfig.OrgName + "日志" + "/" + file_name)
  16445. defer f.Close()
  16446. if err != nil {
  16447. } else {
  16448. _, err = f.Write([]byte("记录日志"))
  16449. }
  16450. }
  16451. }
  16452. type Charset string
  16453. const (
  16454. UTF8 = Charset("UTF-8")
  16455. GB18030 = Charset("GB18030")
  16456. )
  16457. func ConvertToString(src string, srcCode string, tagCode string) string {
  16458. srcCoder := mahonia.NewDecoder(srcCode)
  16459. srcResult := srcCoder.ConvertString(src)
  16460. tagCoder := mahonia.NewDecoder(tagCode)
  16461. _, cdata, _ := tagCoder.Translate([]byte(srcResult), true)
  16462. result := string(cdata)
  16463. return result
  16464. }
  16465. func ReadEleCard(admin_user_id int64, org_id int64, c *HisApiController) string {
  16466. roles, _ := service.GetAdminUserInfoByID(org_id, admin_user_id)
  16467. miConfig, _ := service.FindMedicalInsuranceInfo(org_id)
  16468. var token string
  16469. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  16470. var api string
  16471. if miConfig.MdtrtareaAdmvs == "320921" {
  16472. 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 +
  16473. "&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
  16474. fmt.Println(api)
  16475. } else {
  16476. 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 +
  16477. "&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
  16478. }
  16479. resp, requestErr := http.Get(api)
  16480. if requestErr != nil {
  16481. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  16482. return ""
  16483. }
  16484. body, ioErr := ioutil.ReadAll(resp.Body)
  16485. if ioErr != nil {
  16486. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  16487. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  16488. return ""
  16489. }
  16490. var respJSON map[string]interface{}
  16491. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  16492. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  16493. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  16494. return ""
  16495. }
  16496. var status string
  16497. status = respJSON["data"].(map[string]interface{})["status"].(string)
  16498. //card_type := respJSON["data"].(map[string]interface{})["type"].(string)
  16499. var res ResultTwo //1101结果
  16500. var res10265 ResultTwo10265 //1101结果
  16501. if status == "0" { //读卡成功
  16502. var card_info string //卡信息
  16503. var busi_card_info string
  16504. token = respJSON["data"].(map[string]interface{})["token"].(string)
  16505. busi_card_info = respJSON["data"].(map[string]interface{})["busi_card_info"].(string)
  16506. card_info = respJSON["data"].(map[string]interface{})["card_info"].(string)
  16507. fmt.Println(card_info)
  16508. fmt.Println(busi_card_info)
  16509. respJSON = respJSON["data"].(map[string]interface{})["result"].(map[string]interface{})
  16510. result, _ := json.Marshal(respJSON)
  16511. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  16512. utils.ErrorLog("解析失败:%v", err)
  16513. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  16514. return ""
  16515. }
  16516. res.ErrMsg = res10265.ErrMsg
  16517. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  16518. res.Infcode = infocode
  16519. res.Output = res10265.Output
  16520. res.InfRefmsgid = res10265.InfRefmsgid
  16521. if res.Infcode == 0 {
  16522. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  16523. if err == gorm.ErrRecordNotFound {
  16524. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  16525. return ""
  16526. } else if err != nil {
  16527. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  16528. return ""
  16529. } else {
  16530. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  16531. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  16532. infoStr := string(Iinfos)
  16533. idetinfoStr := string(Idetinfos)
  16534. psn := &models.HisPsn{
  16535. PsnNo: res.Output.Baseinfo.PsnNo,
  16536. Age: res.Output.Baseinfo.Age,
  16537. PatientId: patient.ID,
  16538. Certno: res.Output.Baseinfo.Certno,
  16539. Brdy: res.Output.Baseinfo.Brdy,
  16540. Gend: res.Output.Baseinfo.Gend,
  16541. Naty: res.Output.Baseinfo.Naty,
  16542. PsnCertType: res.Output.Baseinfo.PsnCertType,
  16543. PsnName: res.Output.Baseinfo.PsnName,
  16544. Idetinfo: idetinfoStr,
  16545. Insuinfo: infoStr,
  16546. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  16547. CardInfo: card_info,
  16548. VerifyNumber: token,
  16549. }
  16550. service.CreateHisPsn(psn)
  16551. return token
  16552. }
  16553. }
  16554. } else {
  16555. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  16556. return ""
  16557. }
  16558. } else { //读卡失败
  16559. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  16560. return ""
  16561. }
  16562. return token
  16563. }
  16564. func DeleteExtraSpaceTwo(s string) string {
  16565. //删除字符串中的多余空格,有多个空格时,仅保留一个空格
  16566. s1 := strings.Replace(s, " ", " ", -1) //替换tab为空格
  16567. regstr := "\\s{2,}" //两个及两个以上空格的正则表达式
  16568. reg, _ := regexp.Compile(regstr) //编译正则表达式
  16569. s2 := make([]byte, len(s1)) //定义字符数组切片
  16570. copy(s2, s1) //将字符串复制到切片
  16571. spc_index := reg.FindStringIndex(string(s2)) //在字符串中搜索
  16572. for len(spc_index) > 0 { //找到适配项
  16573. s2 = append(s2[:spc_index[0]+1], s2[spc_index[1]:]...) //删除多余空格
  16574. spc_index = reg.FindStringIndex(string(s2)) //继续在字符串中搜索
  16575. }
  16576. return string(s2)
  16577. }
  16578. func Remove0000(s string) string {
  16579. str := make([]rune, 0, len(s))
  16580. for _, v := range []rune(s) {
  16581. if v == 0 {
  16582. continue
  16583. }
  16584. str = append(str, v)
  16585. }
  16586. return string(str)
  16587. }
  16588. func (c *HisApiController) GetELeCertInfo(code string, operator_id string, operator_name string) (string, string) {
  16589. DllDef := syscall.MustLoadDLL("HeaSecReadInfo.dll")
  16590. readCard := DllDef.MustFindProc("EcQuery")
  16591. pCardInfo := make([]byte, 8192)
  16592. pBusiCardInfo := make([]byte, 8192)
  16593. data := make(map[string]interface{})
  16594. //pData := make(map[string]interface{})
  16595. inputData := make(map[string]interface{})
  16596. inputData["orgId"] = code
  16597. inputData["businessType"] = "01101"
  16598. inputData["operatorId"] = operator_id
  16599. inputData["operatorName"] = operator_name
  16600. inputData["officeId"] = "001"
  16601. inputData["officeName"] = "血透室"
  16602. //
  16603. data["data"] = inputData
  16604. data["transType"] = "ec.query"
  16605. data["orgId"] = code
  16606. bytesData, _ := json.Marshal(data)
  16607. pCardInfo = bytesData
  16608. ret2, _, _ := readCard.Call((uintptr)(unsafe.Pointer(&pCardInfo[0])), (uintptr)(unsafe.Pointer(&pBusiCardInfo[0])))
  16609. fmt.Println(ret2)
  16610. //fmt.Println(DeleteExtraSpace(string(bytesData)))
  16611. //fmt.Println(DeleteExtraSpace(string(pBusiCardInfo)))
  16612. fmt.Println(":", ConvertToString(DeleteExtraSpace(string(bytesData)), "gbk", "utf-8"))
  16613. fmt.Println(":", ConvertToString(DeleteExtraSpace(string(pBusiCardInfo)), "gbk", "utf-8"))
  16614. if ret2 != 0 {
  16615. return "", ""
  16616. }
  16617. return DeleteExtraSpace(string(bytesData)), DeleteExtraSpace(string(pBusiCardInfo))
  16618. }
  16619. func DeleteExtraSpace(s string) string {
  16620. //删除字符串中的多余空格,有多个空格时,仅保留一个空格
  16621. s1 := strings.Replace(s, " ", " ", -1) //替换tab为空格
  16622. regstr := "\\s{2,}" //两个及两个以上空格的正则表达式
  16623. reg, _ := regexp.Compile(regstr) //编译正则表达式
  16624. s2 := make([]byte, len(s1)) //定义字符数组切片
  16625. copy(s2, s1) //将字符串复制到切片
  16626. spc_index := reg.FindStringIndex(string(s2)) //在字符串中搜索
  16627. for len(spc_index) > 0 { //找到适配项
  16628. s2 = append(s2[:spc_index[0]+1], s2[spc_index[1]:]...) //删除多余空格
  16629. spc_index = reg.FindStringIndex(string(s2)) //继续在字符串中搜索
  16630. }
  16631. return string(s2)
  16632. }
  16633. // 对账
  16634. func (c *HisApiController) Post3202() {
  16635. start_time := c.GetString("start_time")
  16636. end_time := c.GetString("end_time")
  16637. //insutype := c.GetString("insutype")
  16638. clr_type := c.GetString("clr_type")
  16639. clr_org := c.GetString("clr_optins")
  16640. admin_user_id, _ := c.GetInt64("admin_user_id")
  16641. adminUser := c.GetAdminUserInfo()
  16642. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  16643. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  16644. if len(clr_org) == 0 {
  16645. clr_org = miConfig.MdtrtareaAdmvs
  16646. }
  16647. timeLayout := "2006-01-02"
  16648. loc, _ := time.LoadLocation("Local")
  16649. startime, _ := time.ParseInLocation(timeLayout+" 15:04:05", start_time+" 00:00:00", loc)
  16650. endtime, _ := time.ParseInLocation(timeLayout+" 15:04:05", end_time+" 23:59:59", loc)
  16651. orders, _ := service.GetOrderByTimeFour(startime.Unix(), endtime.Unix(), adminUser.CurrentOrgId)
  16652. //orders_two, _ := service.GetOrderByTimeFour(startime.Unix(), endtime.Unix(), adminUser.CurrentOrgId, "310", "", clr_type)
  16653. //fixmedins_setl_cnt := int64(len(orders))
  16654. var medfee_sumamt float64
  16655. var acct_pay float64
  16656. var fund_pay_sumamt float64
  16657. for _, item := range orders {
  16658. medfee_sumamt = medfee_sumamt + item.MedfeeSumamt
  16659. acct_pay = acct_pay + item.AcctPay
  16660. fund_pay_sumamt = fund_pay_sumamt + item.FundPaySumamt
  16661. }
  16662. //var medfee_sumamt_two float64
  16663. //var acct_pay_two float64
  16664. //var fund_pay_sumamt_two float64
  16665. //for _, item := range orders_two {
  16666. // medfee_sumamt_two = medfee_sumamt_two + item.MedfeeSumamt
  16667. // acct_pay_two = acct_pay_two + item.AcctPay
  16668. // fund_pay_sumamt_two = fund_pay_sumamt_two + item.FundPaySumamt
  16669. //}
  16670. //var user_name string
  16671. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  16672. //if role.ID == 0 {
  16673. // user_name = "xxx"
  16674. //} else {
  16675. // user_name = role.UserName
  16676. //}
  16677. var res ResultSix
  16678. if config.IsOpen == 1 {
  16679. var bps []*models.BusinessParamsTwo
  16680. var bp models.BusinessParamsTwo
  16681. medfee_sumamt_str := fmt.Sprintf("%.2f", medfee_sumamt)
  16682. acct_pay_str := fmt.Sprintf("%.2f", acct_pay)
  16683. fund_pay_sumamt_str := fmt.Sprintf("%.2f", fund_pay_sumamt)
  16684. bp.MedfeeSumamt = medfee_sumamt_str
  16685. bp.AcctPay = acct_pay_str
  16686. bp.FundPaySumamt = fund_pay_sumamt_str
  16687. bp.Insutype = "390"
  16688. bp.StmtBegndate = start_time
  16689. bp.ClrType = clr_type
  16690. bp.SetlOptins = clr_org
  16691. bp.StmtEnddate = end_time
  16692. bps = append(bps, &bp)
  16693. data := make(map[string]interface{})
  16694. data["bps"] = bps
  16695. data["org_name"] = miConfig.OrgName
  16696. data["doctor"] = role.UserName
  16697. data["fixmedins_code"] = miConfig.Code
  16698. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  16699. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  16700. if miConfig.MdtrtareaAdmvs == "421300" {
  16701. client := &http.Client{}
  16702. bytesData, _ := json.Marshal(data)
  16703. req, _ := http.NewRequest("POST", "http://192.168.124.4:9532/"+"hbyb/3202", bytes.NewReader(bytesData))
  16704. resp, _ := client.Do(req)
  16705. defer resp.Body.Close()
  16706. body, ioErr := ioutil.ReadAll(resp.Body)
  16707. if ioErr != nil {
  16708. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  16709. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  16710. return
  16711. }
  16712. var respJSON map[string]interface{}
  16713. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  16714. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  16715. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  16716. return
  16717. }
  16718. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  16719. userJSONBytes, _ := json.Marshal(respJSON)
  16720. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  16721. utils.ErrorLog("解析失败:%v", err)
  16722. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  16723. return
  16724. }
  16725. }
  16726. if res.Infcode == 0 {
  16727. c.ServeSuccessJSON(map[string]interface{}{
  16728. "msg": "发起成功",
  16729. })
  16730. } else {
  16731. c.ServeSuccessJSON(map[string]interface{}{
  16732. "code": -10,
  16733. "msg": res.ErrMsg,
  16734. })
  16735. }
  16736. }
  16737. }
  16738. func (c *HisApiController) Post3501() {
  16739. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  16740. data := make(map[string]interface{})
  16741. var struct3501s []models.Struct3501
  16742. var struct3501 models.Struct3501
  16743. struct3501.OrgName = miConfig.OrgName
  16744. struct3501.AccessKey = miConfig.AccessKey
  16745. struct3501.RequestUrl = miConfig.Url
  16746. struct3501.SecretKey = miConfig.SecretKey
  16747. struct3501.ManuDate = "2022-08-17"
  16748. struct3501.FixmedinsBchno = ""
  16749. struct3501.ManuLotnum = ""
  16750. struct3501.RxFlag = "0"
  16751. struct3501.ExpyEnd = "2022-08-17"
  16752. struct3501.Invdate = "2022-08-17"
  16753. struct3501.InvCnt = "20.25"
  16754. struct3501.Memo = ""
  16755. struct3501.MedListCodg = "XB01ABD056B002020200517"
  16756. struct3501.FixmedinsHilistId = miConfig.Code
  16757. struct3501.FixmedinsHilistName = miConfig.OrgName
  16758. struct3501s = append(struct3501s, struct3501)
  16759. data["struct_3501s"] = struct3501s
  16760. client := &http.Client{}
  16761. bytesData, _ := json.Marshal(data)
  16762. var req *http.Request
  16763. if miConfig.MdtrtareaAdmvs == "320921" {
  16764. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3501", bytes.NewReader(bytesData))
  16765. } else {
  16766. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3501", bytes.NewReader(bytesData))
  16767. }
  16768. resp, _ := client.Do(req)
  16769. defer resp.Body.Close()
  16770. body, ioErr := ioutil.ReadAll(resp.Body)
  16771. if ioErr != nil {
  16772. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  16773. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  16774. return
  16775. }
  16776. var respJSON map[string]interface{}
  16777. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  16778. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  16779. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  16780. return
  16781. }
  16782. var res ResultSix
  16783. var resSix10265 ResultSix10265 //1101结果
  16784. respJSON = respJSON["data"].(map[string]interface{})["request_log"].(map[string]interface{})
  16785. result, _ := json.Marshal(respJSON)
  16786. if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  16787. utils.ErrorLog("解析失败:%v", err)
  16788. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  16789. return
  16790. }
  16791. res.InfRefmsgid = resSix10265.InfRefmsgid
  16792. res.Output = resSix10265.Output
  16793. res.ErrMsg = resSix10265.ErrMsg
  16794. res.Cainfo = resSix10265.Cainfo
  16795. res.WarnMsg = resSix10265.WarnMsg
  16796. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  16797. res.Infcode = infocode
  16798. if infocode == 0 {
  16799. c.ServeSuccessJSON(map[string]interface{}{
  16800. "msg": "上传成功",
  16801. })
  16802. return
  16803. } else {
  16804. c.ServeSuccessJSON(map[string]interface{}{
  16805. "failed_code": -10,
  16806. "msg": res.ErrMsg,
  16807. })
  16808. return
  16809. }
  16810. }
  16811. func (c *HisApiController) Post3502() {
  16812. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  16813. data := make(map[string]interface{})
  16814. var struct3502s []models.Struct3502
  16815. var struct3502 models.Struct3502
  16816. struct3502.OrgName = miConfig.OrgName
  16817. struct3502.AccessKey = miConfig.AccessKey
  16818. struct3502.RequestUrl = miConfig.Url
  16819. struct3502.SecretKey = miConfig.SecretKey
  16820. struct3502.ManuDate = "2022-08-15"
  16821. struct3502.FixmedinsBchno = ""
  16822. struct3502.ManuLotnum = ""
  16823. struct3502.RxFlag = "0"
  16824. struct3502.ExpyEnd = "2022-08-15"
  16825. struct3502.Invdate = "2022-08-15"
  16826. struct3502.InvCnt = "20.25"
  16827. struct3502.Memo = ""
  16828. struct3502.MedListCodg = "XB01ABD056B002020200517"
  16829. struct3502.FixmedinsHilistId = miConfig.Code
  16830. struct3502.FixmedinsHilistName = miConfig.OrgName
  16831. struct3502s = append(struct3502s, struct3502)
  16832. data["struct_3502s"] = struct3502s
  16833. client := &http.Client{}
  16834. bytesData, _ := json.Marshal(data)
  16835. var req *http.Request
  16836. if miConfig.MdtrtareaAdmvs == "320921" {
  16837. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3501", bytes.NewReader(bytesData))
  16838. } else {
  16839. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3501", bytes.NewReader(bytesData))
  16840. }
  16841. resp, _ := client.Do(req)
  16842. defer resp.Body.Close()
  16843. body, ioErr := ioutil.ReadAll(resp.Body)
  16844. if ioErr != nil {
  16845. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  16846. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  16847. return
  16848. }
  16849. var respJSON map[string]interface{}
  16850. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  16851. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  16852. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  16853. return
  16854. }
  16855. var res ResultSix
  16856. var resSix10265 ResultSix10265 //1101结果
  16857. respJSON = respJSON["data"].(map[string]interface{})["request_log"].(map[string]interface{})
  16858. result, _ := json.Marshal(respJSON)
  16859. if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  16860. utils.ErrorLog("解析失败:%v", err)
  16861. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  16862. return
  16863. }
  16864. res.InfRefmsgid = resSix10265.InfRefmsgid
  16865. res.Output = resSix10265.Output
  16866. res.ErrMsg = resSix10265.ErrMsg
  16867. res.Cainfo = resSix10265.Cainfo
  16868. res.WarnMsg = resSix10265.WarnMsg
  16869. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  16870. res.Infcode = infocode
  16871. if infocode == 0 {
  16872. c.ServeSuccessJSON(map[string]interface{}{
  16873. "msg": "上传成功",
  16874. })
  16875. return
  16876. } else {
  16877. c.ServeSuccessJSON(map[string]interface{}{
  16878. "failed_code": -10,
  16879. "msg": res.ErrMsg,
  16880. })
  16881. return
  16882. }
  16883. }
  16884. func (c *HisApiController) Post3503() {
  16885. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  16886. data := make(map[string]interface{})
  16887. var struct3501s []models.Struct3501
  16888. var struct3501 models.Struct3501
  16889. struct3501.OrgName = miConfig.OrgName
  16890. struct3501.AccessKey = miConfig.AccessKey
  16891. struct3501.RequestUrl = miConfig.Url
  16892. struct3501.SecretKey = miConfig.SecretKey
  16893. struct3501.ManuDate = "2022-08-15"
  16894. struct3501.FixmedinsBchno = ""
  16895. struct3501.ManuLotnum = ""
  16896. struct3501.RxFlag = "0"
  16897. struct3501.ExpyEnd = "2022-08-15"
  16898. struct3501.Invdate = "2022-08-15"
  16899. struct3501.InvCnt = "20.25"
  16900. struct3501.Memo = ""
  16901. struct3501.MedListCodg = "XB01ABD056B002020200517"
  16902. struct3501.FixmedinsHilistId = miConfig.Code
  16903. struct3501.FixmedinsHilistName = miConfig.OrgName
  16904. struct3501s = append(struct3501s, struct3501)
  16905. data["struct_3501s"] = struct3501s
  16906. client := &http.Client{}
  16907. bytesData, _ := json.Marshal(data)
  16908. var req *http.Request
  16909. if miConfig.MdtrtareaAdmvs == "320921" {
  16910. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3501", bytes.NewReader(bytesData))
  16911. } else {
  16912. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3501", bytes.NewReader(bytesData))
  16913. }
  16914. resp, _ := client.Do(req)
  16915. defer resp.Body.Close()
  16916. body, ioErr := ioutil.ReadAll(resp.Body)
  16917. if ioErr != nil {
  16918. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  16919. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  16920. return
  16921. }
  16922. var respJSON map[string]interface{}
  16923. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  16924. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  16925. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  16926. return
  16927. }
  16928. var res ResultSix
  16929. var resSix10265 ResultSix10265 //1101结果
  16930. respJSON = respJSON["data"].(map[string]interface{})["request_log"].(map[string]interface{})
  16931. result, _ := json.Marshal(respJSON)
  16932. if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  16933. utils.ErrorLog("解析失败:%v", err)
  16934. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  16935. return
  16936. }
  16937. res.InfRefmsgid = resSix10265.InfRefmsgid
  16938. res.Output = resSix10265.Output
  16939. res.ErrMsg = resSix10265.ErrMsg
  16940. res.Cainfo = resSix10265.Cainfo
  16941. res.WarnMsg = resSix10265.WarnMsg
  16942. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  16943. res.Infcode = infocode
  16944. if infocode == 0 {
  16945. c.ServeSuccessJSON(map[string]interface{}{
  16946. "msg": "上传成功",
  16947. })
  16948. return
  16949. } else {
  16950. c.ServeSuccessJSON(map[string]interface{}{
  16951. "failed_code": -10,
  16952. "msg": res.ErrMsg,
  16953. })
  16954. return
  16955. }
  16956. }
  16957. func (c *HisApiController) Post3504() {
  16958. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  16959. data := make(map[string]interface{})
  16960. var struct3501s []models.Struct3501
  16961. var struct3501 models.Struct3501
  16962. struct3501.OrgName = miConfig.OrgName
  16963. struct3501.AccessKey = miConfig.AccessKey
  16964. struct3501.RequestUrl = miConfig.Url
  16965. struct3501.SecretKey = miConfig.SecretKey
  16966. struct3501.ManuDate = "2022-08-15"
  16967. struct3501.FixmedinsBchno = ""
  16968. struct3501.ManuLotnum = ""
  16969. struct3501.RxFlag = "0"
  16970. struct3501.ExpyEnd = "2022-08-15"
  16971. struct3501.Invdate = "2022-08-15"
  16972. struct3501.InvCnt = "20.25"
  16973. struct3501.Memo = ""
  16974. struct3501.MedListCodg = "XB01ABD056B002020200517"
  16975. struct3501.FixmedinsHilistId = miConfig.Code
  16976. struct3501.FixmedinsHilistName = miConfig.OrgName
  16977. struct3501s = append(struct3501s, struct3501)
  16978. data["struct_3501s"] = struct3501s
  16979. client := &http.Client{}
  16980. bytesData, _ := json.Marshal(data)
  16981. var req *http.Request
  16982. if miConfig.MdtrtareaAdmvs == "320921" {
  16983. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3501", bytes.NewReader(bytesData))
  16984. } else {
  16985. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3501", bytes.NewReader(bytesData))
  16986. }
  16987. resp, _ := client.Do(req)
  16988. defer resp.Body.Close()
  16989. body, ioErr := ioutil.ReadAll(resp.Body)
  16990. if ioErr != nil {
  16991. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  16992. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  16993. return
  16994. }
  16995. var respJSON map[string]interface{}
  16996. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  16997. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  16998. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  16999. return
  17000. }
  17001. var res ResultSix
  17002. var resSix10265 ResultSix10265 //1101结果
  17003. respJSON = respJSON["data"].(map[string]interface{})["request_log"].(map[string]interface{})
  17004. result, _ := json.Marshal(respJSON)
  17005. if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  17006. utils.ErrorLog("解析失败:%v", err)
  17007. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  17008. return
  17009. }
  17010. res.InfRefmsgid = resSix10265.InfRefmsgid
  17011. res.Output = resSix10265.Output
  17012. res.ErrMsg = resSix10265.ErrMsg
  17013. res.Cainfo = resSix10265.Cainfo
  17014. res.WarnMsg = resSix10265.WarnMsg
  17015. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  17016. res.Infcode = infocode
  17017. if infocode == 0 {
  17018. c.ServeSuccessJSON(map[string]interface{}{
  17019. "msg": "上传成功",
  17020. })
  17021. return
  17022. } else {
  17023. c.ServeSuccessJSON(map[string]interface{}{
  17024. "failed_code": -10,
  17025. "msg": res.ErrMsg,
  17026. })
  17027. return
  17028. }
  17029. }
  17030. func (c *HisApiController) Post3505() {
  17031. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  17032. data := make(map[string]interface{})
  17033. var struct3501s []models.Struct3501
  17034. var struct3501 models.Struct3501
  17035. struct3501.OrgName = miConfig.OrgName
  17036. struct3501.AccessKey = miConfig.AccessKey
  17037. struct3501.RequestUrl = miConfig.Url
  17038. struct3501.SecretKey = miConfig.SecretKey
  17039. struct3501.ManuDate = "2022-08-15"
  17040. struct3501.FixmedinsBchno = ""
  17041. struct3501.ManuLotnum = ""
  17042. struct3501.RxFlag = "0"
  17043. struct3501.ExpyEnd = "2022-08-15"
  17044. struct3501.Invdate = "2022-08-15"
  17045. struct3501.InvCnt = "20.25"
  17046. struct3501.Memo = ""
  17047. struct3501.MedListCodg = "XB01ABD056B002020200517"
  17048. struct3501.FixmedinsHilistId = miConfig.Code
  17049. struct3501.FixmedinsHilistName = miConfig.OrgName
  17050. struct3501s = append(struct3501s, struct3501)
  17051. data["struct_3501s"] = struct3501s
  17052. client := &http.Client{}
  17053. bytesData, _ := json.Marshal(data)
  17054. var req *http.Request
  17055. if miConfig.MdtrtareaAdmvs == "320921" {
  17056. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3501", bytes.NewReader(bytesData))
  17057. } else {
  17058. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3501", bytes.NewReader(bytesData))
  17059. }
  17060. resp, _ := client.Do(req)
  17061. defer resp.Body.Close()
  17062. body, ioErr := ioutil.ReadAll(resp.Body)
  17063. if ioErr != nil {
  17064. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  17065. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  17066. return
  17067. }
  17068. var respJSON map[string]interface{}
  17069. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  17070. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  17071. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  17072. return
  17073. }
  17074. var res ResultSix
  17075. var resSix10265 ResultSix10265 //1101结果
  17076. respJSON = respJSON["data"].(map[string]interface{})["request_log"].(map[string]interface{})
  17077. result, _ := json.Marshal(respJSON)
  17078. if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  17079. utils.ErrorLog("解析失败:%v", err)
  17080. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  17081. return
  17082. }
  17083. res.InfRefmsgid = resSix10265.InfRefmsgid
  17084. res.Output = resSix10265.Output
  17085. res.ErrMsg = resSix10265.ErrMsg
  17086. res.Cainfo = resSix10265.Cainfo
  17087. res.WarnMsg = resSix10265.WarnMsg
  17088. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  17089. res.Infcode = infocode
  17090. if infocode == 0 {
  17091. c.ServeSuccessJSON(map[string]interface{}{
  17092. "msg": "上传成功",
  17093. })
  17094. return
  17095. } else {
  17096. c.ServeSuccessJSON(map[string]interface{}{
  17097. "failed_code": -10,
  17098. "msg": res.ErrMsg,
  17099. })
  17100. return
  17101. }
  17102. }
  17103. func (c *HisApiController) Post3506() {
  17104. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  17105. data := make(map[string]interface{})
  17106. var struct3501s []models.Struct3501
  17107. var struct3501 models.Struct3501
  17108. struct3501.OrgName = miConfig.OrgName
  17109. struct3501.AccessKey = miConfig.AccessKey
  17110. struct3501.RequestUrl = miConfig.Url
  17111. struct3501.SecretKey = miConfig.SecretKey
  17112. struct3501.ManuDate = "2022-08-15"
  17113. struct3501.FixmedinsBchno = ""
  17114. struct3501.ManuLotnum = ""
  17115. struct3501.RxFlag = "0"
  17116. struct3501.ExpyEnd = "2022-08-15"
  17117. struct3501.Invdate = "2022-08-15"
  17118. struct3501.InvCnt = "20.25"
  17119. struct3501.Memo = ""
  17120. struct3501.MedListCodg = "XB01ABD056B002020200517"
  17121. struct3501.FixmedinsHilistId = miConfig.Code
  17122. struct3501.FixmedinsHilistName = miConfig.OrgName
  17123. struct3501s = append(struct3501s, struct3501)
  17124. data["struct_3501s"] = struct3501s
  17125. client := &http.Client{}
  17126. bytesData, _ := json.Marshal(data)
  17127. var req *http.Request
  17128. if miConfig.MdtrtareaAdmvs == "320921" {
  17129. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3501", bytes.NewReader(bytesData))
  17130. } else {
  17131. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3501", bytes.NewReader(bytesData))
  17132. }
  17133. resp, _ := client.Do(req)
  17134. defer resp.Body.Close()
  17135. body, ioErr := ioutil.ReadAll(resp.Body)
  17136. if ioErr != nil {
  17137. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  17138. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  17139. return
  17140. }
  17141. var respJSON map[string]interface{}
  17142. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  17143. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  17144. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  17145. return
  17146. }
  17147. var res ResultSix
  17148. var resSix10265 ResultSix10265 //1101结果
  17149. respJSON = respJSON["data"].(map[string]interface{})["request_log"].(map[string]interface{})
  17150. result, _ := json.Marshal(respJSON)
  17151. if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  17152. utils.ErrorLog("解析失败:%v", err)
  17153. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  17154. return
  17155. }
  17156. res.InfRefmsgid = resSix10265.InfRefmsgid
  17157. res.Output = resSix10265.Output
  17158. res.ErrMsg = resSix10265.ErrMsg
  17159. res.Cainfo = resSix10265.Cainfo
  17160. res.WarnMsg = resSix10265.WarnMsg
  17161. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  17162. res.Infcode = infocode
  17163. if infocode == 0 {
  17164. c.ServeSuccessJSON(map[string]interface{}{
  17165. "msg": "上传成功",
  17166. })
  17167. return
  17168. } else {
  17169. c.ServeSuccessJSON(map[string]interface{}{
  17170. "failed_code": -10,
  17171. "msg": res.ErrMsg,
  17172. })
  17173. return
  17174. }
  17175. }
  17176. func (c *HisApiController) Post3507() {
  17177. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  17178. data := make(map[string]interface{})
  17179. var struct3501s []models.Struct3501
  17180. var struct3501 models.Struct3501
  17181. struct3501.OrgName = miConfig.OrgName
  17182. struct3501.AccessKey = miConfig.AccessKey
  17183. struct3501.RequestUrl = miConfig.Url
  17184. struct3501.SecretKey = miConfig.SecretKey
  17185. struct3501.ManuDate = "2022-08-15"
  17186. struct3501.FixmedinsBchno = ""
  17187. struct3501.ManuLotnum = ""
  17188. struct3501.RxFlag = "0"
  17189. struct3501.ExpyEnd = "2022-08-15"
  17190. struct3501.Invdate = "2022-08-15"
  17191. struct3501.InvCnt = "20.25"
  17192. struct3501.Memo = ""
  17193. struct3501.MedListCodg = "XB01ABD056B002020200517"
  17194. struct3501.FixmedinsHilistId = miConfig.Code
  17195. struct3501.FixmedinsHilistName = miConfig.OrgName
  17196. struct3501s = append(struct3501s, struct3501)
  17197. data["struct_3501s"] = struct3501s
  17198. client := &http.Client{}
  17199. bytesData, _ := json.Marshal(data)
  17200. var req *http.Request
  17201. if miConfig.MdtrtareaAdmvs == "320921" {
  17202. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3501", bytes.NewReader(bytesData))
  17203. } else {
  17204. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3501", bytes.NewReader(bytesData))
  17205. }
  17206. resp, _ := client.Do(req)
  17207. defer resp.Body.Close()
  17208. body, ioErr := ioutil.ReadAll(resp.Body)
  17209. if ioErr != nil {
  17210. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  17211. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  17212. return
  17213. }
  17214. var respJSON map[string]interface{}
  17215. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  17216. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  17217. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  17218. return
  17219. }
  17220. var res ResultSix
  17221. var resSix10265 ResultSix10265 //1101结果
  17222. respJSON = respJSON["data"].(map[string]interface{})["request_log"].(map[string]interface{})
  17223. result, _ := json.Marshal(respJSON)
  17224. if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  17225. utils.ErrorLog("解析失败:%v", err)
  17226. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  17227. return
  17228. }
  17229. res.InfRefmsgid = resSix10265.InfRefmsgid
  17230. res.Output = resSix10265.Output
  17231. res.ErrMsg = resSix10265.ErrMsg
  17232. res.Cainfo = resSix10265.Cainfo
  17233. res.WarnMsg = resSix10265.WarnMsg
  17234. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  17235. res.Infcode = infocode
  17236. if infocode == 0 {
  17237. c.ServeSuccessJSON(map[string]interface{}{
  17238. "msg": "上传成功",
  17239. })
  17240. return
  17241. } else {
  17242. c.ServeSuccessJSON(map[string]interface{}{
  17243. "failed_code": -10,
  17244. "msg": res.ErrMsg,
  17245. })
  17246. return
  17247. }
  17248. }
  17249. func GetELeInfo(code string, operator_id string, operator_name string) (string, string) {
  17250. // WebSocket服务器地址
  17251. serverURL := "ws://127.0.0.1:8899"
  17252. // 解析WebSocket服务器地址
  17253. u, err := url.Parse(serverURL)
  17254. if err != nil {
  17255. }
  17256. // 建立WebSocket连接
  17257. conn, _, err := websocket.DefaultDialer.Dial(u.String(), nil)
  17258. if err != nil {
  17259. }
  17260. defer conn.Close()
  17261. input2 := make(map[string]interface{})
  17262. input := make(map[string]interface{})
  17263. inputData := make(map[string]interface{})
  17264. inputData["orgId"] = code
  17265. inputData["businessType"] = "01101"
  17266. inputData["operatorId"] = operator_id
  17267. inputData["operatorName"] = operator_name
  17268. inputData["officeId"] = "001"
  17269. inputData["officeName"] = "血透室"
  17270. inputData["deviceType"] = ""
  17271. input["data"] = inputData
  17272. input["orgId"] = code
  17273. input["transType"] = "ec.query"
  17274. input2["url"] = "http://igb.hsa.gdgov.cn/prd_nation_eccode/prd_eccode/localcfc/api/hsecfc/localQrCodeQuery"
  17275. input2["indata"] = input
  17276. bytesData, _ := json.Marshal(input2)
  17277. err = conn.WriteMessage(websocket.TextMessage, bytesData)
  17278. if err != nil {
  17279. fmt.Println(err)
  17280. }
  17281. // 接收消息
  17282. _, receivedMessage, err := conn.ReadMessage()
  17283. if err != nil {
  17284. fmt.Println(err)
  17285. }
  17286. return "", string(receivedMessage)
  17287. }
  17288. func GetELeInfoThree(code string, operator_id string, operator_name string) (string, string) {
  17289. // WebSocket服务器地址
  17290. serverURL := "ws://127.0.0.1:8899"
  17291. // 解析WebSocket服务器地址
  17292. u, err := url.Parse(serverURL)
  17293. if err != nil {
  17294. }
  17295. // 建立WebSocket连接
  17296. conn, _, err := websocket.DefaultDialer.Dial(u.String(), nil)
  17297. if err != nil {
  17298. }
  17299. defer conn.Close()
  17300. input2 := make(map[string]interface{})
  17301. input := make(map[string]interface{})
  17302. inputData := make(map[string]interface{})
  17303. inputData["orgId"] = code
  17304. inputData["businessType"] = "01301"
  17305. inputData["operatorId"] = operator_id
  17306. inputData["operatorName"] = operator_name
  17307. inputData["officeId"] = "001"
  17308. inputData["officeName"] = "血透室"
  17309. inputData["deviceType"] = ""
  17310. input["data"] = inputData
  17311. input["orgId"] = code
  17312. input["transType"] = "ec.query"
  17313. input2["url"] = "http://igb.hsa.gdgov.cn/prd_nation_eccode/prd_eccode/localcfc/api/hsecfc/localQrCodeQuery"
  17314. input2["indata"] = input
  17315. bytesData, _ := json.Marshal(input2)
  17316. err = conn.WriteMessage(websocket.TextMessage, bytesData)
  17317. if err != nil {
  17318. fmt.Println(err)
  17319. }
  17320. // 接收消息
  17321. _, receivedMessage, err := conn.ReadMessage()
  17322. if err != nil {
  17323. fmt.Println(err)
  17324. }
  17325. return "", string(receivedMessage)
  17326. }