his_api_controller.go 687KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504250525062507250825092510251125122513251425152516251725182519252025212522252325242525252625272528252925302531253225332534253525362537253825392540254125422543254425452546254725482549255025512552255325542555255625572558255925602561256225632564256525662567256825692570257125722573257425752576257725782579258025812582258325842585258625872588258925902591259225932594259525962597259825992600260126022603260426052606260726082609261026112612261326142615261626172618261926202621262226232624262526262627262826292630263126322633263426352636263726382639264026412642264326442645264626472648264926502651265226532654265526562657265826592660266126622663266426652666266726682669267026712672267326742675267626772678267926802681268226832684268526862687268826892690269126922693269426952696269726982699270027012702270327042705270627072708270927102711271227132714271527162717271827192720272127222723272427252726272727282729273027312732273327342735273627372738273927402741274227432744274527462747274827492750275127522753275427552756275727582759276027612762276327642765276627672768276927702771277227732774277527762777277827792780278127822783278427852786278727882789279027912792279327942795279627972798279928002801280228032804280528062807280828092810281128122813281428152816281728182819282028212822282328242825282628272828282928302831283228332834283528362837283828392840284128422843284428452846284728482849285028512852285328542855285628572858285928602861286228632864286528662867286828692870287128722873287428752876287728782879288028812882288328842885288628872888288928902891289228932894289528962897289828992900290129022903290429052906290729082909291029112912291329142915291629172918291929202921292229232924292529262927292829292930293129322933293429352936293729382939294029412942294329442945294629472948294929502951295229532954295529562957295829592960296129622963296429652966296729682969297029712972297329742975297629772978297929802981298229832984298529862987298829892990299129922993299429952996299729982999300030013002300330043005300630073008300930103011301230133014301530163017301830193020302130223023302430253026302730283029303030313032303330343035303630373038303930403041304230433044304530463047304830493050305130523053305430553056305730583059306030613062306330643065306630673068306930703071307230733074307530763077307830793080308130823083308430853086308730883089309030913092309330943095309630973098309931003101310231033104310531063107310831093110311131123113311431153116311731183119312031213122312331243125312631273128312931303131313231333134313531363137313831393140314131423143314431453146314731483149315031513152315331543155315631573158315931603161316231633164316531663167316831693170317131723173317431753176317731783179318031813182318331843185318631873188318931903191319231933194319531963197319831993200320132023203320432053206320732083209321032113212321332143215321632173218321932203221322232233224322532263227322832293230323132323233323432353236323732383239324032413242324332443245324632473248324932503251325232533254325532563257325832593260326132623263326432653266326732683269327032713272327332743275327632773278327932803281328232833284328532863287328832893290329132923293329432953296329732983299330033013302330333043305330633073308330933103311331233133314331533163317331833193320332133223323332433253326332733283329333033313332333333343335333633373338333933403341334233433344334533463347334833493350335133523353335433553356335733583359336033613362336333643365336633673368336933703371337233733374337533763377337833793380338133823383338433853386338733883389339033913392339333943395339633973398339934003401340234033404340534063407340834093410341134123413341434153416341734183419342034213422342334243425342634273428342934303431343234333434343534363437343834393440344134423443344434453446344734483449345034513452345334543455345634573458345934603461346234633464346534663467346834693470347134723473347434753476347734783479348034813482348334843485348634873488348934903491349234933494349534963497349834993500350135023503350435053506350735083509351035113512351335143515351635173518351935203521352235233524352535263527352835293530353135323533353435353536353735383539354035413542354335443545354635473548354935503551355235533554355535563557355835593560356135623563356435653566356735683569357035713572357335743575357635773578357935803581358235833584358535863587358835893590359135923593359435953596359735983599360036013602360336043605360636073608360936103611361236133614361536163617361836193620362136223623362436253626362736283629363036313632363336343635363636373638363936403641364236433644364536463647364836493650365136523653365436553656365736583659366036613662366336643665366636673668366936703671367236733674367536763677367836793680368136823683368436853686368736883689369036913692369336943695369636973698369937003701370237033704370537063707370837093710371137123713371437153716371737183719372037213722372337243725372637273728372937303731373237333734373537363737373837393740374137423743374437453746374737483749375037513752375337543755375637573758375937603761376237633764376537663767376837693770377137723773377437753776377737783779378037813782378337843785378637873788378937903791379237933794379537963797379837993800380138023803380438053806380738083809381038113812381338143815381638173818381938203821382238233824382538263827382838293830383138323833383438353836383738383839384038413842384338443845384638473848384938503851385238533854385538563857385838593860386138623863386438653866386738683869387038713872387338743875387638773878387938803881388238833884388538863887388838893890389138923893389438953896389738983899390039013902390339043905390639073908390939103911391239133914391539163917391839193920392139223923392439253926392739283929393039313932393339343935393639373938393939403941394239433944394539463947394839493950395139523953395439553956395739583959396039613962396339643965396639673968396939703971397239733974397539763977397839793980398139823983398439853986398739883989399039913992399339943995399639973998399940004001400240034004400540064007400840094010401140124013401440154016401740184019402040214022402340244025402640274028402940304031403240334034403540364037403840394040404140424043404440454046404740484049405040514052405340544055405640574058405940604061406240634064406540664067406840694070407140724073407440754076407740784079408040814082408340844085408640874088408940904091409240934094409540964097409840994100410141024103410441054106410741084109411041114112411341144115411641174118411941204121412241234124412541264127412841294130413141324133413441354136413741384139414041414142414341444145414641474148414941504151415241534154415541564157415841594160416141624163416441654166416741684169417041714172417341744175417641774178417941804181418241834184418541864187418841894190419141924193419441954196419741984199420042014202420342044205420642074208420942104211421242134214421542164217421842194220422142224223422442254226422742284229423042314232423342344235423642374238423942404241424242434244424542464247424842494250425142524253425442554256425742584259426042614262426342644265426642674268426942704271427242734274427542764277427842794280428142824283428442854286428742884289429042914292429342944295429642974298429943004301430243034304430543064307430843094310431143124313431443154316431743184319432043214322432343244325432643274328432943304331433243334334433543364337433843394340434143424343434443454346434743484349435043514352435343544355435643574358435943604361436243634364436543664367436843694370437143724373437443754376437743784379438043814382438343844385438643874388438943904391439243934394439543964397439843994400440144024403440444054406440744084409441044114412441344144415441644174418441944204421442244234424442544264427442844294430443144324433443444354436443744384439444044414442444344444445444644474448444944504451445244534454445544564457445844594460446144624463446444654466446744684469447044714472447344744475447644774478447944804481448244834484448544864487448844894490449144924493449444954496449744984499450045014502450345044505450645074508450945104511451245134514451545164517451845194520452145224523452445254526452745284529453045314532453345344535453645374538453945404541454245434544454545464547454845494550455145524553455445554556455745584559456045614562456345644565456645674568456945704571457245734574457545764577457845794580458145824583458445854586458745884589459045914592459345944595459645974598459946004601460246034604460546064607460846094610461146124613461446154616461746184619462046214622462346244625462646274628462946304631463246334634463546364637463846394640464146424643464446454646464746484649465046514652465346544655465646574658465946604661466246634664466546664667466846694670467146724673467446754676467746784679468046814682468346844685468646874688468946904691469246934694469546964697469846994700470147024703470447054706470747084709471047114712471347144715471647174718471947204721472247234724472547264727472847294730473147324733473447354736473747384739474047414742474347444745474647474748474947504751475247534754475547564757475847594760476147624763476447654766476747684769477047714772477347744775477647774778477947804781478247834784478547864787478847894790479147924793479447954796479747984799480048014802480348044805480648074808480948104811481248134814481548164817481848194820482148224823482448254826482748284829483048314832483348344835483648374838483948404841484248434844484548464847484848494850485148524853485448554856485748584859486048614862486348644865486648674868486948704871487248734874487548764877487848794880488148824883488448854886488748884889489048914892489348944895489648974898489949004901490249034904490549064907490849094910491149124913491449154916491749184919492049214922492349244925492649274928492949304931493249334934493549364937493849394940494149424943494449454946494749484949495049514952495349544955495649574958495949604961496249634964496549664967496849694970497149724973497449754976497749784979498049814982498349844985498649874988498949904991499249934994499549964997499849995000500150025003500450055006500750085009501050115012501350145015501650175018501950205021502250235024502550265027502850295030503150325033503450355036503750385039504050415042504350445045504650475048504950505051505250535054505550565057505850595060506150625063506450655066506750685069507050715072507350745075507650775078507950805081508250835084508550865087508850895090509150925093509450955096509750985099510051015102510351045105510651075108510951105111511251135114511551165117511851195120512151225123512451255126512751285129513051315132513351345135513651375138513951405141514251435144514551465147514851495150515151525153515451555156515751585159516051615162516351645165516651675168516951705171517251735174517551765177517851795180518151825183518451855186518751885189519051915192519351945195519651975198519952005201520252035204520552065207520852095210521152125213521452155216521752185219522052215222522352245225522652275228522952305231523252335234523552365237523852395240524152425243524452455246524752485249525052515252525352545255525652575258525952605261526252635264526552665267526852695270527152725273527452755276527752785279528052815282528352845285528652875288528952905291529252935294529552965297529852995300530153025303530453055306530753085309531053115312531353145315531653175318531953205321532253235324532553265327532853295330533153325333533453355336533753385339534053415342534353445345534653475348534953505351535253535354535553565357535853595360536153625363536453655366536753685369537053715372537353745375537653775378537953805381538253835384538553865387538853895390539153925393539453955396539753985399540054015402540354045405540654075408540954105411541254135414541554165417541854195420542154225423542454255426542754285429543054315432543354345435543654375438543954405441544254435444544554465447544854495450545154525453545454555456545754585459546054615462546354645465546654675468546954705471547254735474547554765477547854795480548154825483548454855486548754885489549054915492549354945495549654975498549955005501550255035504550555065507550855095510551155125513551455155516551755185519552055215522552355245525552655275528552955305531553255335534553555365537553855395540554155425543554455455546554755485549555055515552555355545555555655575558555955605561556255635564556555665567556855695570557155725573557455755576557755785579558055815582558355845585558655875588558955905591559255935594559555965597559855995600560156025603560456055606560756085609561056115612561356145615561656175618561956205621562256235624562556265627562856295630563156325633563456355636563756385639564056415642564356445645564656475648564956505651565256535654565556565657565856595660566156625663566456655666566756685669567056715672567356745675567656775678567956805681568256835684568556865687568856895690569156925693569456955696569756985699570057015702570357045705570657075708570957105711571257135714571557165717571857195720572157225723572457255726572757285729573057315732573357345735573657375738573957405741574257435744574557465747574857495750575157525753575457555756575757585759576057615762576357645765576657675768576957705771577257735774577557765777577857795780578157825783578457855786578757885789579057915792579357945795579657975798579958005801580258035804580558065807580858095810581158125813581458155816581758185819582058215822582358245825582658275828582958305831583258335834583558365837583858395840584158425843584458455846584758485849585058515852585358545855585658575858585958605861586258635864586558665867586858695870587158725873587458755876587758785879588058815882588358845885588658875888588958905891589258935894589558965897589858995900590159025903590459055906590759085909591059115912591359145915591659175918591959205921592259235924592559265927592859295930593159325933593459355936593759385939594059415942594359445945594659475948594959505951595259535954595559565957595859595960596159625963596459655966596759685969597059715972597359745975597659775978597959805981598259835984598559865987598859895990599159925993599459955996599759985999600060016002600360046005600660076008600960106011601260136014601560166017601860196020602160226023602460256026602760286029603060316032603360346035603660376038603960406041604260436044604560466047604860496050605160526053605460556056605760586059606060616062606360646065606660676068606960706071607260736074607560766077607860796080608160826083608460856086608760886089609060916092609360946095609660976098609961006101610261036104610561066107610861096110611161126113611461156116611761186119612061216122612361246125612661276128612961306131613261336134613561366137613861396140614161426143614461456146614761486149615061516152615361546155615661576158615961606161616261636164616561666167616861696170617161726173617461756176617761786179618061816182618361846185618661876188618961906191619261936194619561966197619861996200620162026203620462056206620762086209621062116212621362146215621662176218621962206221622262236224622562266227622862296230623162326233623462356236623762386239624062416242624362446245624662476248624962506251625262536254625562566257625862596260626162626263626462656266626762686269627062716272627362746275627662776278627962806281628262836284628562866287628862896290629162926293629462956296629762986299630063016302630363046305630663076308630963106311631263136314631563166317631863196320632163226323632463256326632763286329633063316332633363346335633663376338633963406341634263436344634563466347634863496350635163526353635463556356635763586359636063616362636363646365636663676368636963706371637263736374637563766377637863796380638163826383638463856386638763886389639063916392639363946395639663976398639964006401640264036404640564066407640864096410641164126413641464156416641764186419642064216422642364246425642664276428642964306431643264336434643564366437643864396440644164426443644464456446644764486449645064516452645364546455645664576458645964606461646264636464646564666467646864696470647164726473647464756476647764786479648064816482648364846485648664876488648964906491649264936494649564966497649864996500650165026503650465056506650765086509651065116512651365146515651665176518651965206521652265236524652565266527652865296530653165326533653465356536653765386539654065416542654365446545654665476548654965506551655265536554655565566557655865596560656165626563656465656566656765686569657065716572657365746575657665776578657965806581658265836584658565866587658865896590659165926593659465956596659765986599660066016602660366046605660666076608660966106611661266136614661566166617661866196620662166226623662466256626662766286629663066316632663366346635663666376638663966406641664266436644664566466647664866496650665166526653665466556656665766586659666066616662666366646665666666676668666966706671667266736674667566766677667866796680668166826683668466856686668766886689669066916692669366946695669666976698669967006701670267036704670567066707670867096710671167126713671467156716671767186719672067216722672367246725672667276728672967306731673267336734673567366737673867396740674167426743674467456746674767486749675067516752675367546755675667576758675967606761676267636764676567666767676867696770677167726773677467756776677767786779678067816782678367846785678667876788678967906791679267936794679567966797679867996800680168026803680468056806680768086809681068116812681368146815681668176818681968206821682268236824682568266827682868296830683168326833683468356836683768386839684068416842684368446845684668476848684968506851685268536854685568566857685868596860686168626863686468656866686768686869687068716872687368746875687668776878687968806881688268836884688568866887688868896890689168926893689468956896689768986899690069016902690369046905690669076908690969106911691269136914691569166917691869196920692169226923692469256926692769286929693069316932693369346935693669376938693969406941694269436944694569466947694869496950695169526953695469556956695769586959696069616962696369646965696669676968696969706971697269736974697569766977697869796980698169826983698469856986698769886989699069916992699369946995699669976998699970007001700270037004700570067007700870097010701170127013701470157016701770187019702070217022702370247025702670277028702970307031703270337034703570367037703870397040704170427043704470457046704770487049705070517052705370547055705670577058705970607061706270637064706570667067706870697070707170727073707470757076707770787079708070817082708370847085708670877088708970907091709270937094709570967097709870997100710171027103710471057106710771087109711071117112711371147115711671177118711971207121712271237124712571267127712871297130713171327133713471357136713771387139714071417142714371447145714671477148714971507151715271537154715571567157715871597160716171627163716471657166716771687169717071717172717371747175717671777178717971807181718271837184718571867187718871897190719171927193719471957196719771987199720072017202720372047205720672077208720972107211721272137214721572167217721872197220722172227223722472257226722772287229723072317232723372347235723672377238723972407241724272437244724572467247724872497250725172527253725472557256725772587259726072617262726372647265726672677268726972707271727272737274727572767277727872797280728172827283728472857286728772887289729072917292729372947295729672977298729973007301730273037304730573067307730873097310731173127313731473157316731773187319732073217322732373247325732673277328732973307331733273337334733573367337733873397340734173427343734473457346734773487349735073517352735373547355735673577358735973607361736273637364736573667367736873697370737173727373737473757376737773787379738073817382738373847385738673877388738973907391739273937394739573967397739873997400740174027403740474057406740774087409741074117412741374147415741674177418741974207421742274237424742574267427742874297430743174327433743474357436743774387439744074417442744374447445744674477448744974507451745274537454745574567457745874597460746174627463746474657466746774687469747074717472747374747475747674777478747974807481748274837484748574867487748874897490749174927493749474957496749774987499750075017502750375047505750675077508750975107511751275137514751575167517751875197520752175227523752475257526752775287529753075317532753375347535753675377538753975407541754275437544754575467547754875497550755175527553755475557556755775587559756075617562756375647565756675677568756975707571757275737574757575767577757875797580758175827583758475857586758775887589759075917592759375947595759675977598759976007601760276037604760576067607760876097610761176127613761476157616761776187619762076217622762376247625762676277628762976307631763276337634763576367637763876397640764176427643764476457646764776487649765076517652765376547655765676577658765976607661766276637664766576667667766876697670767176727673767476757676767776787679768076817682768376847685768676877688768976907691769276937694769576967697769876997700770177027703770477057706770777087709771077117712771377147715771677177718771977207721772277237724772577267727772877297730773177327733773477357736773777387739774077417742774377447745774677477748774977507751775277537754775577567757775877597760776177627763776477657766776777687769777077717772777377747775777677777778777977807781778277837784778577867787778877897790779177927793779477957796779777987799780078017802780378047805780678077808780978107811781278137814781578167817781878197820782178227823782478257826782778287829783078317832783378347835783678377838783978407841784278437844784578467847784878497850785178527853785478557856785778587859786078617862786378647865786678677868786978707871787278737874787578767877787878797880788178827883788478857886788778887889789078917892789378947895789678977898789979007901790279037904790579067907790879097910791179127913791479157916791779187919792079217922792379247925792679277928792979307931793279337934793579367937793879397940794179427943794479457946794779487949795079517952795379547955795679577958795979607961796279637964796579667967796879697970797179727973797479757976797779787979798079817982798379847985798679877988798979907991799279937994799579967997799879998000800180028003800480058006800780088009801080118012801380148015801680178018801980208021802280238024802580268027802880298030803180328033803480358036803780388039804080418042804380448045804680478048804980508051805280538054805580568057805880598060806180628063806480658066806780688069807080718072807380748075807680778078807980808081808280838084808580868087808880898090809180928093809480958096809780988099810081018102810381048105810681078108810981108111811281138114811581168117811881198120812181228123812481258126812781288129813081318132813381348135813681378138813981408141814281438144814581468147814881498150815181528153815481558156815781588159816081618162816381648165816681678168816981708171817281738174817581768177817881798180818181828183818481858186818781888189819081918192819381948195819681978198819982008201820282038204820582068207820882098210821182128213821482158216821782188219822082218222822382248225822682278228822982308231823282338234823582368237823882398240824182428243824482458246824782488249825082518252825382548255825682578258825982608261826282638264826582668267826882698270827182728273827482758276827782788279828082818282828382848285828682878288828982908291829282938294829582968297829882998300830183028303830483058306830783088309831083118312831383148315831683178318831983208321832283238324832583268327832883298330833183328333833483358336833783388339834083418342834383448345834683478348834983508351835283538354835583568357835883598360836183628363836483658366836783688369837083718372837383748375837683778378837983808381838283838384838583868387838883898390839183928393839483958396839783988399840084018402840384048405840684078408840984108411841284138414841584168417841884198420842184228423842484258426842784288429843084318432843384348435843684378438843984408441844284438444844584468447844884498450845184528453845484558456845784588459846084618462846384648465846684678468846984708471847284738474847584768477847884798480848184828483848484858486848784888489849084918492849384948495849684978498849985008501850285038504850585068507850885098510851185128513851485158516851785188519852085218522852385248525852685278528852985308531853285338534853585368537853885398540854185428543854485458546854785488549855085518552855385548555855685578558855985608561856285638564856585668567856885698570857185728573857485758576857785788579858085818582858385848585858685878588858985908591859285938594859585968597859885998600860186028603860486058606860786088609861086118612861386148615861686178618861986208621862286238624862586268627862886298630863186328633863486358636863786388639864086418642864386448645864686478648864986508651865286538654865586568657865886598660866186628663866486658666866786688669867086718672867386748675867686778678867986808681868286838684868586868687868886898690869186928693869486958696869786988699870087018702870387048705870687078708870987108711871287138714871587168717871887198720872187228723872487258726872787288729873087318732873387348735873687378738873987408741874287438744874587468747874887498750875187528753875487558756875787588759876087618762876387648765876687678768876987708771877287738774877587768777877887798780878187828783878487858786878787888789879087918792879387948795879687978798879988008801880288038804880588068807880888098810881188128813881488158816881788188819882088218822882388248825882688278828882988308831883288338834883588368837883888398840884188428843884488458846884788488849885088518852885388548855885688578858885988608861886288638864886588668867886888698870887188728873887488758876887788788879888088818882888388848885888688878888888988908891889288938894889588968897889888998900890189028903890489058906890789088909891089118912891389148915891689178918891989208921892289238924892589268927892889298930893189328933893489358936893789388939894089418942894389448945894689478948894989508951895289538954895589568957895889598960896189628963896489658966896789688969897089718972897389748975897689778978897989808981898289838984898589868987898889898990899189928993899489958996899789988999900090019002900390049005900690079008900990109011901290139014901590169017901890199020902190229023902490259026902790289029903090319032903390349035903690379038903990409041904290439044904590469047904890499050905190529053905490559056905790589059906090619062906390649065906690679068906990709071907290739074907590769077907890799080908190829083908490859086908790889089909090919092909390949095909690979098909991009101910291039104910591069107910891099110911191129113911491159116911791189119912091219122912391249125912691279128912991309131913291339134913591369137913891399140914191429143914491459146914791489149915091519152915391549155915691579158915991609161916291639164916591669167916891699170917191729173917491759176917791789179918091819182918391849185918691879188918991909191919291939194919591969197919891999200920192029203920492059206920792089209921092119212921392149215921692179218921992209221922292239224922592269227922892299230923192329233923492359236923792389239924092419242924392449245924692479248924992509251925292539254925592569257925892599260926192629263926492659266926792689269927092719272927392749275927692779278927992809281928292839284928592869287928892899290929192929293929492959296929792989299930093019302930393049305930693079308930993109311931293139314931593169317931893199320932193229323932493259326932793289329933093319332933393349335933693379338933993409341934293439344934593469347934893499350935193529353935493559356935793589359936093619362936393649365936693679368936993709371937293739374937593769377937893799380938193829383938493859386938793889389939093919392939393949395939693979398939994009401940294039404940594069407940894099410941194129413941494159416941794189419942094219422942394249425942694279428942994309431943294339434943594369437943894399440944194429443944494459446944794489449945094519452945394549455945694579458945994609461946294639464946594669467946894699470947194729473947494759476947794789479948094819482948394849485948694879488948994909491949294939494949594969497949894999500950195029503950495059506950795089509951095119512951395149515951695179518951995209521952295239524952595269527952895299530953195329533953495359536953795389539954095419542954395449545954695479548954995509551955295539554955595569557955895599560956195629563956495659566956795689569957095719572957395749575957695779578957995809581958295839584958595869587958895899590959195929593959495959596959795989599960096019602960396049605960696079608960996109611961296139614961596169617961896199620962196229623962496259626962796289629963096319632963396349635963696379638963996409641964296439644964596469647964896499650965196529653965496559656965796589659966096619662966396649665966696679668966996709671967296739674967596769677967896799680968196829683968496859686968796889689969096919692969396949695969696979698969997009701970297039704970597069707970897099710971197129713971497159716971797189719972097219722972397249725972697279728972997309731973297339734973597369737973897399740974197429743974497459746974797489749975097519752975397549755975697579758975997609761976297639764976597669767976897699770977197729773977497759776977797789779978097819782978397849785978697879788978997909791979297939794979597969797979897999800980198029803980498059806980798089809981098119812981398149815981698179818981998209821982298239824982598269827982898299830983198329833983498359836983798389839984098419842984398449845984698479848984998509851985298539854985598569857985898599860986198629863986498659866986798689869987098719872987398749875987698779878987998809881988298839884988598869887988898899890989198929893989498959896989798989899990099019902990399049905990699079908990999109911991299139914991599169917991899199920992199229923992499259926992799289929993099319932993399349935993699379938993999409941994299439944994599469947994899499950995199529953995499559956995799589959996099619962996399649965996699679968996999709971997299739974997599769977997899799980998199829983998499859986998799889989999099919992999399949995999699979998999910000100011000210003100041000510006100071000810009100101001110012100131001410015100161001710018100191002010021100221002310024100251002610027100281002910030100311003210033100341003510036100371003810039100401004110042100431004410045100461004710048100491005010051100521005310054100551005610057100581005910060100611006210063100641006510066100671006810069100701007110072100731007410075100761007710078100791008010081100821008310084100851008610087100881008910090100911009210093100941009510096100971009810099101001010110102101031010410105101061010710108101091011010111101121011310114101151011610117101181011910120101211012210123101241012510126101271012810129101301013110132101331013410135101361013710138101391014010141101421014310144101451014610147101481014910150101511015210153101541015510156101571015810159101601016110162101631016410165101661016710168101691017010171101721017310174101751017610177101781017910180101811018210183101841018510186101871018810189101901019110192101931019410195101961019710198101991020010201102021020310204102051020610207102081020910210102111021210213102141021510216102171021810219102201022110222102231022410225102261022710228102291023010231102321023310234102351023610237102381023910240102411024210243102441024510246102471024810249102501025110252102531025410255102561025710258102591026010261102621026310264102651026610267102681026910270102711027210273102741027510276102771027810279102801028110282102831028410285102861028710288102891029010291102921029310294102951029610297102981029910300103011030210303103041030510306103071030810309103101031110312103131031410315103161031710318103191032010321103221032310324103251032610327103281032910330103311033210333103341033510336103371033810339103401034110342103431034410345103461034710348103491035010351103521035310354103551035610357103581035910360103611036210363103641036510366103671036810369103701037110372103731037410375103761037710378103791038010381103821038310384103851038610387103881038910390103911039210393103941039510396103971039810399104001040110402104031040410405104061040710408104091041010411104121041310414104151041610417104181041910420104211042210423104241042510426104271042810429104301043110432104331043410435104361043710438104391044010441104421044310444104451044610447104481044910450104511045210453104541045510456104571045810459104601046110462104631046410465104661046710468104691047010471104721047310474104751047610477104781047910480104811048210483104841048510486104871048810489104901049110492104931049410495104961049710498104991050010501105021050310504105051050610507105081050910510105111051210513105141051510516105171051810519105201052110522105231052410525105261052710528105291053010531105321053310534105351053610537105381053910540105411054210543105441054510546105471054810549105501055110552105531055410555105561055710558105591056010561105621056310564105651056610567105681056910570105711057210573105741057510576105771057810579105801058110582105831058410585105861058710588105891059010591105921059310594105951059610597105981059910600106011060210603106041060510606106071060810609106101061110612106131061410615106161061710618106191062010621106221062310624106251062610627106281062910630106311063210633106341063510636106371063810639106401064110642106431064410645106461064710648106491065010651106521065310654106551065610657106581065910660106611066210663106641066510666106671066810669106701067110672106731067410675106761067710678106791068010681106821068310684106851068610687106881068910690106911069210693106941069510696106971069810699107001070110702107031070410705107061070710708107091071010711107121071310714107151071610717107181071910720107211072210723107241072510726107271072810729107301073110732107331073410735107361073710738107391074010741107421074310744107451074610747107481074910750107511075210753107541075510756107571075810759107601076110762107631076410765107661076710768107691077010771107721077310774107751077610777107781077910780107811078210783107841078510786107871078810789107901079110792107931079410795107961079710798107991080010801108021080310804108051080610807108081080910810108111081210813108141081510816108171081810819108201082110822108231082410825108261082710828108291083010831108321083310834108351083610837108381083910840108411084210843108441084510846108471084810849108501085110852108531085410855108561085710858108591086010861108621086310864108651086610867108681086910870108711087210873108741087510876108771087810879108801088110882108831088410885108861088710888108891089010891108921089310894108951089610897108981089910900109011090210903109041090510906109071090810909109101091110912109131091410915109161091710918109191092010921109221092310924109251092610927109281092910930109311093210933109341093510936109371093810939109401094110942109431094410945109461094710948109491095010951109521095310954109551095610957109581095910960109611096210963109641096510966109671096810969109701097110972109731097410975109761097710978109791098010981109821098310984109851098610987109881098910990109911099210993109941099510996109971099810999110001100111002110031100411005110061100711008110091101011011110121101311014110151101611017110181101911020110211102211023110241102511026110271102811029110301103111032110331103411035110361103711038110391104011041110421104311044110451104611047110481104911050110511105211053110541105511056110571105811059110601106111062110631106411065110661106711068110691107011071110721107311074110751107611077110781107911080110811108211083110841108511086110871108811089110901109111092110931109411095110961109711098110991110011101111021110311104111051110611107111081110911110111111111211113111141111511116111171111811119111201112111122111231112411125111261112711128111291113011131111321113311134111351113611137111381113911140111411114211143111441114511146111471114811149111501115111152111531115411155111561115711158111591116011161111621116311164111651116611167111681116911170111711117211173111741117511176111771117811179111801118111182111831118411185111861118711188111891119011191111921119311194111951119611197111981119911200112011120211203112041120511206112071120811209112101121111212112131121411215112161121711218112191122011221112221122311224112251122611227112281122911230112311123211233112341123511236112371123811239112401124111242112431124411245112461124711248112491125011251112521125311254112551125611257112581125911260112611126211263112641126511266112671126811269112701127111272112731127411275112761127711278112791128011281112821128311284112851128611287112881128911290112911129211293112941129511296112971129811299113001130111302113031130411305113061130711308113091131011311113121131311314113151131611317113181131911320113211132211323113241132511326113271132811329113301133111332113331133411335113361133711338113391134011341113421134311344113451134611347113481134911350113511135211353113541135511356113571135811359113601136111362113631136411365113661136711368113691137011371113721137311374113751137611377113781137911380113811138211383113841138511386113871138811389113901139111392113931139411395113961139711398113991140011401114021140311404114051140611407114081140911410114111141211413114141141511416114171141811419114201142111422114231142411425114261142711428114291143011431114321143311434114351143611437114381143911440114411144211443114441144511446114471144811449114501145111452114531145411455114561145711458114591146011461114621146311464114651146611467114681146911470114711147211473114741147511476114771147811479114801148111482114831148411485114861148711488114891149011491114921149311494114951149611497114981149911500115011150211503115041150511506115071150811509115101151111512115131151411515115161151711518115191152011521115221152311524115251152611527115281152911530115311153211533115341153511536115371153811539115401154111542115431154411545115461154711548115491155011551115521155311554115551155611557115581155911560115611156211563115641156511566115671156811569115701157111572115731157411575115761157711578115791158011581115821158311584115851158611587115881158911590115911159211593115941159511596115971159811599116001160111602116031160411605116061160711608116091161011611116121161311614116151161611617116181161911620116211162211623116241162511626116271162811629116301163111632116331163411635116361163711638116391164011641116421164311644116451164611647116481164911650116511165211653116541165511656116571165811659116601166111662116631166411665116661166711668116691167011671116721167311674116751167611677116781167911680116811168211683116841168511686116871168811689116901169111692116931169411695116961169711698116991170011701117021170311704117051170611707117081170911710117111171211713117141171511716117171171811719117201172111722117231172411725117261172711728117291173011731117321173311734117351173611737117381173911740117411174211743117441174511746117471174811749117501175111752117531175411755117561175711758117591176011761117621176311764117651176611767117681176911770117711177211773117741177511776117771177811779117801178111782117831178411785117861178711788117891179011791117921179311794117951179611797117981179911800118011180211803118041180511806118071180811809118101181111812118131181411815118161181711818118191182011821118221182311824118251182611827118281182911830118311183211833118341183511836118371183811839118401184111842118431184411845118461184711848118491185011851118521185311854118551185611857118581185911860118611186211863118641186511866118671186811869118701187111872118731187411875118761187711878118791188011881118821188311884118851188611887118881188911890118911189211893118941189511896118971189811899119001190111902119031190411905119061190711908119091191011911119121191311914119151191611917119181191911920119211192211923119241192511926119271192811929119301193111932119331193411935119361193711938119391194011941119421194311944119451194611947119481194911950119511195211953119541195511956119571195811959119601196111962119631196411965119661196711968119691197011971119721197311974119751197611977119781197911980119811198211983119841198511986119871198811989119901199111992119931199411995119961199711998119991200012001120021200312004120051200612007120081200912010120111201212013120141201512016120171201812019120201202112022120231202412025120261202712028120291203012031120321203312034120351203612037120381203912040120411204212043120441204512046120471204812049120501205112052120531205412055120561205712058120591206012061120621206312064120651206612067120681206912070120711207212073120741207512076120771207812079120801208112082120831208412085120861208712088120891209012091120921209312094120951209612097120981209912100121011210212103121041210512106121071210812109121101211112112121131211412115121161211712118121191212012121121221212312124121251212612127121281212912130121311213212133121341213512136121371213812139121401214112142121431214412145121461214712148121491215012151121521215312154121551215612157121581215912160121611216212163121641216512166121671216812169121701217112172121731217412175121761217712178121791218012181121821218312184121851218612187121881218912190121911219212193121941219512196121971219812199122001220112202122031220412205122061220712208122091221012211122121221312214122151221612217122181221912220122211222212223122241222512226122271222812229122301223112232122331223412235122361223712238122391224012241122421224312244122451224612247122481224912250122511225212253122541225512256122571225812259122601226112262122631226412265122661226712268122691227012271122721227312274122751227612277122781227912280122811228212283122841228512286122871228812289122901229112292122931229412295122961229712298122991230012301123021230312304123051230612307123081230912310123111231212313123141231512316123171231812319123201232112322123231232412325123261232712328123291233012331123321233312334123351233612337123381233912340123411234212343123441234512346123471234812349123501235112352123531235412355123561235712358123591236012361123621236312364123651236612367123681236912370123711237212373123741237512376123771237812379123801238112382123831238412385123861238712388123891239012391123921239312394123951239612397123981239912400124011240212403124041240512406124071240812409124101241112412124131241412415124161241712418124191242012421124221242312424124251242612427124281242912430124311243212433124341243512436124371243812439124401244112442124431244412445124461244712448124491245012451124521245312454124551245612457124581245912460124611246212463124641246512466124671246812469124701247112472124731247412475124761247712478124791248012481124821248312484124851248612487124881248912490124911249212493124941249512496124971249812499125001250112502125031250412505125061250712508125091251012511125121251312514125151251612517125181251912520125211252212523125241252512526125271252812529125301253112532125331253412535125361253712538125391254012541125421254312544125451254612547125481254912550125511255212553125541255512556125571255812559125601256112562125631256412565125661256712568125691257012571125721257312574125751257612577125781257912580125811258212583125841258512586125871258812589125901259112592125931259412595125961259712598125991260012601126021260312604126051260612607126081260912610126111261212613126141261512616126171261812619126201262112622126231262412625126261262712628126291263012631126321263312634126351263612637126381263912640126411264212643126441264512646126471264812649126501265112652126531265412655126561265712658126591266012661126621266312664126651266612667126681266912670126711267212673126741267512676126771267812679126801268112682126831268412685126861268712688126891269012691126921269312694126951269612697126981269912700127011270212703127041270512706127071270812709127101271112712127131271412715127161271712718127191272012721127221272312724127251272612727127281272912730127311273212733127341273512736127371273812739127401274112742127431274412745127461274712748127491275012751127521275312754127551275612757127581275912760127611276212763127641276512766127671276812769127701277112772127731277412775127761277712778127791278012781127821278312784127851278612787127881278912790127911279212793127941279512796127971279812799128001280112802128031280412805128061280712808128091281012811128121281312814128151281612817128181281912820128211282212823128241282512826128271282812829128301283112832128331283412835128361283712838128391284012841128421284312844128451284612847128481284912850128511285212853128541285512856128571285812859128601286112862128631286412865128661286712868128691287012871128721287312874128751287612877128781287912880128811288212883128841288512886128871288812889128901289112892128931289412895128961289712898128991290012901129021290312904129051290612907129081290912910129111291212913129141291512916129171291812919129201292112922129231292412925129261292712928129291293012931129321293312934129351293612937129381293912940129411294212943129441294512946129471294812949129501295112952129531295412955129561295712958129591296012961129621296312964129651296612967129681296912970129711297212973129741297512976129771297812979129801298112982129831298412985129861298712988129891299012991129921299312994129951299612997129981299913000130011300213003130041300513006130071300813009130101301113012130131301413015130161301713018130191302013021130221302313024130251302613027130281302913030130311303213033130341303513036130371303813039130401304113042130431304413045130461304713048130491305013051130521305313054130551305613057130581305913060130611306213063130641306513066130671306813069130701307113072130731307413075130761307713078130791308013081130821308313084130851308613087130881308913090130911309213093130941309513096130971309813099131001310113102131031310413105131061310713108131091311013111131121311313114131151311613117131181311913120131211312213123131241312513126131271312813129131301313113132131331313413135131361313713138131391314013141131421314313144131451314613147131481314913150131511315213153131541315513156131571315813159131601316113162131631316413165131661316713168131691317013171131721317313174131751317613177131781317913180131811318213183131841318513186131871318813189131901319113192131931319413195131961319713198131991320013201132021320313204132051320613207132081320913210132111321213213132141321513216132171321813219132201322113222132231322413225132261322713228132291323013231132321323313234132351323613237132381323913240132411324213243132441324513246132471324813249132501325113252132531325413255132561325713258132591326013261132621326313264132651326613267132681326913270132711327213273132741327513276132771327813279132801328113282132831328413285132861328713288132891329013291132921329313294132951329613297132981329913300133011330213303133041330513306133071330813309133101331113312133131331413315133161331713318133191332013321133221332313324133251332613327133281332913330133311333213333133341333513336133371333813339133401334113342133431334413345133461334713348133491335013351133521335313354133551335613357133581335913360133611336213363133641336513366133671336813369133701337113372133731337413375133761337713378133791338013381133821338313384133851338613387133881338913390133911339213393133941339513396133971339813399134001340113402134031340413405134061340713408134091341013411134121341313414134151341613417134181341913420134211342213423134241342513426134271342813429134301343113432134331343413435134361343713438134391344013441134421344313444134451344613447134481344913450134511345213453134541345513456134571345813459134601346113462134631346413465134661346713468134691347013471134721347313474134751347613477134781347913480134811348213483134841348513486134871348813489134901349113492134931349413495134961349713498134991350013501135021350313504135051350613507135081350913510135111351213513135141351513516135171351813519135201352113522135231352413525135261352713528135291353013531135321353313534135351353613537135381353913540135411354213543135441354513546135471354813549135501355113552135531355413555135561355713558135591356013561135621356313564135651356613567135681356913570135711357213573135741357513576135771357813579135801358113582135831358413585135861358713588135891359013591135921359313594135951359613597135981359913600136011360213603136041360513606136071360813609136101361113612136131361413615136161361713618136191362013621136221362313624136251362613627136281362913630136311363213633136341363513636136371363813639136401364113642136431364413645136461364713648136491365013651136521365313654136551365613657136581365913660136611366213663136641366513666136671366813669136701367113672136731367413675136761367713678136791368013681136821368313684136851368613687136881368913690136911369213693136941369513696136971369813699137001370113702137031370413705137061370713708137091371013711137121371313714137151371613717137181371913720137211372213723137241372513726137271372813729137301373113732137331373413735137361373713738137391374013741137421374313744137451374613747137481374913750137511375213753137541375513756137571375813759137601376113762137631376413765137661376713768137691377013771137721377313774137751377613777137781377913780137811378213783137841378513786137871378813789137901379113792137931379413795137961379713798137991380013801138021380313804138051380613807138081380913810138111381213813138141381513816138171381813819138201382113822138231382413825138261382713828138291383013831138321383313834138351383613837138381383913840138411384213843138441384513846138471384813849138501385113852138531385413855138561385713858138591386013861138621386313864138651386613867138681386913870138711387213873138741387513876138771387813879138801388113882138831388413885138861388713888138891389013891138921389313894138951389613897138981389913900139011390213903139041390513906139071390813909139101391113912139131391413915139161391713918139191392013921139221392313924139251392613927139281392913930139311393213933139341393513936139371393813939139401394113942139431394413945139461394713948139491395013951139521395313954139551395613957139581395913960139611396213963139641396513966139671396813969139701397113972139731397413975139761397713978139791398013981139821398313984139851398613987139881398913990139911399213993139941399513996139971399813999140001400114002140031400414005140061400714008140091401014011140121401314014140151401614017140181401914020140211402214023140241402514026140271402814029140301403114032140331403414035140361403714038140391404014041140421404314044140451404614047140481404914050140511405214053140541405514056140571405814059140601406114062140631406414065140661406714068140691407014071140721407314074140751407614077140781407914080140811408214083140841408514086140871408814089140901409114092140931409414095140961409714098140991410014101141021410314104141051410614107141081410914110141111411214113141141411514116141171411814119141201412114122141231412414125141261412714128141291413014131141321413314134141351413614137141381413914140141411414214143141441414514146141471414814149141501415114152141531415414155141561415714158141591416014161141621416314164141651416614167141681416914170141711417214173141741417514176141771417814179141801418114182141831418414185141861418714188141891419014191141921419314194141951419614197141981419914200142011420214203142041420514206142071420814209142101421114212142131421414215142161421714218142191422014221142221422314224142251422614227142281422914230142311423214233142341423514236142371423814239142401424114242142431424414245142461424714248142491425014251142521425314254142551425614257142581425914260142611426214263142641426514266142671426814269142701427114272142731427414275142761427714278142791428014281142821428314284142851428614287142881428914290142911429214293142941429514296142971429814299143001430114302143031430414305143061430714308143091431014311143121431314314143151431614317143181431914320143211432214323143241432514326143271432814329143301433114332143331433414335143361433714338143391434014341143421434314344143451434614347143481434914350143511435214353143541435514356143571435814359143601436114362143631436414365143661436714368143691437014371143721437314374143751437614377143781437914380143811438214383143841438514386143871438814389143901439114392143931439414395143961439714398143991440014401144021440314404144051440614407144081440914410144111441214413144141441514416144171441814419144201442114422144231442414425144261442714428144291443014431144321443314434144351443614437144381443914440144411444214443144441444514446144471444814449144501445114452144531445414455144561445714458144591446014461144621446314464144651446614467144681446914470144711447214473144741447514476144771447814479144801448114482144831448414485144861448714488144891449014491144921449314494144951449614497144981449914500145011450214503145041450514506145071450814509145101451114512145131451414515145161451714518145191452014521145221452314524145251452614527145281452914530145311453214533145341453514536145371453814539145401454114542145431454414545145461454714548145491455014551145521455314554145551455614557145581455914560145611456214563145641456514566145671456814569145701457114572145731457414575145761457714578145791458014581145821458314584145851458614587145881458914590145911459214593145941459514596145971459814599146001460114602146031460414605146061460714608146091461014611146121461314614146151461614617146181461914620146211462214623146241462514626146271462814629146301463114632146331463414635146361463714638146391464014641146421464314644146451464614647146481464914650146511465214653146541465514656146571465814659146601466114662146631466414665146661466714668146691467014671146721467314674146751467614677146781467914680146811468214683146841468514686146871468814689146901469114692146931469414695146961469714698146991470014701147021470314704147051470614707147081470914710147111471214713147141471514716147171471814719147201472114722147231472414725147261472714728147291473014731147321473314734147351473614737147381473914740147411474214743147441474514746147471474814749147501475114752147531475414755147561475714758147591476014761147621476314764147651476614767147681476914770147711477214773147741477514776147771477814779147801478114782147831478414785147861478714788147891479014791147921479314794147951479614797147981479914800148011480214803148041480514806148071480814809148101481114812148131481414815148161481714818148191482014821148221482314824148251482614827148281482914830148311483214833148341483514836148371483814839148401484114842148431484414845148461484714848148491485014851148521485314854148551485614857148581485914860148611486214863148641486514866148671486814869148701487114872148731487414875148761487714878148791488014881148821488314884148851488614887148881488914890148911489214893148941489514896148971489814899149001490114902149031490414905149061490714908149091491014911149121491314914149151491614917149181491914920149211492214923149241492514926149271492814929149301493114932149331493414935149361493714938149391494014941149421494314944149451494614947149481494914950149511495214953149541495514956149571495814959149601496114962149631496414965149661496714968149691497014971149721497314974149751497614977149781497914980149811498214983149841498514986149871498814989149901499114992149931499414995149961499714998149991500015001150021500315004150051500615007150081500915010150111501215013150141501515016150171501815019150201502115022150231502415025150261502715028150291503015031150321503315034150351503615037150381503915040150411504215043150441504515046150471504815049150501505115052150531505415055150561505715058150591506015061150621506315064150651506615067150681506915070150711507215073150741507515076150771507815079150801508115082150831508415085150861508715088150891509015091150921509315094150951509615097150981509915100151011510215103151041510515106151071510815109151101511115112151131511415115151161511715118151191512015121151221512315124151251512615127151281512915130151311513215133151341513515136151371513815139151401514115142151431514415145151461514715148151491515015151151521515315154151551515615157151581515915160151611516215163151641516515166151671516815169151701517115172151731517415175151761517715178151791518015181151821518315184151851518615187151881518915190151911519215193151941519515196151971519815199152001520115202152031520415205152061520715208152091521015211152121521315214152151521615217152181521915220152211522215223152241522515226152271522815229152301523115232152331523415235152361523715238152391524015241152421524315244152451524615247152481524915250152511525215253152541525515256152571525815259152601526115262152631526415265152661526715268152691527015271152721527315274152751527615277152781527915280152811528215283152841528515286152871528815289152901529115292152931529415295152961529715298152991530015301153021530315304153051530615307153081530915310153111531215313153141531515316153171531815319153201532115322153231532415325153261532715328153291533015331153321533315334153351533615337153381533915340153411534215343153441534515346153471534815349153501535115352153531535415355153561535715358153591536015361153621536315364153651536615367153681536915370153711537215373153741537515376153771537815379153801538115382153831538415385153861538715388153891539015391153921539315394153951539615397153981539915400154011540215403154041540515406154071540815409154101541115412154131541415415154161541715418154191542015421154221542315424154251542615427154281542915430154311543215433154341543515436154371543815439154401544115442154431544415445154461544715448154491545015451154521545315454154551545615457154581545915460154611546215463154641546515466154671546815469154701547115472154731547415475154761547715478154791548015481154821548315484154851548615487154881548915490154911549215493154941549515496154971549815499155001550115502155031550415505155061550715508155091551015511155121551315514155151551615517155181551915520155211552215523155241552515526155271552815529155301553115532155331553415535155361553715538155391554015541155421554315544155451554615547155481554915550155511555215553155541555515556155571555815559155601556115562155631556415565155661556715568155691557015571155721557315574155751557615577155781557915580155811558215583155841558515586155871558815589155901559115592155931559415595155961559715598155991560015601156021560315604156051560615607156081560915610156111561215613156141561515616156171561815619156201562115622156231562415625156261562715628156291563015631156321563315634156351563615637156381563915640156411564215643156441564515646156471564815649156501565115652156531565415655156561565715658156591566015661156621566315664156651566615667156681566915670156711567215673156741567515676156771567815679156801568115682156831568415685156861568715688156891569015691156921569315694156951569615697156981569915700157011570215703157041570515706157071570815709157101571115712157131571415715157161571715718157191572015721157221572315724157251572615727157281572915730157311573215733157341573515736157371573815739157401574115742157431574415745157461574715748157491575015751157521575315754157551575615757157581575915760157611576215763157641576515766157671576815769157701577115772157731577415775157761577715778157791578015781157821578315784157851578615787157881578915790157911579215793157941579515796157971579815799158001580115802158031580415805158061580715808158091581015811158121581315814158151581615817158181581915820158211582215823158241582515826158271582815829158301583115832158331583415835158361583715838158391584015841158421584315844158451584615847158481584915850158511585215853158541585515856158571585815859158601586115862158631586415865158661586715868158691587015871158721587315874158751587615877158781587915880158811588215883158841588515886158871588815889158901589115892158931589415895158961589715898158991590015901159021590315904159051590615907159081590915910159111591215913159141591515916159171591815919159201592115922159231592415925159261592715928159291593015931159321593315934159351593615937159381593915940159411594215943159441594515946159471594815949159501595115952159531595415955159561595715958159591596015961159621596315964159651596615967159681596915970159711597215973159741597515976159771597815979159801598115982159831598415985159861598715988159891599015991159921599315994159951599615997159981599916000160011600216003160041600516006160071600816009160101601116012160131601416015160161601716018160191602016021160221602316024160251602616027160281602916030160311603216033160341603516036160371603816039160401604116042160431604416045160461604716048160491605016051160521605316054160551605616057160581605916060160611606216063160641606516066160671606816069160701607116072160731607416075160761607716078160791608016081160821608316084160851608616087160881608916090160911609216093160941609516096160971609816099161001610116102161031610416105161061610716108161091611016111161121611316114161151611616117161181611916120161211612216123161241612516126161271612816129161301613116132161331613416135161361613716138161391614016141161421614316144161451614616147161481614916150161511615216153161541615516156161571615816159161601616116162161631616416165161661616716168161691617016171161721617316174161751617616177161781617916180161811618216183161841618516186161871618816189161901619116192161931619416195161961619716198161991620016201162021620316204162051620616207162081620916210162111621216213162141621516216162171621816219162201622116222162231622416225162261622716228162291623016231162321623316234162351623616237162381623916240162411624216243162441624516246162471624816249162501625116252162531625416255162561625716258162591626016261162621626316264162651626616267162681626916270162711627216273162741627516276162771627816279162801628116282162831628416285162861628716288162891629016291162921629316294162951629616297162981629916300163011630216303163041630516306163071630816309163101631116312163131631416315163161631716318163191632016321163221632316324163251632616327163281632916330163311633216333163341633516336163371633816339163401634116342163431634416345163461634716348163491635016351163521635316354163551635616357163581635916360163611636216363163641636516366163671636816369163701637116372163731637416375163761637716378163791638016381163821638316384163851638616387163881638916390163911639216393163941639516396163971639816399164001640116402164031640416405164061640716408164091641016411164121641316414164151641616417164181641916420164211642216423164241642516426164271642816429164301643116432164331643416435164361643716438164391644016441164421644316444164451644616447164481644916450164511645216453164541645516456164571645816459164601646116462164631646416465164661646716468164691647016471164721647316474164751647616477164781647916480164811648216483164841648516486164871648816489164901649116492164931649416495164961649716498164991650016501165021650316504165051650616507165081650916510165111651216513165141651516516165171651816519165201652116522165231652416525165261652716528165291653016531165321653316534165351653616537165381653916540165411654216543165441654516546165471654816549165501655116552165531655416555165561655716558165591656016561165621656316564165651656616567165681656916570165711657216573165741657516576165771657816579165801658116582165831658416585165861658716588165891659016591165921659316594165951659616597165981659916600166011660216603166041660516606166071660816609166101661116612166131661416615166161661716618166191662016621166221662316624166251662616627166281662916630166311663216633166341663516636166371663816639166401664116642166431664416645166461664716648166491665016651166521665316654166551665616657166581665916660166611666216663166641666516666166671666816669166701667116672166731667416675166761667716678166791668016681166821668316684166851668616687166881668916690166911669216693166941669516696166971669816699167001670116702167031670416705167061670716708167091671016711167121671316714167151671616717167181671916720167211672216723167241672516726167271672816729167301673116732167331673416735167361673716738167391674016741167421674316744167451674616747167481674916750167511675216753167541675516756167571675816759167601676116762167631676416765167661676716768167691677016771167721677316774167751677616777167781677916780167811678216783167841678516786167871678816789167901679116792167931679416795167961679716798167991680016801168021680316804168051680616807168081680916810168111681216813168141681516816168171681816819168201682116822168231682416825168261682716828168291683016831168321683316834168351683616837168381683916840168411684216843168441684516846168471684816849168501685116852168531685416855168561685716858168591686016861168621686316864168651686616867168681686916870168711687216873168741687516876168771687816879168801688116882168831688416885168861688716888168891689016891168921689316894168951689616897168981689916900169011690216903169041690516906169071690816909169101691116912169131691416915169161691716918169191692016921169221692316924169251692616927169281692916930169311693216933169341693516936169371693816939169401694116942169431694416945169461694716948169491695016951169521695316954169551695616957169581695916960169611696216963169641696516966169671696816969169701697116972169731697416975169761697716978169791698016981169821698316984169851698616987169881698916990169911699216993169941699516996169971699816999170001700117002170031700417005170061700717008170091701017011170121701317014170151701617017170181701917020170211702217023170241702517026170271702817029170301703117032170331703417035170361703717038170391704017041170421704317044170451704617047170481704917050170511705217053170541705517056170571705817059170601706117062170631706417065170661706717068170691707017071170721707317074170751707617077170781707917080170811708217083170841708517086170871708817089170901709117092170931709417095170961709717098170991710017101171021710317104171051710617107171081710917110171111711217113171141711517116171171711817119171201712117122171231712417125171261712717128171291713017131171321713317134171351713617137171381713917140171411714217143171441714517146171471714817149171501715117152171531715417155171561715717158171591716017161171621716317164171651716617167171681716917170171711717217173171741717517176171771717817179171801718117182171831718417185171861718717188171891719017191171921719317194171951719617197171981719917200172011720217203172041720517206172071720817209172101721117212172131721417215172161721717218172191722017221172221722317224172251722617227172281722917230172311723217233172341723517236172371723817239172401724117242172431724417245172461724717248172491725017251172521725317254172551725617257172581725917260172611726217263172641726517266172671726817269172701727117272172731727417275172761727717278172791728017281172821728317284172851728617287172881728917290172911729217293172941729517296172971729817299173001730117302173031730417305173061730717308173091731017311173121731317314173151731617317173181731917320173211732217323173241732517326173271732817329173301733117332173331733417335173361733717338173391734017341173421734317344173451734617347173481734917350173511735217353173541735517356173571735817359173601736117362173631736417365173661736717368173691737017371173721737317374173751737617377173781737917380173811738217383173841738517386173871738817389173901739117392173931739417395173961739717398173991740017401174021740317404174051740617407174081740917410174111741217413174141741517416174171741817419174201742117422174231742417425174261742717428174291743017431174321743317434174351743617437174381743917440174411744217443174441744517446174471744817449174501745117452174531745417455174561745717458174591746017461174621746317464174651746617467174681746917470174711747217473174741747517476174771747817479174801748117482174831748417485174861748717488174891749017491174921749317494174951749617497174981749917500175011750217503175041750517506175071750817509175101751117512175131751417515175161751717518175191752017521175221752317524175251752617527175281752917530175311753217533175341753517536175371753817539175401754117542175431754417545175461754717548175491755017551175521755317554175551755617557175581755917560175611756217563175641756517566175671756817569175701757117572175731757417575175761757717578175791758017581175821758317584175851758617587175881758917590175911759217593175941759517596175971759817599176001760117602176031760417605176061760717608176091761017611176121761317614176151761617617176181761917620176211762217623176241762517626176271762817629176301763117632176331763417635176361763717638176391764017641176421764317644176451764617647176481764917650176511765217653176541765517656176571765817659176601766117662176631766417665176661766717668176691767017671176721767317674176751767617677176781767917680176811768217683176841768517686176871768817689176901769117692176931769417695176961769717698176991770017701177021770317704177051770617707177081770917710177111771217713177141771517716177171771817719177201772117722177231772417725177261772717728177291773017731177321773317734177351773617737177381773917740177411774217743177441774517746177471774817749177501775117752177531775417755177561775717758177591776017761177621776317764177651776617767177681776917770177711777217773177741777517776177771777817779177801778117782177831778417785177861778717788177891779017791177921779317794177951779617797177981779917800178011780217803178041780517806178071780817809178101781117812178131781417815178161781717818178191782017821178221782317824178251782617827178281782917830178311783217833178341783517836178371783817839178401784117842178431784417845178461784717848178491785017851178521785317854178551785617857178581785917860178611786217863178641786517866178671786817869178701787117872178731787417875178761787717878178791788017881178821788317884178851788617887178881788917890178911789217893178941789517896178971789817899179001790117902179031790417905179061790717908179091791017911179121791317914179151791617917179181791917920179211792217923179241792517926179271792817929179301793117932179331793417935179361793717938179391794017941179421794317944179451794617947179481794917950179511795217953179541795517956179571795817959179601796117962179631796417965179661796717968179691797017971179721797317974179751797617977179781797917980179811798217983179841798517986179871798817989179901799117992179931799417995179961799717998179991800018001180021800318004180051800618007180081800918010180111801218013180141801518016180171801818019180201802118022180231802418025180261802718028180291803018031180321803318034180351803618037180381803918040180411804218043180441804518046180471804818049180501805118052180531805418055180561805718058180591806018061180621806318064180651806618067180681806918070180711807218073180741807518076180771807818079180801808118082180831808418085180861808718088180891809018091180921809318094180951809618097180981809918100181011810218103181041810518106181071810818109181101811118112181131811418115181161811718118181191812018121181221812318124181251812618127181281812918130181311813218133181341813518136181371813818139181401814118142181431814418145181461814718148181491815018151181521815318154181551815618157181581815918160181611816218163181641816518166181671816818169181701817118172181731817418175181761817718178181791818018181181821818318184181851818618187181881818918190181911819218193181941819518196181971819818199182001820118202182031820418205182061820718208182091821018211182121821318214182151821618217182181821918220182211822218223182241822518226182271822818229182301823118232182331823418235182361823718238182391824018241182421824318244182451824618247182481824918250182511825218253182541825518256182571825818259182601826118262182631826418265182661826718268182691827018271182721827318274182751827618277182781827918280182811828218283182841828518286182871828818289182901829118292182931829418295182961829718298182991830018301183021830318304183051830618307183081830918310183111831218313183141831518316183171831818319183201832118322183231832418325183261832718328183291833018331183321833318334183351833618337183381833918340183411834218343183441834518346183471834818349183501835118352183531835418355183561835718358183591836018361183621836318364183651836618367183681836918370183711837218373183741837518376183771837818379183801838118382183831838418385183861838718388183891839018391183921839318394183951839618397183981839918400184011840218403184041840518406184071840818409184101841118412184131841418415184161841718418184191842018421184221842318424184251842618427184281842918430184311843218433184341843518436184371843818439184401844118442184431844418445184461844718448184491845018451184521845318454184551845618457184581845918460184611846218463184641846518466184671846818469184701847118472184731847418475184761847718478184791848018481184821848318484184851848618487184881848918490184911849218493184941849518496184971849818499185001850118502185031850418505185061850718508185091851018511185121851318514185151851618517185181851918520185211852218523185241852518526185271852818529185301853118532185331853418535185361853718538185391854018541185421854318544185451854618547185481854918550185511855218553185541855518556185571855818559185601856118562185631856418565185661856718568185691857018571185721857318574185751857618577185781857918580185811858218583185841858518586185871858818589185901859118592185931859418595185961859718598185991860018601186021860318604186051860618607186081860918610186111861218613186141861518616186171861818619186201862118622186231862418625186261862718628186291863018631186321863318634186351863618637186381863918640186411864218643186441864518646186471864818649186501865118652186531865418655186561865718658186591866018661186621866318664186651866618667186681866918670186711867218673186741867518676186771867818679186801868118682186831868418685186861868718688186891869018691186921869318694186951869618697186981869918700187011870218703187041870518706187071870818709187101871118712187131871418715187161871718718187191872018721187221872318724187251872618727187281872918730187311873218733187341873518736187371873818739187401874118742187431874418745187461874718748187491875018751187521875318754187551875618757187581875918760187611876218763187641876518766187671876818769187701877118772187731877418775187761877718778187791878018781187821878318784187851878618787187881878918790187911879218793187941879518796187971879818799188001880118802188031880418805188061880718808
  1. package sg
  2. import (
  3. "archive/zip"
  4. "bytes"
  5. "encoding/json"
  6. "fmt"
  7. "gdyb/controllers"
  8. "gdyb/enums"
  9. "gdyb/models"
  10. "gdyb/service"
  11. "gdyb/utils"
  12. "github.com/astaxie/beego"
  13. "github.com/axgle/mahonia"
  14. "github.com/gorilla/websocket"
  15. "github.com/jinzhu/gorm"
  16. "github.com/shopspring/decimal"
  17. "io"
  18. "io/ioutil"
  19. "math"
  20. "math/rand"
  21. "net/http"
  22. "net/url"
  23. "os"
  24. "path/filepath"
  25. "regexp"
  26. "strconv"
  27. "strings"
  28. "syscall"
  29. "time"
  30. "unsafe"
  31. )
  32. type HisApiController struct {
  33. controllers.BaseAuthAPIController
  34. }
  35. func HisManagerApiRegistRouters() {
  36. //挂号
  37. beego.Router("/api/register/get", &HisApiController{}, "get:GetRegisterInfo")
  38. //上传就诊信息-上传明细-结算
  39. beego.Router("/api/upload/get", &HisApiController{}, "get:GetUploadInfo")
  40. //查询
  41. beego.Router("/api/settle/query", &HisApiController{}, "get:GetSettleAccounts")
  42. //对总账
  43. beego.Router("/api/checkaccount/get", &HisApiController{}, "get:GetCheckAccount")
  44. //对明细
  45. beego.Router("/api/checkdetailaccount/get", &HisApiController{}, "get:GetCheckDetailAccount")
  46. //退费,退明细
  47. beego.Router("/api/refund/post", &HisApiController{}, "get:Refund")
  48. //退号
  49. beego.Router("/api/refundnumber/post", &HisApiController{}, "get:RefundNumber")
  50. //退明细
  51. beego.Router("/api/refunddetail/post", &HisApiController{}, "get:RefundDetail")
  52. //上传就诊信息-上传明细-预结算
  53. beego.Router("/api/presettle/get", &HisApiController{}, "get:GetPreUploadInfo")
  54. beego.Router("/api/treatment/check", &HisApiController{}, "get:CheckTreatment")
  55. beego.Router("/api/org/info", &HisApiController{}, "get:GetOrgInfo")
  56. beego.Router("/api/readcard", &HisApiController{}, "get:ReadCard")
  57. beego.Router("/api/310", &HisApiController{}, "get:Check310")
  58. beego.Router("/api/390", &HisApiController{}, "get:Check390")
  59. beego.Router("/api/patient/info", &HisApiController{}, "get:GetPatientInfo")
  60. beego.Router("/api/checkcode/get", &HisApiController{}, "get:GetCheckCode")
  61. beego.Router("/api/uncheckcode/get", &HisApiController{}, "get:UnCheckCode")
  62. beego.Router("/api/psn/putonrecord", &HisApiController{}, "get:PsnPutOnRecord")
  63. beego.Router("/api/psn/unputonrecord", &HisApiController{}, "get:PsnUnPutOnRecord")
  64. beego.Router("/api/psn/ncds/putonrecord", &HisApiController{}, "get:PsnPutNCDSOnRecord")
  65. beego.Router("/api/psn/ncds/unputonrecord", &HisApiController{}, "get:PsnPutUnNCDSOnRecord")
  66. beego.Router("/api/reversal", &HisApiController{}, "get:ReversalData")
  67. beego.Router("/api/reversal/other", &HisApiController{}, "get:ReversalOtherData")
  68. beego.Router("/api/settlelist/get", &HisApiController{}, "get:GetSettleList")
  69. beego.Router("/api/settlelisthosptial/get", &HisApiController{}, "get:GetSettleListHospital")
  70. beego.Router("/api/pwd/check", &HisApiController{}, "get:CheckCardPWD")
  71. beego.Router("/api/insutype/check", &HisApiController{}, "get:CheckInsutype")
  72. //beego.Router("/api/batchsettlelist/get", &HisApiController{}, "get:GetBatchSettleList")
  73. beego.Router("/api/psn/info", &HisApiController{}, "get:GetPsnNcdsInfo")
  74. beego.Router("/api/allopatry/refund", &HisApiController{}, "post:RefundAllopatry")
  75. beego.Router("/api/check", &HisApiController{}, "get:Check")
  76. //beego.Router("/api/check3101", &HisApiController{}, "get:Check3101")
  77. //beego.Router("/api/check3102", &HisApiController{}, "get:Check3102")
  78. beego.Router("/90990", &HisApiController{}, "get:CheckCardPWDTwo")
  79. beego.Router("/9001", &HisApiController{}, "get:Get9001")
  80. //beego.Router("/api/readelecard", &HisApiController{}, "get:ReadEleCard")
  81. beego.Router("/api/3202", &HisApiController{}, "get:Post3202")
  82. beego.Router("/api/3501", &HisApiController{}, "post:Post3501")
  83. beego.Router("/api/readele", &HisApiController{}, "get:ReadEleToken")
  84. beego.Router("/api/2505", &HisApiController{}, "get:Get2505")
  85. beego.Router("/api/4201A", &HisApiController{}, "get:Get4201A")
  86. beego.Router("/api/4202", &HisApiController{}, "get:Get4202")
  87. beego.Router("/api/4203", &HisApiController{}, "get:Get4203")
  88. beego.Router("/api/4205", &HisApiController{}, "get:Get4205")
  89. beego.Router("/api/4207", &HisApiController{}, "get:Get4207")
  90. beego.Router("/api/4208", &HisApiController{}, "get:Get4208")
  91. beego.Router("/api/4209", &HisApiController{}, "get:Get4209")
  92. beego.Router("/api/allopatry/get", &HisApiController{}, "get:GetAllopatry")
  93. beego.Router("/api/comfirmallopatry/post", &HisApiController{}, "post:ComfirmAllopatry")
  94. beego.Router("/api/allopatry/refund", &HisApiController{}, "get:RefundAllopatry")
  95. beego.Router("/api/settle/query/batch", &HisApiController{}, "get:GetBatchSettleAccounts")
  96. beego.Router("/api/bl4201A", &HisApiController{}, "get:GetBL4201A")
  97. beego.Router("/api/bl4201A", &HisApiController{}, "get:GetBL4201A")
  98. beego.Router("/api/CFYLJG001", &HisApiController{}, "get:GetCFYLJG001")
  99. beego.Router("/api/CFYLJG002", &HisApiController{}, "get:GetCFYLJG002")
  100. beego.Router("/api/CFYLJG003", &HisApiController{}, "get:GetCFYLJG003")
  101. beego.Router("/api/CFYLJG004", &HisApiController{}, "get:GetCFYLJG004")
  102. beego.Router("/api/CFYLJG005", &HisApiController{}, "get:GetCFYLJG005")
  103. beego.Router("/api/CFYLJG006", &HisApiController{}, "get:GetCFYLJG006")
  104. beego.Router("/api/CFYLJG007", &HisApiController{}, "get:GetCFYLJG007")
  105. //beego.Router("/api/CFYLJG008", &HisApiController{}, "get:GetCFYLJG008")
  106. //beego.Router("/api/CFYLJG009", &HisApiController{}, "get:GetCFYLJG009")
  107. //beego.Router("/api/2205", &HisApiController{}, "get:Get2205")
  108. }
  109. func (c *HisApiController) GetCFYLJG001() {
  110. admin_user_id, _ := c.GetInt64("admin_user_id")
  111. patient_id, _ := c.GetInt64("patient_id")
  112. his_patient_id, _ := c.GetInt64("his_patient_id")
  113. record_time := c.GetString("record_time")
  114. his, _ := service.GetHisPatientRecord(c.GetAdminUserInfo().CurrentOrgId, his_patient_id)
  115. psn, _ := service.GetPsnByPatientId(patient_id)
  116. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  117. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  118. var cFYLJG001 models.CFYLJG001
  119. timeLayout := "2006-01-02"
  120. loc, _ := time.LoadLocation("Local")
  121. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  122. if err != nil {
  123. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  124. return
  125. }
  126. recordDateTime := theTime.Unix()
  127. prescriptions, _ := service.GetHisPrescriptionForMedType(c.GetAdminUserInfo().CurrentOrgId, patient_id, recordDateTime)
  128. for _, item := range prescriptions {
  129. doctor, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, item.Creator)
  130. if his.IdCardType == 1 {
  131. bas := strings.Split(psn.CardInfo, "|")
  132. basNumber := bas[1]
  133. fmt.Println(basNumber)
  134. card_sn := bas[3]
  135. card_no := bas[2]
  136. cFYLJG001.MdtrtCertType = "03"
  137. cFYLJG001.CardSn = card_sn
  138. cFYLJG001.MdtrtCertNo = card_no
  139. cFYLJG001.EcToken = ""
  140. cFYLJG001.AuthNo = ""
  141. } else if his.IdCardType == 2 {
  142. cFYLJG001.MdtrtCertType = "02"
  143. cFYLJG001.CardSn = ""
  144. cFYLJG001.MdtrtCertNo = his.IdCardNo
  145. cFYLJG001.EcToken = ""
  146. cFYLJG001.AuthNo = ""
  147. } else if his.IdCardType == 4 {
  148. cFYLJG001.MdtrtCertType = "01"
  149. cFYLJG001.CardSn = ""
  150. cFYLJG001.MdtrtCertNo = psn.VerifyNumber
  151. cFYLJG001.EcToken = psn.VerifyNumber
  152. cFYLJG001.AuthNo = ""
  153. }
  154. cFYLJG001.BizTypeCode = "01"
  155. cFYLJG001.InsuAdmdvs = psn.InsuplcAdmdvs
  156. cFYLJG001.HospRxno = strconv.FormatInt(item.ID, 10)
  157. cFYLJG001.RxTypeCode = "1"
  158. tempTime := time.Unix(item.PreTime, 0)
  159. timeFormatOne := tempTime.Format("2006-01-02 15:04:05")
  160. cFYLJG001.PrscTime = timeFormatOne
  161. var count float64
  162. if item.Type == 1 {
  163. for _, sumItem := range item.HisDoctorAdviceInfo {
  164. count = count + sumItem.PrescribingNumber
  165. }
  166. }
  167. cFYLJG001.RxDrugCnt = count
  168. cFYLJG001.ValiDays = "5"
  169. cFYLJG001.RxCotnFlag = "0"
  170. for _, subItem := range item.HisDoctorAdviceInfo {
  171. var drug models.RxDrug
  172. drug.MedListCodg = subItem.BaseDrugLib.MedicalInsuranceNumber
  173. drug.MedinsListCodg = subItem.BaseDrugLib.MedicalInsuranceNumber
  174. drug.RxItemTypeCode = "11"
  175. drug.DrugDosform = "" //TODO
  176. if subItem.BaseDrugLib.MinUnit != subItem.BaseDrugLib.DoseUnit {
  177. drug.DrugSpec = subItem.BaseDrugLib.Dose + subItem.BaseDrugLib.DoseUnit + "*" + strconv.FormatInt(subItem.BaseDrugLib.MinNumber, 10) + subItem.BaseDrugLib.MinUnit + "/" + subItem.BaseDrugLib.MaxUnit
  178. }
  179. drug.MedcWayDscr = subItem.DeliveryWay
  180. tempTime2 := time.Unix(subItem.StartTime, 0)
  181. timeFormatTwo := tempTime2.Format("2006-01-02 15:04:05")
  182. drug.MedcBegntime = timeFormatTwo
  183. if subItem.Day > 0 {
  184. ts := time.Unix(subItem.StartTime, 0)
  185. record_time := ts.AddDate(0, 0, int(subItem.Day)).Unix()
  186. tempTime3 := time.Unix(record_time, 0)
  187. timeFormat3 := tempTime3.Format("2006-01-02") + " 23:59:00"
  188. drug.MedcEndtime = timeFormat3
  189. } else {
  190. tempTime2 := time.Unix(subItem.StartTime, 0)
  191. timeFormatTwo := tempTime2.Format("2006-01-02") + " 23:59:00"
  192. drug.MedcEndtime = timeFormatTwo
  193. }
  194. drug.MedcDays = strconv.FormatInt(subItem.Day, 10)
  195. drug.DrugPric = fmt.Sprintf("%.2f", subItem.Price)
  196. drug.DrugSumamt = fmt.Sprintf("%.2f", subItem.Price*subItem.PrescribingNumber)
  197. drug.DrugCnt = subItem.PrescribingNumber
  198. drug.DrugDosunt = subItem.PrescribingNumberUnit
  199. drug.SinDoscnt = subItem.SingleDose
  200. drug.SinDosunt = subItem.SingleDoseUnit
  201. drug.UsedFrquCodg = strconv.FormatInt(subItem.ID, 10)
  202. drug.UsedFrquName = subItem.ExecutionFrequency
  203. drug.DrugTotlcnt = fmt.Sprintf("%.2f", subItem.PrescribingNumber)
  204. drug.DrugTotlcntEmp = fmt.Sprintf("%.2f", subItem.PrescribingNumberUnit)
  205. drug.HospApprFlag = "1"
  206. cFYLJG001.List = append(cFYLJG001.List, drug)
  207. }
  208. cFYLJG001.Mdtrtinfo.FixmedinsCode = miConfig.Code
  209. cFYLJG001.Mdtrtinfo.FixmedinsName = miConfig.Code
  210. cFYLJG001.Mdtrtinfo.MdtrtID = his.Number
  211. cFYLJG001.Mdtrtinfo.MedType = item.MedType
  212. cFYLJG001.Mdtrtinfo.IptOtpNo = his.IptOtpNo
  213. cFYLJG001.Mdtrtinfo.OtpIptFlag = "1"
  214. cFYLJG001.Mdtrtinfo.PsnNo = his.PsnNo
  215. cFYLJG001.Mdtrtinfo.PatnName = his.PsnName
  216. cFYLJG001.Mdtrtinfo.Certno = his.IdCardNo
  217. cFYLJG001.Mdtrtinfo.PatnAge = fmt.Sprintf("%.2f", his.Age)
  218. cFYLJG001.Mdtrtinfo.PatnHgt = ""
  219. cFYLJG001.Mdtrtinfo.PatnWt = ""
  220. cFYLJG001.Mdtrtinfo.Gend = his.Gend
  221. cFYLJG001.Mdtrtinfo.PatnAge = fmt.Sprintf("%.2f", his.Age)
  222. cFYLJG001.Mdtrtinfo.PrscDeptName = "肾内科"
  223. cFYLJG001.Mdtrtinfo.PrscDeptCode = "A03.06"
  224. cFYLJG001.Mdtrtinfo.DrCode = doctor.DoctorNumber
  225. cFYLJG001.Mdtrtinfo.PrscDrName = doctor.UserName
  226. cFYLJG001.Mdtrtinfo.DrProfttlCodg = "234"
  227. cFYLJG001.Mdtrtinfo.DrProfttlName = "医师"
  228. cFYLJG001.Mdtrtinfo.DrDeptCode = "A03.06"
  229. cFYLJG001.Mdtrtinfo.DrDeptName = "肾内科"
  230. cFYLJG001.Mdtrtinfo.Caty = "A03.06"
  231. tempTime2 := time.Now().Unix()
  232. tempTime3 := time.Unix(tempTime2, 0)
  233. timeFormatTwo := tempTime3.Format("2006-01-02 15:04:05")
  234. cFYLJG001.Mdtrtinfo.MdtrtTime = timeFormatTwo
  235. cFYLJG001.Mdtrtinfo.DiseCodg = "M07803"
  236. cFYLJG001.Mdtrtinfo.SpDiseFlag = "1"
  237. cFYLJG001.Mdtrtinfo.MaindiagCode = "N18.500"
  238. cFYLJG001.Mdtrtinfo.MaindiagName = "慢性肾脏病5期"
  239. diagnosis_ids := strings.Split(his.Diagnosis, ",")
  240. var config []*models.HisXtDiagnoseConfig
  241. for _, item := range diagnosis_ids {
  242. id, _ := strconv.ParseInt(item, 10, 64)
  243. diagnosisConfig, _ := service.FindDiagnoseById(id)
  244. config = append(config, &diagnosisConfig)
  245. }
  246. for index, item := range config {
  247. if index == 0 {
  248. var dia models.DiseInfo
  249. dia.DiagType = "1"
  250. dia.MaindiagFlag = "1"
  251. dia.DiagSrtNo = strconv.FormatInt(int64(index+1), 10)
  252. dia.DiagCode = item.CountryCode
  253. dia.DiagName = item.ClassName
  254. dia.DiagDept = "肾内科"
  255. dia.DiagDrNo = doctor.DoctorNumber
  256. dia.DiagDrName = doctor.UserName
  257. tempTime3 := time.Unix(item.Ctime, 0)
  258. timeFormatTwo := tempTime3.Format("2006-01-02 15:04:05")
  259. dia.DiagTime = timeFormatTwo
  260. cFYLJG001.Diseinfo = append(cFYLJG001.Diseinfo, dia)
  261. } else {
  262. var dia models.DiseInfo
  263. dia.DiagType = "1"
  264. dia.MaindiagFlag = "0"
  265. dia.DiagSrtNo = strconv.FormatInt(int64(index+1), 10)
  266. dia.DiagCode = item.CountryCode
  267. dia.DiagName = item.ClassName
  268. dia.DiagDept = "肾内科"
  269. dia.DiagDrNo = doctor.DoctorNumber
  270. dia.DiagDrName = doctor.UserName
  271. tempTime3 := time.Unix(item.Ctime, 0)
  272. timeFormatTwo := tempTime3.Format("2006-01-02 15:04:05")
  273. dia.DiagTime = timeFormatTwo
  274. cFYLJG001.Diseinfo = append(cFYLJG001.Diseinfo, dia)
  275. }
  276. }
  277. fmt.Println(cFYLJG001)
  278. service.GetCFYLJG001(miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, cFYLJG001)
  279. }
  280. }
  281. func (c *HisApiController) GetCFYLJG002() {
  282. admin_user_id, _ := c.GetInt64("admin_user_id")
  283. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  284. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  285. service.GetCFYLJG002(miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, "", "", "")
  286. }
  287. func (c *HisApiController) GetCFYLJG003() {
  288. admin_user_id, _ := c.GetInt64("admin_user_id")
  289. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  290. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  291. var cFYLJG003 models.CFYLJG003
  292. service.GetCFYLJG003(miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, cFYLJG003)
  293. }
  294. func (c *HisApiController) GetCFYLJG004() {
  295. admin_user_id, _ := c.GetInt64("admin_user_id")
  296. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  297. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  298. var cFYLJG004 models.CFYLJG004
  299. service.GetCFYLJG004(miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, cFYLJG004)
  300. }
  301. func (c *HisApiController) GetCFYLJG005() {
  302. admin_user_id, _ := c.GetInt64("admin_user_id")
  303. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  304. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  305. var cFYLJG005 models.CFYLJG005
  306. service.GetCFYLJG005(miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, cFYLJG005)
  307. }
  308. func (c *HisApiController) GetCFYLJG006() {
  309. admin_user_id, _ := c.GetInt64("admin_user_id")
  310. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  311. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  312. var cFYLJG006 models.CFYLJG006
  313. service.GetCFYLJG006(miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, cFYLJG006)
  314. }
  315. func (c *HisApiController) GetCFYLJG007() {
  316. admin_user_id, _ := c.GetInt64("admin_user_id")
  317. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  318. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  319. var cFYLJG007 models.CFYLJG007
  320. service.GetCFYLJG007(miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, cFYLJG007)
  321. }
  322. func (c *HisApiController) GetBL4201A() {
  323. order_id, _ := c.GetInt64("order_id")
  324. admin_user_id, _ := c.GetInt64("admin_user_id")
  325. order, _ := service.GetHisOrderByIDTwo(order_id)
  326. his, _ := service.GetInHospitalRecordByNumber(order.MdtrtId)
  327. order_info, _ := service.GetHisOrderInfoByNumber(order.MdtrtId)
  328. order_info_two, _ := service.GetHisOrderInfoByNumberTwo(order.MdtrtId)
  329. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  330. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  331. department, _ := service.GetDepartMentDetail(his.Departments)
  332. pre, _ := service.GetNewHisPrescriptionByNumber(order.Number)
  333. doctor, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, pre.Creator)
  334. if order.ID == 0 {
  335. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisOrderNoExistParamWrong)
  336. return
  337. }
  338. var struct4201A models.Struct4201A
  339. var fsiOPFLDs []models.FsiOwnpayPatnFeeListDDTO
  340. for _, items := range order_info {
  341. memo := make(map[string]interface{})
  342. var fsiOPFLD models.FsiOwnpayPatnFeeListDDTO
  343. fsiOPFLD.FixmedinsMdtrtID = items.OrderNumber
  344. fsiOPFLD.MedType = "14"
  345. fsiOPFLD.BkkpSn = items.FeedetlSn
  346. fsiOPFLD.FixmedinsCode = miConfig.Code
  347. fsiOPFLD.FixmedinsName = miConfig.OrgName
  348. fsiOPFLD.Cnt = fmt.Sprintf("%.2f", items.Cnt)
  349. fsiOPFLD.Pric = fmt.Sprintf("%.2f", items.Pric)
  350. fsiOPFLD.DetItemFeeSumamt = fmt.Sprintf("%.2f", items.DetItemFeeSumamt)
  351. if items.AdviceId > 0 && items.ProjectId == 0 && items.HisDoctorAdviceInfo.BaseDrugLib.IsUser != 1 && len(items.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber) > 0 {
  352. fsiOPFLD.FeeOcurTime = time.Unix(items.HisDoctorAdviceInfo.CreatedTime, 0).Format("2006-01-02 15:04:05")
  353. fsiOPFLD.MedListCodg = items.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber
  354. fsiOPFLD.MedinsListCodg = items.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber
  355. fsiOPFLD.MedinsListName = items.HisDoctorAdviceInfo.BaseDrugLib.DrugName
  356. fsiOPFLD.Prodname = items.HisDoctorAdviceInfo.BaseDrugLib.DrugName
  357. fsiOPFLD.BilgDeptName = department.Name
  358. fsiOPFLD.BilgDeptCodg = department.Number
  359. fsiOPFLD.BilgDrCode = doctor.DoctorNumber
  360. fsiOPFLD.BilgDrName = doctor.UserName
  361. fsiOPFLD.MedChrgitmType = "09"
  362. memo["hosp_appr_flag"] = "1"
  363. memo["invoice_no"] = order.MdtrtId
  364. memo["memo"] = "自费"
  365. bytesData, _ := json.Marshal(memo)
  366. fsiOPFLD.Memo = string(bytesData)
  367. fsiOPFLDs = append(fsiOPFLDs, fsiOPFLD)
  368. } else if items.AdviceId == 0 && items.ProjectId > 0 {
  369. if items.HisPrescriptionProject.Type == 2 && len(items.HisPrescriptionProject.HisProject.MedicalCode) > 0 {
  370. fsiOPFLD.FeeOcurTime = time.Unix(items.HisPrescriptionProject.Ctime, 0).Format("2006-01-02 15:04:05")
  371. fsiOPFLD.MedListCodg = items.HisPrescriptionProject.HisProject.MedicalCode
  372. fsiOPFLD.MedinsListCodg = items.HisPrescriptionProject.HisProject.MedicalCode
  373. fsiOPFLD.MedinsListName = items.HisPrescriptionProject.HisProject.ProjectName
  374. fsiOPFLD.Prodname = items.HisPrescriptionProject.HisProject.ProjectName
  375. fsiOPFLD.BilgDeptName = department.Name
  376. fsiOPFLD.BilgDeptCodg = department.Number
  377. fsiOPFLD.BilgDrCode = doctor.DoctorNumber
  378. fsiOPFLD.BilgDrName = doctor.UserName
  379. switch items.HisPrescriptionProject.HisProject.CostClassify {
  380. case 0:
  381. break
  382. case 1:
  383. fsiOPFLD.MedChrgitmType = "14"
  384. break
  385. case 2:
  386. fsiOPFLD.MedChrgitmType = "05"
  387. break
  388. case 3:
  389. fsiOPFLD.MedChrgitmType = "03"
  390. break
  391. case 4:
  392. fsiOPFLD.MedChrgitmType = "03"
  393. break
  394. case 5:
  395. fsiOPFLD.MedChrgitmType = "08"
  396. break
  397. case 6:
  398. fsiOPFLD.MedChrgitmType = "14"
  399. break
  400. case 7:
  401. fsiOPFLD.MedChrgitmType = "14"
  402. break
  403. case 8:
  404. fsiOPFLD.MedChrgitmType = "03"
  405. break
  406. case 9:
  407. fsiOPFLD.MedChrgitmType = "14"
  408. break
  409. case 10:
  410. fsiOPFLD.MedChrgitmType = "14"
  411. break
  412. case 11:
  413. fsiOPFLD.MedChrgitmType = "06"
  414. break
  415. case 12:
  416. fsiOPFLD.MedChrgitmType = "12"
  417. break
  418. case 13:
  419. fsiOPFLD.MedChrgitmType = "01"
  420. break
  421. case 14:
  422. fsiOPFLD.MedChrgitmType = "04"
  423. break
  424. case 15:
  425. fsiOPFLD.MedChrgitmType = "14"
  426. break
  427. }
  428. memo["hosp_appr_flag"] = "1"
  429. memo["invoice_no"] = order.MdtrtId
  430. memo["memo"] = "自费"
  431. bytesData, _ := json.Marshal(memo)
  432. fsiOPFLD.Memo = string(bytesData)
  433. fsiOPFLDs = append(fsiOPFLDs, fsiOPFLD)
  434. } else if items.HisPrescriptionProject.Type == 3 && items.HisPrescriptionProject.GoodInfo.IsUser != 1 && len(items.HisPrescriptionProject.GoodInfo.MedicalInsuranceNumber) > 0 {
  435. fsiOPFLD.FeeOcurTime = time.Unix(items.HisPrescriptionProject.Ctime, 0).Format("2006-01-02 15:04:05")
  436. fsiOPFLD.MedListCodg = items.HisPrescriptionProject.GoodInfo.MedicalInsuranceNumber
  437. fsiOPFLD.MedinsListCodg = items.HisPrescriptionProject.GoodInfo.MedicalInsuranceNumber
  438. fsiOPFLD.BilgDeptName = department.Name
  439. fsiOPFLD.BilgDeptCodg = department.Number
  440. fsiOPFLD.BilgDrCode = doctor.DoctorNumber
  441. fsiOPFLD.BilgDrName = doctor.UserName
  442. fsiOPFLD.MedinsListName = items.HisPrescriptionProject.GoodInfo.GoodName
  443. fsiOPFLD.Prodname = items.HisPrescriptionProject.GoodInfo.GoodName
  444. fsiOPFLD.MedChrgitmType = "08"
  445. memo["hosp_appr_flag"] = "1"
  446. memo["invoice_no"] = order.MdtrtId
  447. memo["memo"] = "自费"
  448. bytesData, _ := json.Marshal(memo)
  449. fsiOPFLD.Memo = string(bytesData)
  450. fsiOPFLDs = append(fsiOPFLDs, fsiOPFLD)
  451. }
  452. }
  453. }
  454. for _, items := range order_info_two {
  455. memo := make(map[string]interface{})
  456. var fsiOPFLD models.FsiOwnpayPatnFeeListDDTO
  457. fsiOPFLD.FixmedinsMdtrtID = items.OrderNumber
  458. fsiOPFLD.MedType = "14"
  459. fsiOPFLD.BkkpSn = items.FeedetlSn
  460. fsiOPFLD.FixmedinsCode = miConfig.Code
  461. fsiOPFLD.FixmedinsName = miConfig.OrgName
  462. fsiOPFLD.Cnt = fmt.Sprintf("%.2f", items.Cnt)
  463. fsiOPFLD.Pric = fmt.Sprintf("%.2f", items.Pric)
  464. fsiOPFLD.DetItemFeeSumamt = fmt.Sprintf("%.2f", items.DetItemFeeSumamt)
  465. if items.AdviceId > 0 && items.ProjectId == 0 && items.HisDoctorAdviceInfo.BaseDrugLib.IsUser != 1 && len(items.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber) > 0 {
  466. fsiOPFLD.FeeOcurTime = time.Unix(items.HisDoctorAdviceInfo.CreatedTime, 0).Format("2006-01-02 15:04:05")
  467. fsiOPFLD.MedListCodg = items.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber
  468. fsiOPFLD.MedinsListCodg = items.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber
  469. fsiOPFLD.MedinsListName = items.HisDoctorAdviceInfo.BaseDrugLib.DrugName
  470. fsiOPFLD.Prodname = items.HisDoctorAdviceInfo.BaseDrugLib.DrugName
  471. fsiOPFLD.BilgDeptName = department.Name
  472. fsiOPFLD.BilgDeptCodg = department.Number
  473. fsiOPFLD.BilgDrCode = doctor.DoctorNumber
  474. fsiOPFLD.BilgDrName = doctor.UserName
  475. fsiOPFLD.MedChrgitmType = "09"
  476. memo["hosp_appr_flag"] = "1"
  477. memo["invoice_no"] = order.MdtrtId
  478. memo["memo"] = "自费"
  479. bytesData, _ := json.Marshal(memo)
  480. fsiOPFLD.Memo = string(bytesData)
  481. fsiOPFLDs = append(fsiOPFLDs, fsiOPFLD)
  482. } else if items.AdviceId == 0 && items.ProjectId > 0 {
  483. if items.HisPrescriptionProject.Type == 2 && len(items.HisPrescriptionProject.HisProject.MedicalCode) > 0 {
  484. fsiOPFLD.FeeOcurTime = time.Unix(items.HisPrescriptionProject.Ctime, 0).Format("2006-01-02 15:04:05")
  485. fsiOPFLD.MedListCodg = items.HisPrescriptionProject.HisProject.MedicalCode
  486. fsiOPFLD.MedinsListName = items.HisPrescriptionProject.HisProject.ProjectName
  487. fsiOPFLD.Prodname = items.HisPrescriptionProject.HisProject.ProjectName
  488. fsiOPFLD.MedinsListCodg = items.HisPrescriptionProject.HisProject.MedicalCode
  489. fsiOPFLD.BilgDeptName = department.Name
  490. fsiOPFLD.BilgDeptCodg = department.Number
  491. fsiOPFLD.BilgDrCode = doctor.DoctorNumber
  492. fsiOPFLD.BilgDrName = doctor.UserName
  493. switch items.HisPrescriptionProject.HisProject.CostClassify {
  494. case 0:
  495. break
  496. case 1:
  497. fsiOPFLD.MedChrgitmType = "14"
  498. break
  499. case 2:
  500. fsiOPFLD.MedChrgitmType = "05"
  501. break
  502. case 3:
  503. fsiOPFLD.MedChrgitmType = "03"
  504. break
  505. case 4:
  506. fsiOPFLD.MedChrgitmType = "03"
  507. break
  508. case 5:
  509. fsiOPFLD.MedChrgitmType = "08"
  510. break
  511. case 6:
  512. fsiOPFLD.MedChrgitmType = "14"
  513. break
  514. case 7:
  515. fsiOPFLD.MedChrgitmType = "14"
  516. break
  517. case 8:
  518. fsiOPFLD.MedChrgitmType = "03"
  519. break
  520. case 9:
  521. fsiOPFLD.MedChrgitmType = "14"
  522. break
  523. case 10:
  524. fsiOPFLD.MedChrgitmType = "14"
  525. break
  526. case 11:
  527. fsiOPFLD.MedChrgitmType = "06"
  528. break
  529. case 12:
  530. fsiOPFLD.MedChrgitmType = "12"
  531. break
  532. case 13:
  533. fsiOPFLD.MedChrgitmType = "01"
  534. break
  535. case 14:
  536. fsiOPFLD.MedChrgitmType = "04"
  537. break
  538. case 15:
  539. fsiOPFLD.MedChrgitmType = "14"
  540. break
  541. }
  542. memo["hosp_appr_flag"] = "1"
  543. memo["invoice_no"] = order.MdtrtId
  544. memo["memo"] = "自费"
  545. bytesData, _ := json.Marshal(memo)
  546. fsiOPFLD.Memo = string(bytesData)
  547. fsiOPFLDs = append(fsiOPFLDs, fsiOPFLD)
  548. } else if items.HisPrescriptionProject.Type == 3 && len(items.HisPrescriptionProject.GoodInfo.MedicalInsuranceNumber) > 0 && items.HisPrescriptionProject.GoodInfo.IsUser != 1 {
  549. fsiOPFLD.FeeOcurTime = time.Unix(items.HisPrescriptionProject.Ctime, 0).Format("2006-01-02 15:04:05")
  550. fsiOPFLD.MedListCodg = items.HisPrescriptionProject.GoodInfo.MedicalInsuranceNumber
  551. fsiOPFLD.MedinsListCodg = items.HisPrescriptionProject.GoodInfo.MedicalInsuranceNumber
  552. fsiOPFLD.BilgDeptName = department.Name
  553. fsiOPFLD.BilgDeptCodg = department.Number
  554. fsiOPFLD.BilgDrCode = doctor.DoctorNumber
  555. fsiOPFLD.BilgDrName = doctor.UserName
  556. fsiOPFLD.MedinsListName = items.HisPrescriptionProject.GoodInfo.GoodName
  557. fsiOPFLD.Prodname = items.HisPrescriptionProject.GoodInfo.GoodName
  558. fsiOPFLD.MedChrgitmType = "08"
  559. memo["hosp_appr_flag"] = "1"
  560. memo["invoice_no"] = order.MdtrtId
  561. memo["memo"] = "自费"
  562. bytesData, _ := json.Marshal(memo)
  563. fsiOPFLD.Memo = string(bytesData)
  564. fsiOPFLDs = append(fsiOPFLDs, fsiOPFLD)
  565. }
  566. }
  567. }
  568. fmt.Println(fsiOPFLDs)
  569. struct4201A.Fopfd = fsiOPFLDs
  570. fmt.Println(struct4201A.Fopfd)
  571. result, requestLog := service.Gdyb4201A(miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, struct4201A)
  572. saveLog(result, requestLog, "4201A", "自费费用明细上传")
  573. var res2 ResultSix
  574. var respJSON2 map[string]interface{}
  575. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  576. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  577. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  578. return
  579. }
  580. userJSONBytes2, _ := json.Marshal(respJSON2)
  581. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  582. utils.ErrorLog("解析失败:%v", err)
  583. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  584. return
  585. }
  586. if res2.Infcode != 0 {
  587. c.ServeSuccessJSON(map[string]interface{}{
  588. "failed_code": -10,
  589. "msg": res2.ErrMsg,
  590. })
  591. return
  592. } else {
  593. order.IsUploadOrderInfo = 1
  594. service.UpdateOrder(order)
  595. c.ServeSuccessJSON(map[string]interface{}{
  596. "msg": "上传成功",
  597. })
  598. }
  599. }
  600. func (c *HisApiController) Get2505() {
  601. miConfig, _ := service.FindMedicalInsuranceInfo(10215)
  602. 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")
  603. }
  604. func (c *HisApiController) Get4201A() {
  605. order_id, _ := c.GetInt64("order_id")
  606. admin_user_id, _ := c.GetInt64("admin_user_id")
  607. order, _ := service.GetHisOrderByIDTwo(order_id)
  608. his, _ := service.GetInHospitalRecordByNumber(order.MdtrtId)
  609. order_info, _ := service.GetHisOrderInfoByNumber(order.MdtrtId)
  610. order_info_two, _ := service.GetHisOrderInfoByNumberTwo(order.MdtrtId)
  611. //order_info = append(order_info, order_info_two...)
  612. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  613. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  614. department, _ := service.GetDepartMentDetail(his.Departments)
  615. pre, _ := service.GetNewHisPrescriptionByNumber(order.Number)
  616. doctor, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, pre.Creator)
  617. if order.ID == 0 {
  618. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisOrderNoExistParamWrong)
  619. return
  620. }
  621. var struct4201A models.Struct4201A
  622. var fsiOPFLDs []models.FsiOwnpayPatnFeeListDDTO
  623. for _, items := range order_info {
  624. memo := make(map[string]interface{})
  625. var fsiOPFLD models.FsiOwnpayPatnFeeListDDTO
  626. fsiOPFLD.FixmedinsMdtrtID = items.OrderNumber
  627. fsiOPFLD.MedType = "14"
  628. fsiOPFLD.BkkpSn = items.FeedetlSn
  629. fsiOPFLD.FixmedinsCode = miConfig.Code
  630. fsiOPFLD.FixmedinsName = miConfig.OrgName
  631. fsiOPFLD.Cnt = fmt.Sprintf("%.2f", items.Cnt)
  632. fsiOPFLD.Pric = fmt.Sprintf("%.2f", items.Pric)
  633. fsiOPFLD.DetItemFeeSumamt = fmt.Sprintf("%.2f", items.DetItemFeeSumamt)
  634. if items.AdviceId > 0 && items.ProjectId == 0 && items.HisDoctorAdviceInfo.BaseDrugLib.IsUser != 1 && len(items.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber) > 0 {
  635. fsiOPFLD.FeeOcurTime = time.Unix(items.HisDoctorAdviceInfo.CreatedTime, 0).Format("2006-01-02 15:04:05")
  636. fsiOPFLD.MedListCodg = items.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber
  637. fsiOPFLD.MedinsListCodg = items.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber
  638. fsiOPFLD.MedinsListName = items.HisDoctorAdviceInfo.BaseDrugLib.DrugName
  639. fsiOPFLD.Prodname = items.HisDoctorAdviceInfo.BaseDrugLib.DrugName
  640. fsiOPFLD.BilgDeptName = department.Name
  641. fsiOPFLD.BilgDeptCodg = department.Number
  642. fsiOPFLD.BilgDrCode = doctor.DoctorNumber
  643. fsiOPFLD.BilgDrName = doctor.UserName
  644. fsiOPFLD.MedChrgitmType = "09"
  645. memo["hosp_appr_flag"] = "1"
  646. memo["invoice_no"] = order.MdtrtId
  647. memo["memo"] = "自费"
  648. bytesData, _ := json.Marshal(memo)
  649. fsiOPFLD.Memo = string(bytesData)
  650. fsiOPFLDs = append(fsiOPFLDs, fsiOPFLD)
  651. } else if items.AdviceId == 0 && items.ProjectId > 0 {
  652. if items.HisPrescriptionProject.Type == 2 && len(items.HisPrescriptionProject.HisProject.MedicalCode) > 0 {
  653. fsiOPFLD.FeeOcurTime = time.Unix(items.HisPrescriptionProject.Ctime, 0).Format("2006-01-02 15:04:05")
  654. fsiOPFLD.MedListCodg = items.HisPrescriptionProject.HisProject.MedicalCode
  655. fsiOPFLD.MedinsListCodg = items.HisPrescriptionProject.HisProject.MedicalCode
  656. fsiOPFLD.MedinsListName = items.HisPrescriptionProject.HisProject.ProjectName
  657. fsiOPFLD.Prodname = items.HisPrescriptionProject.HisProject.ProjectName
  658. fsiOPFLD.BilgDeptName = department.Name
  659. fsiOPFLD.BilgDeptCodg = department.Number
  660. fsiOPFLD.BilgDrCode = doctor.DoctorNumber
  661. fsiOPFLD.BilgDrName = doctor.UserName
  662. switch items.HisPrescriptionProject.HisProject.CostClassify {
  663. case 0:
  664. break
  665. case 1:
  666. fsiOPFLD.MedChrgitmType = "14"
  667. break
  668. case 2:
  669. fsiOPFLD.MedChrgitmType = "05"
  670. break
  671. case 3:
  672. fsiOPFLD.MedChrgitmType = "03"
  673. break
  674. case 4:
  675. fsiOPFLD.MedChrgitmType = "03"
  676. break
  677. case 5:
  678. fsiOPFLD.MedChrgitmType = "08"
  679. break
  680. case 6:
  681. fsiOPFLD.MedChrgitmType = "14"
  682. break
  683. case 7:
  684. fsiOPFLD.MedChrgitmType = "14"
  685. break
  686. case 8:
  687. fsiOPFLD.MedChrgitmType = "03"
  688. break
  689. case 9:
  690. fsiOPFLD.MedChrgitmType = "14"
  691. break
  692. case 10:
  693. fsiOPFLD.MedChrgitmType = "14"
  694. break
  695. case 11:
  696. fsiOPFLD.MedChrgitmType = "06"
  697. break
  698. case 12:
  699. fsiOPFLD.MedChrgitmType = "12"
  700. break
  701. case 13:
  702. fsiOPFLD.MedChrgitmType = "01"
  703. break
  704. case 14:
  705. fsiOPFLD.MedChrgitmType = "04"
  706. break
  707. case 15:
  708. fsiOPFLD.MedChrgitmType = "14"
  709. break
  710. }
  711. memo["hosp_appr_flag"] = "1"
  712. memo["invoice_no"] = order.MdtrtId
  713. memo["memo"] = "自费"
  714. bytesData, _ := json.Marshal(memo)
  715. fsiOPFLD.Memo = string(bytesData)
  716. fsiOPFLDs = append(fsiOPFLDs, fsiOPFLD)
  717. } else if items.HisPrescriptionProject.Type == 3 && items.HisPrescriptionProject.GoodInfo.IsUser != 1 && len(items.HisPrescriptionProject.GoodInfo.MedicalInsuranceNumber) > 0 {
  718. fsiOPFLD.FeeOcurTime = time.Unix(items.HisPrescriptionProject.Ctime, 0).Format("2006-01-02 15:04:05")
  719. fsiOPFLD.MedListCodg = items.HisPrescriptionProject.GoodInfo.MedicalInsuranceNumber
  720. fsiOPFLD.MedinsListCodg = items.HisPrescriptionProject.GoodInfo.MedicalInsuranceNumber
  721. fsiOPFLD.BilgDeptName = department.Name
  722. fsiOPFLD.BilgDeptCodg = department.Number
  723. fsiOPFLD.BilgDrCode = doctor.DoctorNumber
  724. fsiOPFLD.BilgDrName = doctor.UserName
  725. fsiOPFLD.MedinsListName = items.HisPrescriptionProject.GoodInfo.GoodName
  726. fsiOPFLD.Prodname = items.HisPrescriptionProject.GoodInfo.GoodName
  727. fsiOPFLD.MedChrgitmType = "08"
  728. memo["hosp_appr_flag"] = "1"
  729. memo["invoice_no"] = order.MdtrtId
  730. memo["memo"] = "自费"
  731. bytesData, _ := json.Marshal(memo)
  732. fsiOPFLD.Memo = string(bytesData)
  733. fsiOPFLDs = append(fsiOPFLDs, fsiOPFLD)
  734. }
  735. }
  736. }
  737. for _, items := range order_info_two {
  738. memo := make(map[string]interface{})
  739. var fsiOPFLD models.FsiOwnpayPatnFeeListDDTO
  740. fsiOPFLD.FixmedinsMdtrtID = items.OrderNumber
  741. fsiOPFLD.MedType = "14"
  742. fsiOPFLD.BkkpSn = items.FeedetlSn
  743. fsiOPFLD.FixmedinsCode = miConfig.Code
  744. fsiOPFLD.FixmedinsName = miConfig.OrgName
  745. fsiOPFLD.Cnt = fmt.Sprintf("%.2f", items.Cnt)
  746. fsiOPFLD.Pric = fmt.Sprintf("%.2f", items.Pric)
  747. fsiOPFLD.DetItemFeeSumamt = fmt.Sprintf("%.2f", items.DetItemFeeSumamt)
  748. if items.AdviceId > 0 && items.ProjectId == 0 && items.HisDoctorAdviceInfo.BaseDrugLib.IsUser != 1 && len(items.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber) > 0 {
  749. fsiOPFLD.FeeOcurTime = time.Unix(items.HisDoctorAdviceInfo.CreatedTime, 0).Format("2006-01-02 15:04:05")
  750. fsiOPFLD.MedListCodg = items.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber
  751. fsiOPFLD.MedinsListCodg = items.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber
  752. fsiOPFLD.MedinsListName = items.HisDoctorAdviceInfo.BaseDrugLib.DrugName
  753. fsiOPFLD.Prodname = items.HisDoctorAdviceInfo.BaseDrugLib.DrugName
  754. fsiOPFLD.BilgDeptName = department.Name
  755. fsiOPFLD.BilgDeptCodg = department.Number
  756. fsiOPFLD.BilgDrCode = doctor.DoctorNumber
  757. fsiOPFLD.BilgDrName = doctor.UserName
  758. fsiOPFLD.MedChrgitmType = "09"
  759. memo["hosp_appr_flag"] = "1"
  760. memo["invoice_no"] = order.MdtrtId
  761. memo["memo"] = "自费"
  762. bytesData, _ := json.Marshal(memo)
  763. fsiOPFLD.Memo = string(bytesData)
  764. fsiOPFLDs = append(fsiOPFLDs, fsiOPFLD)
  765. } else if items.AdviceId == 0 && items.ProjectId > 0 {
  766. if items.HisPrescriptionProject.Type == 2 && len(items.HisPrescriptionProject.HisProject.MedicalCode) > 0 {
  767. fsiOPFLD.FeeOcurTime = time.Unix(items.HisPrescriptionProject.Ctime, 0).Format("2006-01-02 15:04:05")
  768. fsiOPFLD.MedListCodg = items.HisPrescriptionProject.HisProject.MedicalCode
  769. fsiOPFLD.MedinsListName = items.HisPrescriptionProject.HisProject.ProjectName
  770. fsiOPFLD.Prodname = items.HisPrescriptionProject.HisProject.ProjectName
  771. fsiOPFLD.MedinsListCodg = items.HisPrescriptionProject.HisProject.MedicalCode
  772. fsiOPFLD.BilgDeptName = department.Name
  773. fsiOPFLD.BilgDeptCodg = department.Number
  774. fsiOPFLD.BilgDrCode = doctor.DoctorNumber
  775. fsiOPFLD.BilgDrName = doctor.UserName
  776. switch items.HisPrescriptionProject.HisProject.CostClassify {
  777. case 0:
  778. break
  779. case 1:
  780. fsiOPFLD.MedChrgitmType = "14"
  781. break
  782. case 2:
  783. fsiOPFLD.MedChrgitmType = "05"
  784. break
  785. case 3:
  786. fsiOPFLD.MedChrgitmType = "03"
  787. break
  788. case 4:
  789. fsiOPFLD.MedChrgitmType = "03"
  790. break
  791. case 5:
  792. fsiOPFLD.MedChrgitmType = "08"
  793. break
  794. case 6:
  795. fsiOPFLD.MedChrgitmType = "14"
  796. break
  797. case 7:
  798. fsiOPFLD.MedChrgitmType = "14"
  799. break
  800. case 8:
  801. fsiOPFLD.MedChrgitmType = "03"
  802. break
  803. case 9:
  804. fsiOPFLD.MedChrgitmType = "14"
  805. break
  806. case 10:
  807. fsiOPFLD.MedChrgitmType = "14"
  808. break
  809. case 11:
  810. fsiOPFLD.MedChrgitmType = "06"
  811. break
  812. case 12:
  813. fsiOPFLD.MedChrgitmType = "12"
  814. break
  815. case 13:
  816. fsiOPFLD.MedChrgitmType = "01"
  817. break
  818. case 14:
  819. fsiOPFLD.MedChrgitmType = "04"
  820. break
  821. case 15:
  822. fsiOPFLD.MedChrgitmType = "14"
  823. break
  824. }
  825. memo["hosp_appr_flag"] = "1"
  826. memo["invoice_no"] = order.MdtrtId
  827. memo["memo"] = "自费"
  828. bytesData, _ := json.Marshal(memo)
  829. fsiOPFLD.Memo = string(bytesData)
  830. fsiOPFLDs = append(fsiOPFLDs, fsiOPFLD)
  831. } else if items.HisPrescriptionProject.Type == 3 && len(items.HisPrescriptionProject.GoodInfo.MedicalInsuranceNumber) > 0 && items.HisPrescriptionProject.GoodInfo.IsUser != 1 {
  832. fsiOPFLD.FeeOcurTime = time.Unix(items.HisPrescriptionProject.Ctime, 0).Format("2006-01-02 15:04:05")
  833. fsiOPFLD.MedListCodg = items.HisPrescriptionProject.GoodInfo.MedicalInsuranceNumber
  834. fsiOPFLD.MedinsListCodg = items.HisPrescriptionProject.GoodInfo.MedicalInsuranceNumber
  835. fsiOPFLD.BilgDeptName = department.Name
  836. fsiOPFLD.BilgDeptCodg = department.Number
  837. fsiOPFLD.BilgDrCode = doctor.DoctorNumber
  838. fsiOPFLD.BilgDrName = doctor.UserName
  839. fsiOPFLD.MedinsListName = items.HisPrescriptionProject.GoodInfo.GoodName
  840. fsiOPFLD.Prodname = items.HisPrescriptionProject.GoodInfo.GoodName
  841. fsiOPFLD.MedChrgitmType = "08"
  842. memo["hosp_appr_flag"] = "1"
  843. memo["invoice_no"] = order.MdtrtId
  844. memo["memo"] = "自费"
  845. bytesData, _ := json.Marshal(memo)
  846. fsiOPFLD.Memo = string(bytesData)
  847. fsiOPFLDs = append(fsiOPFLDs, fsiOPFLD)
  848. }
  849. }
  850. }
  851. fmt.Println(fsiOPFLDs)
  852. struct4201A.Fopfd = fsiOPFLDs
  853. fmt.Println(struct4201A.Fopfd)
  854. result, requestLog := service.Gdyb4201A(miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, struct4201A)
  855. saveLog(result, requestLog, "4201A", "自费费用明细上传")
  856. var res2 ResultSix
  857. var respJSON2 map[string]interface{}
  858. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  859. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  860. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  861. return
  862. }
  863. userJSONBytes2, _ := json.Marshal(respJSON2)
  864. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  865. utils.ErrorLog("解析失败:%v", err)
  866. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  867. return
  868. }
  869. if res2.Infcode != 0 {
  870. c.ServeSuccessJSON(map[string]interface{}{
  871. "failed_code": -10,
  872. "msg": res2.ErrMsg,
  873. })
  874. return
  875. } else {
  876. order.IsUploadOrderInfo = 1
  877. service.UpdateOrder(order)
  878. c.ServeSuccessJSON(map[string]interface{}{
  879. "msg": "上传成功",
  880. })
  881. }
  882. }
  883. func (c *HisApiController) Get4202() {
  884. order_id, _ := c.GetInt64("order_id")
  885. admin_user_id, _ := c.GetInt64("admin_user_id")
  886. order, _ := service.GetHisOrderByIDTwo(order_id)
  887. his, _ := service.GetInHospitalRecordByNumber(order.MdtrtId)
  888. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  889. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  890. if order.ID == 0 {
  891. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisOrderNoExistParamWrong)
  892. return
  893. }
  894. var struct4202 models.Struct4202
  895. struct4202.OwnPayPatnMdtrtD.FixmedinsMdtrtID = his.Number
  896. struct4202.OwnPayPatnMdtrtD.FixmedinsCode = miConfig.Code
  897. struct4202.OwnPayPatnMdtrtD.FixmedinsName = miConfig.OrgName
  898. struct4202.OwnPayPatnMdtrtD.PsnCertType = "01"
  899. struct4202.OwnPayPatnMdtrtD.Certno = his.IdCardNo
  900. struct4202.OwnPayPatnMdtrtD.PsnName = his.Name
  901. struct4202.OwnPayPatnMdtrtD.Begntime = his.InHosptialTime
  902. struct4202.OwnPayPatnMdtrtD.MedType = "14"
  903. struct4202.OwnPayPatnMdtrtD.ValiFlag = "1"
  904. struct4202.OwnPayPatnMdtrtD.MedfeeSumamt = fmt.Sprintf("%.2f", order.MedfeeSumamt)
  905. diagnosis_ids := strings.Split(his.Diagnosis, ",")
  906. var config []*models.HisXtDiagnoseConfig
  907. for _, item := range diagnosis_ids {
  908. id, _ := strconv.ParseInt(item, 10, 64)
  909. diagnosisConfig, _ := service.FindDiagnoseById(id)
  910. config = append(config, &diagnosisConfig)
  911. }
  912. var tempDiaginfos []models.OwnPayPatnDiagListD
  913. for index, item := range config {
  914. if index == 0 {
  915. var tempDiaginfo models.OwnPayPatnDiagListD
  916. tempDiaginfo.InoutDiagType = "1"
  917. tempDiaginfo.DiagCode = item.CountryCode
  918. tempDiaginfo.DiagName = item.CountryContentName
  919. tempDiaginfo.DiagType = "1"
  920. tempDiaginfo.DiagSrtNo = "1"
  921. tempDiaginfo.MaindiagFlag = "1"
  922. tempDiaginfo.ValiFlag = "1"
  923. tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  924. } else {
  925. var tempDiaginfo models.OwnPayPatnDiagListD
  926. tempDiaginfo.DiagCode = item.CountryCode
  927. tempDiaginfo.DiagName = item.CountryContentName
  928. tempDiaginfo.DiagType = "2"
  929. tempDiaginfo.DiagSrtNo = strconv.FormatInt(int64(index+1), 10)
  930. tempDiaginfo.MaindiagFlag = "0"
  931. tempDiaginfo.ValiFlag = "1"
  932. tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  933. }
  934. }
  935. struct4202.ODiagListD = tempDiaginfos
  936. result, requestLog := service.Gdyb4202(miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, struct4202)
  937. saveLog(result, requestLog, "4202", "自费就诊和诊断信息上传")
  938. var res2 ResultSix
  939. var respJSON2 map[string]interface{}
  940. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  941. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  942. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  943. return
  944. }
  945. userJSONBytes2, _ := json.Marshal(respJSON2)
  946. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  947. utils.ErrorLog("解析失败:%v", err)
  948. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  949. return
  950. }
  951. if res2.Infcode != 0 {
  952. c.ServeSuccessJSON(map[string]interface{}{
  953. "failed_code": -10,
  954. "msg": res2.ErrMsg,
  955. })
  956. return
  957. } else {
  958. order.IsUploadDiagnose = 1
  959. service.UpdateOrder(order)
  960. c.ServeSuccessJSON(map[string]interface{}{
  961. "msg": "上传成功",
  962. })
  963. }
  964. }
  965. func (c *HisApiController) Get4203() {
  966. admin_user_id, _ := c.GetInt64("admin_user_id")
  967. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  968. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  969. order_id, _ := c.GetInt64("order_id")
  970. order, _ := service.GetHisOrderByIDTwo1111(order_id)
  971. number := ""
  972. his, _ := service.GetHisPatientByNumber(order.MdtrtId)
  973. hospital, _ := service.GetInHospitalRecordByNumber(order.MdtrtId)
  974. if his.ID == 0 {
  975. number = hospital.Number
  976. } else {
  977. number = his.Number
  978. }
  979. result, requestLog := service.Gdyb4203(miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, number)
  980. saveLog(result, requestLog, "4203", "自费就诊与结算明细上传完成")
  981. var res2 ResultSix
  982. var respJSON2 map[string]interface{}
  983. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  984. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  985. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  986. return
  987. }
  988. userJSONBytes2, _ := json.Marshal(respJSON2)
  989. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  990. utils.ErrorLog("解析失败:%v", err)
  991. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  992. return
  993. }
  994. if res2.Infcode != 0 {
  995. c.ServeSuccessJSON(map[string]interface{}{
  996. "failed_code": -10,
  997. "msg": res2.ErrMsg,
  998. })
  999. return
  1000. } else {
  1001. order.IsUploadSuccess = 1
  1002. service.UpdateOrderTwo(order)
  1003. c.ServeSuccessJSON(map[string]interface{}{
  1004. "msg": "上传成功",
  1005. })
  1006. }
  1007. }
  1008. func (c *HisApiController) Get4205() {
  1009. order_id, _ := c.GetInt64("order_id")
  1010. admin_user_id, _ := c.GetInt64("admin_user_id")
  1011. fapiao_code := c.GetString("fapiao_code")
  1012. order, _ := service.GetHisOrderByIDTwo1111(order_id)
  1013. his, _ := service.GetHisPatientByNumber(order.MdtrtId)
  1014. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  1015. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  1016. order_info, _ := service.GetHisOrderInfoByNumber(order.Number)
  1017. order_info_two, _ := service.GetHisOrderInfoByNumberTwo(order.Number)
  1018. //order_info = append(order_info, order_info_two...)
  1019. department, _ := service.GetDepartMentDetail(his.Departments)
  1020. pre, _ := service.GetNewHisPrescriptionByNumber(order.Number)
  1021. doctor, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, pre.Creator)
  1022. if order.ID == 0 {
  1023. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisOrderNoExistParamWrong)
  1024. return
  1025. }
  1026. var struct4201A models.Struct4201A
  1027. var fsiOPFLDs []models.FsiOwnpayPatnFeeListDDTO
  1028. for _, items := range order_info {
  1029. memo := make(map[string]interface{})
  1030. var fsiOPFLD models.FsiOwnpayPatnFeeListDDTO
  1031. fsiOPFLD.FixmedinsMdtrtID = items.OrderNumber
  1032. fsiOPFLD.MedType = pre.MedType
  1033. fsiOPFLD.FixmedinsCode = miConfig.Code
  1034. fsiOPFLD.FixmedinsName = miConfig.OrgName
  1035. fsiOPFLD.Cnt = fmt.Sprintf("%.2f", items.Cnt)
  1036. fsiOPFLD.Pric = fmt.Sprintf("%.2f", items.Pric)
  1037. fsiOPFLD.DetItemFeeSumamt = fmt.Sprintf("%.2f", items.DetItemFeeSumamt)
  1038. if items.AdviceId > 0 && items.ProjectId == 0 && items.HisDoctorAdviceInfo.BaseDrugLib.IsUser != 1 && len(items.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber) > 0 {
  1039. fsiOPFLD.FeeOcurTime = time.Unix(items.HisDoctorAdviceInfo.CreatedTime, 0).Format("2006-01-02 15:04:05")
  1040. fsiOPFLD.MedListCodg = items.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber
  1041. fsiOPFLD.BkkpSn = items.HisDoctorAdviceInfo.FeedetlSn
  1042. fsiOPFLD.MedinsListCodg = items.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber
  1043. fsiOPFLD.MedinsListName = items.HisDoctorAdviceInfo.BaseDrugLib.DrugName
  1044. fsiOPFLD.Prodname = items.HisDoctorAdviceInfo.BaseDrugLib.DrugName
  1045. fsiOPFLD.BilgDeptName = department.Name
  1046. fsiOPFLD.BilgDeptCodg = department.Number
  1047. fsiOPFLD.BilgDrCode = doctor.DoctorNumber
  1048. fsiOPFLD.BilgDrName = doctor.UserName
  1049. fsiOPFLD.MedChrgitmType = "09"
  1050. memo["hosp_appr_flag"] = "1"
  1051. memo["invoice_no"] = fapiao_code
  1052. memo["memo"] = "自费"
  1053. bytesData, _ := json.Marshal(memo)
  1054. fsiOPFLD.Memo = string(bytesData)
  1055. fsiOPFLDs = append(fsiOPFLDs, fsiOPFLD)
  1056. } else if items.AdviceId == 0 && items.ProjectId > 0 {
  1057. fsiOPFLD.BkkpSn = items.HisPrescriptionProject.FeedetlSn
  1058. if items.HisPrescriptionProject.Type == 2 && len(items.HisPrescriptionProject.HisProject.MedicalCode) > 0 {
  1059. fsiOPFLD.FeeOcurTime = time.Unix(items.HisPrescriptionProject.Ctime, 0).Format("2006-01-02 15:04:05")
  1060. fsiOPFLD.MedListCodg = items.HisPrescriptionProject.HisProject.MedicalCode
  1061. fsiOPFLD.MedinsListCodg = items.HisPrescriptionProject.HisProject.MedicalCode
  1062. fsiOPFLD.MedinsListName = items.HisPrescriptionProject.HisProject.ProjectName
  1063. fsiOPFLD.Prodname = items.HisPrescriptionProject.HisProject.ProjectName
  1064. fsiOPFLD.BilgDeptName = department.Name
  1065. fsiOPFLD.BilgDeptCodg = department.Number
  1066. fsiOPFLD.BilgDrCode = doctor.DoctorNumber
  1067. fsiOPFLD.BilgDrName = doctor.UserName
  1068. switch items.HisPrescriptionProject.HisProject.CostClassify {
  1069. case 0:
  1070. break
  1071. case 1:
  1072. fsiOPFLD.MedChrgitmType = "14"
  1073. break
  1074. case 2:
  1075. fsiOPFLD.MedChrgitmType = "05"
  1076. break
  1077. case 3:
  1078. fsiOPFLD.MedChrgitmType = "03"
  1079. break
  1080. case 4:
  1081. fsiOPFLD.MedChrgitmType = "03"
  1082. break
  1083. case 5:
  1084. fsiOPFLD.MedChrgitmType = "08"
  1085. break
  1086. case 6:
  1087. fsiOPFLD.MedChrgitmType = "14"
  1088. break
  1089. case 7:
  1090. fsiOPFLD.MedChrgitmType = "14"
  1091. break
  1092. case 8:
  1093. fsiOPFLD.MedChrgitmType = "03"
  1094. break
  1095. case 9:
  1096. fsiOPFLD.MedChrgitmType = "14"
  1097. break
  1098. case 10:
  1099. fsiOPFLD.MedChrgitmType = "14"
  1100. break
  1101. case 11:
  1102. fsiOPFLD.MedChrgitmType = "06"
  1103. break
  1104. case 12:
  1105. fsiOPFLD.MedChrgitmType = "12"
  1106. break
  1107. case 13:
  1108. fsiOPFLD.MedChrgitmType = "01"
  1109. break
  1110. case 14:
  1111. fsiOPFLD.MedChrgitmType = "04"
  1112. break
  1113. case 15:
  1114. fsiOPFLD.MedChrgitmType = "14"
  1115. break
  1116. }
  1117. memo["hosp_appr_flag"] = "1"
  1118. memo["invoice_no"] = fapiao_code
  1119. memo["memo"] = "自费"
  1120. bytesData, _ := json.Marshal(memo)
  1121. fsiOPFLD.Memo = string(bytesData)
  1122. fsiOPFLDs = append(fsiOPFLDs, fsiOPFLD)
  1123. } else if items.HisPrescriptionProject.Type == 3 && items.HisPrescriptionProject.GoodInfo.IsUser != 1 && len(items.HisPrescriptionProject.GoodInfo.MedicalInsuranceNumber) > 0 {
  1124. fsiOPFLD.FeeOcurTime = time.Unix(items.HisPrescriptionProject.Ctime, 0).Format("2006-01-02 15:04:05")
  1125. fsiOPFLD.MedListCodg = items.HisPrescriptionProject.GoodInfo.MedicalInsuranceNumber
  1126. fsiOPFLD.MedinsListCodg = items.HisPrescriptionProject.GoodInfo.MedicalInsuranceNumber
  1127. fsiOPFLD.BilgDeptName = department.Name
  1128. fsiOPFLD.BilgDeptCodg = department.Number
  1129. fsiOPFLD.BilgDrCode = doctor.DoctorNumber
  1130. fsiOPFLD.BilgDrName = doctor.UserName
  1131. fsiOPFLD.MedinsListName = items.HisPrescriptionProject.GoodInfo.GoodName
  1132. fsiOPFLD.Prodname = items.HisPrescriptionProject.GoodInfo.GoodName
  1133. fsiOPFLD.MedChrgitmType = "08"
  1134. memo["hosp_appr_flag"] = "1"
  1135. memo["invoice_no"] = fapiao_code
  1136. memo["memo"] = "自费"
  1137. bytesData, _ := json.Marshal(memo)
  1138. fsiOPFLD.Memo = string(bytesData)
  1139. fsiOPFLDs = append(fsiOPFLDs, fsiOPFLD)
  1140. }
  1141. }
  1142. }
  1143. for _, items := range order_info_two {
  1144. memo := make(map[string]interface{})
  1145. var fsiOPFLD models.FsiOwnpayPatnFeeListDDTO
  1146. fsiOPFLD.FixmedinsMdtrtID = items.OrderNumber
  1147. fsiOPFLD.MedType = pre.MedType
  1148. fsiOPFLD.BkkpSn = items.FeedetlSn
  1149. fsiOPFLD.FixmedinsCode = miConfig.Code
  1150. fsiOPFLD.FixmedinsName = miConfig.OrgName
  1151. fsiOPFLD.Cnt = fmt.Sprintf("%.2f", items.Cnt)
  1152. fsiOPFLD.Pric = fmt.Sprintf("%.2f", items.Pric)
  1153. fsiOPFLD.DetItemFeeSumamt = fmt.Sprintf("%.2f", items.DetItemFeeSumamt)
  1154. if items.AdviceId > 0 && items.ProjectId == 0 && items.HisDoctorAdviceInfo.BaseDrugLib.IsUser != 1 && len(items.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber) > 0 {
  1155. fsiOPFLD.FeeOcurTime = time.Unix(items.HisDoctorAdviceInfo.CreatedTime, 0).Format("2006-01-02 15:04:05")
  1156. fsiOPFLD.MedListCodg = items.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber
  1157. fsiOPFLD.MedinsListCodg = items.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber
  1158. fsiOPFLD.MedinsListName = items.HisDoctorAdviceInfo.BaseDrugLib.DrugName
  1159. fsiOPFLD.Prodname = items.HisDoctorAdviceInfo.BaseDrugLib.DrugName
  1160. fsiOPFLD.BilgDeptName = department.Name
  1161. fsiOPFLD.BilgDeptCodg = department.Number
  1162. fsiOPFLD.BilgDrCode = doctor.DoctorNumber
  1163. fsiOPFLD.BilgDrName = doctor.UserName
  1164. fsiOPFLD.MedChrgitmType = "09"
  1165. memo["hosp_appr_flag"] = "1"
  1166. memo["invoice_no"] = fapiao_code
  1167. memo["memo"] = "自费"
  1168. bytesData, _ := json.Marshal(memo)
  1169. fsiOPFLD.Memo = string(bytesData)
  1170. fsiOPFLDs = append(fsiOPFLDs, fsiOPFLD)
  1171. } else if items.AdviceId == 0 && items.ProjectId > 0 {
  1172. fsiOPFLD.BkkpSn = items.HisPrescriptionProject.FeedetlSn
  1173. if items.HisPrescriptionProject.Type == 2 && len(items.HisPrescriptionProject.HisProject.MedicalCode) > 0 {
  1174. fsiOPFLD.FeeOcurTime = time.Unix(items.HisPrescriptionProject.Ctime, 0).Format("2006-01-02 15:04:05")
  1175. fsiOPFLD.MedListCodg = items.HisPrescriptionProject.HisProject.MedicalCode
  1176. fsiOPFLD.MedinsListName = items.HisPrescriptionProject.HisProject.ProjectName
  1177. fsiOPFLD.Prodname = items.HisPrescriptionProject.HisProject.ProjectName
  1178. fsiOPFLD.MedinsListCodg = items.HisPrescriptionProject.HisProject.MedicalCode
  1179. fsiOPFLD.BilgDeptName = department.Name
  1180. fsiOPFLD.BilgDeptCodg = department.Number
  1181. fsiOPFLD.BilgDrCode = doctor.DoctorNumber
  1182. fsiOPFLD.BilgDrName = doctor.UserName
  1183. switch items.HisPrescriptionProject.HisProject.CostClassify {
  1184. case 0:
  1185. break
  1186. case 1:
  1187. fsiOPFLD.MedChrgitmType = "14"
  1188. break
  1189. case 2:
  1190. fsiOPFLD.MedChrgitmType = "05"
  1191. break
  1192. case 3:
  1193. fsiOPFLD.MedChrgitmType = "03"
  1194. break
  1195. case 4:
  1196. fsiOPFLD.MedChrgitmType = "03"
  1197. break
  1198. case 5:
  1199. fsiOPFLD.MedChrgitmType = "08"
  1200. break
  1201. case 6:
  1202. fsiOPFLD.MedChrgitmType = "14"
  1203. break
  1204. case 7:
  1205. fsiOPFLD.MedChrgitmType = "14"
  1206. break
  1207. case 8:
  1208. fsiOPFLD.MedChrgitmType = "03"
  1209. break
  1210. case 9:
  1211. fsiOPFLD.MedChrgitmType = "14"
  1212. break
  1213. case 10:
  1214. fsiOPFLD.MedChrgitmType = "14"
  1215. break
  1216. case 11:
  1217. fsiOPFLD.MedChrgitmType = "06"
  1218. break
  1219. case 12:
  1220. fsiOPFLD.MedChrgitmType = "12"
  1221. break
  1222. case 13:
  1223. fsiOPFLD.MedChrgitmType = "01"
  1224. break
  1225. case 14:
  1226. fsiOPFLD.MedChrgitmType = "04"
  1227. break
  1228. case 15:
  1229. fsiOPFLD.MedChrgitmType = "14"
  1230. break
  1231. }
  1232. memo["hosp_appr_flag"] = "1"
  1233. memo["invoice_no"] = fapiao_code
  1234. memo["memo"] = "自费"
  1235. bytesData, _ := json.Marshal(memo)
  1236. fsiOPFLD.Memo = string(bytesData)
  1237. fsiOPFLDs = append(fsiOPFLDs, fsiOPFLD)
  1238. } else if items.HisPrescriptionProject.Type == 3 && len(items.HisPrescriptionProject.GoodInfo.MedicalInsuranceNumber) > 0 && items.HisPrescriptionProject.GoodInfo.IsUser != 1 {
  1239. fsiOPFLD.FeeOcurTime = time.Unix(items.HisPrescriptionProject.Ctime, 0).Format("2006-01-02 15:04:05")
  1240. fsiOPFLD.MedListCodg = items.HisPrescriptionProject.GoodInfo.MedicalInsuranceNumber
  1241. fsiOPFLD.MedinsListCodg = items.HisPrescriptionProject.GoodInfo.MedicalInsuranceNumber
  1242. fsiOPFLD.BilgDeptName = department.Name
  1243. fsiOPFLD.BilgDeptCodg = department.Number
  1244. fsiOPFLD.BilgDrCode = doctor.DoctorNumber
  1245. fsiOPFLD.BilgDrName = doctor.UserName
  1246. fsiOPFLD.MedinsListName = items.HisPrescriptionProject.GoodInfo.GoodName
  1247. fsiOPFLD.Prodname = items.HisPrescriptionProject.GoodInfo.GoodName
  1248. fsiOPFLD.MedChrgitmType = "08"
  1249. memo["hosp_appr_flag"] = "1"
  1250. memo["invoice_no"] = fapiao_code
  1251. memo["memo"] = "自费"
  1252. bytesData, _ := json.Marshal(memo)
  1253. fsiOPFLD.Memo = string(bytesData)
  1254. fsiOPFLDs = append(fsiOPFLDs, fsiOPFLD)
  1255. }
  1256. }
  1257. }
  1258. fmt.Println(fsiOPFLDs)
  1259. struct4201A.Fopfd = fsiOPFLDs
  1260. fmt.Println(struct4201A.Fopfd)
  1261. var struct4202 models.Struct4202
  1262. timeLayout := "2006-01-02 15:04:05"
  1263. dataTimeStr := time.Unix(his.Ctime, 0).Format(timeLayout)
  1264. struct4202.OwnPayPatnMdtrtD.FixmedinsMdtrtID = his.Number
  1265. struct4202.OwnPayPatnMdtrtD.FixmedinsCode = miConfig.Code
  1266. struct4202.OwnPayPatnMdtrtD.FixmedinsName = miConfig.OrgName
  1267. struct4202.OwnPayPatnMdtrtD.PsnCertType = "01"
  1268. struct4202.OwnPayPatnMdtrtD.Certno = his.IdCardNo
  1269. struct4202.OwnPayPatnMdtrtD.PsnName = his.Name
  1270. struct4202.OwnPayPatnMdtrtD.Begntime = dataTimeStr
  1271. struct4202.OwnPayPatnMdtrtD.MedType = pre.MedType
  1272. struct4202.OwnPayPatnMdtrtD.ValiFlag = "1"
  1273. struct4202.OwnPayPatnMdtrtD.MedfeeSumamt = fmt.Sprintf("%.2f", order.MedfeeSumamt)
  1274. diagnosis_ids := strings.Split(his.Diagnosis, ",")
  1275. var config []*models.HisXtDiagnoseConfig
  1276. for _, item := range diagnosis_ids {
  1277. id, _ := strconv.ParseInt(item, 10, 64)
  1278. diagnosisConfig, _ := service.FindDiagnoseById(id)
  1279. config = append(config, &diagnosisConfig)
  1280. }
  1281. var tempDiaginfos []models.OwnPayPatnDiagListD
  1282. for index, item := range config {
  1283. if index == 0 {
  1284. var tempDiaginfo models.OwnPayPatnDiagListD
  1285. tempDiaginfo.InoutDiagType = "1"
  1286. tempDiaginfo.DiagCode = item.CountryCode
  1287. tempDiaginfo.DiagName = item.CountryContentName
  1288. tempDiaginfo.DiagType = "1"
  1289. tempDiaginfo.DiagSrtNo = "1"
  1290. tempDiaginfo.MaindiagFlag = "1"
  1291. tempDiaginfo.ValiFlag = "1"
  1292. tempDiaginfo.DiagDrName = doctor.UserName
  1293. tempDiaginfo.DiagDrCode = doctor.DoctorNumber
  1294. tempDiaginfo.DiagTime = time.Unix(pre.Ctime, 0).Format("2006-01-02 15:04:05")
  1295. tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  1296. } else {
  1297. var tempDiaginfo models.OwnPayPatnDiagListD
  1298. tempDiaginfo.DiagCode = item.CountryCode
  1299. tempDiaginfo.DiagName = item.CountryContentName
  1300. tempDiaginfo.DiagType = "2"
  1301. tempDiaginfo.DiagSrtNo = strconv.FormatInt(int64(index+1), 10)
  1302. tempDiaginfo.MaindiagFlag = "0"
  1303. tempDiaginfo.ValiFlag = "1"
  1304. tempDiaginfo.DiagDrName = doctor.UserName
  1305. tempDiaginfo.DiagDrCode = doctor.DoctorNumber
  1306. tempDiaginfo.DiagTime = time.Unix(pre.Ctime, 0).Format("2006-01-02 15:04:05")
  1307. tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  1308. }
  1309. }
  1310. struct4202.ODiagListD = tempDiaginfos
  1311. result, requestLog := service.Gdyb4205(miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, struct4202, struct4201A)
  1312. saveLog(result, requestLog, "4205", "自费就诊和诊断信息上传")
  1313. var res2 ResultSix
  1314. var respJSON2 map[string]interface{}
  1315. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  1316. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  1317. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1318. return
  1319. }
  1320. userJSONBytes2, _ := json.Marshal(respJSON2)
  1321. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  1322. utils.ErrorLog("解析失败:%v", err)
  1323. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1324. return
  1325. }
  1326. if res2.Infcode != 0 {
  1327. c.ServeSuccessJSON(map[string]interface{}{
  1328. "failed_code": -10,
  1329. "msg": res2.ErrMsg,
  1330. })
  1331. return
  1332. } else {
  1333. order.IsUploadDiagnose = 1
  1334. order.IsUploadOrderInfo = 1
  1335. service.UpdateOrderTwo(order)
  1336. c.ServeSuccessJSON(map[string]interface{}{
  1337. "msg": "上传成功",
  1338. })
  1339. }
  1340. }
  1341. func (c *HisApiController) Get4207() {
  1342. admin_user_id, _ := c.GetInt64("admin_user_id")
  1343. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  1344. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  1345. order_id, _ := c.GetInt64("order_id")
  1346. order, _ := service.GetHisOrderByIDTwo(order_id)
  1347. //his, _ := service.GetInHospitalRecordByNumber(order.MdtrtId)
  1348. var struct4207 models.Struct4207
  1349. struct4207.PageNum = "1"
  1350. struct4207.PageSize = "1000"
  1351. struct4207.FixmedinsCode = miConfig.Code
  1352. struct4207.FixmedinsMdtrtID = order.Number
  1353. result, requestLog := service.Gdyb4207(miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, struct4207)
  1354. saveLog(result, requestLog, "4207", "查询")
  1355. var res2 ResultSix
  1356. var respJSON2 map[string]interface{}
  1357. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  1358. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  1359. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1360. return
  1361. }
  1362. userJSONBytes2, _ := json.Marshal(respJSON2)
  1363. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  1364. utils.ErrorLog("解析失败:%v", err)
  1365. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1366. return
  1367. }
  1368. if res2.Infcode != 0 {
  1369. c.ServeSuccessJSON(map[string]interface{}{
  1370. "failed_code": -10,
  1371. "msg": res2.ErrMsg,
  1372. })
  1373. return
  1374. } else {
  1375. c.ServeSuccessJSON(map[string]interface{}{
  1376. "msg": "查询成功",
  1377. })
  1378. }
  1379. }
  1380. func (c *HisApiController) Get4208() {
  1381. admin_user_id, _ := c.GetInt64("admin_user_id")
  1382. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  1383. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  1384. order_id, _ := c.GetInt64("order_id")
  1385. order, _ := service.GetHisOrderByIDTwo(order_id)
  1386. his, _ := service.GetInHospitalRecordByNumber(order.MdtrtId)
  1387. var struct4208 models.Struct4208
  1388. struct4208.PageNum = "1"
  1389. struct4208.PageSize = "1000"
  1390. struct4208.PsnCertType = "01"
  1391. struct4208.Certno = his.Certno
  1392. struct4208.MedType = order.MedType
  1393. struct4208.PsnName = his.Name
  1394. result, requestLog := service.Gdyb4208(miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, struct4208)
  1395. saveLog(result, requestLog, "4208", "查询")
  1396. var res2 ResultSix
  1397. var respJSON2 map[string]interface{}
  1398. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  1399. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  1400. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1401. return
  1402. }
  1403. userJSONBytes2, _ := json.Marshal(respJSON2)
  1404. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  1405. utils.ErrorLog("解析失败:%v", err)
  1406. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1407. return
  1408. }
  1409. if res2.Infcode != 0 {
  1410. c.ServeSuccessJSON(map[string]interface{}{
  1411. "failed_code": -10,
  1412. "msg": res2.ErrMsg,
  1413. })
  1414. return
  1415. } else {
  1416. c.ServeSuccessJSON(map[string]interface{}{
  1417. "msg": "查询成功",
  1418. })
  1419. }
  1420. }
  1421. func (c *HisApiController) Get4209() {
  1422. admin_user_id, _ := c.GetInt64("admin_user_id")
  1423. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  1424. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  1425. order_id, _ := c.GetInt64("order_id")
  1426. order, _ := service.GetHisOrderByIDTwo(order_id)
  1427. //his, _ := service.GetInHospitalRecordByNumber(order.MdtrtId)
  1428. var struct4209 models.Struct4209
  1429. struct4209.FixmedinsMdtrtID = order.Number
  1430. struct4209.FixmedinsCode = miConfig.Code
  1431. struct4209.PageSize = "1000"
  1432. struct4209.PageNum = "1"
  1433. result, requestLog := service.Gdyb4209(miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, struct4209)
  1434. saveLog(result, requestLog, "4209", "查询")
  1435. var res2 ResultSix
  1436. var respJSON2 map[string]interface{}
  1437. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  1438. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  1439. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1440. return
  1441. }
  1442. userJSONBytes2, _ := json.Marshal(respJSON2)
  1443. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  1444. utils.ErrorLog("解析失败:%v", err)
  1445. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1446. return
  1447. }
  1448. if res2.Infcode != 0 {
  1449. c.ServeSuccessJSON(map[string]interface{}{
  1450. "failed_code": -10,
  1451. "msg": res2.ErrMsg,
  1452. })
  1453. return
  1454. } else {
  1455. c.ServeSuccessJSON(map[string]interface{}{
  1456. "msg": "查询成功",
  1457. })
  1458. }
  1459. }
  1460. type Result3101 struct {
  1461. Infcode string `json:"infcode"`
  1462. InfRefmsgid string `json:"inf_refmsgid"`
  1463. RefmsgTime string `json:"refmsg_time"`
  1464. RespondTime string `json:"respond_time"`
  1465. Enctype string `json:"enctype"`
  1466. Signtype string `json:"signtype"`
  1467. ErrMsg string `json:"err_msg"`
  1468. Output struct {
  1469. Result []struct {
  1470. JudgeResultDetailDtos []struct {
  1471. VolaItemType string `json:"vola_item_type"`
  1472. MdtrtID string `json:"mdtrt_id"`
  1473. JrdID string `json:"jrd_id"`
  1474. PatnID string `json:"patn_id"`
  1475. RxID string `json:"rx_id"`
  1476. VolaAmt interface{} `json:"vola_amt"`
  1477. } `json:"judge_result_detail_dtos"`
  1478. RuleID string `json:"rule_id"`
  1479. VolaEvid string `json:"vola_evid"`
  1480. MdtrtID string `json:"mdtrt_id"`
  1481. RuleName string `json:"rule_name"`
  1482. VolaAmtStas string `json:"vola_amt_stas"`
  1483. JrID string `json:"jr_id"`
  1484. PatnID string `json:"patn_id"`
  1485. SevDeg string `json:"sev_deg"`
  1486. VolaAmt float64 `json:"vola_amt"`
  1487. VolaBhvrType string `json:"vola_bhvr_type"`
  1488. VolaCont string `json:"vola_cont"`
  1489. } `json:"result"`
  1490. } `json:"output"`
  1491. }
  1492. func (c *HisApiController) ReadEleToken() {
  1493. admin_user_id, _ := c.GetInt64("admin_user_id")
  1494. his_patient_id, _ := c.GetInt64("his_patient_id")
  1495. adminUser := c.GetAdminUserInfo()
  1496. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  1497. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  1498. his, _ := service.GetNewHisPatientInfoFour(c.GetAdminUserInfo().CurrentOrgId, his_patient_id)
  1499. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  1500. tokens := ReadEleCard(admin_user_id, c.GetAdminUserInfo().CurrentOrgId, c)
  1501. if len(tokens) > 0 {
  1502. c.ServeSuccessJSON(map[string]interface{}{
  1503. "msg": "读取成功",
  1504. })
  1505. } else {
  1506. c.ServeSuccessJSON(map[string]interface{}{
  1507. "failed_code": -10,
  1508. "msg": "读取失败",
  1509. })
  1510. }
  1511. } else if miConfig.MdtrtareaAdmvs == "350500" {
  1512. _, outPutInfo, errMsg := service.ReadEleCardForSettle(miConfig.Code, roles.UserName, roles.AdminUserId)
  1513. if len(errMsg) == 0 {
  1514. type ELeData struct {
  1515. Data struct {
  1516. IdNo string `json:"idNo"`
  1517. IdType string `json:"idType"`
  1518. UserName string `json:"userName"`
  1519. EcToken string `json:"ecToken"`
  1520. InsuOrg string `json:"insuOrg"`
  1521. Gender string `json:"gender"`
  1522. Birthday string `json:"birthday"`
  1523. Nationality string `json:"nationality"`
  1524. Email string `json:"email"`
  1525. Extra string `json:"extra"`
  1526. } `json:"data"`
  1527. Code int `json:"code"`
  1528. Message string `json:"message"`
  1529. }
  1530. var ele ELeData
  1531. err := json.Unmarshal([]byte(outPutInfo), &ele)
  1532. if err != nil {
  1533. utils.ErrorLog("解析失败:%v", err)
  1534. }
  1535. token := ele.Data.EcToken
  1536. if len(token) > 0 {
  1537. psn := &models.HisPsn{
  1538. PsnNo: his.PsnNo,
  1539. Age: 0,
  1540. PatientId: his.PatientId,
  1541. Certno: his.Certno,
  1542. Brdy: his.Brdy,
  1543. Gend: his.Gend,
  1544. Naty: his.Naty,
  1545. PsnCertType: his.PsnCertType,
  1546. PsnName: his.PsnName,
  1547. Idetinfo: his.Idetinfo,
  1548. Insuinfo: his.Iinfo,
  1549. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  1550. CardInfo: outPutInfo,
  1551. VerifyNumber: token,
  1552. }
  1553. service.CreateHisPsn(psn)
  1554. }
  1555. if len(token) > 0 {
  1556. c.ServeSuccessJSON(map[string]interface{}{
  1557. "msg": "读取成功",
  1558. })
  1559. } else {
  1560. c.ServeSuccessJSON(map[string]interface{}{
  1561. "failed_code": -10,
  1562. "msg": "读取失败",
  1563. })
  1564. }
  1565. }
  1566. } else if miConfig.MdtrtareaAdmvs == "360399" {
  1567. if initFlag == 0 {
  1568. c.TestGetJiangXiBasBaseInit()
  1569. }
  1570. json_result := GetJxEleBaseInfo(c.GetAdminUserInfo().CurrentOrgId)
  1571. type ELeData struct {
  1572. Data struct {
  1573. IdNo string `json:"idNo"`
  1574. IdType string `json:"idType"`
  1575. UserName string `json:"userName"`
  1576. EcToken string `json:"ecToken"`
  1577. InsuOrg string `json:"insuOrg"`
  1578. Gender string `json:"gender"`
  1579. Birthday string `json:"birthday"`
  1580. Nationality string `json:"nationality"`
  1581. Email string `json:"email"`
  1582. Extra string `json:"extra"`
  1583. } `json:"data"`
  1584. Code int `json:"code"`
  1585. Message string `json:"message"`
  1586. }
  1587. var ele ELeData
  1588. err := json.Unmarshal([]byte(json_result), &ele)
  1589. if err != nil {
  1590. utils.ErrorLog("解析失败:%v", err)
  1591. }
  1592. token := ele.Data.EcToken
  1593. token = Remove0000(token)
  1594. fmt.Println(ele.Data.UserName)
  1595. 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)
  1596. saveLog(result2, requestLog2, "1101", "获取人员信息")
  1597. var res ResultTwo
  1598. if err := json.Unmarshal([]byte(result2), &res); err != nil {
  1599. utils.ErrorLog("解析失败:%v", err)
  1600. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1601. return
  1602. }
  1603. if res.Infcode == 0 {
  1604. patient, err := service.GetPatientByNumber(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  1605. if err == gorm.ErrRecordNotFound {
  1606. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  1607. return
  1608. } else if err != nil {
  1609. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  1610. return
  1611. } else {
  1612. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  1613. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  1614. infoStr := string(Iinfos)
  1615. idetinfoStr := string(Idetinfos)
  1616. psn := &models.HisPsn{
  1617. PsnNo: res.Output.Baseinfo.PsnNo,
  1618. Age: res.Output.Baseinfo.Age,
  1619. PatientId: patient.ID,
  1620. Certno: res.Output.Baseinfo.Certno,
  1621. Brdy: res.Output.Baseinfo.Brdy,
  1622. Gend: res.Output.Baseinfo.Gend,
  1623. Naty: res.Output.Baseinfo.Naty,
  1624. PsnCertType: res.Output.Baseinfo.PsnCertType,
  1625. PsnName: res.Output.Baseinfo.PsnName,
  1626. Idetinfo: idetinfoStr,
  1627. Insuinfo: infoStr,
  1628. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  1629. CardInfo: "",
  1630. VerifyNumber: token,
  1631. }
  1632. service.CreateHisPsn(psn)
  1633. c.ServeSuccessJSON(map[string]interface{}{
  1634. "patient": patient,
  1635. "number": token,
  1636. })
  1637. }
  1638. } else {
  1639. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  1640. return
  1641. }
  1642. } else if miConfig.MdtrtareaAdmvs == "430800" {
  1643. idNo := c.GetString("idNo")
  1644. userName := c.GetString("userName")
  1645. ecToken := c.GetString("ecToken")
  1646. insuOrg := c.GetString("insuOrg")
  1647. result2, requestLog2 := service.Hnyb1101ForEleCert(miConfig.OrgName, roles.UserName, miConfig.Code, insuOrg, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, miConfig.Url, miConfig.AccessKey, ecToken, "", idNo, userName)
  1648. saveLog(result2, requestLog2, "1101", "获取人员信息")
  1649. var res ResultTwo
  1650. if err := json.Unmarshal([]byte(result2), &res); err != nil {
  1651. utils.ErrorLog("解析失败:%v", err)
  1652. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1653. return
  1654. }
  1655. if res.Infcode == 0 {
  1656. patient, err := service.GetPatientByNumber(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  1657. if err == gorm.ErrRecordNotFound {
  1658. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  1659. return
  1660. } else if err != nil {
  1661. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  1662. return
  1663. } else {
  1664. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  1665. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  1666. infoStr := string(Iinfos)
  1667. idetinfoStr := string(Idetinfos)
  1668. psn := &models.HisPsn{
  1669. PsnNo: res.Output.Baseinfo.PsnNo,
  1670. Age: res.Output.Baseinfo.Age,
  1671. PatientId: patient.ID,
  1672. Certno: res.Output.Baseinfo.Certno,
  1673. Brdy: res.Output.Baseinfo.Brdy,
  1674. Gend: res.Output.Baseinfo.Gend,
  1675. Naty: res.Output.Baseinfo.Naty,
  1676. PsnCertType: res.Output.Baseinfo.PsnCertType,
  1677. PsnName: res.Output.Baseinfo.PsnName,
  1678. Idetinfo: idetinfoStr,
  1679. Insuinfo: infoStr,
  1680. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  1681. CardInfo: "",
  1682. VerifyNumber: ecToken,
  1683. InsuplcAdmdvs: insuOrg,
  1684. }
  1685. service.CreateHisPsn(psn)
  1686. c.ServeSuccessJSON(map[string]interface{}{
  1687. "patient": patient,
  1688. "number": ecToken,
  1689. })
  1690. }
  1691. } else {
  1692. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  1693. return
  1694. }
  1695. } else {
  1696. //if initFlag == 0 {
  1697. // c.TestGetBasBaseInit()
  1698. //}
  1699. //token := c.GetEleBaseInfo()
  1700. //token = Remove0000(token)
  1701. type ELeData struct {
  1702. Code string `json:"code"`
  1703. Data struct {
  1704. Aac002 string `json:"aac002"`
  1705. Aaz500 string `json:"aaz500"`
  1706. ActCardNo string `json:"actCardNo"`
  1707. Bab520 string `json:"bab520"`
  1708. Bkz543 string `json:"bkz543"`
  1709. BusinessType string `json:"businessType"`
  1710. CertfCodg string `json:"certfCodg"`
  1711. EcIndexNo string `json:"ecIndexNo"`
  1712. EcToken string `json:"ecToken"`
  1713. ID0000 string `json:"id0000"`
  1714. IDNo string `json:"idNo"`
  1715. IDType string `json:"idType"`
  1716. Idcode string `json:"idcode"`
  1717. IdentityToken string `json:"identity_token"`
  1718. InsuOrg string `json:"insuOrg"`
  1719. OfficeID string `json:"officeId"`
  1720. OfficeName string `json:"officeName"`
  1721. OperatorID string `json:"operatorId"`
  1722. OperatorName string `json:"operatorName"`
  1723. OrgID string `json:"orgId"`
  1724. UserName string `json:"userName"`
  1725. } `json:"data"`
  1726. Infno interface{} `json:"infno"`
  1727. Message string `json:"message"`
  1728. OrgID string `json:"orgId"`
  1729. TransType string `json:"transType"`
  1730. }
  1731. _, result := GetELeInfoThree(miConfig.Code, "1", roles.UserName)
  1732. fmt.Println(result)
  1733. outPutInfo := Remove0000(result)
  1734. fmt.Println(outPutInfo)
  1735. var ele ELeData
  1736. err := json.Unmarshal([]byte(outPutInfo), &ele)
  1737. if err != nil {
  1738. utils.ErrorLog("解析失败:%v", err)
  1739. }
  1740. token := ele.Data.EcToken
  1741. if len(token) > 0 {
  1742. result2, requestLog2 := service.Gdyb1101ForEleCerttwo(miConfig.OrgName, roles.UserName, miConfig.Code, ele.Data.InsuOrg, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, token, ele.Data.UserName, ele.Data.IDNo)
  1743. saveLog(result2, requestLog2, "1101", "获取人员信息")
  1744. var res ResultTwo
  1745. if err := json.Unmarshal([]byte(result2), &res); err != nil {
  1746. utils.ErrorLog("解析失败:%v", err)
  1747. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1748. return
  1749. }
  1750. if res.Infcode == 0 {
  1751. patient, err := service.GetPatientByNumber(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  1752. if err == gorm.ErrRecordNotFound {
  1753. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  1754. return
  1755. } else if err != nil {
  1756. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  1757. return
  1758. } else {
  1759. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  1760. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  1761. infoStr := string(Iinfos)
  1762. idetinfoStr := string(Idetinfos)
  1763. psn := &models.HisPsn{
  1764. PsnNo: res.Output.Baseinfo.PsnNo,
  1765. Age: res.Output.Baseinfo.Age,
  1766. PatientId: patient.ID,
  1767. Certno: res.Output.Baseinfo.Certno,
  1768. Brdy: res.Output.Baseinfo.Brdy,
  1769. Gend: res.Output.Baseinfo.Gend,
  1770. Naty: res.Output.Baseinfo.Naty,
  1771. PsnCertType: res.Output.Baseinfo.PsnCertType,
  1772. PsnName: res.Output.Baseinfo.PsnName,
  1773. Idetinfo: idetinfoStr,
  1774. Insuinfo: infoStr,
  1775. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  1776. CardInfo: "",
  1777. VerifyNumber: token,
  1778. }
  1779. service.CreateHisPsn(psn)
  1780. c.ServeSuccessJSON(map[string]interface{}{
  1781. "msg": "读取成功",
  1782. })
  1783. }
  1784. } else {
  1785. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  1786. return
  1787. }
  1788. } else {
  1789. c.ServeSuccessJSON(map[string]interface{}{
  1790. "failed_code": -10,
  1791. "msg": "读取失败",
  1792. })
  1793. }
  1794. }
  1795. }
  1796. func (c *HisApiController) Get9001() {
  1797. adminUser := c.GetAdminUserInfo()
  1798. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  1799. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, 185)
  1800. if miConfig.MdtrtareaAdmvs == "350500" {
  1801. service.GetFjAuthorizationInfo(miConfig.Code)
  1802. } else if miConfig.MdtrtareaAdmvs == "131023" {
  1803. result, _ := service.HeBeiyb9001(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, 1669)
  1804. var dat map[string]interface{}
  1805. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  1806. fmt.Println(dat)
  1807. } else {
  1808. fmt.Println(err)
  1809. }
  1810. userJSONBytes, _ := json.Marshal(dat)
  1811. var res models.Result9001
  1812. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  1813. utils.ErrorLog("解析失败:%v", err)
  1814. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1815. return
  1816. }
  1817. } else {
  1818. result, _ := service.Gdyb9001(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, 1669)
  1819. var dat map[string]interface{}
  1820. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  1821. fmt.Println(dat)
  1822. } else {
  1823. fmt.Println(err)
  1824. }
  1825. userJSONBytes, _ := json.Marshal(dat)
  1826. var res models.Result9001
  1827. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  1828. utils.ErrorLog("解析失败:%v", err)
  1829. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1830. return
  1831. }
  1832. }
  1833. }
  1834. 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) {
  1835. var res Result3101
  1836. adminUser := c.GetAdminUserInfo()
  1837. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  1838. //his, _ := service.GetNewHisPatientInfoFour(c.GetAdminUserInfo().CurrentOrgId, his_patient_id)
  1839. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  1840. //record_time := c.GetString("record_time")
  1841. //trig_scen := c.GetString("trig_scen")
  1842. timeLayout := "2006-01-02"
  1843. loc, _ := time.LoadLocation("Local")
  1844. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  1845. if err != nil {
  1846. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  1847. return res
  1848. }
  1849. recordDateTime := theTime.Unix()
  1850. var patientPrescription models.HisPrescriptionInfo
  1851. //patientPrescription, _ = service.FindHisPatientPrescriptionInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  1852. //if patientPrescription.ID == 0 {
  1853. patientPrescription, _ = service.FindLastPatientPrescriptionInfoTwo(adminUser.CurrentOrgId, patient_id, recordDateTime)
  1854. //}
  1855. department, _ := service.GetDepartMentDetail(patientPrescription.Departments)
  1856. doctor_info, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, patientPrescription.DoctorId)
  1857. //
  1858. diagnosis_ids := strings.Split(patientPrescription.Diagnosis, ",")
  1859. //prescriptions, _ := service.GetNewHisPrescriptionTen(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  1860. var pp models.PublicParams
  1861. pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  1862. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  1863. pp.FixmedinsName = miConfig.OrgName
  1864. pp.FixmedinsCode = miConfig.Code
  1865. pp.RequestUrl = miConfig.Url
  1866. pp.Cainfo = miConfig.Cainfo
  1867. pp.SecretKey = miConfig.SecretKey
  1868. pp.AccessKey = miConfig.AccessKey
  1869. pp.OpterName = roles.UserName
  1870. var config []*models.HisXtDiagnoseConfig
  1871. for _, item := range diagnosis_ids {
  1872. id, _ := strconv.ParseInt(item, 10, 64)
  1873. diagnosisConfig, _ := service.FindDiagnoseById(id)
  1874. config = append(config, &diagnosisConfig)
  1875. }
  1876. var pd models.PatientDtos
  1877. pd.PatnID = his.PsnNo
  1878. pd.PatnName = his.Name
  1879. pd.Gend = his.Gend
  1880. pd.Brdy = his.Brdy
  1881. pd.Poolarea = miConfig.MdtrtareaAdmvs
  1882. pd.CurrMdtrtID = his.Number
  1883. var fed models.FsiEncounterDtos
  1884. fed.MdtrtID = his.Number
  1885. fed.MedinsID = miConfig.Code
  1886. fed.MedinsName = miConfig.OrgName
  1887. fed.MedinsAdmdvs = miConfig.MdtrtareaAdmvs
  1888. fed.MedMdtrtType = "1"
  1889. fed.MedinsType = "1"
  1890. fed.MedinsLv = "11"
  1891. tm := time.Unix(his.RecordDate, 0)
  1892. s_tm := tm.Format("2006-01-02 15:04:05")
  1893. fed.AdmDate = s_tm
  1894. fed.DscgDate = s_tm
  1895. fed.DscgMainDiseCodg = config[0].CountryCode
  1896. fed.DscgMainDiseName = config[0].CountryContentName
  1897. //诊断信息
  1898. var fdds []*models.FsiDiagnoseDtos
  1899. for index, item := range config {
  1900. if index == 0 {
  1901. var fdd models.FsiDiagnoseDtos
  1902. fdd.DiseID = strconv.FormatInt(item.ID, 10)
  1903. fdd.InoutDiseType = "1"
  1904. fdd.MaindiseFlag = "1"
  1905. fdd.DiseDate = s_tm
  1906. fdd.DiasSrtNo = "1"
  1907. fdd.DiseName = item.CountryContentName
  1908. fdd.DiseCodg = item.CountryCode
  1909. fdds = append(fdds, &fdd)
  1910. } else {
  1911. var fdd models.FsiDiagnoseDtos
  1912. fdd.DiseID = strconv.FormatInt(item.ID, 10)
  1913. fdd.InoutDiseType = "1"
  1914. fdd.MaindiseFlag = "1"
  1915. fdd.DiseDate = s_tm
  1916. fdd.DiasSrtNo = strconv.FormatInt(int64(index), 10)
  1917. fdd.DiseName = item.CountryContentName
  1918. fdd.DiseCodg = item.CountryCode
  1919. fdds = append(fdds, &fdd)
  1920. }
  1921. }
  1922. fed.DrCodg = strconv.FormatInt(doctor_info.ID, 10)
  1923. fed.AdmDeptCodg = strconv.FormatInt(department.ID, 10)
  1924. fed.AdmDeptName = department.Name
  1925. fed.DscgDeptCodg = strconv.FormatInt(department.ID, 10)
  1926. fed.DscgDeptName = department.Name
  1927. fed.MedMdtrtType = "1"
  1928. fed.MedType = "11"
  1929. //if his.Insutype == "390" {
  1930. // fed.MedType = "1402"
  1931. //} else {
  1932. // fed.MedType = "9933"
  1933. //}
  1934. var orders []*models.FsiOrderDtos
  1935. if trig_scen == "2" {
  1936. //处方医嘱信息
  1937. for _, item := range prescriptions {
  1938. for _, subItem := range item.HisDoctorAdviceInfo {
  1939. var order models.FsiOrderDtos
  1940. order.RxID = strconv.FormatInt(item.ID, 10)
  1941. order.Rxno = strconv.FormatInt(item.ID, 10)
  1942. order.LongDrordFlag = "0"
  1943. order.HilistType = "1"
  1944. order.ChrgType = "1"
  1945. order.DrordBhvr = "-"
  1946. order.HilistCode = subItem.BaseDrugLib.MedicalInsuranceNumber
  1947. order.HosplistName = subItem.BaseDrugLib.DrugName
  1948. order.HilistLv = "1"
  1949. order.HilistPric = fmt.Sprintf("%.2f", subItem.Price)
  1950. order.HosplistCode = subItem.BaseDrugLib.MedicalInsuranceNumber
  1951. order.HosplistName = subItem.BaseDrugLib.DrugName
  1952. order.Cnt = fmt.Sprintf("%.2f", subItem.PrescribingNumber)
  1953. order.Pric = fmt.Sprintf("%.2f", subItem.Price)
  1954. order.Sumamt = fmt.Sprintf("%.2f", (subItem.PrescribingNumber * subItem.Price))
  1955. order.OwnpayAmt = ""
  1956. order.SelfpayAmt = ""
  1957. order.Spec = ""
  1958. order.SpecUnt = ""
  1959. order.DrordBegnDate = s_tm
  1960. order.DrordStopDate = ""
  1961. order.DrordDrCodg = "1"
  1962. order.DrordDeptName = department.Name
  1963. order.DrordDrCodg = "1"
  1964. order.DrordDrName = doctor_info.UserName
  1965. order.DrordDrProfttl = ""
  1966. order.CurrDrordFlag = "1"
  1967. orders = append(orders, &order)
  1968. }
  1969. for _, subItem := range item.HisPrescriptionProject {
  1970. if subItem.Type == 2 {
  1971. var order models.FsiOrderDtos
  1972. order.RxID = strconv.FormatInt(item.ID, 10)
  1973. order.Rxno = strconv.FormatInt(item.ID, 10)
  1974. order.LongDrordFlag = "0"
  1975. order.HilistType = "1"
  1976. order.ChrgType = "1"
  1977. order.DrordBhvr = "-"
  1978. order.HilistCode = subItem.HisProject.MedicalCode
  1979. order.HosplistName = subItem.HisProject.ProjectName
  1980. order.HilistLv = "1"
  1981. order.HilistPric = fmt.Sprintf("%.2f", subItem.Price)
  1982. order.HosplistCode = subItem.HisProject.MedicalCode
  1983. order.HosplistName = subItem.HisProject.ProjectName
  1984. order.Cnt = subItem.Count
  1985. cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  1986. order.Pric = fmt.Sprintf("%.2f", subItem.Price)
  1987. order.Sumamt = fmt.Sprintf("%.2f", subItem.Price*cnt)
  1988. order.OwnpayAmt = ""
  1989. order.SelfpayAmt = ""
  1990. order.Spec = ""
  1991. order.SpecUnt = ""
  1992. order.DrordBegnDate = s_tm
  1993. order.DrordStopDate = ""
  1994. order.DrordDrCodg = "1"
  1995. order.DrordDeptName = department.Name
  1996. order.DrordDrCodg = "1"
  1997. order.DrordDrName = doctor_info.UserName
  1998. order.DrordDrProfttl = ""
  1999. order.CurrDrordFlag = "1"
  2000. orders = append(orders, &order)
  2001. }
  2002. if subItem.Type == 3 {
  2003. var order models.FsiOrderDtos
  2004. order.RxID = strconv.FormatInt(item.ID, 10)
  2005. order.Rxno = strconv.FormatInt(item.ID, 10)
  2006. order.LongDrordFlag = "0"
  2007. order.HilistType = "1"
  2008. order.ChrgType = "1"
  2009. order.DrordBhvr = "-"
  2010. order.HilistCode = subItem.GoodInfo.MedicalInsuranceNumber
  2011. order.HosplistName = subItem.GoodInfo.GoodName
  2012. order.HilistLv = "1"
  2013. order.HilistPric = fmt.Sprintf("%.2f", subItem.Price)
  2014. order.HosplistCode = subItem.GoodInfo.MedicalInsuranceNumber
  2015. order.HosplistName = subItem.GoodInfo.GoodName
  2016. order.Cnt = subItem.Count
  2017. cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  2018. order.Pric = fmt.Sprintf("%.2f", subItem.Price)
  2019. order.Sumamt = fmt.Sprintf("%.2f", subItem.Price*cnt)
  2020. order.OwnpayAmt = ""
  2021. order.SelfpayAmt = ""
  2022. order.Spec = ""
  2023. order.SpecUnt = ""
  2024. order.DrordBegnDate = s_tm
  2025. order.DrordStopDate = ""
  2026. order.DrordDrCodg = "1"
  2027. order.DrordDeptName = department.Name
  2028. order.DrordDrCodg = "1"
  2029. order.DrordDrName = doctor_info.UserName
  2030. order.DrordDrProfttl = ""
  2031. order.CurrDrordFlag = "1"
  2032. orders = append(orders, &order)
  2033. }
  2034. }
  2035. }
  2036. //处方医嘱信息
  2037. }
  2038. fed.MatnStas = "0"
  2039. fed.MedfeeSumamt = "0"
  2040. fed.OwnpayAmt = "0"
  2041. fed.SelfpayAmt = "0"
  2042. fed.AcctPayamt = "0"
  2043. fed.MaAmt = "0"
  2044. fed.HifpPayamt = "0"
  2045. fed.SetlTotlnum = "1"
  2046. fed.Insutype = his.Insutype
  2047. fed.ReimFlag = "0"
  2048. fed.OutSetlFlag = "0"
  2049. var fopd []*models.FsiOperationDtosData
  2050. data := make(map[string]interface{})
  2051. data["fed"] = fed
  2052. data["fdd"] = fdds
  2053. data["fod"] = orders
  2054. data["pd"] = pd
  2055. data["pp"] = pp
  2056. data["fopd"] = fopd
  2057. data["trig_scen"] = trig_scen
  2058. fmt.Println(data)
  2059. fmt.Println(fed)
  2060. fmt.Println(fdds)
  2061. fmt.Println(orders)
  2062. fmt.Println(pd)
  2063. fmt.Println(pp)
  2064. fmt.Println(fopd)
  2065. client := &http.Client{}
  2066. bytesData, _ := json.Marshal(data)
  2067. var req *http.Request
  2068. if miConfig.MdtrtareaAdmvs == "320921" {
  2069. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3101", bytes.NewReader(bytesData))
  2070. } else {
  2071. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3101", bytes.NewReader(bytesData))
  2072. }
  2073. resp, _ := client.Do(req)
  2074. defer resp.Body.Close()
  2075. body, ioErr := ioutil.ReadAll(resp.Body)
  2076. if ioErr != nil {
  2077. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  2078. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2079. return res
  2080. }
  2081. var respJSON map[string]interface{}
  2082. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  2083. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  2084. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2085. return res
  2086. }
  2087. respJSON = respJSON["data"].(map[string]interface{})["request_log"].(map[string]interface{})
  2088. fmt.Println(respJSON)
  2089. result, _ := json.Marshal(respJSON)
  2090. fmt.Println(result)
  2091. if err := json.Unmarshal([]byte(result), &res); err != nil {
  2092. utils.ErrorLog("解析失败:%v", err)
  2093. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2094. return res
  2095. }
  2096. return res
  2097. }
  2098. 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) {
  2099. adminUser := c.GetAdminUserInfo()
  2100. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  2101. his, _ := service.GetNewHisPatientInfoFour(c.GetAdminUserInfo().CurrentOrgId, his_patient_id)
  2102. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  2103. //record_time := c.GetString("record_time")
  2104. //trig_scen := c.GetString("trig_scen")
  2105. timeLayout := "2006-01-02"
  2106. loc, _ := time.LoadLocation("Local")
  2107. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  2108. if err != nil {
  2109. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  2110. return res
  2111. }
  2112. recordDateTime := theTime.Unix()
  2113. var patientPrescription models.HisPrescriptionInfo
  2114. patientPrescription, _ = service.FindHisPatientPrescriptionInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  2115. if patientPrescription.ID == 0 {
  2116. patientPrescription, _ = service.FindLastPatientPrescriptionInfo(adminUser.CurrentOrgId, patient_id, recordDateTime)
  2117. }
  2118. department, _ := service.GetDepartMentDetail(patientPrescription.Departments)
  2119. doctor_info, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, patientPrescription.DoctorId)
  2120. //
  2121. diagnosis_ids := strings.Split(patientPrescription.Diagnosis, ",")
  2122. //prescriptions, _ := service.GetNewHisPrescriptionTen(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  2123. var pp models.PublicParams
  2124. pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  2125. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  2126. pp.FixmedinsName = miConfig.OrgName
  2127. pp.FixmedinsCode = miConfig.Code
  2128. pp.RequestUrl = miConfig.Url
  2129. pp.Cainfo = miConfig.Cainfo
  2130. pp.SecretKey = miConfig.SecretKey
  2131. pp.AccessKey = miConfig.AccessKey
  2132. pp.OpterName = roles.UserName
  2133. var config []*models.HisXtDiagnoseConfig
  2134. for _, item := range diagnosis_ids {
  2135. id, _ := strconv.ParseInt(item, 10, 64)
  2136. diagnosisConfig, _ := service.FindDiagnoseById(id)
  2137. config = append(config, &diagnosisConfig)
  2138. }
  2139. var pd models.PatientDtos
  2140. pd.PatnID = his.PsnNo
  2141. pd.PatnName = his.Name
  2142. pd.Gend = his.Gend
  2143. pd.Brdy = his.Brdy
  2144. pd.Poolarea = his.InsuplcAdmdvs
  2145. pd.CurrMdtrtID = his.Number
  2146. var fed models.FsiEncounterDtos
  2147. fed.MdtrtID = his.Number
  2148. fed.MedinsID = miConfig.Code
  2149. fed.MedinsName = miConfig.OrgName
  2150. fed.MedinsAdmdvs = miConfig.MdtrtareaAdmvs
  2151. fed.MedMdtrtType = "1"
  2152. fed.MedinsType = "1"
  2153. fed.MedinsLv = "11"
  2154. tm := time.Unix(his.RecordDate, 0)
  2155. s_tm := tm.Format("2006-01-02 15:04:05")
  2156. fed.AdmDate = s_tm
  2157. fed.DscgDate = s_tm
  2158. fed.DscgMainDiseCodg = config[0].CountryCode
  2159. fed.DscgMainDiseName = config[0].CountryContentName
  2160. //诊断信息
  2161. var fdds []*models.FsiDiagnoseDtos
  2162. for index, item := range config {
  2163. if index == 0 {
  2164. var fdd models.FsiDiagnoseDtos
  2165. fdd.DiseID = strconv.FormatInt(item.ID, 10)
  2166. fdd.InoutDiseType = "1"
  2167. fdd.MaindiseFlag = "1"
  2168. fdd.DiseDate = s_tm
  2169. fdd.DiasSrtNo = "1"
  2170. fdd.DiseName = item.CountryContentName
  2171. fdd.DiseCodg = item.CountryCode
  2172. fdds = append(fdds, &fdd)
  2173. } else {
  2174. var fdd models.FsiDiagnoseDtos
  2175. fdd.DiseID = strconv.FormatInt(item.ID, 10)
  2176. fdd.InoutDiseType = "1"
  2177. fdd.MaindiseFlag = "1"
  2178. fdd.DiseDate = s_tm
  2179. fdd.DiasSrtNo = strconv.FormatInt(int64(index), 10)
  2180. fdd.DiseName = item.CountryContentName
  2181. fdd.DiseCodg = item.CountryCode
  2182. fdds = append(fdds, &fdd)
  2183. }
  2184. }
  2185. fed.DrCodg = strconv.FormatInt(doctor_info.ID, 10)
  2186. fed.AdmDeptCodg = strconv.FormatInt(department.ID, 10)
  2187. fed.AdmDeptName = department.Name
  2188. fed.DscgDeptCodg = strconv.FormatInt(department.ID, 10)
  2189. fed.DscgDeptName = department.Name
  2190. fed.MedMdtrtType = "1"
  2191. fed.MedType = "11"
  2192. //if his.Insutype == "390" {
  2193. // fed.MedType = "1402"
  2194. //} else {
  2195. // fed.MedType = "9933"
  2196. //}
  2197. var orders []*models.FsiOrderDtos
  2198. if trig_scen == "2" {
  2199. //处方医嘱信息
  2200. for _, item := range prescriptions {
  2201. for _, subItem := range item.HisDoctorAdviceInfo {
  2202. var order models.FsiOrderDtos
  2203. order.RxID = strconv.FormatInt(item.ID, 10)
  2204. order.Rxno = strconv.FormatInt(item.ID, 10)
  2205. order.LongDrordFlag = "0"
  2206. order.HilistType = "1"
  2207. order.ChrgType = "1"
  2208. order.DrordBhvr = "-"
  2209. order.HilistCode = subItem.BaseDrugLib.MedicalInsuranceNumber
  2210. order.HosplistName = subItem.BaseDrugLib.DrugName
  2211. order.HilistLv = "1"
  2212. order.HilistPric = fmt.Sprintf("%.2f", subItem.Price)
  2213. order.HosplistCode = subItem.BaseDrugLib.MedicalInsuranceNumber
  2214. order.HosplistName = subItem.BaseDrugLib.DrugName
  2215. order.Cnt = fmt.Sprintf("%.2f", subItem.PrescribingNumber)
  2216. order.Pric = fmt.Sprintf("%.2f", subItem.Price)
  2217. order.Sumamt = fmt.Sprintf("%.2f", (subItem.PrescribingNumber * subItem.Price))
  2218. order.OwnpayAmt = ""
  2219. order.SelfpayAmt = ""
  2220. order.Spec = ""
  2221. order.SpecUnt = ""
  2222. order.DrordBegnDate = s_tm
  2223. order.DrordStopDate = ""
  2224. order.DrordDrCodg = "1"
  2225. order.DrordDeptName = department.Name
  2226. order.DrordDrCodg = "1"
  2227. order.DrordDrName = doctor_info.UserName
  2228. order.DrordDrProfttl = ""
  2229. order.CurrDrordFlag = "1"
  2230. orders = append(orders, &order)
  2231. }
  2232. for _, subItem := range item.HisPrescriptionProject {
  2233. if subItem.Type == 2 {
  2234. var order models.FsiOrderDtos
  2235. order.RxID = strconv.FormatInt(item.ID, 10)
  2236. order.Rxno = strconv.FormatInt(item.ID, 10)
  2237. order.LongDrordFlag = "0"
  2238. order.HilistType = "1"
  2239. order.ChrgType = "1"
  2240. order.DrordBhvr = "-"
  2241. order.HilistCode = subItem.HisProject.MedicalCode
  2242. order.HosplistName = subItem.HisProject.ProjectName
  2243. order.HilistLv = "1"
  2244. order.HilistPric = fmt.Sprintf("%.2f", subItem.Price)
  2245. order.HosplistCode = subItem.HisProject.MedicalCode
  2246. order.HosplistName = subItem.HisProject.ProjectName
  2247. order.Cnt = subItem.Count
  2248. cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  2249. order.Pric = fmt.Sprintf("%.2f", subItem.Price)
  2250. order.Sumamt = fmt.Sprintf("%.2f", subItem.Price*cnt)
  2251. order.OwnpayAmt = ""
  2252. order.SelfpayAmt = ""
  2253. order.Spec = ""
  2254. order.SpecUnt = ""
  2255. order.DrordBegnDate = s_tm
  2256. order.DrordStopDate = ""
  2257. order.DrordDrCodg = "1"
  2258. order.DrordDeptName = department.Name
  2259. order.DrordDrCodg = "1"
  2260. order.DrordDrName = doctor_info.UserName
  2261. order.DrordDrProfttl = ""
  2262. order.CurrDrordFlag = "1"
  2263. orders = append(orders, &order)
  2264. }
  2265. if subItem.Type == 3 {
  2266. var order models.FsiOrderDtos
  2267. order.RxID = strconv.FormatInt(item.ID, 10)
  2268. order.Rxno = strconv.FormatInt(item.ID, 10)
  2269. order.LongDrordFlag = "0"
  2270. order.HilistType = "1"
  2271. order.ChrgType = "1"
  2272. order.DrordBhvr = "-"
  2273. order.HilistCode = subItem.GoodInfo.MedicalInsuranceNumber
  2274. order.HosplistName = subItem.GoodInfo.GoodName
  2275. order.HilistLv = "1"
  2276. order.HilistPric = fmt.Sprintf("%.2f", subItem.Price)
  2277. order.HosplistCode = subItem.GoodInfo.MedicalInsuranceNumber
  2278. order.HosplistName = subItem.GoodInfo.GoodName
  2279. order.Cnt = subItem.Count
  2280. cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  2281. order.Pric = fmt.Sprintf("%.2f", subItem.Price)
  2282. order.Sumamt = fmt.Sprintf("%.2f", subItem.Price*cnt)
  2283. order.OwnpayAmt = ""
  2284. order.SelfpayAmt = ""
  2285. order.Spec = ""
  2286. order.SpecUnt = ""
  2287. order.DrordBegnDate = s_tm
  2288. order.DrordStopDate = ""
  2289. order.DrordDrCodg = "1"
  2290. order.DrordDeptName = department.Name
  2291. order.DrordDrCodg = "1"
  2292. order.DrordDrName = doctor_info.UserName
  2293. order.DrordDrProfttl = ""
  2294. order.CurrDrordFlag = "1"
  2295. orders = append(orders, &order)
  2296. }
  2297. }
  2298. }
  2299. //处方医嘱信息
  2300. }
  2301. fed.MatnStas = "0"
  2302. fed.MedfeeSumamt = "0"
  2303. fed.OwnpayAmt = "0"
  2304. fed.SelfpayAmt = "0"
  2305. fed.AcctPayamt = "0"
  2306. fed.MaAmt = "0"
  2307. fed.HifpPayamt = "0"
  2308. fed.SetlTotlnum = "1"
  2309. fed.Insutype = his.Insutype
  2310. fed.ReimFlag = "0"
  2311. fed.OutSetlFlag = "0"
  2312. var fopd []*models.FsiOperationDtosData
  2313. data := make(map[string]interface{})
  2314. data["fed"] = fed
  2315. data["fdd"] = fdds
  2316. data["fod"] = orders
  2317. data["pd"] = pd
  2318. data["pp"] = pp
  2319. data["fopd"] = fopd
  2320. data["trig_scen"] = trig_scen
  2321. fmt.Println(data)
  2322. fmt.Println(fed)
  2323. fmt.Println(fdds)
  2324. fmt.Println(orders)
  2325. fmt.Println(pd)
  2326. fmt.Println(pp)
  2327. fmt.Println(fopd)
  2328. client := &http.Client{}
  2329. bytesData, _ := json.Marshal(data)
  2330. var req *http.Request
  2331. if miConfig.MdtrtareaAdmvs == "320921" {
  2332. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3101", bytes.NewReader(bytesData))
  2333. } else {
  2334. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3101", bytes.NewReader(bytesData))
  2335. }
  2336. resp, _ := client.Do(req)
  2337. defer resp.Body.Close()
  2338. body, ioErr := ioutil.ReadAll(resp.Body)
  2339. if ioErr != nil {
  2340. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  2341. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2342. return res
  2343. }
  2344. var respJSON map[string]interface{}
  2345. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  2346. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  2347. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2348. return res
  2349. }
  2350. respJSON = respJSON["data"].(map[string]interface{})["request_log"].(map[string]interface{})
  2351. result, _ := json.Marshal(respJSON)
  2352. if err := json.Unmarshal([]byte(result), &res); err != nil {
  2353. utils.ErrorLog("解析失败:%v", err)
  2354. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2355. return res
  2356. }
  2357. return res
  2358. }
  2359. func Check3102(c *HisApiController, patient_id int64, his_patient_id int64, admin_user_id int64, trig_scen string, order_id int64) (res Result3101) {
  2360. ////patient_id, _ := c.GetInt64("patient_id")
  2361. //order_id, _ := c.GetInt64("order_id")
  2362. ////his_patient_id, _ := c.GetInt64("his_patient_id")
  2363. ////admin_user_id, _ := c.GetInt64("admin_user_id")
  2364. //trig_scen := c.GetString("trig_scen")
  2365. adminUser := c.GetAdminUserInfo()
  2366. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  2367. his, _ := service.GetNewHisPatientInfoFour(c.GetAdminUserInfo().CurrentOrgId, his_patient_id)
  2368. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  2369. record_time := c.GetString("record_time")
  2370. order, _ := service.GetHisOrderByID(order_id)
  2371. timeLayout := "2006-01-02"
  2372. loc, _ := time.LoadLocation("Local")
  2373. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  2374. if err != nil {
  2375. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  2376. return
  2377. }
  2378. recordDateTime := theTime.Unix()
  2379. var patientPrescription models.HisPrescriptionInfo
  2380. patientPrescription, _ = service.FindHisPatientPrescriptionInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  2381. if patientPrescription.ID == 0 {
  2382. patientPrescription, _ = service.FindLastPatientPrescriptionInfo(adminUser.CurrentOrgId, patient_id, recordDateTime)
  2383. }
  2384. department, _ := service.GetDepartMentDetail(patientPrescription.Departments)
  2385. doctor_info, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, patientPrescription.DoctorId)
  2386. //
  2387. diagnosis_ids := strings.Split(his.Diagnosis, ",")
  2388. prescriptions, _ := service.GetNewHisPrescriptionTen(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  2389. var pp models.PublicParams
  2390. pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  2391. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  2392. pp.FixmedinsName = miConfig.OrgName
  2393. pp.FixmedinsCode = miConfig.Code
  2394. pp.RequestUrl = miConfig.Url
  2395. pp.Cainfo = miConfig.Cainfo
  2396. pp.SecretKey = miConfig.SecretKey
  2397. pp.AccessKey = miConfig.AccessKey
  2398. pp.OpterName = roles.UserName
  2399. var config []*models.HisXtDiagnoseConfig
  2400. for _, item := range diagnosis_ids {
  2401. id, _ := strconv.ParseInt(item, 10, 64)
  2402. diagnosisConfig, _ := service.FindDiagnoseById(id)
  2403. config = append(config, &diagnosisConfig)
  2404. }
  2405. var pd models.PatientDtos
  2406. pd.PatnID = his.PsnNo
  2407. pd.PatnName = his.Name
  2408. pd.Gend = his.Gend
  2409. pd.Brdy = his.Brdy
  2410. pd.Poolarea = his.InsuplcAdmdvs
  2411. pd.CurrMdtrtID = his.Number
  2412. var fed models.FsiEncounterDtos
  2413. fed.MdtrtID = his.Number
  2414. fed.MedinsID = miConfig.Code
  2415. fed.MedinsName = miConfig.OrgName
  2416. fed.MedinsAdmdvs = miConfig.MdtrtareaAdmvs
  2417. fed.MedMdtrtType = "1"
  2418. fed.MedinsType = "1"
  2419. fed.MedinsLv = "11"
  2420. tm := time.Unix(his.RecordDate, 0)
  2421. s_tm := tm.Format("2006-01-02 15:04:05")
  2422. fed.AdmDate = s_tm
  2423. fed.DscgDate = s_tm
  2424. fed.DscgMainDiseCodg = config[0].CountryCode
  2425. fed.DscgMainDiseName = config[0].CountryContentName
  2426. //诊断信息
  2427. var fdds []*models.FsiDiagnoseDtos
  2428. for index, item := range config {
  2429. if index == 0 {
  2430. var fdd models.FsiDiagnoseDtos
  2431. fdd.DiseID = strconv.FormatInt(item.ID, 10)
  2432. fdd.InoutDiseType = "1"
  2433. fdd.MaindiseFlag = "1"
  2434. fdd.DiseDate = s_tm
  2435. fdd.DiasSrtNo = "1"
  2436. fdd.DiseName = item.CountryContentName
  2437. fdd.DiseCodg = item.CountryCode
  2438. fdds = append(fdds, &fdd)
  2439. } else {
  2440. var fdd models.FsiDiagnoseDtos
  2441. fdd.DiseID = strconv.FormatInt(item.ID, 10)
  2442. fdd.InoutDiseType = "1"
  2443. fdd.MaindiseFlag = "1"
  2444. fdd.DiseDate = s_tm
  2445. fdd.DiasSrtNo = strconv.FormatInt(int64(index), 10)
  2446. fdd.DiseName = item.CountryContentName
  2447. fdd.DiseCodg = item.CountryCode
  2448. fdds = append(fdds, &fdd)
  2449. }
  2450. }
  2451. fed.DrCodg = strconv.FormatInt(doctor_info.ID, 10)
  2452. fed.AdmDeptCodg = strconv.FormatInt(department.ID, 10)
  2453. fed.AdmDeptName = department.Name
  2454. fed.DscgDeptCodg = strconv.FormatInt(department.ID, 10)
  2455. fed.DscgDeptName = department.Name
  2456. fed.MedType = order.MedType
  2457. //处方医嘱信息
  2458. var orders []*models.FsiOrderDtos
  2459. //for _, item := range prescriptions {
  2460. // for _, subItem := range item.HisDoctorAdviceInfo {
  2461. // var order models.FsiOrderDtos
  2462. // order.RxID = strconv.FormatInt(item.ID, 10)
  2463. // order.Rxno = strconv.FormatInt(item.ID, 10)
  2464. // order.LongDrordFlag = "0"
  2465. // order.HilistType = "1"
  2466. // order.ChrgType = "1"
  2467. // order.DrordBhvr = "-"
  2468. // order.HilistCode = subItem.BaseDrugLib.MedicalInsuranceNumber
  2469. // order.HosplistName = subItem.BaseDrugLib.DrugName
  2470. // order.HilistLv = "1"
  2471. // order.HilistPric = strconv.FormatFloat(subItem.Price, 'E', -1, 64)
  2472. // order.HosplistCode = subItem.BaseDrugLib.MedicalInsuranceNumber
  2473. // order.HosplistName = subItem.BaseDrugLib.DrugName
  2474. // order.Cnt = strconv.FormatFloat(subItem.PrescribingNumber, 'E', -1, 64)
  2475. // order.Pric = strconv.FormatFloat(subItem.Price, 'E', -1, 64)
  2476. // order.Sumamt = strconv.FormatFloat((subItem.Price * subItem.PrescribingNumber), 'E', -1, 64)
  2477. // order.OwnpayAmt = ""
  2478. // order.SelfpayAmt = ""
  2479. // order.Spec = ""
  2480. // order.SpecUnt = ""
  2481. // order.DrordBegnDate = s_tm
  2482. // order.DrordStopDate = ""
  2483. // order.DrordDrCodg = "1"
  2484. // order.DrordDeptName = department.Name
  2485. // order.DrordDrCodg = "1"
  2486. // order.DrordDrName = doctor_info.UserName
  2487. // order.DrordDrProfttl = ""
  2488. // order.CurrDrordFlag = "1"
  2489. // orders = append(orders, &order)
  2490. // }
  2491. // for _, subItem := range item.HisPrescriptionProject {
  2492. // if subItem.Type == 2 {
  2493. // var order models.FsiOrderDtos
  2494. // order.RxID = strconv.FormatInt(item.ID, 10)
  2495. // order.Rxno = strconv.FormatInt(item.ID, 10)
  2496. // order.LongDrordFlag = "0"
  2497. // order.HilistType = "1"
  2498. // order.ChrgType = "1"
  2499. // order.DrordBhvr = "-"
  2500. // order.HilistCode = subItem.HisProject.MedicalCode
  2501. // order.HosplistName = subItem.HisProject.ProjectName
  2502. // order.HilistLv = "1"
  2503. // order.HilistPric = strconv.FormatFloat(subItem.Price, 'E', -1, 64)
  2504. // order.HosplistCode = subItem.HisProject.MedicalCode
  2505. // order.HosplistName = subItem.HisProject.ProjectName
  2506. // order.Cnt = subItem.Count
  2507. // cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  2508. //
  2509. // order.Pric = strconv.FormatFloat(subItem.Price, 'E', -1, 64)
  2510. // order.Sumamt = strconv.FormatFloat((subItem.Price * cnt), 'E', -1, 64)
  2511. // order.OwnpayAmt = ""
  2512. // order.SelfpayAmt = ""
  2513. // order.Spec = ""
  2514. // order.SpecUnt = ""
  2515. // order.DrordBegnDate = s_tm
  2516. // order.DrordStopDate = ""
  2517. // order.DrordDrCodg = "1"
  2518. // order.DrordDeptName = department.Name
  2519. // order.DrordDrCodg = "1"
  2520. // order.DrordDrName = doctor_info.UserName
  2521. // order.DrordDrProfttl = ""
  2522. // order.CurrDrordFlag = "1"
  2523. // orders = append(orders, &order)
  2524. //
  2525. // }
  2526. // if subItem.Type == 3 {
  2527. //
  2528. // var order models.FsiOrderDtos
  2529. // order.RxID = strconv.FormatInt(item.ID, 10)
  2530. // order.Rxno = strconv.FormatInt(item.ID, 10)
  2531. // order.LongDrordFlag = "0"
  2532. // order.HilistType = "1"
  2533. // order.ChrgType = "1"
  2534. // order.DrordBhvr = "-"
  2535. // order.HilistCode = subItem.GoodInfo.MedicalInsuranceNumber
  2536. // order.HosplistName = subItem.GoodInfo.GoodName
  2537. // order.HilistLv = "1"
  2538. // order.HilistPric = strconv.FormatFloat(subItem.Price, 'E', -1, 64)
  2539. // order.HosplistCode = subItem.GoodInfo.MedicalInsuranceNumber
  2540. // order.HosplistName = subItem.GoodInfo.GoodName
  2541. // order.Cnt = subItem.Count
  2542. // cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  2543. // order.Pric = strconv.FormatFloat(subItem.Price, 'E', -1, 64)
  2544. // order.Sumamt = strconv.FormatFloat((subItem.Price * cnt), 'E', -1, 64)
  2545. // order.OwnpayAmt = ""
  2546. // order.SelfpayAmt = ""
  2547. // order.Spec = ""
  2548. // order.SpecUnt = ""
  2549. // order.DrordBegnDate = s_tm
  2550. // order.DrordStopDate = ""
  2551. // order.DrordDrCodg = "1"
  2552. // order.DrordDeptName = department.Name
  2553. // order.DrordDrCodg = "1"
  2554. // order.DrordDrName = doctor_info.UserName
  2555. // order.DrordDrProfttl = ""
  2556. // order.CurrDrordFlag = "1"
  2557. // orders = append(orders, &order)
  2558. //
  2559. // }
  2560. // }
  2561. //}
  2562. for _, item := range prescriptions {
  2563. for _, subItem := range item.HisDoctorAdviceInfo {
  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.BaseDrugLib.MedicalInsuranceNumber
  2572. order.HosplistName = subItem.BaseDrugLib.DrugName
  2573. order.HilistLv = "1"
  2574. order.HilistPric = fmt.Sprintf("%.2f", subItem.Price)
  2575. order.HosplistCode = subItem.BaseDrugLib.MedicalInsuranceNumber
  2576. order.HosplistName = subItem.BaseDrugLib.DrugName
  2577. order.Cnt = fmt.Sprintf("%.2f", subItem.PrescribingNumber)
  2578. order.Pric = fmt.Sprintf("%.2f", subItem.Price)
  2579. order.Sumamt = fmt.Sprintf("%.2f", (subItem.PrescribingNumber * subItem.Price))
  2580. order.OwnpayAmt = ""
  2581. order.SelfpayAmt = ""
  2582. order.Spec = ""
  2583. order.SpecUnt = ""
  2584. order.DrordBegnDate = s_tm
  2585. order.DrordStopDate = ""
  2586. order.DrordDrCodg = "1"
  2587. order.DrordDeptName = department.Name
  2588. order.DrordDrCodg = "1"
  2589. order.DrordDrName = doctor_info.UserName
  2590. order.DrordDrProfttl = ""
  2591. order.CurrDrordFlag = "1"
  2592. orders = append(orders, &order)
  2593. }
  2594. for _, subItem := range item.HisPrescriptionProject {
  2595. if subItem.Type == 2 {
  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.HisProject.MedicalCode
  2604. order.HosplistName = subItem.HisProject.ProjectName
  2605. order.HilistLv = "1"
  2606. order.HilistPric = fmt.Sprintf("%.2f", subItem.Price)
  2607. order.HosplistCode = subItem.HisProject.MedicalCode
  2608. order.HosplistName = subItem.HisProject.ProjectName
  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. if subItem.Type == 3 {
  2628. var order models.FsiOrderDtos
  2629. order.RxID = strconv.FormatInt(item.ID, 10)
  2630. order.Rxno = strconv.FormatInt(item.ID, 10)
  2631. order.LongDrordFlag = "0"
  2632. order.HilistType = "1"
  2633. order.ChrgType = "1"
  2634. order.DrordBhvr = "-"
  2635. order.HilistCode = subItem.GoodInfo.MedicalInsuranceNumber
  2636. order.HosplistName = subItem.GoodInfo.GoodName
  2637. order.HilistLv = "1"
  2638. order.HilistPric = fmt.Sprintf("%.2f", subItem.Price)
  2639. order.HosplistCode = subItem.GoodInfo.MedicalInsuranceNumber
  2640. order.HosplistName = subItem.GoodInfo.GoodName
  2641. order.Cnt = subItem.Count
  2642. cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  2643. order.Pric = fmt.Sprintf("%.2f", subItem.Price)
  2644. order.Sumamt = fmt.Sprintf("%.2f", subItem.Price*cnt)
  2645. order.OwnpayAmt = ""
  2646. order.SelfpayAmt = ""
  2647. order.Spec = ""
  2648. order.SpecUnt = ""
  2649. order.DrordBegnDate = s_tm
  2650. order.DrordStopDate = ""
  2651. order.DrordDrCodg = "1"
  2652. order.DrordDeptName = department.Name
  2653. order.DrordDrCodg = "1"
  2654. order.DrordDrName = doctor_info.UserName
  2655. order.DrordDrProfttl = ""
  2656. order.CurrDrordFlag = "1"
  2657. orders = append(orders, &order)
  2658. }
  2659. }
  2660. }
  2661. //处方医嘱信息
  2662. fed.MatnStas = "0"
  2663. fed.MedfeeSumamt = fmt.Sprintf("%.2f", order.MedfeeSumamt)
  2664. fed.OwnpayAmt = fmt.Sprintf("%.2f", order.FulamtOwnpayAmt)
  2665. fed.SelfpayAmt = fmt.Sprintf("%.2f", order.PreselfpayAmt)
  2666. fed.AcctPayamt = fmt.Sprintf("%.2f", order.AcctPay)
  2667. fed.MaAmt = fmt.Sprintf("%.2f", order.MafPay)
  2668. fed.HifpPayamt = fmt.Sprintf("%.2f", order.HifpPay)
  2669. fed.SetlTotlnum = "1"
  2670. fed.Insutype = his.Insutype
  2671. fed.ReimFlag = "0"
  2672. fed.OutSetlFlag = "0"
  2673. var fopd []*models.FsiOperationDtosData
  2674. data := make(map[string]interface{})
  2675. data["fed"] = fed
  2676. data["fdd"] = fdds
  2677. data["fod"] = orders
  2678. data["pd"] = pd
  2679. data["pp"] = pp
  2680. data["fopd"] = fopd
  2681. data["trig_scen"] = trig_scen
  2682. client := &http.Client{}
  2683. bytesData, _ := json.Marshal(data)
  2684. var req *http.Request
  2685. if miConfig.MdtrtareaAdmvs == "320921" {
  2686. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3102", bytes.NewReader(bytesData))
  2687. } else {
  2688. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3102", bytes.NewReader(bytesData))
  2689. }
  2690. resp, _ := client.Do(req)
  2691. defer resp.Body.Close()
  2692. body, ioErr := ioutil.ReadAll(resp.Body)
  2693. if ioErr != nil {
  2694. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  2695. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2696. return res
  2697. }
  2698. var respJSON map[string]interface{}
  2699. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  2700. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  2701. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2702. return res
  2703. }
  2704. respJSON = respJSON["data"].(map[string]interface{})["request_log"].(map[string]interface{})
  2705. result, _ := json.Marshal(respJSON)
  2706. if err := json.Unmarshal([]byte(result), &res); err != nil {
  2707. utils.ErrorLog("解析失败:%v", err)
  2708. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2709. return res
  2710. }
  2711. return res
  2712. //手术操作集合
  2713. //手术操作集合
  2714. }
  2715. func (c *HisApiController) Check() {
  2716. psn_no := c.GetString("psn_no")
  2717. in := c.GetString("in")
  2718. mt := c.GetString("mt")
  2719. baseParams := models.BaseParams{
  2720. SecretKey: "MSDBYGxXm1Mtyi3PtOUB7n1ktcxwyW57",
  2721. FixmedinsCode: "H15049901371",
  2722. InsuplcAdmdvs: "150499",
  2723. MdtrtareaAdmvs: "150499",
  2724. OrgName: "赤峰费森血液透析中心",
  2725. Doctor: "1111",
  2726. }
  2727. service.Gdyb2001(baseParams, psn_no, in, mt)
  2728. }
  2729. func (c *HisApiController) GetPsnNcdsInfo() {
  2730. admin_user_id, _ := c.GetInt64("admin_user_id")
  2731. patient_id, _ := c.GetInt64("patient_id")
  2732. id, _ := c.GetInt64("id")
  2733. adminUser := c.GetAdminUserInfo()
  2734. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  2735. //config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  2736. //patient, _ := service.GetPatientByID(c.GetAdminUserInfo().CurrentOrgId, id)
  2737. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  2738. psn_record, _ := service.GetPsnNCDSRecordById(id)
  2739. //
  2740. //if psn_record.ID == 0 {
  2741. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorPsnRecordNoExistWrong)
  2742. // return
  2743. //}
  2744. var res Result5301
  2745. var res10265 Result5301For10265
  2746. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  2747. psn_info, _ := service.GetPsnByPatientId(patient_id)
  2748. var api string
  2749. if miConfig.MdtrtareaAdmvs == "320921" {
  2750. 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 +
  2751. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&psn_no=" + psn_info.PsnNo + "&cainfo=" + miConfig.Cainfo
  2752. } else {
  2753. 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 +
  2754. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&psn_no=" + psn_info.PsnNo + "&cainfo=" + miConfig.Cainfo
  2755. }
  2756. resp, requestErr := http.Get(api)
  2757. if requestErr != nil {
  2758. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2759. return
  2760. }
  2761. body, ioErr := ioutil.ReadAll(resp.Body)
  2762. if ioErr != nil {
  2763. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  2764. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2765. return
  2766. }
  2767. var respJSON map[string]interface{}
  2768. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  2769. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  2770. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2771. return
  2772. }
  2773. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  2774. result, _ := json.Marshal(respJSON)
  2775. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  2776. utils.ErrorLog("解析失败:%v", err)
  2777. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2778. return
  2779. }
  2780. res.ErrMsg = res10265.ErrMsg
  2781. res.Output = res10265.Output
  2782. res.InfRefmsgid = res10265.InfRefmsgid
  2783. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  2784. res.Infcode = infocode
  2785. } else if miConfig.MdtrtareaAdmvs == "360399" {
  2786. p, _ := service.GetHisPatientById(patient_id)
  2787. result, _ := service.Jxyb5301(p.PsnNo, miConfig.OrgName, role.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, miConfig.Url, miConfig.AccessKey, "")
  2788. var dat map[string]interface{}
  2789. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  2790. fmt.Println(dat)
  2791. } else {
  2792. fmt.Println(err)
  2793. }
  2794. userJSONBytes, _ := json.Marshal(dat)
  2795. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  2796. utils.ErrorLog("解析失败:%v", err)
  2797. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2798. return
  2799. }
  2800. } else if miConfig.MdtrtareaAdmvs == "430800" {
  2801. p, _ := service.GetHisPatientById(patient_id)
  2802. result, _ := service.Hnyb5301(p.PsnNo, miConfig.OrgName, role.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, miConfig.Url, miConfig.AccessKey, "")
  2803. var dat map[string]interface{}
  2804. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  2805. fmt.Println(dat)
  2806. } else {
  2807. fmt.Println(err)
  2808. }
  2809. userJSONBytes, _ := json.Marshal(dat)
  2810. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  2811. utils.ErrorLog("解析失败:%v", err)
  2812. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2813. return
  2814. }
  2815. } else {
  2816. result := service.Gdyb5301(psn_record.PsnNo, miConfig.OrgName, role.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey)
  2817. var dat map[string]interface{}
  2818. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  2819. fmt.Println(dat)
  2820. } else {
  2821. fmt.Println(err)
  2822. }
  2823. userJSONBytes, _ := json.Marshal(dat)
  2824. if miConfig.Code == "H15049901371" {
  2825. if err := json.Unmarshal(userJSONBytes, &res10265); err != nil {
  2826. utils.ErrorLog("解析失败:%v", err)
  2827. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2828. return
  2829. }
  2830. res.InfRefmsgid = res10265.InfRefmsgid
  2831. res.Output = res10265.Output
  2832. res.ErrMsg = res10265.ErrMsg
  2833. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  2834. res.Infcode = infocode
  2835. } else {
  2836. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  2837. utils.ErrorLog("解析失败:%v", err)
  2838. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2839. return
  2840. }
  2841. }
  2842. }
  2843. if res.Infcode == 0 {
  2844. c.ServeSuccessJSON(map[string]interface{}{
  2845. "result": res.Output.Result,
  2846. })
  2847. }
  2848. }
  2849. func (c *HisApiController) CheckInsutype() {
  2850. his_patient_id, _ := c.GetInt64("his_patient_id")
  2851. admin_user_id, _ := c.GetInt64("admin_user_id")
  2852. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  2853. his, _ := service.GetNewHisPatientInfoFour(c.GetAdminUserInfo().CurrentOrgId, his_patient_id)
  2854. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  2855. result := service.Gdyb90100(his.PsnNo, miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey)
  2856. var dat map[string]interface{}
  2857. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  2858. fmt.Println(dat)
  2859. } else {
  2860. fmt.Println(err)
  2861. }
  2862. userJSONBytes, _ := json.Marshal(dat)
  2863. var res Result90100
  2864. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  2865. utils.ErrorLog("解析失败:%v", err)
  2866. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2867. return
  2868. }
  2869. if res.Infcode != 0 {
  2870. c.ServeSuccessJSON(map[string]interface{}{
  2871. "failed_code": -10,
  2872. "msg": res.ErrMsg,
  2873. })
  2874. return
  2875. } else {
  2876. fmt.Println(res)
  2877. }
  2878. }
  2879. func (c *HisApiController) CheckCardPWD() {
  2880. card_pwd := c.GetString("card_pwd")
  2881. his_patient_id, _ := c.GetInt64("his_patient_id")
  2882. admin_user_id, _ := c.GetInt64("admin_user_id")
  2883. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  2884. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  2885. his, _ := service.GetNewHisPatientInfoFour(c.GetAdminUserInfo().CurrentOrgId, his_patient_id)
  2886. psn, _ := service.GetPsnByPatientId(his.PatientId)
  2887. bas := strings.Split(psn.CardInfo, "|")
  2888. basNumber := bas[2]
  2889. if psn.InsuplcAdmdvs[:4] == "4403" {
  2890. result := service.Gdyb90991(his.PsnNo, miConfig.OrgName, roles.UserName, miConfig.Code, his.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, card_pwd, basNumber)
  2891. var dat map[string]interface{}
  2892. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  2893. fmt.Println(dat)
  2894. } else {
  2895. fmt.Println(err)
  2896. }
  2897. userJSONBytes, _ := json.Marshal(dat)
  2898. var res Result90991
  2899. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  2900. utils.ErrorLog("解析失败:%v", err)
  2901. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2902. return
  2903. }
  2904. if res.Infcode != 0 {
  2905. c.ServeSuccessJSON(map[string]interface{}{
  2906. "failed_code": -10,
  2907. "msg": res.ErrMsg,
  2908. })
  2909. return
  2910. } else {
  2911. if res.Output.Result.SscnoCheckStat == "0" && res.Output.Result.CardStat != "10" {
  2912. var msg string
  2913. switch res.Output.Result.CardStat {
  2914. case "00":
  2915. msg = "未激活"
  2916. break
  2917. case "10":
  2918. msg = "激活"
  2919. break
  2920. case "20":
  2921. msg = "窗口挂失"
  2922. break
  2923. case "21":
  2924. msg = "电话挂失"
  2925. break
  2926. case "22":
  2927. msg = "单位网上申报挂失"
  2928. break
  2929. case "23":
  2930. msg = "保健办挂失"
  2931. break
  2932. case "24":
  2933. msg = "个人网上挂失"
  2934. break
  2935. case "25":
  2936. msg = "网上服务大厅挂失"
  2937. break
  2938. case "30":
  2939. msg = "注销"
  2940. break
  2941. case "40":
  2942. msg = "回收"
  2943. break
  2944. case "99":
  2945. msg = "制卡中(无效卡)"
  2946. break
  2947. }
  2948. c.ServeSuccessJSON(map[string]interface{}{
  2949. "failed_code": -10,
  2950. "msg": msg,
  2951. })
  2952. return
  2953. } else {
  2954. c.ServeSuccessJSON(map[string]interface{}{
  2955. "msg": "校验成功",
  2956. })
  2957. return
  2958. }
  2959. }
  2960. } else {
  2961. c.ServeSuccessJSON(map[string]interface{}{
  2962. "msg": "校验成功",
  2963. })
  2964. return
  2965. }
  2966. }
  2967. func (c *HisApiController) CheckCardPWDTwo() {
  2968. //card_pwd := c.GetString("card_pwd")
  2969. //his_patient_id, _ := c.GetInt64("his_patient_id")
  2970. admin_user_id, _ := c.GetInt64("admin_user_id")
  2971. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  2972. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  2973. result := service.Gdyb90991("44030000000629690364", miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, "000000", "BDM421363")
  2974. var dat map[string]interface{}
  2975. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  2976. fmt.Println(dat)
  2977. } else {
  2978. fmt.Println(err)
  2979. }
  2980. userJSONBytes, _ := json.Marshal(dat)
  2981. var res Result90991
  2982. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  2983. utils.ErrorLog("解析失败:%v", err)
  2984. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2985. return
  2986. }
  2987. if res.Infcode != 0 {
  2988. c.ServeSuccessJSON(map[string]interface{}{
  2989. "failed_code": -10,
  2990. "msg": res.ErrMsg,
  2991. })
  2992. return
  2993. } else {
  2994. if res.Output.Result.SscnoCheckStat == "0" {
  2995. var msg string
  2996. switch res.Output.Result.CardStat {
  2997. case "00":
  2998. msg = "未激活"
  2999. break
  3000. case "10":
  3001. msg = "激活"
  3002. break
  3003. case "20":
  3004. msg = "窗口挂失"
  3005. break
  3006. case "21":
  3007. msg = "电话挂失"
  3008. break
  3009. case "22":
  3010. msg = "单位网上申报挂失"
  3011. break
  3012. case "23":
  3013. msg = "保健办挂失"
  3014. break
  3015. case "24":
  3016. msg = "个人网上挂失"
  3017. break
  3018. case "25":
  3019. msg = "网上服务大厅挂失"
  3020. break
  3021. case "30":
  3022. msg = "注销"
  3023. break
  3024. case "40":
  3025. msg = "回收"
  3026. break
  3027. case "99":
  3028. msg = "制卡中(无效卡)"
  3029. break
  3030. }
  3031. c.ServeSuccessJSON(map[string]interface{}{
  3032. "failed_code": -10,
  3033. "msg": msg,
  3034. })
  3035. return
  3036. } else {
  3037. c.ServeSuccessJSON(map[string]interface{}{
  3038. "msg": "校验成功",
  3039. })
  3040. return
  3041. }
  3042. }
  3043. }
  3044. type ELeCertData struct {
  3045. Data struct {
  3046. Extra string `json:"extra"`
  3047. IDNo string `json:"idNo"`
  3048. IDType string `json:"idType"`
  3049. EcToken string `json:"ecToken"`
  3050. InsuOrg string `json:"insuOrg"`
  3051. UserName string `json:"userName"`
  3052. EcIndexNo string `json:"ecIndexNo"`
  3053. Gender string `json:"gender"`
  3054. Birthday string `json:"birthday"`
  3055. Nationality string `json:"nationality"`
  3056. Email string `json:"email"`
  3057. } `json:"OutData"`
  3058. }
  3059. func (c *HisApiController) ReadCard() {
  3060. id_card_type, _ := c.GetInt64("id_card_type")
  3061. admin_user_id, _ := c.GetInt64("admin_user_id")
  3062. certificates, _ := c.GetInt64("certificates")
  3063. //insuplc_admdvs_str := c.GetString("insuplc_admdvs")
  3064. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  3065. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  3066. switch id_card_type {
  3067. case 1:
  3068. if miConfig.MdtrtareaAdmvs == "421300" {
  3069. var res ResultTwo
  3070. api := "http://192.168.124.4:9532/" + "hbyb/1101?cert_no=" + "" +
  3071. "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  3072. "&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)
  3073. resp, requestErr := http.Get(api)
  3074. if requestErr != nil {
  3075. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3076. return
  3077. }
  3078. body, ioErr := ioutil.ReadAll(resp.Body)
  3079. if ioErr != nil {
  3080. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  3081. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3082. return
  3083. }
  3084. var respJSON map[string]interface{}
  3085. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  3086. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  3087. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3088. return
  3089. }
  3090. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  3091. result, _ := json.Marshal(respJSON)
  3092. fmt.Println("log")
  3093. fmt.Println(string(result))
  3094. if err := json.Unmarshal([]byte(result), &res); err != nil {
  3095. utils.ErrorLog("解析失败:%v", err)
  3096. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3097. return
  3098. }
  3099. if res.Infcode == 0 {
  3100. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  3101. if err == gorm.ErrRecordNotFound {
  3102. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  3103. return
  3104. } else if err != nil {
  3105. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  3106. return
  3107. } else {
  3108. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  3109. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  3110. infoStr := string(Iinfos)
  3111. idetinfoStr := string(Idetinfos)
  3112. psn := &models.HisPsn{
  3113. PsnNo: res.Output.Baseinfo.PsnNo,
  3114. Age: res.Output.Baseinfo.Age,
  3115. PatientId: patient.ID,
  3116. Certno: res.Output.Baseinfo.Certno,
  3117. Brdy: res.Output.Baseinfo.Brdy,
  3118. Gend: res.Output.Baseinfo.Gend,
  3119. Naty: res.Output.Baseinfo.Naty,
  3120. PsnCertType: res.Output.Baseinfo.PsnCertType,
  3121. PsnName: res.Output.Baseinfo.PsnName,
  3122. Idetinfo: idetinfoStr,
  3123. Insuinfo: infoStr,
  3124. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  3125. }
  3126. service.CreateHisPsn(psn)
  3127. c.ServeSuccessJSON(map[string]interface{}{
  3128. "patient": patient,
  3129. "number": res.Output.Baseinfo.Certno,
  3130. })
  3131. }
  3132. } else {
  3133. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  3134. return
  3135. }
  3136. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  3137. var api string
  3138. if miConfig.MdtrtareaAdmvs == "320921" {
  3139. 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 +
  3140. "&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
  3141. fmt.Println(api)
  3142. } else {
  3143. 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 +
  3144. "&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)
  3145. }
  3146. resp, requestErr := http.Get(api)
  3147. if requestErr != nil {
  3148. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3149. return
  3150. }
  3151. body, ioErr := ioutil.ReadAll(resp.Body)
  3152. if ioErr != nil {
  3153. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  3154. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3155. return
  3156. }
  3157. var respJSON map[string]interface{}
  3158. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  3159. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  3160. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3161. return
  3162. }
  3163. var status string
  3164. status = respJSON["data"].(map[string]interface{})["status"].(string)
  3165. card_type := respJSON["data"].(map[string]interface{})["type"].(string)
  3166. //console.log()
  3167. fmt.Println("type===")
  3168. fmt.Println(card_type)
  3169. var token string
  3170. var res ResultTwo //1101结果
  3171. var res10265 ResultTwo10265 //1101结果
  3172. var card_info string //卡信息
  3173. var busi_card_info string
  3174. card_info = respJSON["data"].(map[string]interface{})["card_info"].(string)
  3175. busi_card_info = respJSON["data"].(map[string]interface{})["busi_card_info"].(string)
  3176. if status == "0" { //读卡成功
  3177. if card_type == "1" {
  3178. respJSON = respJSON["data"].(map[string]interface{})["result"].(map[string]interface{})
  3179. result, _ := json.Marshal(respJSON)
  3180. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  3181. utils.ErrorLog("解析失败:%v", err)
  3182. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3183. return
  3184. }
  3185. res.ErrMsg = res10265.ErrMsg
  3186. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  3187. res.Infcode = infocode
  3188. res.Output = res10265.Output
  3189. res.InfRefmsgid = res10265.InfRefmsgid
  3190. } else {
  3191. //var card_info string //卡信息
  3192. //var busi_card_info string
  3193. token = respJSON["data"].(map[string]interface{})["token"].(string)
  3194. //busi_card_info = respJSON["data"].(map[string]interface{})["busi_card_info"].(string)
  3195. //fmt.Println(card_info)
  3196. //fmt.Println(busi_card_info)
  3197. respJSON = respJSON["data"].(map[string]interface{})["result"].(map[string]interface{})
  3198. result, _ := json.Marshal(respJSON)
  3199. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  3200. utils.ErrorLog("解析失败:%v", err)
  3201. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3202. return
  3203. }
  3204. res.ErrMsg = res10265.ErrMsg
  3205. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  3206. res.Infcode = infocode
  3207. res.Output = res10265.Output
  3208. res.InfRefmsgid = res10265.InfRefmsgid
  3209. }
  3210. if res.Infcode == 0 {
  3211. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  3212. if err == gorm.ErrRecordNotFound {
  3213. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  3214. return
  3215. } else if err != nil {
  3216. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  3217. return
  3218. } else {
  3219. if card_type == "1" {
  3220. bas := strings.Split(card_info, "|")
  3221. basNumber := bas[2]
  3222. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  3223. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  3224. infoStr := string(Iinfos)
  3225. idetinfoStr := string(Idetinfos)
  3226. psn := &models.HisPsn{
  3227. PsnNo: res.Output.Baseinfo.PsnNo,
  3228. Age: res.Output.Baseinfo.Age,
  3229. PatientId: patient.ID,
  3230. Certno: res.Output.Baseinfo.Certno,
  3231. Brdy: res.Output.Baseinfo.Brdy,
  3232. Gend: res.Output.Baseinfo.Gend,
  3233. Naty: res.Output.Baseinfo.Naty,
  3234. PsnCertType: res.Output.Baseinfo.PsnCertType,
  3235. PsnName: res.Output.Baseinfo.PsnName,
  3236. Idetinfo: idetinfoStr,
  3237. Insuinfo: infoStr,
  3238. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  3239. CardInfo: card_info,
  3240. VerifyNumber: busi_card_info,
  3241. }
  3242. service.CreateHisPsn(psn)
  3243. var rf []*ResultFive
  3244. json.Unmarshal([]byte(infoStr), &rf)
  3245. var insutypes []*ResultFive
  3246. var insutype string
  3247. var is390 int = 0
  3248. var is310 int = 0
  3249. for _, item := range rf {
  3250. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  3251. insutypes = append(insutypes, item)
  3252. }
  3253. }
  3254. if len(insutypes) == 1 {
  3255. insutype = insutypes[0].Insutype
  3256. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  3257. } else {
  3258. for _, i := range insutypes {
  3259. if i.Insutype == "390" {
  3260. is390 = 1
  3261. }
  3262. if i.Insutype == "310" {
  3263. is310 = 1
  3264. }
  3265. }
  3266. }
  3267. if is390 == 1 {
  3268. insutype = "390"
  3269. }
  3270. if is310 == 1 {
  3271. insutype = "310"
  3272. }
  3273. if len(insutypes) == 0 {
  3274. insutype = "310"
  3275. }
  3276. c.ServeSuccessJSON(map[string]interface{}{
  3277. "patient": patient,
  3278. "number": basNumber,
  3279. "insutype": insutype,
  3280. })
  3281. } else {
  3282. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  3283. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  3284. infoStr := string(Iinfos)
  3285. idetinfoStr := string(Idetinfos)
  3286. psn := &models.HisPsn{
  3287. PsnNo: res.Output.Baseinfo.PsnNo,
  3288. Age: res.Output.Baseinfo.Age,
  3289. PatientId: patient.ID,
  3290. Certno: res.Output.Baseinfo.Certno,
  3291. Brdy: res.Output.Baseinfo.Brdy,
  3292. Gend: res.Output.Baseinfo.Gend,
  3293. Naty: res.Output.Baseinfo.Naty,
  3294. PsnCertType: res.Output.Baseinfo.PsnCertType,
  3295. PsnName: res.Output.Baseinfo.PsnName,
  3296. Idetinfo: idetinfoStr,
  3297. Insuinfo: infoStr,
  3298. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  3299. CardInfo: card_info,
  3300. VerifyNumber: token,
  3301. }
  3302. service.CreateHisPsn(psn)
  3303. c.ServeSuccessJSON(map[string]interface{}{
  3304. "patient": patient,
  3305. "number": token,
  3306. })
  3307. }
  3308. }
  3309. } else {
  3310. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  3311. return
  3312. }
  3313. } else { //读卡失败
  3314. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  3315. return
  3316. }
  3317. } else if miConfig.MdtrtareaAdmvs == "350500" {
  3318. cardnum, cardCode, id_card_no, name, errmsg := c.GetFjBasBaseInfo()
  3319. cardnum = DeleteExtraSpaceTwo(cardnum)
  3320. cardCode = DeleteExtraSpaceTwo(cardCode)
  3321. id_card_no = DeleteExtraSpaceTwo(id_card_no)
  3322. name = DeleteExtraSpaceTwo(name)
  3323. errmsg = DeleteExtraSpaceTwo(errmsg)
  3324. cardnum = Remove0000(cardnum)
  3325. cardCode = Remove0000(cardCode)
  3326. id_card_no = Remove0000(id_card_no)
  3327. name = Remove0000(name)
  3328. errmsg = Remove0000(errmsg)
  3329. patient, _ := service.GetPatientByIDCard(id_card_no, miConfig.UserOrgId)
  3330. basStr := cardnum + "|" + cardCode + "|" + id_card_no + "|" + name
  3331. //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)
  3332. //fmt.Println(result2)
  3333. //fmt.Println(requestLog2)
  3334. //fmt.Println(errMsgLog2)
  3335. 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)
  3336. saveLog(result, requestLog, "1101", "获取人员信息")
  3337. fmt.Println(errMsgLog)
  3338. if len(errMsgLog) > 0 {
  3339. } else {
  3340. var dat map[string]interface{}
  3341. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  3342. fmt.Println(dat)
  3343. } else {
  3344. fmt.Println(err)
  3345. }
  3346. userJSONBytes, _ := json.Marshal(dat)
  3347. var res ResultTwo
  3348. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  3349. utils.ErrorLog("解析失败:%v", err)
  3350. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3351. return
  3352. }
  3353. res.ErrMsg = errMsgLog
  3354. if res.Infcode == 0 {
  3355. patient, err := service.GetPatientByNumber(id_card_no, c.GetAdminUserInfo().CurrentOrgId)
  3356. if err == gorm.ErrRecordNotFound {
  3357. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  3358. return
  3359. } else if err != nil {
  3360. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  3361. return
  3362. } else {
  3363. fmt.Println(res)
  3364. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  3365. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  3366. infoStr := string(Iinfos)
  3367. idetinfoStr := string(Idetinfos)
  3368. var rf []*ResultFive
  3369. json.Unmarshal([]byte(infoStr), &rf)
  3370. var insutypes []*ResultFive
  3371. var insutype string
  3372. var is390 int = 0
  3373. var is310 int = 0
  3374. for _, item := range rf {
  3375. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  3376. insutypes = append(insutypes, item)
  3377. }
  3378. }
  3379. if len(insutypes) == 1 {
  3380. insutype = insutypes[0].Insutype
  3381. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  3382. } else {
  3383. for _, i := range insutypes {
  3384. if i.Insutype == "390" {
  3385. is390 = 1
  3386. }
  3387. if i.Insutype == "310" {
  3388. is310 = 1
  3389. }
  3390. }
  3391. }
  3392. if is390 == 1 {
  3393. insutype = "390"
  3394. }
  3395. if is310 == 1 {
  3396. insutype = "310"
  3397. }
  3398. if len(insutypes) == 0 {
  3399. insutype = "390"
  3400. }
  3401. var insuplc_admdvs string
  3402. for _, item := range rf {
  3403. if item.Insutype == insutype {
  3404. insuplc_admdvs = item.InsuplcAdmdvs
  3405. }
  3406. }
  3407. psn := &models.HisPsn{
  3408. PsnNo: res.Output.Baseinfo.PsnNo,
  3409. Age: res.Output.Baseinfo.Age,
  3410. PatientId: patient.ID,
  3411. Certno: res.Output.Baseinfo.Certno,
  3412. Brdy: res.Output.Baseinfo.Brdy,
  3413. Gend: res.Output.Baseinfo.Gend,
  3414. Naty: res.Output.Baseinfo.Naty,
  3415. PsnCertType: res.Output.Baseinfo.PsnCertType,
  3416. PsnName: res.Output.Baseinfo.PsnName,
  3417. Idetinfo: idetinfoStr,
  3418. Insuinfo: infoStr,
  3419. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  3420. CardInfo: basStr,
  3421. VerifyNumber: "",
  3422. InsuplcAdmdvs: insuplc_admdvs,
  3423. }
  3424. service.CreateHisPsn(psn)
  3425. c.ServeSuccessJSON(map[string]interface{}{
  3426. "patient": patient,
  3427. "number": cardnum,
  3428. "insutype": insutype,
  3429. })
  3430. }
  3431. } else {
  3432. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  3433. return
  3434. }
  3435. }
  3436. } else if miConfig.MdtrtareaAdmvs == "360399" {
  3437. fmt.Println(initFlag)
  3438. fmt.Println("initFlag")
  3439. if initFlag == 0 {
  3440. c.TestGetJiangXiBasBaseInit()
  3441. }
  3442. basStr := c.GetBasBaseInfo()
  3443. if len(basStr) == 0 {
  3444. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeReadCardException)
  3445. return
  3446. }
  3447. fmt.Println(basStr)
  3448. bas := strings.Split(basStr, "|")
  3449. basNumber := bas[1]
  3450. fmt.Println(basNumber)
  3451. card_sn := bas[3]
  3452. fmt.Println(card_sn)
  3453. 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, "")
  3454. //result := service.Jxyb1101(basNumber, miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, id_card_type, card_sn, certificates)
  3455. var dat map[string]interface{}
  3456. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  3457. fmt.Println(dat)
  3458. } else {
  3459. fmt.Println(err)
  3460. }
  3461. userJSONBytes, _ := json.Marshal(dat)
  3462. var res ResultTwo
  3463. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  3464. utils.ErrorLog("解析失败:%v", err)
  3465. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3466. return
  3467. }
  3468. if res.Infcode == 0 {
  3469. patient, err := service.GetPatientByNumber(basNumber, c.GetAdminUserInfo().CurrentOrgId)
  3470. if err == gorm.ErrRecordNotFound {
  3471. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  3472. return
  3473. } else if err != nil {
  3474. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  3475. return
  3476. } else {
  3477. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  3478. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  3479. infoStr := string(Iinfos)
  3480. idetinfoStr := string(Idetinfos)
  3481. psn := &models.HisPsn{
  3482. PsnNo: res.Output.Baseinfo.PsnNo,
  3483. Age: res.Output.Baseinfo.Age,
  3484. PatientId: patient.ID,
  3485. Certno: res.Output.Baseinfo.Certno,
  3486. Brdy: res.Output.Baseinfo.Brdy,
  3487. Gend: res.Output.Baseinfo.Gend,
  3488. Naty: res.Output.Baseinfo.Naty,
  3489. PsnCertType: res.Output.Baseinfo.PsnCertType,
  3490. PsnName: res.Output.Baseinfo.PsnName,
  3491. Idetinfo: idetinfoStr,
  3492. Insuinfo: infoStr,
  3493. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  3494. CardInfo: basStr,
  3495. VerifyNumber: "",
  3496. }
  3497. service.CreateHisPsn(psn)
  3498. var rf []*ResultFive
  3499. json.Unmarshal([]byte(infoStr), &rf)
  3500. var insutypes []*ResultFive
  3501. var insutype string
  3502. var is390 int = 0
  3503. var is310 int = 0
  3504. for _, item := range rf {
  3505. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  3506. insutypes = append(insutypes, item)
  3507. }
  3508. }
  3509. if len(insutypes) == 1 {
  3510. insutype = insutypes[0].Insutype
  3511. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  3512. } else {
  3513. for _, i := range insutypes {
  3514. if i.Insutype == "390" {
  3515. is390 = 1
  3516. }
  3517. if i.Insutype == "310" {
  3518. is310 = 1
  3519. }
  3520. }
  3521. }
  3522. if is390 == 1 {
  3523. insutype = "390"
  3524. }
  3525. if is310 == 1 {
  3526. insutype = "310"
  3527. }
  3528. if len(insutypes) == 0 {
  3529. insutype = "310"
  3530. }
  3531. c.ServeSuccessJSON(map[string]interface{}{
  3532. "patient": patient,
  3533. "number": basNumber,
  3534. "insutype": insutype,
  3535. })
  3536. }
  3537. } else {
  3538. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  3539. return
  3540. }
  3541. } else if miConfig.MdtrtareaAdmvs == "430800" {
  3542. fmt.Println(initFlag)
  3543. fmt.Println("initFlag")
  3544. if initFlag == 0 {
  3545. c.TestGetHnBasBaseInit()
  3546. }
  3547. basStr := c.GetBasBaseInfo()
  3548. if len(basStr) == 0 {
  3549. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeReadCardException)
  3550. return
  3551. }
  3552. fmt.Println(basStr)
  3553. bas := strings.Split(basStr, "|")
  3554. basNumber := bas[1]
  3555. fmt.Println(basNumber)
  3556. card_sn := bas[3]
  3557. card_no := bas[2]
  3558. fmt.Println(card_sn)
  3559. name := bas[4]
  3560. name = ConvertToString(name, "gbk", "utf-8")
  3561. 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)
  3562. //result := service.Jxyb1101(basNumber, miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, id_card_type, card_sn, certificates)
  3563. var dat map[string]interface{}
  3564. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  3565. fmt.Println(dat)
  3566. } else {
  3567. fmt.Println(err)
  3568. }
  3569. userJSONBytes, _ := json.Marshal(dat)
  3570. var res ResultTwo
  3571. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  3572. utils.ErrorLog("解析失败:%v", err)
  3573. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3574. return
  3575. }
  3576. if res.Infcode == 0 {
  3577. patient, err := service.GetPatientByNumber(basNumber, c.GetAdminUserInfo().CurrentOrgId)
  3578. if err == gorm.ErrRecordNotFound {
  3579. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  3580. return
  3581. } else if err != nil {
  3582. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  3583. return
  3584. } else {
  3585. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  3586. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  3587. infoStr := string(Iinfos)
  3588. idetinfoStr := string(Idetinfos)
  3589. psn := &models.HisPsn{
  3590. PsnNo: res.Output.Baseinfo.PsnNo,
  3591. Age: res.Output.Baseinfo.Age,
  3592. PatientId: patient.ID,
  3593. Certno: res.Output.Baseinfo.Certno,
  3594. Brdy: res.Output.Baseinfo.Brdy,
  3595. Gend: res.Output.Baseinfo.Gend,
  3596. Naty: res.Output.Baseinfo.Naty,
  3597. PsnCertType: res.Output.Baseinfo.PsnCertType,
  3598. PsnName: res.Output.Baseinfo.PsnName,
  3599. Idetinfo: idetinfoStr,
  3600. Insuinfo: infoStr,
  3601. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  3602. CardInfo: basStr,
  3603. VerifyNumber: "",
  3604. }
  3605. service.CreateHisPsn(psn)
  3606. var rf []*ResultFive
  3607. json.Unmarshal([]byte(infoStr), &rf)
  3608. var insutypes []*ResultFive
  3609. var insutype string
  3610. var is390 int = 0
  3611. var is310 int = 0
  3612. for _, item := range rf {
  3613. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  3614. insutypes = append(insutypes, item)
  3615. }
  3616. }
  3617. if len(insutypes) == 1 {
  3618. insutype = insutypes[0].Insutype
  3619. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  3620. } else {
  3621. for _, i := range insutypes {
  3622. if i.Insutype == "390" {
  3623. is390 = 1
  3624. }
  3625. if i.Insutype == "310" {
  3626. is310 = 1
  3627. }
  3628. }
  3629. }
  3630. if is390 == 1 {
  3631. insutype = "390"
  3632. }
  3633. if is310 == 1 {
  3634. insutype = "310"
  3635. }
  3636. if len(insutypes) == 0 {
  3637. insutype = "310"
  3638. }
  3639. c.ServeSuccessJSON(map[string]interface{}{
  3640. "patient": patient,
  3641. "number": basNumber,
  3642. "insutype": insutype,
  3643. })
  3644. }
  3645. } else {
  3646. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  3647. return
  3648. }
  3649. } else {
  3650. if initFlag == 0 {
  3651. c.TestGetBasBaseInit()
  3652. }
  3653. basStr := c.GetBasBaseInfo()
  3654. if len(basStr) == 0 {
  3655. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeReadCardException)
  3656. return
  3657. }
  3658. fmt.Println(basStr)
  3659. bas := strings.Split(basStr, "|")
  3660. basNumber := bas[1]
  3661. fmt.Println(basNumber)
  3662. card_sn := bas[3]
  3663. fmt.Println(card_sn)
  3664. cardNumber := bas[2]
  3665. fmt.Println(cardNumber)
  3666. patient, _ := service.GetPatientByIDCard(basNumber, miConfig.UserOrgId)
  3667. var result string
  3668. if bas[0][:2] == "44" {
  3669. 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)
  3670. } else {
  3671. 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)
  3672. }
  3673. var dat map[string]interface{}
  3674. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  3675. fmt.Println(dat)
  3676. } else {
  3677. fmt.Println(err)
  3678. }
  3679. userJSONBytes, _ := json.Marshal(dat)
  3680. var res ResultTwo
  3681. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  3682. utils.ErrorLog("解析失败:%v", err)
  3683. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3684. return
  3685. }
  3686. if res.Infcode == 0 {
  3687. patient, err := service.GetPatientByNumber(basNumber, c.GetAdminUserInfo().CurrentOrgId)
  3688. if err == gorm.ErrRecordNotFound {
  3689. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  3690. return
  3691. } else if err != nil {
  3692. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  3693. return
  3694. } else {
  3695. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  3696. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  3697. infoStr := string(Iinfos)
  3698. idetinfoStr := string(Idetinfos)
  3699. var rf []*ResultFive
  3700. json.Unmarshal([]byte(infoStr), &rf)
  3701. var insutypes []*ResultFive
  3702. var insutype string
  3703. var is390 int = 0
  3704. var is310 int = 0
  3705. var insuplc_admdvs string
  3706. for _, item := range rf {
  3707. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  3708. insutypes = append(insutypes, item)
  3709. }
  3710. }
  3711. if len(insutypes) == 1 {
  3712. insutype = insutypes[0].Insutype
  3713. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  3714. } else {
  3715. for _, i := range insutypes {
  3716. if i.Insutype == "390" {
  3717. is390 = 1
  3718. }
  3719. if i.Insutype == "310" {
  3720. is310 = 1
  3721. }
  3722. }
  3723. }
  3724. if is390 == 1 {
  3725. insutype = "390"
  3726. }
  3727. if is310 == 1 {
  3728. insutype = "310"
  3729. }
  3730. if len(insutypes) == 0 {
  3731. insutype = "310"
  3732. }
  3733. for _, item := range rf {
  3734. if item.Insutype == insutype {
  3735. insuplc_admdvs = item.InsuplcAdmdvs
  3736. }
  3737. }
  3738. psn := &models.HisPsn{
  3739. PsnNo: res.Output.Baseinfo.PsnNo,
  3740. Age: res.Output.Baseinfo.Age,
  3741. PatientId: patient.ID,
  3742. Certno: res.Output.Baseinfo.Certno,
  3743. Brdy: res.Output.Baseinfo.Brdy,
  3744. Gend: res.Output.Baseinfo.Gend,
  3745. Naty: res.Output.Baseinfo.Naty,
  3746. PsnCertType: res.Output.Baseinfo.PsnCertType,
  3747. PsnName: res.Output.Baseinfo.PsnName,
  3748. Idetinfo: idetinfoStr,
  3749. Insuinfo: infoStr,
  3750. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  3751. CardInfo: basStr,
  3752. VerifyNumber: "",
  3753. InsuplcAdmdvs: insuplc_admdvs,
  3754. }
  3755. service.CreateHisPsn(psn)
  3756. c.ServeSuccessJSON(map[string]interface{}{
  3757. "patient": patient,
  3758. "number": basNumber,
  3759. })
  3760. }
  3761. } else {
  3762. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  3763. return
  3764. }
  3765. break
  3766. }
  3767. case 2:
  3768. if miConfig.MdtrtareaAdmvs == "430800" {
  3769. if initFlag == 0 {
  3770. c.TestGetHnBasBaseInit()
  3771. }
  3772. SFZStr := c.GetSFZBaseInfo()
  3773. if len(SFZStr) == 0 {
  3774. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeReadCardException)
  3775. return
  3776. }
  3777. fmt.Println(SFZStr)
  3778. id_card_str := strings.Split(SFZStr, "^")
  3779. card_no := id_card_str[0]
  3780. patient, _ := service.GetPatientByNumber(card_no, c.GetAdminUserInfo().CurrentOrgId)
  3781. //name := id_card_str[1]
  3782. //name = ConvertToString(name, "gbk", "utf-8")
  3783. 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)
  3784. var dat map[string]interface{}
  3785. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  3786. fmt.Println(dat)
  3787. } else {
  3788. fmt.Println(err)
  3789. }
  3790. userJSONBytes, _ := json.Marshal(dat)
  3791. var res ResultTwo
  3792. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  3793. utils.ErrorLog("解析失败:%v", err)
  3794. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3795. return
  3796. }
  3797. if res.Infcode == 0 {
  3798. patient, err := service.GetPatientByNumber(card_no, c.GetAdminUserInfo().CurrentOrgId)
  3799. if err == gorm.ErrRecordNotFound {
  3800. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  3801. return
  3802. } else if err != nil {
  3803. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  3804. return
  3805. } else {
  3806. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  3807. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  3808. infoStr := string(Iinfos)
  3809. idetinfoStr := string(Idetinfos)
  3810. psn := &models.HisPsn{
  3811. PsnNo: res.Output.Baseinfo.PsnNo,
  3812. Age: res.Output.Baseinfo.Age,
  3813. PatientId: patient.ID,
  3814. Certno: res.Output.Baseinfo.Certno,
  3815. Brdy: res.Output.Baseinfo.Brdy,
  3816. Gend: res.Output.Baseinfo.Gend,
  3817. Naty: res.Output.Baseinfo.Naty,
  3818. PsnCertType: res.Output.Baseinfo.PsnCertType,
  3819. PsnName: res.Output.Baseinfo.PsnName,
  3820. Idetinfo: idetinfoStr,
  3821. Insuinfo: infoStr,
  3822. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  3823. CardInfo: SFZStr,
  3824. VerifyNumber: "",
  3825. }
  3826. service.CreateHisPsn(psn)
  3827. var rf []*ResultFive
  3828. json.Unmarshal([]byte(infoStr), &rf)
  3829. var insutypes []*ResultFive
  3830. var insutype string
  3831. var is390 int = 0
  3832. var is310 int = 0
  3833. for _, item := range rf {
  3834. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  3835. insutypes = append(insutypes, item)
  3836. }
  3837. }
  3838. if len(insutypes) == 1 {
  3839. insutype = insutypes[0].Insutype
  3840. } else {
  3841. for _, i := range insutypes {
  3842. if i.Insutype == "390" {
  3843. is390 = 1
  3844. }
  3845. if i.Insutype == "310" {
  3846. is310 = 1
  3847. }
  3848. }
  3849. }
  3850. if is390 == 1 {
  3851. insutype = "390"
  3852. }
  3853. if is310 == 1 {
  3854. insutype = "310"
  3855. }
  3856. if len(insutypes) == 0 {
  3857. insutype = "310"
  3858. }
  3859. c.ServeSuccessJSON(map[string]interface{}{
  3860. "patient": patient,
  3861. "number": card_no,
  3862. "insutype": insutype,
  3863. })
  3864. }
  3865. } else {
  3866. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  3867. return
  3868. }
  3869. } else {
  3870. SFZStr := c.GetSFZBaseInfo()
  3871. id_card_str := strings.Split(SFZStr, "^")
  3872. id_card_number := id_card_str[0]
  3873. card_sn := ""
  3874. result := service.Gdyb1101B(id_card_number, miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, id_card_type, card_sn, certificates, "", "")
  3875. var dat map[string]interface{}
  3876. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  3877. fmt.Println(dat)
  3878. } else {
  3879. fmt.Println(err)
  3880. }
  3881. userJSONBytes, _ := json.Marshal(dat)
  3882. var res ResultTwo
  3883. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  3884. utils.ErrorLog("解析失败:%v", err)
  3885. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3886. return
  3887. }
  3888. if res.Infcode == 0 {
  3889. patient, err := service.GetPatientByNumber(id_card_number, c.GetAdminUserInfo().CurrentOrgId)
  3890. if err == gorm.ErrRecordNotFound {
  3891. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  3892. return
  3893. } else if err != nil {
  3894. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  3895. return
  3896. } else {
  3897. c.ServeSuccessJSON(map[string]interface{}{
  3898. "patient": patient,
  3899. "number": id_card_number,
  3900. })
  3901. }
  3902. } else {
  3903. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  3904. return
  3905. }
  3906. }
  3907. break
  3908. case 3:
  3909. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  3910. var api string
  3911. if miConfig.MdtrtareaAdmvs == "320921" {
  3912. 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 +
  3913. "&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
  3914. fmt.Println(api)
  3915. } else {
  3916. 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 +
  3917. "&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)
  3918. }
  3919. resp, requestErr := http.Get(api)
  3920. if requestErr != nil {
  3921. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3922. return
  3923. }
  3924. body, ioErr := ioutil.ReadAll(resp.Body)
  3925. if ioErr != nil {
  3926. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  3927. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3928. return
  3929. }
  3930. var respJSON map[string]interface{}
  3931. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  3932. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  3933. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3934. return
  3935. }
  3936. var status string
  3937. status = respJSON["data"].(map[string]interface{})["status"].(string)
  3938. card_type := respJSON["data"].(map[string]interface{})["type"].(string)
  3939. var token string
  3940. var res ResultTwo //1101结果
  3941. var res10265 ResultTwo10265 //1101结果
  3942. var card_info string //卡信息
  3943. var busi_card_info string
  3944. //card_info = respJSON["data"].(map[string]interface{})["card_info"].(string)
  3945. busi_card_info = respJSON["data"].(map[string]interface{})["busi_card_info"].(string)
  3946. if status == "0" { //读卡成功
  3947. if card_type == "1" {
  3948. respJSON = respJSON["data"].(map[string]interface{})["result"].(map[string]interface{})
  3949. result, _ := json.Marshal(respJSON)
  3950. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  3951. utils.ErrorLog("解析失败:%v", err)
  3952. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3953. return
  3954. }
  3955. res.ErrMsg = res10265.ErrMsg
  3956. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  3957. res.Infcode = infocode
  3958. res.Output = res10265.Output
  3959. res.InfRefmsgid = res10265.InfRefmsgid
  3960. } else {
  3961. //var card_info string //卡信息
  3962. //var busi_card_info string
  3963. token = respJSON["data"].(map[string]interface{})["token"].(string)
  3964. //busi_card_info = respJSON["data"].(map[string]interface{})["busi_card_info"].(string)
  3965. //fmt.Println(card_info)
  3966. //fmt.Println(busi_card_info)
  3967. respJSON = respJSON["data"].(map[string]interface{})["result"].(map[string]interface{})
  3968. result, _ := json.Marshal(respJSON)
  3969. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  3970. utils.ErrorLog("解析失败:%v", err)
  3971. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3972. return
  3973. }
  3974. res.ErrMsg = res10265.ErrMsg
  3975. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  3976. res.Infcode = infocode
  3977. res.Output = res10265.Output
  3978. res.InfRefmsgid = res10265.InfRefmsgid
  3979. }
  3980. if res.Infcode == 0 {
  3981. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  3982. if err == gorm.ErrRecordNotFound {
  3983. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  3984. return
  3985. } else if err != nil {
  3986. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  3987. return
  3988. } else {
  3989. if card_type == "1" {
  3990. bas := strings.Split(card_info, "|")
  3991. basNumber := bas[2]
  3992. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  3993. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  3994. infoStr := string(Iinfos)
  3995. idetinfoStr := string(Idetinfos)
  3996. psn := &models.HisPsn{
  3997. PsnNo: res.Output.Baseinfo.PsnNo,
  3998. Age: res.Output.Baseinfo.Age,
  3999. PatientId: patient.ID,
  4000. Certno: res.Output.Baseinfo.Certno,
  4001. Brdy: res.Output.Baseinfo.Brdy,
  4002. Gend: res.Output.Baseinfo.Gend,
  4003. Naty: res.Output.Baseinfo.Naty,
  4004. PsnCertType: res.Output.Baseinfo.PsnCertType,
  4005. PsnName: res.Output.Baseinfo.PsnName,
  4006. Idetinfo: idetinfoStr,
  4007. Insuinfo: infoStr,
  4008. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  4009. CardInfo: card_info,
  4010. VerifyNumber: busi_card_info,
  4011. }
  4012. service.CreateHisPsn(psn)
  4013. c.ServeSuccessJSON(map[string]interface{}{
  4014. "patient": patient,
  4015. "number": basNumber,
  4016. })
  4017. } else {
  4018. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  4019. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  4020. infoStr := string(Iinfos)
  4021. idetinfoStr := string(Idetinfos)
  4022. psn := &models.HisPsn{
  4023. PsnNo: res.Output.Baseinfo.PsnNo,
  4024. Age: res.Output.Baseinfo.Age,
  4025. PatientId: patient.ID,
  4026. Certno: res.Output.Baseinfo.Certno,
  4027. Brdy: res.Output.Baseinfo.Brdy,
  4028. Gend: res.Output.Baseinfo.Gend,
  4029. Naty: res.Output.Baseinfo.Naty,
  4030. PsnCertType: res.Output.Baseinfo.PsnCertType,
  4031. PsnName: res.Output.Baseinfo.PsnName,
  4032. Idetinfo: idetinfoStr,
  4033. Insuinfo: infoStr,
  4034. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  4035. CardInfo: card_info,
  4036. VerifyNumber: token,
  4037. }
  4038. service.CreateHisPsn(psn)
  4039. var rf []*ResultFive
  4040. json.Unmarshal([]byte(infoStr), &rf)
  4041. var insutypes []*ResultFive
  4042. var insutype string
  4043. var is390 int = 0
  4044. var is310 int = 0
  4045. for _, item := range rf {
  4046. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  4047. insutypes = append(insutypes, item)
  4048. }
  4049. }
  4050. if len(insutypes) == 1 {
  4051. insutype = insutypes[0].Insutype
  4052. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  4053. } else {
  4054. for _, i := range insutypes {
  4055. if i.Insutype == "390" {
  4056. is390 = 1
  4057. }
  4058. if i.Insutype == "310" {
  4059. is310 = 1
  4060. }
  4061. }
  4062. }
  4063. if is390 == 1 {
  4064. insutype = "390"
  4065. }
  4066. if is310 == 1 {
  4067. insutype = "310"
  4068. }
  4069. if len(insutypes) == 0 {
  4070. insutype = "310"
  4071. }
  4072. c.ServeSuccessJSON(map[string]interface{}{
  4073. "patient": patient,
  4074. "number": token,
  4075. "insutype": insutype,
  4076. })
  4077. }
  4078. }
  4079. } else {
  4080. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  4081. return
  4082. }
  4083. } else { //读卡失败
  4084. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  4085. return
  4086. }
  4087. }
  4088. break
  4089. case 4:
  4090. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  4091. var api string
  4092. if miConfig.MdtrtareaAdmvs == "320921" {
  4093. 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 +
  4094. "&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
  4095. fmt.Println(api)
  4096. } else {
  4097. 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 +
  4098. "&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)
  4099. }
  4100. resp, requestErr := http.Get(api)
  4101. if requestErr != nil {
  4102. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4103. return
  4104. }
  4105. body, ioErr := ioutil.ReadAll(resp.Body)
  4106. if ioErr != nil {
  4107. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  4108. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4109. return
  4110. }
  4111. var respJSON map[string]interface{}
  4112. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  4113. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  4114. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4115. return
  4116. }
  4117. var status string
  4118. status = respJSON["data"].(map[string]interface{})["status"].(string)
  4119. //card_type := respJSON["data"].(map[string]interface{})["type"].(string)
  4120. var token string
  4121. var res ResultTwo //1101结果
  4122. var res10265 ResultTwo10265 //1101结果
  4123. if status == "0" { //读卡成功
  4124. var card_info string //卡信息
  4125. var busi_card_info string
  4126. token = respJSON["data"].(map[string]interface{})["token"].(string)
  4127. busi_card_info = respJSON["data"].(map[string]interface{})["busi_card_info"].(string)
  4128. card_info = respJSON["data"].(map[string]interface{})["card_info"].(string)
  4129. fmt.Println(card_info)
  4130. fmt.Println(busi_card_info)
  4131. respJSON = respJSON["data"].(map[string]interface{})["result"].(map[string]interface{})
  4132. result, _ := json.Marshal(respJSON)
  4133. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  4134. utils.ErrorLog("解析失败:%v", err)
  4135. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4136. return
  4137. }
  4138. res.ErrMsg = res10265.ErrMsg
  4139. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  4140. res.Infcode = infocode
  4141. res.Output = res10265.Output
  4142. res.InfRefmsgid = res10265.InfRefmsgid
  4143. if res.Infcode == 0 {
  4144. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  4145. if err == gorm.ErrRecordNotFound {
  4146. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  4147. return
  4148. } else if err != nil {
  4149. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  4150. return
  4151. } else {
  4152. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  4153. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  4154. infoStr := string(Iinfos)
  4155. idetinfoStr := string(Idetinfos)
  4156. psn := &models.HisPsn{
  4157. PsnNo: res.Output.Baseinfo.PsnNo,
  4158. Age: res.Output.Baseinfo.Age,
  4159. PatientId: patient.ID,
  4160. Certno: res.Output.Baseinfo.Certno,
  4161. Brdy: res.Output.Baseinfo.Brdy,
  4162. Gend: res.Output.Baseinfo.Gend,
  4163. Naty: res.Output.Baseinfo.Naty,
  4164. PsnCertType: res.Output.Baseinfo.PsnCertType,
  4165. PsnName: res.Output.Baseinfo.PsnName,
  4166. Idetinfo: idetinfoStr,
  4167. Insuinfo: infoStr,
  4168. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  4169. CardInfo: card_info,
  4170. VerifyNumber: token,
  4171. }
  4172. var rf []*ResultFive
  4173. json.Unmarshal([]byte(infoStr), &rf)
  4174. var insutypes []*ResultFive
  4175. var insutype string
  4176. var is390 int = 0
  4177. var is310 int = 0
  4178. for _, item := range rf {
  4179. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  4180. insutypes = append(insutypes, item)
  4181. }
  4182. }
  4183. if len(insutypes) == 1 {
  4184. insutype = insutypes[0].Insutype
  4185. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  4186. } else {
  4187. for _, i := range insutypes {
  4188. if i.Insutype == "390" {
  4189. is390 = 1
  4190. }
  4191. if i.Insutype == "310" {
  4192. is310 = 1
  4193. }
  4194. }
  4195. }
  4196. if is390 == 1 {
  4197. insutype = "390"
  4198. }
  4199. if is310 == 1 {
  4200. insutype = "310"
  4201. }
  4202. if len(insutypes) == 0 {
  4203. insutype = "310"
  4204. }
  4205. service.CreateHisPsn(psn)
  4206. c.ServeSuccessJSON(map[string]interface{}{
  4207. "patient": patient,
  4208. "number": token,
  4209. "insutype": insutype,
  4210. })
  4211. }
  4212. } else {
  4213. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  4214. return
  4215. }
  4216. } else { //读卡失败
  4217. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  4218. return
  4219. }
  4220. } else if miConfig.MdtrtareaAdmvs == "430800" {
  4221. idNo := c.GetString("idNo")
  4222. userName := c.GetString("userName")
  4223. ecToken := c.GetString("ecToken")
  4224. insuOrg := c.GetString("insuOrg")
  4225. result2, requestLog2 := service.Hnyb1101ForEleCert(miConfig.OrgName, roles.UserName, miConfig.Code, insuOrg, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, miConfig.Url, miConfig.AccessKey, ecToken, "", idNo, userName)
  4226. saveLog(result2, requestLog2, "1101", "获取人员信息")
  4227. var res ResultTwo
  4228. if err := json.Unmarshal([]byte(result2), &res); err != nil {
  4229. utils.ErrorLog("解析失败:%v", err)
  4230. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4231. return
  4232. }
  4233. if res.Infcode == 0 {
  4234. patient, err := service.GetPatientByNumber(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  4235. if err == gorm.ErrRecordNotFound {
  4236. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  4237. return
  4238. } else if err != nil {
  4239. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  4240. return
  4241. } else {
  4242. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  4243. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  4244. infoStr := string(Iinfos)
  4245. idetinfoStr := string(Idetinfos)
  4246. psn := &models.HisPsn{
  4247. PsnNo: res.Output.Baseinfo.PsnNo,
  4248. Age: res.Output.Baseinfo.Age,
  4249. PatientId: patient.ID,
  4250. Certno: res.Output.Baseinfo.Certno,
  4251. Brdy: res.Output.Baseinfo.Brdy,
  4252. Gend: res.Output.Baseinfo.Gend,
  4253. Naty: res.Output.Baseinfo.Naty,
  4254. PsnCertType: res.Output.Baseinfo.PsnCertType,
  4255. PsnName: res.Output.Baseinfo.PsnName,
  4256. Idetinfo: idetinfoStr,
  4257. Insuinfo: infoStr,
  4258. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  4259. CardInfo: "",
  4260. Stage: "1",
  4261. VerifyNumber: ecToken,
  4262. InsuplcAdmdvs: insuOrg,
  4263. }
  4264. service.CreateHisPsn(psn)
  4265. var rf []*ResultFive
  4266. json.Unmarshal([]byte(infoStr), &rf)
  4267. var insutypes []*ResultFive
  4268. var insutype string
  4269. var is390 int = 0
  4270. var is310 int = 0
  4271. for _, item := range rf {
  4272. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  4273. insutypes = append(insutypes, item)
  4274. }
  4275. }
  4276. if len(insutypes) == 1 {
  4277. insutype = insutypes[0].Insutype
  4278. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  4279. } else {
  4280. for _, i := range insutypes {
  4281. if i.Insutype == "390" {
  4282. is390 = 1
  4283. }
  4284. if i.Insutype == "310" {
  4285. is310 = 1
  4286. }
  4287. }
  4288. }
  4289. if is390 == 1 {
  4290. insutype = "390"
  4291. }
  4292. if is310 == 1 {
  4293. insutype = "310"
  4294. }
  4295. if len(insutypes) == 0 {
  4296. insutype = "310"
  4297. }
  4298. c.ServeSuccessJSON(map[string]interface{}{
  4299. "patient": patient,
  4300. "number": ecToken,
  4301. "insutype": insutype,
  4302. })
  4303. }
  4304. } else {
  4305. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  4306. return
  4307. }
  4308. } else if miConfig.MdtrtareaAdmvs == "360399" {
  4309. //if initFlag == 0 {
  4310. c.TestGetJiangXiBasBaseInit()
  4311. //}
  4312. //if initEleFlag == 0 {
  4313. // GetJxEleBaseInitInfo(c.GetAdminUserInfo().CurrentOrgId)
  4314. //}
  4315. json_result := GetJxEleBaseInfo(c.GetAdminUserInfo().CurrentOrgId)
  4316. type ELeData struct {
  4317. Data struct {
  4318. IdNo string `json:"idNo"`
  4319. IdType string `json:"idType"`
  4320. UserName string `json:"userName"`
  4321. EcToken string `json:"ecToken"`
  4322. InsuOrg string `json:"insuOrg"`
  4323. Gender string `json:"gender"`
  4324. Birthday string `json:"birthday"`
  4325. Nationality string `json:"nationality"`
  4326. Email string `json:"email"`
  4327. Extra string `json:"extra"`
  4328. } `json:"data"`
  4329. Code int `json:"code"`
  4330. Message string `json:"message"`
  4331. }
  4332. var ele ELeData
  4333. err := json.Unmarshal([]byte(json_result), &ele)
  4334. if err != nil {
  4335. utils.ErrorLog("解析失败:%v", err)
  4336. }
  4337. token := ele.Data.EcToken
  4338. token = Remove0000(token)
  4339. 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)
  4340. saveLog(result2, requestLog2, "1101", "获取人员信息")
  4341. var res ResultTwo
  4342. if err := json.Unmarshal([]byte(result2), &res); err != nil {
  4343. utils.ErrorLog("解析失败:%v", err)
  4344. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4345. return
  4346. }
  4347. if res.Infcode == 0 {
  4348. patient, err := service.GetPatientByNumber(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  4349. if err == gorm.ErrRecordNotFound {
  4350. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  4351. return
  4352. } else if err != nil {
  4353. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  4354. return
  4355. } else {
  4356. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  4357. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  4358. infoStr := string(Iinfos)
  4359. idetinfoStr := string(Idetinfos)
  4360. psn := &models.HisPsn{
  4361. PsnNo: res.Output.Baseinfo.PsnNo,
  4362. Age: res.Output.Baseinfo.Age,
  4363. PatientId: patient.ID,
  4364. Certno: res.Output.Baseinfo.Certno,
  4365. Brdy: res.Output.Baseinfo.Brdy,
  4366. Gend: res.Output.Baseinfo.Gend,
  4367. Naty: res.Output.Baseinfo.Naty,
  4368. PsnCertType: res.Output.Baseinfo.PsnCertType,
  4369. PsnName: res.Output.Baseinfo.PsnName,
  4370. Idetinfo: idetinfoStr,
  4371. Insuinfo: infoStr,
  4372. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  4373. CardInfo: "",
  4374. //RecordDate:
  4375. VerifyNumber: token,
  4376. }
  4377. service.CreateHisPsn(psn)
  4378. var rf []*ResultFive
  4379. json.Unmarshal([]byte(infoStr), &rf)
  4380. var insutypes []*ResultFive
  4381. var insutype string
  4382. var is390 int = 0
  4383. var is310 int = 0
  4384. for _, item := range rf {
  4385. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  4386. insutypes = append(insutypes, item)
  4387. }
  4388. }
  4389. if len(insutypes) == 1 {
  4390. insutype = insutypes[0].Insutype
  4391. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  4392. } else {
  4393. for _, i := range insutypes {
  4394. if i.Insutype == "390" {
  4395. is390 = 1
  4396. }
  4397. if i.Insutype == "310" {
  4398. is310 = 1
  4399. }
  4400. }
  4401. }
  4402. if is390 == 1 {
  4403. insutype = "390"
  4404. }
  4405. if is310 == 1 {
  4406. insutype = "310"
  4407. }
  4408. if len(insutypes) == 0 {
  4409. insutype = "310"
  4410. }
  4411. c.ServeSuccessJSON(map[string]interface{}{
  4412. "patient": patient,
  4413. "number": token,
  4414. "insutype": insutype,
  4415. })
  4416. }
  4417. } else {
  4418. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  4419. return
  4420. }
  4421. } else if miConfig.MdtrtareaAdmvs == "430800" {
  4422. //if initFlag == 0 {
  4423. c.TestGetJiangXiBasBaseInit()
  4424. //}
  4425. //if initEleFlag == 0 {
  4426. // GetJxEleBaseInitInfo(c.GetAdminUserInfo().CurrentOrgId)
  4427. //}
  4428. json_result := GetJxEleBaseInfo(c.GetAdminUserInfo().CurrentOrgId)
  4429. type ELeData struct {
  4430. Data struct {
  4431. IdNo string `json:"idNo"`
  4432. IdType string `json:"idType"`
  4433. UserName string `json:"userName"`
  4434. EcToken string `json:"ecToken"`
  4435. InsuOrg string `json:"insuOrg"`
  4436. Gender string `json:"gender"`
  4437. Birthday string `json:"birthday"`
  4438. Nationality string `json:"nationality"`
  4439. Email string `json:"email"`
  4440. Extra string `json:"extra"`
  4441. } `json:"data"`
  4442. Code int `json:"code"`
  4443. Message string `json:"message"`
  4444. }
  4445. var ele ELeData
  4446. err := json.Unmarshal([]byte(json_result), &ele)
  4447. if err != nil {
  4448. utils.ErrorLog("解析失败:%v", err)
  4449. }
  4450. token := ele.Data.EcToken
  4451. token = Remove0000(token)
  4452. 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)
  4453. saveLog(result2, requestLog2, "1101", "获取人员信息")
  4454. var res ResultTwo
  4455. if err := json.Unmarshal([]byte(result2), &res); err != nil {
  4456. utils.ErrorLog("解析失败:%v", err)
  4457. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4458. return
  4459. }
  4460. if res.Infcode == 0 {
  4461. patient, err := service.GetPatientByNumber(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  4462. if err == gorm.ErrRecordNotFound {
  4463. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  4464. return
  4465. } else if err != nil {
  4466. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  4467. return
  4468. } else {
  4469. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  4470. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  4471. infoStr := string(Iinfos)
  4472. idetinfoStr := string(Idetinfos)
  4473. psn := &models.HisPsn{
  4474. PsnNo: res.Output.Baseinfo.PsnNo,
  4475. Age: res.Output.Baseinfo.Age,
  4476. PatientId: patient.ID,
  4477. Certno: res.Output.Baseinfo.Certno,
  4478. Brdy: res.Output.Baseinfo.Brdy,
  4479. Gend: res.Output.Baseinfo.Gend,
  4480. Naty: res.Output.Baseinfo.Naty,
  4481. PsnCertType: res.Output.Baseinfo.PsnCertType,
  4482. PsnName: res.Output.Baseinfo.PsnName,
  4483. Idetinfo: idetinfoStr,
  4484. Insuinfo: infoStr,
  4485. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  4486. CardInfo: "",
  4487. VerifyNumber: token,
  4488. }
  4489. service.CreateHisPsn(psn)
  4490. var rf []*ResultFive
  4491. json.Unmarshal([]byte(infoStr), &rf)
  4492. var insutypes []*ResultFive
  4493. var insutype string
  4494. var is390 int = 0
  4495. var is310 int = 0
  4496. for _, item := range rf {
  4497. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  4498. insutypes = append(insutypes, item)
  4499. }
  4500. }
  4501. if len(insutypes) == 1 {
  4502. insutype = insutypes[0].Insutype
  4503. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  4504. } else {
  4505. for _, i := range insutypes {
  4506. if i.Insutype == "390" {
  4507. is390 = 1
  4508. }
  4509. if i.Insutype == "310" {
  4510. is310 = 1
  4511. }
  4512. }
  4513. }
  4514. if is390 == 1 {
  4515. insutype = "390"
  4516. }
  4517. if is310 == 1 {
  4518. insutype = "310"
  4519. }
  4520. if len(insutypes) == 0 {
  4521. insutype = "310"
  4522. }
  4523. c.ServeSuccessJSON(map[string]interface{}{
  4524. "patient": patient,
  4525. "number": token,
  4526. "insutype": insutype,
  4527. })
  4528. }
  4529. } else {
  4530. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  4531. return
  4532. }
  4533. } else if miConfig.MdtrtareaAdmvs == "350500" {
  4534. type ELeData struct {
  4535. Code string `json:"code"`
  4536. Data struct {
  4537. Aac002 string `json:"aac002"`
  4538. Aaz500 string `json:"aaz500"`
  4539. ActCardNo string `json:"actCardNo"`
  4540. Bab520 string `json:"bab520"`
  4541. Bkz543 string `json:"bkz543"`
  4542. BusinessType string `json:"businessType"`
  4543. CertfCodg string `json:"certfCodg"`
  4544. EcIndexNo string `json:"ecIndexNo"`
  4545. EcToken string `json:"ecToken"`
  4546. ID0000 string `json:"id0000"`
  4547. IDNo string `json:"idNo"`
  4548. IDType string `json:"idType"`
  4549. Idcode string `json:"idcode"`
  4550. IdentityToken string `json:"identity_token"`
  4551. InsuOrg string `json:"insuOrg"`
  4552. OfficeID string `json:"officeId"`
  4553. OfficeName string `json:"officeName"`
  4554. OperatorID string `json:"operatorId"`
  4555. OperatorName string `json:"operatorName"`
  4556. OrgID string `json:"orgId"`
  4557. UserName string `json:"userName"`
  4558. } `json:"data"`
  4559. Infno interface{} `json:"infno"`
  4560. Message string `json:"message"`
  4561. OrgID string `json:"orgId"`
  4562. TransType string `json:"transType"`
  4563. }
  4564. inputInfo, outPutInfo, _ := service.ReadEleCard(miConfig.Code)
  4565. outPutInfo = Remove0000(outPutInfo)
  4566. if len(outPutInfo) > 0 {
  4567. var ele ELeData
  4568. err := json.Unmarshal([]byte(outPutInfo), &ele)
  4569. if err != nil {
  4570. utils.ErrorLog("解析失败:%v", err)
  4571. }
  4572. token := ele.Data.EcToken
  4573. fmt.Println(inputInfo)
  4574. fmt.Println(outPutInfo)
  4575. 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)
  4576. saveLog(result, requestLog, "1101", "获取人员信息")
  4577. var dat map[string]interface{}
  4578. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  4579. fmt.Println(dat)
  4580. } else {
  4581. fmt.Println(err)
  4582. }
  4583. userJSONBytes, _ := json.Marshal(dat)
  4584. var res ResultTwo
  4585. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  4586. utils.ErrorLog("解析失败:%v", err)
  4587. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4588. return
  4589. }
  4590. res.ErrMsg = errMsgLog
  4591. if res.Infcode == 0 {
  4592. patient, err := service.GetPatientByNumber(ele.Data.IDNo, c.GetAdminUserInfo().CurrentOrgId)
  4593. if err == gorm.ErrRecordNotFound {
  4594. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  4595. return
  4596. } else if err != nil {
  4597. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  4598. return
  4599. } else {
  4600. fmt.Println(res)
  4601. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  4602. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  4603. infoStr := string(Iinfos)
  4604. idetinfoStr := string(Idetinfos)
  4605. psn := &models.HisPsn{
  4606. PsnNo: res.Output.Baseinfo.PsnNo,
  4607. Age: res.Output.Baseinfo.Age,
  4608. PatientId: patient.ID,
  4609. Certno: res.Output.Baseinfo.Certno,
  4610. Brdy: res.Output.Baseinfo.Brdy,
  4611. Gend: res.Output.Baseinfo.Gend,
  4612. Naty: res.Output.Baseinfo.Naty,
  4613. PsnCertType: res.Output.Baseinfo.PsnCertType,
  4614. PsnName: res.Output.Baseinfo.PsnName,
  4615. Idetinfo: idetinfoStr,
  4616. Insuinfo: infoStr,
  4617. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  4618. CardInfo: outPutInfo,
  4619. VerifyNumber: token,
  4620. InsuplcAdmdvs: ele.Data.InsuOrg,
  4621. }
  4622. service.CreateHisPsn(psn)
  4623. var rf []*ResultFive
  4624. json.Unmarshal([]byte(infoStr), &rf)
  4625. var insutypes []*ResultFive
  4626. var insutype string
  4627. var is390 int = 0
  4628. var is310 int = 0
  4629. for _, item := range rf {
  4630. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  4631. insutypes = append(insutypes, item)
  4632. }
  4633. }
  4634. if len(insutypes) == 1 {
  4635. insutype = insutypes[0].Insutype
  4636. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  4637. } else {
  4638. for _, i := range insutypes {
  4639. if i.Insutype == "390" {
  4640. is390 = 1
  4641. }
  4642. if i.Insutype == "310" {
  4643. is310 = 1
  4644. }
  4645. }
  4646. }
  4647. if is390 == 1 {
  4648. insutype = "390"
  4649. }
  4650. if is310 == 1 {
  4651. insutype = "310"
  4652. }
  4653. if len(insutypes) == 0 {
  4654. insutype = "310"
  4655. }
  4656. c.ServeSuccessJSON(map[string]interface{}{
  4657. "patient": patient,
  4658. "number": token,
  4659. "insutype": insutype,
  4660. })
  4661. }
  4662. } else {
  4663. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  4664. return
  4665. }
  4666. }
  4667. } else {
  4668. type ELeData struct {
  4669. Code string `json:"code"`
  4670. Data struct {
  4671. Aac002 string `json:"aac002"`
  4672. Aaz500 string `json:"aaz500"`
  4673. ActCardNo string `json:"actCardNo"`
  4674. Bab520 string `json:"bab520"`
  4675. Bkz543 string `json:"bkz543"`
  4676. BusinessType string `json:"businessType"`
  4677. CertfCodg string `json:"certfCodg"`
  4678. EcIndexNo string `json:"ecIndexNo"`
  4679. EcToken string `json:"ecToken"`
  4680. ID0000 string `json:"id0000"`
  4681. IDNo string `json:"idNo"`
  4682. IDType string `json:"idType"`
  4683. Idcode string `json:"idcode"`
  4684. IdentityToken string `json:"identity_token"`
  4685. InsuOrg string `json:"insuOrg"`
  4686. OfficeID string `json:"officeId"`
  4687. OfficeName string `json:"officeName"`
  4688. OperatorID string `json:"operatorId"`
  4689. OperatorName string `json:"operatorName"`
  4690. OrgID string `json:"orgId"`
  4691. UserName string `json:"userName"`
  4692. } `json:"data"`
  4693. Infno interface{} `json:"infno"`
  4694. Message string `json:"message"`
  4695. OrgID string `json:"orgId"`
  4696. TransType string `json:"transType"`
  4697. }
  4698. _, result := GetELeInfo(miConfig.Code, "1", roles.UserName)
  4699. fmt.Println(result)
  4700. outPutInfo := Remove0000(result)
  4701. fmt.Println(outPutInfo)
  4702. if len(outPutInfo) > 0 {
  4703. var ele ELeData
  4704. err := json.Unmarshal([]byte(outPutInfo), &ele)
  4705. if err != nil {
  4706. utils.ErrorLog("解析失败:%v", err)
  4707. }
  4708. token := ele.Data.EcToken
  4709. fmt.Println(outPutInfo)
  4710. result, requestLog := service.Gdyb1101ForEleCert(miConfig.OrgName, roles.UserName, miConfig.Code, ele.Data.InsuOrg, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, token, ele.Data.UserName, ele.Data.IDNo)
  4711. saveLog(result, requestLog, "1101", "获取人员信息")
  4712. var dat map[string]interface{}
  4713. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  4714. fmt.Println(dat)
  4715. } else {
  4716. fmt.Println(err)
  4717. }
  4718. userJSONBytes, _ := json.Marshal(dat)
  4719. var res ResultTwo
  4720. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  4721. utils.ErrorLog("解析失败:%v", err)
  4722. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4723. return
  4724. }
  4725. if res.Infcode == 0 {
  4726. patient, err := service.GetPatientByNumber(ele.Data.IDNo, c.GetAdminUserInfo().CurrentOrgId)
  4727. if err == gorm.ErrRecordNotFound {
  4728. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  4729. return
  4730. } else if err != nil {
  4731. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  4732. return
  4733. } else {
  4734. fmt.Println(res)
  4735. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  4736. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  4737. infoStr := string(Iinfos)
  4738. idetinfoStr := string(Idetinfos)
  4739. psn := &models.HisPsn{
  4740. PsnNo: res.Output.Baseinfo.PsnNo,
  4741. Age: res.Output.Baseinfo.Age,
  4742. PatientId: patient.ID,
  4743. Certno: res.Output.Baseinfo.Certno,
  4744. Brdy: res.Output.Baseinfo.Brdy,
  4745. Gend: res.Output.Baseinfo.Gend,
  4746. Naty: res.Output.Baseinfo.Naty,
  4747. PsnCertType: res.Output.Baseinfo.PsnCertType,
  4748. PsnName: res.Output.Baseinfo.PsnName,
  4749. Idetinfo: idetinfoStr,
  4750. Insuinfo: infoStr,
  4751. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  4752. CardInfo: outPutInfo,
  4753. VerifyNumber: token,
  4754. InsuplcAdmdvs: ele.Data.InsuOrg,
  4755. }
  4756. service.CreateHisPsn(psn)
  4757. var rf []*ResultFive
  4758. json.Unmarshal([]byte(infoStr), &rf)
  4759. var insutypes []*ResultFive
  4760. var insutype string
  4761. var is390 int = 0
  4762. var is310 int = 0
  4763. for _, item := range rf {
  4764. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  4765. insutypes = append(insutypes, item)
  4766. }
  4767. }
  4768. if len(insutypes) == 1 {
  4769. insutype = insutypes[0].Insutype
  4770. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  4771. } else {
  4772. for _, i := range insutypes {
  4773. if i.Insutype == "390" {
  4774. is390 = 1
  4775. }
  4776. if i.Insutype == "310" {
  4777. is310 = 1
  4778. }
  4779. }
  4780. }
  4781. if is390 == 1 {
  4782. insutype = "390"
  4783. }
  4784. if is310 == 1 {
  4785. insutype = "310"
  4786. }
  4787. if len(insutypes) == 0 {
  4788. insutype = "310"
  4789. }
  4790. c.ServeSuccessJSON(map[string]interface{}{
  4791. "patient": patient,
  4792. "number": token,
  4793. "insutype": insutype,
  4794. })
  4795. }
  4796. } else {
  4797. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  4798. return
  4799. }
  4800. }
  4801. //fmt.Println(result)
  4802. //
  4803. //if initFlag == 0 {
  4804. // c.TestGetBasBaseInit()
  4805. //}
  4806. //token := c.GetEleBaseInfo()
  4807. //
  4808. //token = Remove0000(token)
  4809. //
  4810. //result2, requestLog2 := service.Gdyb1101ForEleCert(miConfig.OrgName, roles.UserName, miConfig.Code, insuplc_admdvs_str, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, token, "", "")
  4811. //saveLog(result2, requestLog2, "1101", "获取人员信息")
  4812. ////
  4813. //var res ResultTwo
  4814. //if err := json.Unmarshal([]byte(result2), &res); err != nil {
  4815. // utils.ErrorLog("解析失败:%v", err)
  4816. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4817. // return
  4818. //}
  4819. //
  4820. //if res.Infcode == 0 {
  4821. // patient, err := service.GetPatientByNumber(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  4822. // if err == gorm.ErrRecordNotFound {
  4823. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  4824. // return
  4825. // } else if err != nil {
  4826. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  4827. // return
  4828. //
  4829. // } else {
  4830. // Iinfos, _ := json.Marshal(res.Output.Iinfo)
  4831. // Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  4832. // infoStr := string(Iinfos)
  4833. // idetinfoStr := string(Idetinfos)
  4834. //
  4835. //
  4836. //
  4837. //
  4838. // var rf []*ResultFive
  4839. // json.Unmarshal([]byte(infoStr), &rf)
  4840. //
  4841. // var insutypes []*ResultFive
  4842. // var insutype string
  4843. // var is390 int = 0
  4844. // var is310 int = 0
  4845. // var insuplc_admdvs string
  4846. //
  4847. // for _, item := range rf {
  4848. // if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  4849. // insutypes = append(insutypes, item)
  4850. // }
  4851. // }
  4852. //
  4853. // if len(insutypes) == 1 {
  4854. // insutype = insutypes[0].Insutype
  4855. // //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  4856. // } else {
  4857. // for _, i := range insutypes {
  4858. // if i.Insutype == "390" {
  4859. // is390 = 1
  4860. // }
  4861. //
  4862. // if i.Insutype == "310" {
  4863. // is310 = 1
  4864. // }
  4865. // }
  4866. // }
  4867. // if is390 == 1 {
  4868. // insutype = "390"
  4869. // }
  4870. //
  4871. // if is310 == 1 {
  4872. // insutype = "310"
  4873. // }
  4874. // if len(insutypes) == 0 {
  4875. // insutype = "310"
  4876. // }
  4877. // for _, item := range rf {
  4878. // if item.Insutype == insutype {
  4879. // insuplc_admdvs = item.InsuplcAdmdvs
  4880. // }
  4881. // }
  4882. // psn := &models.HisPsn{
  4883. // PsnNo: res.Output.Baseinfo.PsnNo,
  4884. // Age: res.Output.Baseinfo.Age,
  4885. // PatientId: patient.ID,
  4886. // Certno: res.Output.Baseinfo.Certno,
  4887. // Brdy: res.Output.Baseinfo.Brdy,
  4888. // Gend: res.Output.Baseinfo.Gend,
  4889. // Naty: res.Output.Baseinfo.Naty,
  4890. // PsnCertType: res.Output.Baseinfo.PsnCertType,
  4891. // PsnName: res.Output.Baseinfo.PsnName,
  4892. // Idetinfo: idetinfoStr,
  4893. // Insuinfo: infoStr,
  4894. // UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  4895. // CardInfo: "",
  4896. // VerifyNumber: token,
  4897. // InsuplcAdmdvs: insuplc_admdvs,
  4898. // }
  4899. // service.CreateHisPsn(psn)
  4900. //
  4901. // c.ServeSuccessJSON(map[string]interface{}{
  4902. // "patient": patient,
  4903. // "number": token,
  4904. // })
  4905. // }
  4906. //} else {
  4907. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  4908. // return
  4909. //}
  4910. }
  4911. break
  4912. }
  4913. }
  4914. var initFlag int64 = 0
  4915. var initEleFlag int64 = 0
  4916. func (c *HisApiController) TestGetBasBaseInit() {
  4917. DllDef := syscall.MustLoadDLL("SSCard.dll")
  4918. Iinit := DllDef.MustFindProc("Init")
  4919. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  4920. ret, _, err := Iinit.Call(StrPtr("http://igb.hsa.gdgov.cn/gdyb_api/prd/api/card/initDll"), StrPtr(miConfig.InsuplcAdmdvs))
  4921. if ret != 0 {
  4922. fmt.Println("SSCard的报错原因:", err)
  4923. fmt.Println("SSCard的运算结果为:", ret)
  4924. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeReadCardException)
  4925. return
  4926. }
  4927. result := int(ret)
  4928. fmt.Println("SSCard的运算结果为1:", result)
  4929. initFlag = 1
  4930. return
  4931. }
  4932. func (c *HisApiController) HandleJiangXiReadCard() {
  4933. fmt.Println("~~~~~~")
  4934. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  4935. admin_user_id, _ := c.GetInt64("admin_user_id")
  4936. id_card_type, _ := c.GetInt64("id_card_type")
  4937. //certificates, _ := c.GetInt64("certificates")
  4938. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  4939. if initFlag == 0 {
  4940. c.TestGetJiangXiBasBaseInit()
  4941. }
  4942. basStr := c.GetBasBaseInfo()
  4943. if len(basStr) == 0 {
  4944. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeReadCardException)
  4945. return
  4946. }
  4947. fmt.Println(basStr)
  4948. bas := strings.Split(basStr, "|")
  4949. basNumber := bas[1]
  4950. fmt.Println(basNumber)
  4951. card_sn := bas[3]
  4952. fmt.Println(card_sn)
  4953. 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, "")
  4954. //result := service.Jxyb1101(basNumber, miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, id_card_type, card_sn, certificates)
  4955. var dat map[string]interface{}
  4956. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  4957. fmt.Println(dat)
  4958. } else {
  4959. fmt.Println(err)
  4960. }
  4961. userJSONBytes, _ := json.Marshal(dat)
  4962. var res ResultTwo
  4963. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  4964. utils.ErrorLog("解析失败:%v", err)
  4965. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4966. return
  4967. }
  4968. if res.Infcode == 0 {
  4969. patient, err := service.GetPatientByNumber(basNumber, c.GetAdminUserInfo().CurrentOrgId)
  4970. if err == gorm.ErrRecordNotFound {
  4971. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  4972. return
  4973. } else if err != nil {
  4974. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  4975. return
  4976. } else {
  4977. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  4978. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  4979. infoStr := string(Iinfos)
  4980. idetinfoStr := string(Idetinfos)
  4981. psn := &models.HisPsn{
  4982. PsnNo: res.Output.Baseinfo.PsnNo,
  4983. Age: res.Output.Baseinfo.Age,
  4984. PatientId: patient.ID,
  4985. Certno: res.Output.Baseinfo.Certno,
  4986. Brdy: res.Output.Baseinfo.Brdy,
  4987. Gend: res.Output.Baseinfo.Gend,
  4988. Naty: res.Output.Baseinfo.Naty,
  4989. PsnCertType: res.Output.Baseinfo.PsnCertType,
  4990. PsnName: res.Output.Baseinfo.PsnName,
  4991. Idetinfo: idetinfoStr,
  4992. Insuinfo: infoStr,
  4993. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  4994. CardInfo: basStr,
  4995. VerifyNumber: "",
  4996. }
  4997. service.CreateHisPsn(psn)
  4998. c.ServeSuccessJSON(map[string]interface{}{
  4999. "patient": patient,
  5000. "number": basNumber,
  5001. })
  5002. }
  5003. } else {
  5004. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  5005. return
  5006. }
  5007. }
  5008. func (c *HisApiController) TestGetHnBasBaseInit() {
  5009. DllDef := syscall.MustLoadDLL("SSCard.dll")
  5010. Iinit := DllDef.MustFindProc("Init")
  5011. //miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  5012. //http://10.77.211.236/CSB/hsa-fsi-1303
  5013. ret, _, err := Iinit.Call(StrPtr("http://10.93.32.89:20001/hsa-hgs-adapt/api/card/initDll"), StrPtr("430100|10.93.32.89:20001"))
  5014. if ret != 0 {
  5015. fmt.Println("SSCard的报错原因:", err)
  5016. fmt.Println("SSCard的运算结果为:", ret)
  5017. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeReadCardException)
  5018. return
  5019. }
  5020. result := int(ret)
  5021. fmt.Println("SSCard的运算结果为1:", result)
  5022. initFlag = 1
  5023. return
  5024. }
  5025. func (c *HisApiController) TestGetJiangXiBasBaseInit() {
  5026. DllDef := syscall.MustLoadDLL("SSCard.dll")
  5027. Iinit := DllDef.MustFindProc("Init")
  5028. //miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  5029. //http://10.77.211.236/CSB/hsa-fsi-1303
  5030. ret, _, err := Iinit.Call(StrPtr("http://10.77.224.18:9001/1.0.0/agent-card-init"), StrPtr("360399"))
  5031. if ret != 0 {
  5032. fmt.Println("SSCard的报错原因:", err)
  5033. fmt.Println("SSCard的运算结果为:", ret)
  5034. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeReadCardException)
  5035. return
  5036. }
  5037. result := int(ret)
  5038. fmt.Println("SSCard的运算结果为1:", result)
  5039. initFlag = 1
  5040. return
  5041. }
  5042. func (c *HisApiController) GetSFZBaseInfo() string {
  5043. DllDef := syscall.MustLoadDLL("SSCard.dll")
  5044. readCard := DllDef.MustFindProc("ReadSFZ")
  5045. if readCard == nil {
  5046. fmt.Println("readcard is nil")
  5047. readCard = DllDef.MustFindProc("ReadSFZ")
  5048. }
  5049. str := make([]byte, 8096)
  5050. str1 := make([]byte, 8096)
  5051. r, _, _ := readCard.Call((uintptr)(unsafe.Pointer(&str[0])), IntPtr(8096), (uintptr)(unsafe.Pointer(&str1[0])), IntPtr(8096))
  5052. fmt.Println(r)
  5053. return Remove0000(string(str))
  5054. }
  5055. func (c *HisApiController) GetEleBaseInfo() string {
  5056. DllDef := syscall.MustLoadDLL("SSCard.dll")
  5057. readCard := DllDef.MustFindProc("GetQRBase")
  5058. fmt.Println(readCard)
  5059. if readCard == nil {
  5060. fmt.Println("readcard is nil")
  5061. readCard = DllDef.MustFindProc("GetQRBase")
  5062. }
  5063. str := make([]byte, 1024)
  5064. str1 := make([]byte, 1024)
  5065. ret2, _, _ := readCard.Call(uintptr(180), (uintptr)(unsafe.Pointer(&str[0])), uintptr(1024), (uintptr)(unsafe.Pointer(&str1[0])), uintptr(1024))
  5066. fmt.Println(ret2)
  5067. fmt.Println(string(str1))
  5068. fmt.Println(string(str))
  5069. fmt.Println(":", ConvertToString(string(str1), "gbk", "utf-8"))
  5070. fmt.Println(":", ConvertToString(string(str), "gbk", "utf-8"))
  5071. if ret2 != 0 {
  5072. return ""
  5073. }
  5074. return string(str)
  5075. }
  5076. func GetHnEleBaseInfo(code string, operator_id int64, operator_name string) (string, string) {
  5077. DllDef := syscall.MustLoadDLL("NationECCode.dll")
  5078. readCard := DllDef.MustFindProc("NationEcTrans")
  5079. fmt.Println(readCard)
  5080. fmt.Println("!!!!!")
  5081. pBusiCardInfo := make([]byte, 2048)
  5082. input := make(map[string]interface{})
  5083. inputData := make(map[string]interface{})
  5084. inputData["orgId"] = code
  5085. inputData["businessType"] = "01101"
  5086. inputData["operatorId"] = "1"
  5087. inputData["operatorName"] = "admin"
  5088. inputData["officeId"] = "001"
  5089. inputData["officeName"] = "血透室"
  5090. inputData["deviceType"] = ""
  5091. input["data"] = inputData
  5092. input["orgId"] = code
  5093. input["transType"] = "ec.query"
  5094. bytesData, _ := json.Marshal(input)
  5095. ret2, _, _ := readCard.Call(StrPtr("https://10.93.32.89:20001/localcfc/api/hsecfc/localQrCodeQuery"), StrPtr(string(bytesData)), (uintptr)(unsafe.Pointer(&pBusiCardInfo[0])))
  5096. fmt.Println(ret2)
  5097. fmt.Println(DeleteExtraSpace(string(pBusiCardInfo)))
  5098. fmt.Println(":", ConvertToString(DeleteExtraSpace(string(pBusiCardInfo)), "gbk", "utf-8"))
  5099. return DeleteExtraSpace(""), DeleteExtraSpace(string(pBusiCardInfo))
  5100. }
  5101. func GetgdEleBaseInfo(code string, operator_id int64, operator_name string) (string, string) {
  5102. DllDef := syscall.MustLoadDLL("NationECCode.dll")
  5103. readCard := DllDef.MustFindProc("NationEcTrans")
  5104. fmt.Println(readCard)
  5105. fmt.Println("!!!!!")
  5106. pBusiCardInfo := make([]byte, 2048)
  5107. input := make(map[string]interface{})
  5108. inputData := make(map[string]interface{})
  5109. inputData["orgId"] = code
  5110. inputData["businessType"] = "01101"
  5111. inputData["operatorId"] = "9"
  5112. inputData["operatorName"] = "admin"
  5113. inputData["officeId"] = "001"
  5114. inputData["officeName"] = "血透室"
  5115. inputData["deviceType"] = ""
  5116. input["data"] = inputData
  5117. input["orgId"] = code
  5118. input["transType"] = "ec.query"
  5119. bytesData, _ := json.Marshal(input)
  5120. 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])))
  5121. fmt.Println(ret2)
  5122. fmt.Println(DeleteExtraSpace(string(pBusiCardInfo)))
  5123. fmt.Println(":", ConvertToString(DeleteExtraSpace(string(pBusiCardInfo)), "gbk", "utf-8"))
  5124. return DeleteExtraSpace(""), ConvertToString(DeleteExtraSpace(string(pBusiCardInfo)), "gbk", "utf-8")
  5125. }
  5126. func GetgdEleBaseInfoTwo(code string, operator_id int64, operator_name string) (string, string) {
  5127. DllDef := syscall.MustLoadDLL("NationECCode.dll")
  5128. readCard := DllDef.MustFindProc("NationEcTrans")
  5129. fmt.Println(readCard)
  5130. fmt.Println("!!!!!")
  5131. pBusiCardInfo := make([]byte, 2048)
  5132. input := make(map[string]interface{})
  5133. inputData := make(map[string]interface{})
  5134. inputData["orgId"] = code
  5135. inputData["businessType"] = "01301"
  5136. inputData["operatorId"] = "9"
  5137. inputData["operatorName"] = "admin"
  5138. inputData["officeId"] = "001"
  5139. inputData["officeName"] = "血透室"
  5140. inputData["deviceType"] = ""
  5141. input["data"] = inputData
  5142. input["orgId"] = code
  5143. input["transType"] = "ec.query"
  5144. bytesData, _ := json.Marshal(input)
  5145. 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])))
  5146. fmt.Println(ret2)
  5147. fmt.Println(DeleteExtraSpace(string(pBusiCardInfo)))
  5148. fmt.Println(":", ConvertToString(DeleteExtraSpace(string(pBusiCardInfo)), "gbk", "utf-8"))
  5149. return DeleteExtraSpace(""), ConvertToString(DeleteExtraSpace(string(pBusiCardInfo)), "gbk", "utf-8")
  5150. }
  5151. func GetJxEleBaseInfo(org_id int64) string {
  5152. DllDef := syscall.MustLoadDLL("SSCard.dll")
  5153. readCard := DllDef.MustFindProc("NationEcTrans")
  5154. miConfig, _ := service.FindMedicalInsuranceInfo(org_id)
  5155. if readCard == nil {
  5156. fmt.Println("readcard is nil")
  5157. readCard = DllDef.MustFindProc("NationEcTrans")
  5158. }
  5159. str1 := make([]byte, 1024)
  5160. data := make(map[string]interface{})
  5161. inputData := make(map[string]interface{})
  5162. inputData["orgId"] = miConfig.Code
  5163. inputData["businessType"] = "01101"
  5164. inputData["operatorId"] = "test001"
  5165. inputData["operatorName"] = "cn"
  5166. inputData["officeId"] = "32760"
  5167. inputData["officeName"] = "waike"
  5168. inputData["deviceType"] = ""
  5169. data["data"] = inputData
  5170. data["transType"] = "ec.query"
  5171. data["extra "] = ""
  5172. data["orgId"] = miConfig.Code
  5173. bytesData, _ := json.Marshal(data)
  5174. //bytesData, _ := json.Marshal(data)
  5175. //bytesData = []byte(ConvertToString(string(bytesData), "utf-8", "gbk"))
  5176. ret2, _, _ := readCard.Call(StrPtr("http://10.77.224.18:9001/1.0.0/localQrCodeQuery"), (uintptr)(unsafe.Pointer(&bytesData[0])), (uintptr)(unsafe.Pointer(&str1[0])))
  5177. fmt.Println(ret2)
  5178. fmt.Println(string(str1))
  5179. fmt.Println(":", ConvertToString(string(str1), "gbk", "utf-8"))
  5180. if ret2 != 0 {
  5181. return ""
  5182. }
  5183. return Remove0000(ConvertToString(string(str1), "gbk", "utf-8"))
  5184. }
  5185. func GetJxEleBaseInitInfo(org_id int64) string {
  5186. DllDef := syscall.MustLoadDLL("SSCard.dll")
  5187. readCard := DllDef.MustFindProc("NationEcTrans")
  5188. miConfig, _ := service.FindMedicalInsuranceInfo(org_id)
  5189. if readCard == nil {
  5190. fmt.Println("readcard is nil")
  5191. readCard = DllDef.MustFindProc("NationEcTrans")
  5192. }
  5193. str1 := make([]byte, 2048)
  5194. data := make(map[string]interface{})
  5195. inputData := make(map[string]interface{})
  5196. inputData["orgId"] = miConfig.Code
  5197. inputData["businessType"] = "01101"
  5198. inputData["operatorId"] = "1"
  5199. inputData["operatorName"] = "huangchuang"
  5200. inputData["officeId"] = "101"
  5201. inputData["officeName"] = "xuetou"
  5202. inputData["deviceType"] = ""
  5203. data["data"] = inputData
  5204. data["transType"] = "ec.query"
  5205. data["orgId"] = miConfig.Code
  5206. bytesData, _ := json.Marshal(data)
  5207. bytesData = []byte(ConvertToString(string(bytesData), "utf-8", "gbk"))
  5208. ret2, _, _ := readCard.Call(StrPtr("http://10.77.224.18:9001/1.0.0/getEncDynamicKey"), (uintptr)(unsafe.Pointer(&bytesData[0])), (uintptr)(unsafe.Pointer(&str1[0])))
  5209. fmt.Println("http://10.77.224.18:9001/1.0.0/getEncDynamicKey")
  5210. fmt.Println(ret2)
  5211. fmt.Println(string(str1))
  5212. fmt.Println(":", ConvertToString(string(str1), "gbk", "utf-8"))
  5213. if ret2 != 0 {
  5214. return ""
  5215. }
  5216. if len(Remove0000(ConvertToString(string(str1), "gbk", "utf-8"))) > 0 {
  5217. initEleFlag = 1
  5218. }
  5219. return Remove0000(ConvertToString(string(str1), "gbk", "utf-8"))
  5220. }
  5221. func (c *HisApiController) GetBasBaseInfo() string {
  5222. DllDef := syscall.MustLoadDLL("SSCard.dll")
  5223. readCard := DllDef.MustFindProc("ReadCardBas")
  5224. if readCard == nil {
  5225. fmt.Println("readcard is nil")
  5226. readCard = DllDef.MustFindProc("ReadCardBas")
  5227. }
  5228. str := make([]byte, 1024)
  5229. str1 := make([]byte, 1024)
  5230. ret2, _, _ := readCard.Call((uintptr)(unsafe.Pointer(&str[0])), uintptr(1024), (uintptr)(unsafe.Pointer(&str1[0])), uintptr(1024))
  5231. fmt.Println(string(str1))
  5232. fmt.Println(string(str))
  5233. fmt.Println(":", ConvertToString(string(str1), "gbk", "utf-8"))
  5234. fmt.Println(":", ConvertToString(string(str), "gbk", "utf-8"))
  5235. if ret2 != 0 {
  5236. return ""
  5237. }
  5238. return string(str)
  5239. }
  5240. func (c *HisApiController) GetFjBasBaseInfo() (string, string, string, string, string) {
  5241. DllDef := syscall.MustLoadDLL("chs_fjs_standard.dll")
  5242. readCard := DllDef.MustFindProc("read_cardinfo")
  5243. if readCard == nil {
  5244. fmt.Println("readcard is nil")
  5245. readCard = DllDef.MustFindProc("read_cardinfo")
  5246. }
  5247. str := make([]byte, 1024) //卡号
  5248. str1 := make([]byte, 1024) //卡识别码
  5249. str2 := make([]byte, 1024) //身份证号
  5250. str3 := make([]byte, 1024) //姓名
  5251. str4 := make([]byte, 1024) //错误信息
  5252. 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])))
  5253. fmt.Println(string(str1))
  5254. fmt.Println(string(str))
  5255. fmt.Println(string(str2))
  5256. fmt.Println(string(str3))
  5257. fmt.Println(string(str4))
  5258. fmt.Println(":", ConvertToString(string(str1), "gbk", "utf-8"))
  5259. fmt.Println(":", ConvertToString(string(str), "gbk", "utf-8"))
  5260. fmt.Println(":", ConvertToString(string(str2), "gbk", "utf-8"))
  5261. fmt.Println(":", ConvertToString(string(str3), "gbk", "utf-8"))
  5262. fmt.Println(":", ConvertToString(string(str4), "gbk", "utf-8"))
  5263. if ret2 != 0 {
  5264. return "", "", "", "", ""
  5265. }
  5266. return string(str), string(str1), string(str2), string(str3), string(str4)
  5267. }
  5268. type CustomFundPay struct {
  5269. FundPayType string `json:"fund_pay_type"`
  5270. FundPayamt float64 `json:"fund_payamt"`
  5271. }
  5272. func (c *HisApiController) GetSettleList() {
  5273. order_id, _ := c.GetInt64("order_id")
  5274. admin_user_id, _ := c.GetInt64("admin_user_id")
  5275. order, _ := service.GetHisOrderByIDTwo(order_id)
  5276. roles, _ := service.GetDoctorListTwo(c.GetAdminUserInfo().CurrentOrgId)
  5277. his, _ := service.GetHisPatientByNumber(order.MdtrtId)
  5278. admin, _ := service.GetAdminUserByUserID(roles[0].AdminUserId)
  5279. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  5280. depart, _ := service.GetDepartMentDetail(curRoles.DepartmentId)
  5281. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  5282. pre, _ := service.GetNewHisPrescriptionByNumber(order.Number)
  5283. doctor, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, pre.Creator)
  5284. if order.ID == 0 {
  5285. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisOrderNoExistParamWrong)
  5286. return
  5287. }
  5288. //last_order, _ := service.GetLastHisOrder(c.GetAdminUserInfo().CurrentOrgId)
  5289. //max_order, _ := service.GetLastHisOrderTwo(c.GetAdminUserInfo().CurrentOrgId)
  5290. //count, _ := strconv.ParseInt(max_order.FaPiaoNumber, 10, 64)
  5291. //fmt.Println(count)
  5292. //var zero string
  5293. //number := count + 1
  5294. //if number >= 1000 {
  5295. // zero = "0000" + strconv.FormatInt(number, 10)
  5296. //} else if number >= 10000 {
  5297. // zero = "000" + strconv.FormatInt(number, 10)
  5298. //} else if number >= 100000 {
  5299. // zero = "00" + strconv.FormatInt(number, 10)
  5300. //} else if number >= 1000000 {
  5301. // zero = "0" + strconv.FormatInt(number, 10)
  5302. //} else {
  5303. // zero = strconv.FormatInt(number, 10)
  5304. //}
  5305. //fmt.Println(zero)
  5306. struct4101 := service.Struct4101{
  5307. PsnNo: order.PsnNo,
  5308. MdtrtId: order.MdtrtId,
  5309. SetlId: order.SetlId,
  5310. PsnName: order.PsnName,
  5311. Gend: order.Gend,
  5312. Brdy: his.Brdy,
  5313. Age: his.Age,
  5314. Naty: order.Naty,
  5315. PatnCertType: "01",
  5316. Certno: order.Certno,
  5317. Prfs: "90",
  5318. ConerName: roles[0].UserName,
  5319. PatnRlts: "99",
  5320. ConerAddr: miConfig.OrgName,
  5321. ConerTel: admin.Mobile,
  5322. HiType: order.Insutype,
  5323. Insuplc: miConfig.InsuplcAdmdvs,
  5324. MaindiagFlag: "1",
  5325. BillCode: order.SetlId,
  5326. BillNo: order.SetlId,
  5327. BizSn: order.Number,
  5328. PsnSelfPay: order.PsnPartAmt,
  5329. PsnOwnPay: order.PsnPartAmt,
  5330. AcctPay: order.AcctPay,
  5331. PsnCashpay: order.PsnCashPay,
  5332. HiPaymtd: "1",
  5333. Hsorg: miConfig.InsuplcAdmdvs,
  5334. HsorgOpter: miConfig.InsuplcAdmdvs,
  5335. MedinsFillPsn: curRoles.UserName,
  5336. MedinsFillDept: depart.Name,
  5337. IptMedType: "2",
  5338. }
  5339. struct4101.SetlBegnDate = order.SetlTime
  5340. struct4101.SetlEndDate = order.SetlTime
  5341. time_arr := strings.Split(order.SetlTime, " ")
  5342. struct4101.AdmTime = time_arr[0]
  5343. struct4101.AdmEndTime = time_arr[0]
  5344. var rf []CustomFundPay
  5345. json.Unmarshal([]byte(order.SetlDetail), &rf)
  5346. var tempFunPays []service.CustomStruct
  5347. for _, item := range rf {
  5348. var tempFunPay service.CustomStruct
  5349. tempFunPay.FundPayamt = item.FundPayamt
  5350. tempFunPay.FundPayType = item.FundPayType
  5351. tempFunPays = append(tempFunPays, tempFunPay)
  5352. }
  5353. struct4101.CustomStruct = tempFunPays
  5354. var tempDiaginfos []service.DiaginfoStructTwo
  5355. var tempOpspdiseinfo2 service.OpspdiseinfoStruct
  5356. var tempOpspdiseinfos []service.OpspdiseinfoStruct
  5357. diagnosis_ids := strings.Split(his.Diagnosis, ",")
  5358. var config []*models.HisXtDiagnoseConfig
  5359. for _, item := range diagnosis_ids {
  5360. id, _ := strconv.ParseInt(item, 10, 64)
  5361. diagnosisConfig, _ := service.FindDiagnoseById(id)
  5362. config = append(config, &diagnosisConfig)
  5363. }
  5364. for index, item := range config {
  5365. if index == 0 {
  5366. var tempDiaginfo service.DiaginfoStructTwo
  5367. tempDiaginfo.DiagCode = item.CountryCode
  5368. tempDiaginfo.DiagName = item.CountryContentName
  5369. tempDiaginfo.DiagType = "1"
  5370. tempDiaginfo.MaindiagFlag = "1"
  5371. tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  5372. } else {
  5373. var tempDiaginfo service.DiaginfoStructTwo
  5374. tempDiaginfo.DiagCode = item.CountryCode
  5375. tempDiaginfo.DiagName = item.CountryContentName
  5376. tempDiaginfo.DiagType = "2"
  5377. tempDiaginfo.MaindiagFlag = "0"
  5378. tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  5379. }
  5380. }
  5381. struct4101.Diseinfo = tempDiaginfos
  5382. sickConfigTwo, _ := service.FindSickById(his.SickType)
  5383. tempOpspdiseinfo2.DiagCode = sickConfigTwo.ContentCode
  5384. tempOpspdiseinfo2.DiagName = sickConfigTwo.CountryContentName
  5385. tempOpspdiseinfo2.OprnOprtCode = sickConfigTwo.ContentCode
  5386. tempOpspdiseinfo2.OprnOprtName = sickConfigTwo.CountryContentName
  5387. tempOpspdiseinfos = append(tempOpspdiseinfos, tempOpspdiseinfo2)
  5388. struct4101.OpspdiseinfoStruct = tempOpspdiseinfos
  5389. var iteminfo service.IteminfoStruct
  5390. var bedCostTotal float64 = 0 //床位总费
  5391. var bedCostSelfTotal float64 = 0 //床位自费
  5392. var bedCostPartSelfTotal float64 = 0 //床位部分项目自费
  5393. var operationCostTotal float64 = 0 //手术费
  5394. var operationCostSelfTotal float64 = 0 //手术费
  5395. var operationCostPartSelfTotal float64 = 0 //手术费
  5396. var otherCostTotal float64 = 0 //其他费用
  5397. var otherCostSelfTotal float64 = 0 //其他费用
  5398. var otherCostPartSelfTotal float64 = 0 //其他费用
  5399. var materialCostTotal float64 = 0 //材料费
  5400. var materialCostSelfTotal float64 = 0 //材料费
  5401. var materialCostPartSelfTotal float64 = 0 //材料费
  5402. var westernMedicineCostTotal float64 = 0 //西药费
  5403. var westernMedicineCostSelfTotal float64 = 0 //西药费
  5404. var westernMedicineCostPartSelfTotal float64 = 0 //西药费
  5405. var chineseTraditionalMedicineCostTotal float64 = 0 //中成药
  5406. var chineseTraditionalMedicineCostSelfTotal float64 = 0 //中成药
  5407. var chineseTraditionalMedicineCostPartSelfTotal float64 = 0 //中成药
  5408. var checkCostTotal float64 = 0 //检查费
  5409. var checkCostSelfTotal float64 = 0 //检查费
  5410. var checkCostPartSelfTotal float64 = 0 //检查费
  5411. var laboratoryCostTotal float64 = 0 //化验费
  5412. var laboratoryCostSelfTotal float64 = 0 //化验费
  5413. var laboratoryCostPartSelfTotal float64 = 0 //化验费
  5414. var treatCostTotal float64 = 0 //治疗费用
  5415. var treatCostSelfTotal float64 = 0 //治疗费用
  5416. var treatCostPartSelfTotal float64 = 0 //治疗费用
  5417. decimal.DivisionPrecision = 2
  5418. var bed_fulamt_ownpay_amt float64 = 0
  5419. var operation_fulamt_ownpay_amt float64 = 0
  5420. var other_fulamt_ownpay_amt float64 = 0
  5421. var westernMedicine_fulamt_ownpay_amt float64 = 0
  5422. var chineseTraditional_fulamt_ownpay_amt float64 = 0
  5423. var check_fulamt_ownpay_amt float64 = 0
  5424. var material_fulamt_ownpay_amt float64 = 0
  5425. var laboratory_fulamt_ownpay_amt float64 = 0
  5426. var treat_fulamt_ownpay_amt float64 = 0
  5427. var bed_claa_sunmfee float64 = 0
  5428. var bed_clab_amt float64 = 0
  5429. var bed_other_amt float64 = 0
  5430. var operation_claa_sunmfee float64 = 0
  5431. var operation_clab_amt float64 = 0
  5432. var operation_other_amt float64 = 0
  5433. var other_claa_sunmfee float64 = 0
  5434. var other_clab_amt float64 = 0
  5435. var other_other_amt float64 = 0
  5436. var westernMedicine_claa_sunmfee float64 = 0
  5437. var westernMedicine_clab_amt float64 = 0
  5438. var westernMedicine_other_amt float64 = 0
  5439. var chineseTraditional_claa_sunmfee float64 = 0
  5440. var chineseTraditional_clab_amt float64 = 0
  5441. var chineseTraditional_other_amt float64 = 0
  5442. var check_claa_sunmfee float64 = 0
  5443. var check_clab_amt float64 = 0
  5444. var check_other_amt float64 = 0
  5445. var material_claa_sunmfee float64 = 0
  5446. var material_clab_amt float64 = 0
  5447. var material_other_amt float64 = 0
  5448. var laboratory_claa_sunmfee float64 = 0
  5449. var laboratory_clab_amt float64 = 0
  5450. var laboratory_other_amt float64 = 0
  5451. var treat_claa_sunmfee float64 = 0
  5452. var treat_clab_amt float64 = 0
  5453. var treat_other_amt float64 = 0
  5454. for _, item := range order.HisOrderInfo {
  5455. if item.MedChrgitmType == "01" { //床位费
  5456. bedCostTotal, _ = decimal.NewFromFloat(bedCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  5457. bedCostSelfTotal, _ = decimal.NewFromFloat(bedCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  5458. bedCostPartSelfTotal, _ = decimal.NewFromFloat(bedCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  5459. bed_fulamt_ownpay_amt, _ = decimal.NewFromFloat(bed_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  5460. if item.ChrgitmLv == "1" {
  5461. bed_claa_sunmfee, _ = decimal.NewFromFloat(bed_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  5462. }
  5463. if item.ChrgitmLv == "2" {
  5464. bed_clab_amt, _ = decimal.NewFromFloat(bed_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  5465. }
  5466. if item.ChrgitmLv == "3" {
  5467. bed_other_amt, _ = decimal.NewFromFloat(bed_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  5468. }
  5469. }
  5470. if item.MedChrgitmType == "03" { //检查费
  5471. checkCostTotal, _ = decimal.NewFromFloat(checkCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  5472. checkCostSelfTotal, _ = decimal.NewFromFloat(checkCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  5473. checkCostPartSelfTotal, _ = decimal.NewFromFloat(checkCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  5474. check_fulamt_ownpay_amt, _ = decimal.NewFromFloat(check_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  5475. if item.ChrgitmLv == "1" {
  5476. check_claa_sunmfee, _ = decimal.NewFromFloat(check_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  5477. }
  5478. if item.ChrgitmLv == "2" {
  5479. check_clab_amt, _ = decimal.NewFromFloat(check_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  5480. }
  5481. if item.ChrgitmLv == "3" {
  5482. check_other_amt, _ = decimal.NewFromFloat(check_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  5483. }
  5484. }
  5485. if item.MedChrgitmType == "04" { //化验费
  5486. laboratoryCostTotal, _ = decimal.NewFromFloat(laboratoryCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  5487. laboratoryCostSelfTotal, _ = decimal.NewFromFloat(laboratoryCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  5488. laboratoryCostPartSelfTotal, _ = decimal.NewFromFloat(laboratoryCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  5489. laboratory_fulamt_ownpay_amt, _ = decimal.NewFromFloat(laboratory_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  5490. if item.ChrgitmLv == "1" {
  5491. laboratory_claa_sunmfee, _ = decimal.NewFromFloat(laboratory_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  5492. }
  5493. if item.ChrgitmLv == "2" {
  5494. laboratory_clab_amt, _ = decimal.NewFromFloat(laboratory_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  5495. }
  5496. if item.ChrgitmLv == "3" {
  5497. laboratory_other_amt, _ = decimal.NewFromFloat(laboratory_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  5498. }
  5499. }
  5500. if item.MedChrgitmType == "05" { //治疗费
  5501. treatCostTotal, _ = decimal.NewFromFloat(treatCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  5502. treatCostSelfTotal, _ = decimal.NewFromFloat(treatCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  5503. treatCostPartSelfTotal, _ = decimal.NewFromFloat(treatCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  5504. treat_fulamt_ownpay_amt, _ = decimal.NewFromFloat(treat_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  5505. if item.ChrgitmLv == "1" {
  5506. treat_claa_sunmfee, _ = decimal.NewFromFloat(treat_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  5507. }
  5508. if item.ChrgitmLv == "2" {
  5509. treat_clab_amt, _ = decimal.NewFromFloat(treat_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  5510. }
  5511. if item.ChrgitmLv == "3" {
  5512. treat_other_amt, _ = decimal.NewFromFloat(treat_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  5513. }
  5514. }
  5515. if item.MedChrgitmType == "06" { //手术费
  5516. operationCostTotal, _ = decimal.NewFromFloat(operationCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  5517. operationCostSelfTotal, _ = decimal.NewFromFloat(operationCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  5518. operationCostPartSelfTotal, _ = decimal.NewFromFloat(operationCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  5519. operation_fulamt_ownpay_amt, _ = decimal.NewFromFloat(operation_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  5520. if item.ChrgitmLv == "1" {
  5521. operation_claa_sunmfee, _ = decimal.NewFromFloat(operation_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  5522. }
  5523. if item.ChrgitmLv == "2" {
  5524. operation_clab_amt, _ = decimal.NewFromFloat(operation_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  5525. }
  5526. if item.ChrgitmLv == "3" {
  5527. operation_other_amt, _ = decimal.NewFromFloat(operation_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  5528. }
  5529. }
  5530. if item.MedChrgitmType == "08" { //材料费
  5531. materialCostTotal, _ = decimal.NewFromFloat(materialCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  5532. materialCostSelfTotal, _ = decimal.NewFromFloat(materialCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  5533. materialCostPartSelfTotal, _ = decimal.NewFromFloat(materialCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  5534. material_fulamt_ownpay_amt, _ = decimal.NewFromFloat(material_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  5535. if item.ChrgitmLv == "1" {
  5536. material_claa_sunmfee, _ = decimal.NewFromFloat(material_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  5537. }
  5538. if item.ChrgitmLv == "2" {
  5539. material_clab_amt, _ = decimal.NewFromFloat(material_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  5540. }
  5541. if item.ChrgitmLv == "3" {
  5542. material_other_amt, _ = decimal.NewFromFloat(material_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  5543. }
  5544. }
  5545. if item.MedChrgitmType == "09" { //西药费
  5546. westernMedicineCostTotal, _ = decimal.NewFromFloat(westernMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  5547. westernMedicineCostSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  5548. westernMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  5549. westernMedicine_fulamt_ownpay_amt, _ = decimal.NewFromFloat(westernMedicine_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  5550. if item.ChrgitmLv == "1" {
  5551. westernMedicine_claa_sunmfee, _ = decimal.NewFromFloat(westernMedicine_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  5552. }
  5553. if item.ChrgitmLv == "2" {
  5554. westernMedicine_clab_amt, _ = decimal.NewFromFloat(westernMedicine_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  5555. }
  5556. if item.ChrgitmLv == "3" {
  5557. westernMedicine_other_amt, _ = decimal.NewFromFloat(westernMedicine_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  5558. }
  5559. }
  5560. if item.MedChrgitmType == "11" { //中成费
  5561. chineseTraditionalMedicineCostTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  5562. chineseTraditionalMedicineCostSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  5563. chineseTraditionalMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  5564. chineseTraditional_fulamt_ownpay_amt, _ = decimal.NewFromFloat(chineseTraditional_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  5565. if item.ChrgitmLv == "1" {
  5566. chineseTraditional_claa_sunmfee, _ = decimal.NewFromFloat(chineseTraditional_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  5567. }
  5568. if item.ChrgitmLv == "2" {
  5569. chineseTraditional_clab_amt, _ = decimal.NewFromFloat(chineseTraditional_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  5570. }
  5571. if item.ChrgitmLv == "3" {
  5572. chineseTraditional_other_amt, _ = decimal.NewFromFloat(chineseTraditional_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  5573. }
  5574. }
  5575. if item.MedChrgitmType == "14" { //其他费
  5576. otherCostTotal, _ = decimal.NewFromFloat(otherCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  5577. otherCostSelfTotal, _ = decimal.NewFromFloat(otherCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  5578. otherCostPartSelfTotal, _ = decimal.NewFromFloat(otherCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  5579. other_fulamt_ownpay_amt, _ = decimal.NewFromFloat(other_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  5580. if item.ChrgitmLv == "1" {
  5581. other_claa_sunmfee, _ = decimal.NewFromFloat(other_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  5582. }
  5583. if item.ChrgitmLv == "2" {
  5584. other_clab_amt, _ = decimal.NewFromFloat(other_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  5585. }
  5586. if item.ChrgitmLv == "3" {
  5587. other_other_amt, _ = decimal.NewFromFloat(other_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  5588. }
  5589. }
  5590. }
  5591. var iteminfoStructs []service.IteminfoStruct
  5592. if bedCostTotal != 0 {
  5593. iteminfo.MedChrgitm = "01"
  5594. iteminfo.FulamtOwnpayAmt = bed_fulamt_ownpay_amt
  5595. iteminfo.Amt = bedCostTotal
  5596. iteminfo.ClaaSumfee = bed_claa_sunmfee
  5597. iteminfo.ClabAmt = bed_clab_amt
  5598. iteminfo.OthAmt = bed_other_amt
  5599. iteminfoStructs = append(iteminfoStructs, iteminfo)
  5600. }
  5601. if checkCostTotal != 0 {
  5602. iteminfo.MedChrgitm = "03"
  5603. iteminfo.FulamtOwnpayAmt = check_fulamt_ownpay_amt
  5604. iteminfo.Amt = checkCostTotal
  5605. iteminfo.ClaaSumfee = check_claa_sunmfee
  5606. iteminfo.ClabAmt = check_clab_amt
  5607. iteminfo.OthAmt = check_other_amt
  5608. iteminfoStructs = append(iteminfoStructs, iteminfo)
  5609. }
  5610. if laboratoryCostTotal != 0 {
  5611. iteminfo.MedChrgitm = "04"
  5612. iteminfo.FulamtOwnpayAmt = laboratory_fulamt_ownpay_amt
  5613. iteminfo.Amt = laboratoryCostTotal
  5614. iteminfo.ClaaSumfee = laboratory_claa_sunmfee
  5615. iteminfo.ClabAmt = laboratory_clab_amt
  5616. iteminfo.OthAmt = laboratory_other_amt
  5617. iteminfoStructs = append(iteminfoStructs, iteminfo)
  5618. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  5619. }
  5620. if treatCostTotal != 0 {
  5621. iteminfo.MedChrgitm = "05"
  5622. iteminfo.FulamtOwnpayAmt = treat_fulamt_ownpay_amt
  5623. iteminfo.Amt = treatCostTotal
  5624. iteminfo.ClaaSumfee = treat_claa_sunmfee
  5625. iteminfo.ClabAmt = treat_clab_amt
  5626. iteminfo.OthAmt = treat_other_amt
  5627. iteminfoStructs = append(iteminfoStructs, iteminfo)
  5628. //(struct4101.IteminfoStruct, iteminfo)
  5629. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  5630. }
  5631. if operationCostTotal != 0 {
  5632. iteminfo.MedChrgitm = "06"
  5633. iteminfo.FulamtOwnpayAmt = bed_fulamt_ownpay_amt
  5634. iteminfo.Amt = operationCostTotal
  5635. iteminfo.ClaaSumfee = operation_claa_sunmfee
  5636. iteminfo.ClabAmt = operation_clab_amt
  5637. iteminfo.OthAmt = operation_other_amt
  5638. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  5639. iteminfoStructs = append(iteminfoStructs, iteminfo)
  5640. }
  5641. if materialCostTotal != 0 {
  5642. iteminfo.MedChrgitm = "08"
  5643. iteminfo.FulamtOwnpayAmt = material_fulamt_ownpay_amt
  5644. iteminfo.Amt = materialCostTotal
  5645. iteminfo.ClaaSumfee = material_claa_sunmfee
  5646. iteminfo.ClabAmt = material_clab_amt
  5647. iteminfo.OthAmt = material_other_amt
  5648. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  5649. iteminfoStructs = append(iteminfoStructs, iteminfo)
  5650. }
  5651. if westernMedicineCostTotal != 0 {
  5652. iteminfo.MedChrgitm = "09"
  5653. iteminfo.FulamtOwnpayAmt = westernMedicine_fulamt_ownpay_amt
  5654. iteminfo.Amt = westernMedicineCostTotal
  5655. iteminfo.ClaaSumfee = westernMedicine_claa_sunmfee
  5656. iteminfo.ClabAmt = westernMedicine_clab_amt
  5657. iteminfo.OthAmt = westernMedicine_other_amt
  5658. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  5659. iteminfoStructs = append(iteminfoStructs, iteminfo)
  5660. }
  5661. if chineseTraditionalMedicineCostTotal != 0 {
  5662. iteminfo.MedChrgitm = "11"
  5663. iteminfo.FulamtOwnpayAmt = westernMedicine_fulamt_ownpay_amt
  5664. iteminfo.Amt = westernMedicineCostTotal
  5665. iteminfo.ClaaSumfee = westernMedicine_claa_sunmfee
  5666. iteminfo.ClabAmt = westernMedicine_clab_amt
  5667. iteminfo.OthAmt = westernMedicine_other_amt
  5668. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  5669. iteminfoStructs = append(iteminfoStructs, iteminfo)
  5670. }
  5671. if otherCostTotal != 0 {
  5672. iteminfo.MedChrgitm = "14"
  5673. iteminfo.FulamtOwnpayAmt = other_fulamt_ownpay_amt
  5674. iteminfo.Amt = otherCostTotal
  5675. iteminfo.ClaaSumfee = other_claa_sunmfee
  5676. iteminfo.ClabAmt = other_clab_amt
  5677. iteminfo.OthAmt = other_other_amt
  5678. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  5679. iteminfoStructs = append(iteminfoStructs, iteminfo)
  5680. }
  5681. struct4101.IteminfoStruct = iteminfoStructs
  5682. struct4101.Ntly = "中国"
  5683. struct4101.AdmCaty = "A03.06"
  5684. struct4101.DoctorName = doctor.UserName
  5685. struct4101.DoctorCode = doctor.DoctorNumber
  5686. var res ResultSeventeen
  5687. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  5688. struct4101.BillCode = order.Number
  5689. struct4101.BillNo = order.SetlId
  5690. var resOther ResultSeventeenOther
  5691. var pp models.PublicParams
  5692. pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  5693. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  5694. pp.FixmedinsName = miConfig.OrgName
  5695. pp.FixmedinsCode = miConfig.Code
  5696. pp.RequestUrl = miConfig.Url
  5697. pp.Cainfo = miConfig.Cainfo
  5698. pp.SecretKey = miConfig.SecretKey
  5699. pp.AccessKey = miConfig.AccessKey
  5700. pp.OpterName = curRoles.UserName
  5701. client := &http.Client{}
  5702. var req *http.Request
  5703. data := make(map[string]interface{})
  5704. data["struct4101"] = struct4101
  5705. data["pp"] = pp
  5706. bytesData, _ := json.Marshal(data)
  5707. if miConfig.MdtrtareaAdmvs == "320921" {
  5708. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/4101", bytes.NewReader(bytesData))
  5709. } else {
  5710. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/4101", bytes.NewReader(bytesData))
  5711. }
  5712. resp, _ := client.Do(req)
  5713. defer resp.Body.Close()
  5714. body, ioErr := ioutil.ReadAll(resp.Body)
  5715. if ioErr != nil {
  5716. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  5717. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5718. return
  5719. }
  5720. var respJSON map[string]interface{}
  5721. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  5722. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  5723. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5724. return
  5725. }
  5726. respJSON = respJSON["data"].(map[string]interface{})["request_log"].(map[string]interface{})
  5727. userJSONBytes, _ := json.Marshal(respJSON)
  5728. fmt.Println("log")
  5729. fmt.Println(string(userJSONBytes))
  5730. if err := json.Unmarshal(userJSONBytes, &resOther); err != nil {
  5731. utils.ErrorLog("解析失败:%v", err)
  5732. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5733. return
  5734. }
  5735. res.InfRefmsgid = resOther.InfRefmsgid
  5736. res.Output = resOther.Output
  5737. res.ErrMsg = resOther.ErrMsg
  5738. infocode, _ := strconv.ParseInt(resOther.Infcode, 10, 64)
  5739. res.Infcode = infocode
  5740. } else if miConfig.MdtrtareaAdmvs == "360399" {
  5741. var pp models.PublicParams
  5742. pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  5743. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  5744. pp.FixmedinsName = miConfig.OrgName
  5745. pp.FixmedinsCode = miConfig.Code
  5746. pp.RequestUrl = miConfig.Url
  5747. pp.Cainfo = miConfig.Cainfo
  5748. pp.SecretKey = miConfig.SecretKey
  5749. pp.AccessKey = miConfig.AccessKey
  5750. pp.OpterName = curRoles.UserName
  5751. result, _ := service.Jxyb4101(struct4101, pp)
  5752. var dat map[string]interface{}
  5753. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  5754. fmt.Println(dat)
  5755. } else {
  5756. fmt.Println(err)
  5757. }
  5758. userJSONBytes, _ := json.Marshal(dat)
  5759. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  5760. utils.ErrorLog("解析失败:%v", err)
  5761. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5762. return
  5763. }
  5764. } else if miConfig.MdtrtareaAdmvs == "430800" {
  5765. var pp models.PublicParams
  5766. pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  5767. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  5768. pp.FixmedinsName = miConfig.OrgName
  5769. pp.FixmedinsCode = miConfig.Code
  5770. pp.RequestUrl = miConfig.Url
  5771. pp.Cainfo = miConfig.Cainfo
  5772. pp.SecretKey = miConfig.SecretKey
  5773. pp.AccessKey = miConfig.AccessKey
  5774. pp.OpterName = curRoles.UserName
  5775. result, _ := service.Hnyb4101(struct4101, pp)
  5776. var dat map[string]interface{}
  5777. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  5778. fmt.Println(dat)
  5779. } else {
  5780. fmt.Println(err)
  5781. }
  5782. userJSONBytes, _ := json.Marshal(dat)
  5783. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  5784. utils.ErrorLog("解析失败:%v", err)
  5785. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5786. return
  5787. }
  5788. } else {
  5789. result, _ := service.Gdyb4101(struct4101, miConfig.SecretKey, miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.UserOrgId)
  5790. var dat map[string]interface{}
  5791. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  5792. fmt.Println(dat)
  5793. } else {
  5794. fmt.Println(err)
  5795. }
  5796. userJSONBytes, _ := json.Marshal(dat)
  5797. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  5798. utils.ErrorLog("解析失败:%v", err)
  5799. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5800. return
  5801. }
  5802. }
  5803. if res.Infcode != 0 {
  5804. c.ServeSuccessJSON(map[string]interface{}{
  5805. "failed_code": -10,
  5806. "msg": res.ErrMsg,
  5807. })
  5808. return
  5809. } else {
  5810. //order.FaPiaoNumber = zero
  5811. //order.FaPiaoCode = last_order.FaPiaoCode
  5812. //service.UpdateOrder(order)
  5813. hisFundSettleListResult := &models.HisFundSettleListResult{
  5814. Number: res.Output.SetlListId,
  5815. Status: 1,
  5816. Ctime: time.Now().Unix(),
  5817. Mtime: time.Now().Unix(),
  5818. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  5819. IsUpload: 1,
  5820. OrderId: order_id,
  5821. }
  5822. service.CreateUploadRecord(hisFundSettleListResult)
  5823. c.ServeSuccessJSON(map[string]interface{}{
  5824. "msg": "上传成功",
  5825. "result": hisFundSettleListResult,
  5826. })
  5827. return
  5828. }
  5829. }
  5830. func (c *HisApiController) GetSettleListHospital() {
  5831. order_id, _ := c.GetInt64("order_id")
  5832. admin_user_id, _ := c.GetInt64("admin_user_id")
  5833. order, _ := service.GetHisOrderByIDTwo(order_id)
  5834. roles, _ := service.GetDoctorListTwo(c.GetAdminUserInfo().CurrentOrgId)
  5835. his, _ := service.GetInHospitalRecordByNumber(order.MdtrtId)
  5836. admin, _ := service.GetAdminUserByUserID(roles[0].AdminUserId)
  5837. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  5838. depart, _ := service.GetDepartMentDetail(curRoles.DepartmentId)
  5839. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  5840. if order.ID == 0 {
  5841. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisOrderNoExistParamWrong)
  5842. return
  5843. }
  5844. last_order, _ := service.GetLastHisOrder(c.GetAdminUserInfo().CurrentOrgId)
  5845. max_order, _ := service.GetLastHisOrderTwo(c.GetAdminUserInfo().CurrentOrgId)
  5846. count, _ := strconv.ParseInt(max_order.FaPiaoNumber, 10, 64)
  5847. fmt.Println(count)
  5848. var zero string
  5849. number := count + 1
  5850. if number >= 1000 {
  5851. zero = "0000" + strconv.FormatInt(number, 10)
  5852. } else if number >= 10000 {
  5853. zero = "000" + strconv.FormatInt(number, 10)
  5854. } else if number >= 100000 {
  5855. zero = "00" + strconv.FormatInt(number, 10)
  5856. } else if number >= 1000000 {
  5857. zero = "0" + strconv.FormatInt(number, 10)
  5858. } else {
  5859. zero = strconv.FormatInt(number, 10)
  5860. }
  5861. fmt.Println(zero)
  5862. struct4101 := service.Struct4101{
  5863. PsnNo: order.PsnNo,
  5864. MdtrtId: order.MdtrtId,
  5865. SetlId: order.SetlId,
  5866. PsnName: order.PsnName,
  5867. Gend: order.Gend,
  5868. Brdy: his.Brdy,
  5869. Age: int64(order.Age),
  5870. Naty: order.Naty,
  5871. PatnCertType: "01",
  5872. Certno: order.Certno,
  5873. Prfs: "90",
  5874. ConerName: roles[0].UserName,
  5875. PatnRlts: "99",
  5876. ConerAddr: miConfig.OrgName,
  5877. ConerTel: admin.Mobile,
  5878. HiType: order.Insutype,
  5879. Insuplc: miConfig.InsuplcAdmdvs,
  5880. MaindiagFlag: "1",
  5881. BillCode: order.SetlId,
  5882. BillNo: order.SetlId,
  5883. BizSn: order.Number,
  5884. PsnSelfPay: order.PsnPartAmt,
  5885. PsnOwnPay: order.PsnPartAmt,
  5886. AcctPay: order.AcctPay,
  5887. PsnCashpay: order.PsnCashPay,
  5888. HiPaymtd: "1",
  5889. Hsorg: miConfig.InsuplcAdmdvs,
  5890. HsorgOpter: miConfig.InsuplcAdmdvs,
  5891. MedinsFillPsn: curRoles.UserName,
  5892. MedinsFillDept: depart.Name,
  5893. IptMedType: "2",
  5894. AdmTime: his.InHosptialTime,
  5895. AdmEndTime: his.OutHosptialTime,
  5896. }
  5897. struct4101.SetlBegnDate = order.SetlTime
  5898. struct4101.SetlEndDate = order.SetlTime
  5899. var rf []CustomFundPay
  5900. json.Unmarshal([]byte(order.SetlDetail), &rf)
  5901. var tempFunPays []service.CustomStruct
  5902. for _, item := range rf {
  5903. var tempFunPay service.CustomStruct
  5904. tempFunPay.FundPayamt = item.FundPayamt
  5905. tempFunPay.FundPayType = item.FundPayType
  5906. tempFunPays = append(tempFunPays, tempFunPay)
  5907. }
  5908. struct4101.CustomStruct = tempFunPays
  5909. var tempDiaginfos []service.DiaginfoStructTwo
  5910. var tempOpspdiseinfo2 service.OpspdiseinfoStruct
  5911. var tempOpspdiseinfos []service.OpspdiseinfoStruct
  5912. diagnosis_ids := strings.Split(his.Diagnosis, ",")
  5913. var config []*models.HisXtDiagnoseConfig
  5914. for _, item := range diagnosis_ids {
  5915. id, _ := strconv.ParseInt(item, 10, 64)
  5916. diagnosisConfig, _ := service.FindDiagnoseById(id)
  5917. config = append(config, &diagnosisConfig)
  5918. }
  5919. for index, item := range config {
  5920. if index == 0 {
  5921. var tempDiaginfo service.DiaginfoStructTwo
  5922. tempDiaginfo.DiagCode = item.CountryCode
  5923. tempDiaginfo.DiagName = item.CountryContentName
  5924. tempDiaginfo.DiagType = "1"
  5925. tempDiaginfo.MaindiagFlag = "1"
  5926. tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  5927. } else {
  5928. var tempDiaginfo service.DiaginfoStructTwo
  5929. tempDiaginfo.DiagCode = item.CountryCode
  5930. tempDiaginfo.DiagName = item.CountryContentName
  5931. tempDiaginfo.DiagType = "2"
  5932. tempDiaginfo.MaindiagFlag = "0"
  5933. tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  5934. }
  5935. }
  5936. struct4101.Diseinfo = tempDiaginfos
  5937. sickConfigTwo, _ := service.FindSickById(his.SickType)
  5938. tempOpspdiseinfo2.DiagCode = sickConfigTwo.ContentCode
  5939. tempOpspdiseinfo2.DiagName = sickConfigTwo.CountryContentName
  5940. tempOpspdiseinfo2.OprnOprtCode = ""
  5941. tempOpspdiseinfo2.OprnOprtName = ""
  5942. tempOpspdiseinfos = append(tempOpspdiseinfos, tempOpspdiseinfo2)
  5943. struct4101.OpspdiseinfoStruct = tempOpspdiseinfos
  5944. var iteminfo service.IteminfoStruct
  5945. var bedCostTotal float64 = 0 //床位总费
  5946. var bedCostSelfTotal float64 = 0 //床位自费
  5947. var bedCostPartSelfTotal float64 = 0 //床位部分项目自费
  5948. var operationCostTotal float64 = 0 //手术费
  5949. var operationCostSelfTotal float64 = 0 //手术费
  5950. var operationCostPartSelfTotal float64 = 0 //手术费
  5951. var otherCostTotal float64 = 0 //其他费用
  5952. var otherCostSelfTotal float64 = 0 //其他费用
  5953. var otherCostPartSelfTotal float64 = 0 //其他费用
  5954. var materialCostTotal float64 = 0 //材料费
  5955. var materialCostSelfTotal float64 = 0 //材料费
  5956. var materialCostPartSelfTotal float64 = 0 //材料费
  5957. var westernMedicineCostTotal float64 = 0 //西药费
  5958. var westernMedicineCostSelfTotal float64 = 0 //西药费
  5959. var westernMedicineCostPartSelfTotal float64 = 0 //西药费
  5960. var chineseTraditionalMedicineCostTotal float64 = 0 //中成药
  5961. var chineseTraditionalMedicineCostSelfTotal float64 = 0 //中成药
  5962. var chineseTraditionalMedicineCostPartSelfTotal float64 = 0 //中成药
  5963. var checkCostTotal float64 = 0 //检查费
  5964. var checkCostSelfTotal float64 = 0 //检查费
  5965. var checkCostPartSelfTotal float64 = 0 //检查费
  5966. var laboratoryCostTotal float64 = 0 //化验费
  5967. var laboratoryCostSelfTotal float64 = 0 //化验费
  5968. var laboratoryCostPartSelfTotal float64 = 0 //化验费
  5969. var treatCostTotal float64 = 0 //治疗费用
  5970. var treatCostSelfTotal float64 = 0 //治疗费用
  5971. var treatCostPartSelfTotal float64 = 0 //治疗费用
  5972. decimal.DivisionPrecision = 2
  5973. var bed_fulamt_ownpay_amt float64 = 0
  5974. var operation_fulamt_ownpay_amt float64 = 0
  5975. var other_fulamt_ownpay_amt float64 = 0
  5976. var westernMedicine_fulamt_ownpay_amt float64 = 0
  5977. var chineseTraditional_fulamt_ownpay_amt float64 = 0
  5978. var check_fulamt_ownpay_amt float64 = 0
  5979. var material_fulamt_ownpay_amt float64 = 0
  5980. var laboratory_fulamt_ownpay_amt float64 = 0
  5981. var treat_fulamt_ownpay_amt float64 = 0
  5982. var bed_claa_sunmfee float64 = 0
  5983. var bed_clab_amt float64 = 0
  5984. var bed_other_amt float64 = 0
  5985. var operation_claa_sunmfee float64 = 0
  5986. var operation_clab_amt float64 = 0
  5987. var operation_other_amt float64 = 0
  5988. var other_claa_sunmfee float64 = 0
  5989. var other_clab_amt float64 = 0
  5990. var other_other_amt float64 = 0
  5991. var westernMedicine_claa_sunmfee float64 = 0
  5992. var westernMedicine_clab_amt float64 = 0
  5993. var westernMedicine_other_amt float64 = 0
  5994. var chineseTraditional_claa_sunmfee float64 = 0
  5995. var chineseTraditional_clab_amt float64 = 0
  5996. var chineseTraditional_other_amt float64 = 0
  5997. var check_claa_sunmfee float64 = 0
  5998. var check_clab_amt float64 = 0
  5999. var check_other_amt float64 = 0
  6000. var material_claa_sunmfee float64 = 0
  6001. var material_clab_amt float64 = 0
  6002. var material_other_amt float64 = 0
  6003. var laboratory_claa_sunmfee float64 = 0
  6004. var laboratory_clab_amt float64 = 0
  6005. var laboratory_other_amt float64 = 0
  6006. var treat_claa_sunmfee float64 = 0
  6007. var treat_clab_amt float64 = 0
  6008. var treat_other_amt float64 = 0
  6009. for _, item := range order.HisOrderInfo {
  6010. if item.MedChrgitmType == "01" { //床位费
  6011. bedCostTotal, _ = decimal.NewFromFloat(bedCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  6012. bedCostSelfTotal, _ = decimal.NewFromFloat(bedCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  6013. bedCostPartSelfTotal, _ = decimal.NewFromFloat(bedCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  6014. bed_fulamt_ownpay_amt, _ = decimal.NewFromFloat(bed_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  6015. if item.ChrgitmLv == "1" {
  6016. bed_claa_sunmfee, _ = decimal.NewFromFloat(bed_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  6017. }
  6018. if item.ChrgitmLv == "2" {
  6019. bed_clab_amt, _ = decimal.NewFromFloat(bed_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  6020. }
  6021. if item.ChrgitmLv == "3" {
  6022. bed_other_amt, _ = decimal.NewFromFloat(bed_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  6023. }
  6024. }
  6025. if item.MedChrgitmType == "03" { //检查费
  6026. checkCostTotal, _ = decimal.NewFromFloat(checkCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  6027. checkCostSelfTotal, _ = decimal.NewFromFloat(checkCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  6028. checkCostPartSelfTotal, _ = decimal.NewFromFloat(checkCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  6029. check_fulamt_ownpay_amt, _ = decimal.NewFromFloat(check_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  6030. if item.ChrgitmLv == "1" {
  6031. check_claa_sunmfee, _ = decimal.NewFromFloat(check_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  6032. }
  6033. if item.ChrgitmLv == "2" {
  6034. check_clab_amt, _ = decimal.NewFromFloat(check_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  6035. }
  6036. if item.ChrgitmLv == "3" {
  6037. check_other_amt, _ = decimal.NewFromFloat(check_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  6038. }
  6039. }
  6040. if item.MedChrgitmType == "04" { //化验费
  6041. laboratoryCostTotal, _ = decimal.NewFromFloat(laboratoryCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  6042. laboratoryCostSelfTotal, _ = decimal.NewFromFloat(laboratoryCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  6043. laboratoryCostPartSelfTotal, _ = decimal.NewFromFloat(laboratoryCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  6044. laboratory_fulamt_ownpay_amt, _ = decimal.NewFromFloat(laboratory_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  6045. if item.ChrgitmLv == "1" {
  6046. laboratory_claa_sunmfee, _ = decimal.NewFromFloat(laboratory_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  6047. }
  6048. if item.ChrgitmLv == "2" {
  6049. laboratory_clab_amt, _ = decimal.NewFromFloat(laboratory_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  6050. }
  6051. if item.ChrgitmLv == "3" {
  6052. laboratory_other_amt, _ = decimal.NewFromFloat(laboratory_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  6053. }
  6054. }
  6055. if item.MedChrgitmType == "05" { //治疗费
  6056. treatCostTotal, _ = decimal.NewFromFloat(treatCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  6057. treatCostSelfTotal, _ = decimal.NewFromFloat(treatCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  6058. treatCostPartSelfTotal, _ = decimal.NewFromFloat(treatCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  6059. treat_fulamt_ownpay_amt, _ = decimal.NewFromFloat(treat_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  6060. if item.ChrgitmLv == "1" {
  6061. treat_claa_sunmfee, _ = decimal.NewFromFloat(treat_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  6062. }
  6063. if item.ChrgitmLv == "2" {
  6064. treat_clab_amt, _ = decimal.NewFromFloat(treat_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  6065. }
  6066. if item.ChrgitmLv == "3" {
  6067. treat_other_amt, _ = decimal.NewFromFloat(treat_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  6068. }
  6069. }
  6070. if item.MedChrgitmType == "06" { //手术费
  6071. operationCostTotal, _ = decimal.NewFromFloat(operationCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  6072. operationCostSelfTotal, _ = decimal.NewFromFloat(operationCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  6073. operationCostPartSelfTotal, _ = decimal.NewFromFloat(operationCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  6074. operation_fulamt_ownpay_amt, _ = decimal.NewFromFloat(operation_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  6075. if item.ChrgitmLv == "1" {
  6076. operation_claa_sunmfee, _ = decimal.NewFromFloat(operation_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  6077. }
  6078. if item.ChrgitmLv == "2" {
  6079. operation_clab_amt, _ = decimal.NewFromFloat(operation_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  6080. }
  6081. if item.ChrgitmLv == "3" {
  6082. operation_other_amt, _ = decimal.NewFromFloat(operation_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  6083. }
  6084. }
  6085. if item.MedChrgitmType == "08" { //材料费
  6086. materialCostTotal, _ = decimal.NewFromFloat(materialCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  6087. materialCostSelfTotal, _ = decimal.NewFromFloat(materialCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  6088. materialCostPartSelfTotal, _ = decimal.NewFromFloat(materialCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  6089. material_fulamt_ownpay_amt, _ = decimal.NewFromFloat(material_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  6090. if item.ChrgitmLv == "1" {
  6091. material_claa_sunmfee, _ = decimal.NewFromFloat(material_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  6092. }
  6093. if item.ChrgitmLv == "2" {
  6094. material_clab_amt, _ = decimal.NewFromFloat(material_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  6095. }
  6096. if item.ChrgitmLv == "3" {
  6097. material_other_amt, _ = decimal.NewFromFloat(material_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  6098. }
  6099. }
  6100. if item.MedChrgitmType == "09" { //西药费
  6101. westernMedicineCostTotal, _ = decimal.NewFromFloat(westernMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  6102. westernMedicineCostSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  6103. westernMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  6104. westernMedicine_fulamt_ownpay_amt, _ = decimal.NewFromFloat(westernMedicine_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  6105. if item.ChrgitmLv == "1" {
  6106. westernMedicine_claa_sunmfee, _ = decimal.NewFromFloat(westernMedicine_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  6107. }
  6108. if item.ChrgitmLv == "2" {
  6109. westernMedicine_clab_amt, _ = decimal.NewFromFloat(westernMedicine_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  6110. }
  6111. if item.ChrgitmLv == "3" {
  6112. westernMedicine_other_amt, _ = decimal.NewFromFloat(westernMedicine_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  6113. }
  6114. }
  6115. if item.MedChrgitmType == "11" { //中成费
  6116. chineseTraditionalMedicineCostTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  6117. chineseTraditionalMedicineCostSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  6118. chineseTraditionalMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  6119. chineseTraditional_fulamt_ownpay_amt, _ = decimal.NewFromFloat(chineseTraditional_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  6120. if item.ChrgitmLv == "1" {
  6121. chineseTraditional_claa_sunmfee, _ = decimal.NewFromFloat(chineseTraditional_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  6122. }
  6123. if item.ChrgitmLv == "2" {
  6124. chineseTraditional_clab_amt, _ = decimal.NewFromFloat(chineseTraditional_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  6125. }
  6126. if item.ChrgitmLv == "3" {
  6127. chineseTraditional_other_amt, _ = decimal.NewFromFloat(chineseTraditional_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  6128. }
  6129. }
  6130. if item.MedChrgitmType == "14" { //其他费
  6131. otherCostTotal, _ = decimal.NewFromFloat(otherCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  6132. otherCostSelfTotal, _ = decimal.NewFromFloat(otherCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  6133. otherCostPartSelfTotal, _ = decimal.NewFromFloat(otherCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  6134. other_fulamt_ownpay_amt, _ = decimal.NewFromFloat(other_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  6135. if item.ChrgitmLv == "1" {
  6136. other_claa_sunmfee, _ = decimal.NewFromFloat(other_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  6137. }
  6138. if item.ChrgitmLv == "2" {
  6139. other_clab_amt, _ = decimal.NewFromFloat(other_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  6140. }
  6141. if item.ChrgitmLv == "3" {
  6142. other_other_amt, _ = decimal.NewFromFloat(other_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  6143. }
  6144. }
  6145. }
  6146. var iteminfoStructs []service.IteminfoStruct
  6147. if bedCostTotal != 0 {
  6148. iteminfo.MedChrgitm = "01"
  6149. iteminfo.FulamtOwnpayAmt = bed_fulamt_ownpay_amt
  6150. iteminfo.Amt = bedCostTotal
  6151. iteminfo.ClaaSumfee = bed_claa_sunmfee
  6152. iteminfo.ClabAmt = bed_clab_amt
  6153. iteminfo.OthAmt = bed_other_amt
  6154. iteminfoStructs = append(iteminfoStructs, iteminfo)
  6155. }
  6156. if checkCostTotal != 0 {
  6157. iteminfo.MedChrgitm = "03"
  6158. iteminfo.FulamtOwnpayAmt = check_fulamt_ownpay_amt
  6159. iteminfo.Amt = checkCostTotal
  6160. iteminfo.ClaaSumfee = check_claa_sunmfee
  6161. iteminfo.ClabAmt = check_clab_amt
  6162. iteminfo.OthAmt = check_other_amt
  6163. iteminfoStructs = append(iteminfoStructs, iteminfo)
  6164. }
  6165. if laboratoryCostTotal != 0 {
  6166. iteminfo.MedChrgitm = "04"
  6167. iteminfo.FulamtOwnpayAmt = laboratory_fulamt_ownpay_amt
  6168. iteminfo.Amt = laboratoryCostTotal
  6169. iteminfo.ClaaSumfee = laboratory_claa_sunmfee
  6170. iteminfo.ClabAmt = laboratory_clab_amt
  6171. iteminfo.OthAmt = laboratory_other_amt
  6172. iteminfoStructs = append(iteminfoStructs, iteminfo)
  6173. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  6174. }
  6175. if treatCostTotal != 0 {
  6176. iteminfo.MedChrgitm = "05"
  6177. iteminfo.FulamtOwnpayAmt = treat_fulamt_ownpay_amt
  6178. iteminfo.Amt = treatCostTotal
  6179. iteminfo.ClaaSumfee = treat_claa_sunmfee
  6180. iteminfo.ClabAmt = treat_clab_amt
  6181. iteminfo.OthAmt = treat_other_amt
  6182. iteminfoStructs = append(iteminfoStructs, iteminfo)
  6183. //(struct4101.IteminfoStruct, iteminfo)
  6184. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  6185. }
  6186. if operationCostTotal != 0 {
  6187. iteminfo.MedChrgitm = "06"
  6188. iteminfo.FulamtOwnpayAmt = bed_fulamt_ownpay_amt
  6189. iteminfo.Amt = operationCostTotal
  6190. iteminfo.ClaaSumfee = operation_claa_sunmfee
  6191. iteminfo.ClabAmt = operation_clab_amt
  6192. iteminfo.OthAmt = operation_other_amt
  6193. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  6194. iteminfoStructs = append(iteminfoStructs, iteminfo)
  6195. }
  6196. if materialCostTotal != 0 {
  6197. iteminfo.MedChrgitm = "08"
  6198. iteminfo.FulamtOwnpayAmt = material_fulamt_ownpay_amt
  6199. iteminfo.Amt = materialCostTotal
  6200. iteminfo.ClaaSumfee = material_claa_sunmfee
  6201. iteminfo.ClabAmt = material_clab_amt
  6202. iteminfo.OthAmt = material_other_amt
  6203. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  6204. iteminfoStructs = append(iteminfoStructs, iteminfo)
  6205. }
  6206. if westernMedicineCostTotal != 0 {
  6207. iteminfo.MedChrgitm = "09"
  6208. iteminfo.FulamtOwnpayAmt = westernMedicine_fulamt_ownpay_amt
  6209. iteminfo.Amt = westernMedicineCostTotal
  6210. iteminfo.ClaaSumfee = westernMedicine_claa_sunmfee
  6211. iteminfo.ClabAmt = westernMedicine_clab_amt
  6212. iteminfo.OthAmt = westernMedicine_other_amt
  6213. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  6214. iteminfoStructs = append(iteminfoStructs, iteminfo)
  6215. }
  6216. if chineseTraditionalMedicineCostTotal != 0 {
  6217. iteminfo.MedChrgitm = "11"
  6218. iteminfo.FulamtOwnpayAmt = westernMedicine_fulamt_ownpay_amt
  6219. iteminfo.Amt = westernMedicineCostTotal
  6220. iteminfo.ClaaSumfee = westernMedicine_claa_sunmfee
  6221. iteminfo.ClabAmt = westernMedicine_clab_amt
  6222. iteminfo.OthAmt = westernMedicine_other_amt
  6223. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  6224. iteminfoStructs = append(iteminfoStructs, iteminfo)
  6225. }
  6226. if otherCostTotal != 0 {
  6227. iteminfo.MedChrgitm = "14"
  6228. iteminfo.FulamtOwnpayAmt = other_fulamt_ownpay_amt
  6229. iteminfo.Amt = otherCostTotal
  6230. iteminfo.ClaaSumfee = other_claa_sunmfee
  6231. iteminfo.ClabAmt = other_clab_amt
  6232. iteminfo.OthAmt = other_other_amt
  6233. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  6234. iteminfoStructs = append(iteminfoStructs, iteminfo)
  6235. }
  6236. struct4101.IteminfoStruct = iteminfoStructs
  6237. struct4101.Ntly = "中国"
  6238. struct4101.AdmCaty = "A03.06"
  6239. var resOther ResultSeventeenOther
  6240. var res ResultSeventeen
  6241. if miConfig.MdtrtareaAdmvs == "150499" {
  6242. var pp models.PublicParams
  6243. pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  6244. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  6245. pp.FixmedinsName = miConfig.OrgName
  6246. pp.FixmedinsCode = miConfig.Code
  6247. pp.RequestUrl = miConfig.Url
  6248. pp.Cainfo = miConfig.Cainfo
  6249. pp.SecretKey = miConfig.SecretKey
  6250. pp.AccessKey = miConfig.AccessKey
  6251. pp.OpterName = curRoles.UserName
  6252. client := &http.Client{}
  6253. var req *http.Request
  6254. data := make(map[string]interface{})
  6255. data["struct4101"] = struct4101
  6256. data["pp"] = pp
  6257. bytesData, _ := json.Marshal(data)
  6258. req, _ = http.NewRequest("POST", "http://172.16.13.254:9532/"+"nmyb/4101", bytes.NewReader(bytesData))
  6259. resp, _ := client.Do(req)
  6260. defer resp.Body.Close()
  6261. body, ioErr := ioutil.ReadAll(resp.Body)
  6262. if ioErr != nil {
  6263. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  6264. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6265. return
  6266. }
  6267. var respJSON map[string]interface{}
  6268. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  6269. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  6270. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6271. return
  6272. }
  6273. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  6274. userJSONBytes, _ := json.Marshal(respJSON)
  6275. if err := json.Unmarshal(userJSONBytes, &resOther); err != nil {
  6276. utils.ErrorLog("解析失败:%v", err)
  6277. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6278. return
  6279. }
  6280. res.InfRefmsgid = resOther.InfRefmsgid
  6281. res.Output = resOther.Output
  6282. res.ErrMsg = resOther.ErrMsg
  6283. infocode, _ := strconv.ParseInt(resOther.Infcode, 10, 64)
  6284. res.Infcode = infocode
  6285. } else {
  6286. result, _ := service.Gdyb4101(struct4101, miConfig.SecretKey, miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.UserOrgId)
  6287. var dat map[string]interface{}
  6288. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  6289. fmt.Println(dat)
  6290. } else {
  6291. fmt.Println(err)
  6292. }
  6293. userJSONBytes, _ := json.Marshal(dat)
  6294. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  6295. utils.ErrorLog("解析失败:%v", err)
  6296. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6297. return
  6298. }
  6299. }
  6300. if res.Infcode != 0 {
  6301. c.ServeSuccessJSON(map[string]interface{}{
  6302. "failed_code": -10,
  6303. "msg": res.ErrMsg,
  6304. })
  6305. return
  6306. } else {
  6307. if miConfig.MdtrtareaAdmvs != "150499" {
  6308. order.FaPiaoNumber = zero
  6309. order.FaPiaoCode = last_order.FaPiaoCode
  6310. service.UpdateOrder(order)
  6311. }
  6312. hisFundSettleListResult := &models.HisFundSettleListResult{
  6313. Number: res.Output.SetlListId,
  6314. Status: 1,
  6315. Ctime: time.Now().Unix(),
  6316. Mtime: time.Now().Unix(),
  6317. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  6318. IsUpload: 1,
  6319. OrderId: order_id,
  6320. }
  6321. service.CreateUploadRecord(hisFundSettleListResult)
  6322. c.ServeSuccessJSON(map[string]interface{}{
  6323. "msg": "上传成功",
  6324. "result": hisFundSettleListResult,
  6325. })
  6326. return
  6327. }
  6328. }
  6329. //func (c *HisApiController) GetBatchSettleList() {
  6330. // orders, _ := service.GetAllHisOrder(10106)
  6331. // for _, item := range orders {
  6332. // order_id := item.ID
  6333. // order, _ := service.GetHisOrderByIDTwo(order_id)
  6334. // roles, _ := service.GetDoctorListTwo(c.GetAdminUserInfo().CurrentOrgId)
  6335. // his, _ := service.GetHisPatientByNumber(order.MdtrtId)
  6336. // admin, _ := service.GetAdminUserByUserID(roles[0].AdminUserId)
  6337. // curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, 2495)
  6338. // depart, _ := service.GetDepartMentDetail(curRoles.DepartmentId)
  6339. // miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  6340. //
  6341. // pre, _ := service.GetNewHisPrescriptionByNumber(order.Number)
  6342. //
  6343. // doctor, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, pre.Creator)
  6344. //
  6345. // if order.ID == 0 {
  6346. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisOrderNoExistParamWrong)
  6347. // return
  6348. // }
  6349. // if his.BalanceAccountsType == 2 {
  6350. // continue
  6351. // }
  6352. // struct4101 := service.Struct4101{
  6353. // PsnNo: order.PsnNo,
  6354. // MdtrtId: order.MdtrtId,
  6355. // SetlId: order.SetlId,
  6356. // PsnName: order.PsnName,
  6357. // Gend: order.Gend,
  6358. // Brdy: his.Brdy,
  6359. // Age: his.Age,
  6360. // Naty: order.Naty,
  6361. // PatnCertType: "01",
  6362. // Certno: order.Certno,
  6363. // Prfs: "90",
  6364. // ConerName: roles[0].UserName,
  6365. // PatnRlts: "99",
  6366. // ConerAddr: miConfig.OrgName,
  6367. // ConerTel: admin.Mobile,
  6368. // HiType: order.Insutype,
  6369. // Insuplc: his.InsuplcAdmdvs,
  6370. // MaindiagFlag: "1",
  6371. // BillCode: order.SetlId,
  6372. // BillNo: order.SetlId,
  6373. // BizSn: order.Number,
  6374. // PsnSelfPay: order.PsnPartAmt,
  6375. // PsnOwnPay: order.PsnPartAmt,
  6376. // AcctPay: order.AcctPay,
  6377. // PsnCashpay: order.PsnCashPay,
  6378. // HiPaymtd: "1",
  6379. // Hsorg: his.InsuplcAdmdvs,
  6380. // HsorgOpter: his.InsuplcAdmdvs,
  6381. // MedinsFillPsn: curRoles.UserName,
  6382. // MedinsFillDept: depart.Name,
  6383. // IptMedType: "2",
  6384. // }
  6385. // struct4101.SetlBegnDate = order.SetlTime
  6386. // struct4101.SetlEndDate = order.SetlTime
  6387. // //if order.SettleType == 1 {
  6388. // // t := time.Unix(int64(order.SettleAccountsDate), 0)
  6389. // // dateStr := t.Format("2006-01-02")
  6390. // // struct4101.SetlBegnDate = dateStr
  6391. // // struct4101.SetlEndDate = dateStr
  6392. // //} else {
  6393. // // t := time.Unix(int64(order.SettleStartTime), 0)
  6394. // // t2 := time.Unix(int64(order.SettleEndTime), 0)
  6395. // // dateStartStr := t.Format("2006-01-02")
  6396. // // dateEndStr := t2.Format("2006-01-02")
  6397. // // struct4101.SetlBegnDate = dateStartStr
  6398. // // struct4101.SetlEndDate = dateEndStr
  6399. // //}
  6400. //
  6401. // var rf []CustomFundPay
  6402. // json.Unmarshal([]byte(order.SetlDetail), &rf)
  6403. //
  6404. // var tempFunPays []service.CustomStruct
  6405. // var tempFunPay610100 service.CustomStruct
  6406. //
  6407. // for _, item := range rf {
  6408. // if item.FundPayType == "610100" {
  6409. // tempFunPay610100.FundPayamt, _ = decimal.NewFromFloat(tempFunPay610100.FundPayamt).Add(decimal.NewFromFloat(item.FundPayamt)).Float64()
  6410. // tempFunPay610100.FundPayType = item.FundPayType
  6411. // } else {
  6412. // var tempFunPay service.CustomStruct
  6413. // tempFunPay.FundPayamt = item.FundPayamt
  6414. // tempFunPay.FundPayType = item.FundPayType
  6415. // tempFunPays = append(tempFunPays, tempFunPay)
  6416. // }
  6417. // }
  6418. // tempFunPays = append(tempFunPays, tempFunPay610100)
  6419. // struct4101.CustomStruct = tempFunPays
  6420. //
  6421. // var tempDiaginfos []service.DiaginfoStructTwo
  6422. // var tempOpspdiseinfo2 service.OpspdiseinfoStruct
  6423. // var tempOpspdiseinfos []service.OpspdiseinfoStruct
  6424. //
  6425. // diagnosis_ids := strings.Split(his.Diagnosis, ",")
  6426. // var config []*models.HisXtDiagnoseConfig
  6427. // for _, item := range diagnosis_ids {
  6428. // id, _ := strconv.ParseInt(item, 10, 64)
  6429. // diagnosisConfig, _ := service.FindDiagnoseById(id)
  6430. // config = append(config, &diagnosisConfig)
  6431. // }
  6432. //
  6433. // for index, item := range config {
  6434. // if index == 0 {
  6435. // var tempDiaginfo service.DiaginfoStructTwo
  6436. // tempDiaginfo.DiagCode = item.CountryCode
  6437. // tempDiaginfo.DiagName = item.CountryContentName
  6438. // tempDiaginfo.DiagType = "1"
  6439. // tempDiaginfo.MaindiagFlag = "1"
  6440. // tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  6441. // } else {
  6442. //
  6443. // var tempDiaginfo service.DiaginfoStructTwo
  6444. // tempDiaginfo.DiagCode = item.CountryCode
  6445. // tempDiaginfo.DiagName = item.CountryContentName
  6446. // tempDiaginfo.DiagType = "2"
  6447. // tempDiaginfo.MaindiagFlag = "0"
  6448. // tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  6449. // }
  6450. // }
  6451. // struct4101.Diseinfo = tempDiaginfos
  6452. //
  6453. // sickConfigTwo, _ := service.FindSickById(his.SickType)
  6454. // tempOpspdiseinfo2.DiagCode = sickConfigTwo.ContentCode
  6455. // tempOpspdiseinfo2.DiagName = sickConfigTwo.CountryContentName
  6456. // tempOpspdiseinfo2.OprnOprtCode = ""
  6457. // tempOpspdiseinfo2.OprnOprtName = ""
  6458. // tempOpspdiseinfos = append(tempOpspdiseinfos, tempOpspdiseinfo2)
  6459. // struct4101.OpspdiseinfoStruct = tempOpspdiseinfos
  6460. //
  6461. // var iteminfo service.IteminfoStruct
  6462. //
  6463. // var bedCostTotal float64 = 0 //床位总费
  6464. // var bedCostSelfTotal float64 = 0 //床位自费
  6465. // var bedCostPartSelfTotal float64 = 0 //床位部分项目自费
  6466. //
  6467. // var examineCostTotal float64 = 0 //诊查总费
  6468. // var examineCostSelfTotal float64 = 0 //诊查自费
  6469. // var examineCostPartSelfTotal float64 = 0 //诊查部分项目自费
  6470. //
  6471. // var nursingCostTotal float64 = 0 //护理总费
  6472. // var nursingCostSelfTotal float64 = 0 //护理自费
  6473. // var nursingCostPartSelfTotal float64 = 0 //护理部分项目自费
  6474. //
  6475. // var chineseMedicineCostTotal float64 = 0 //中成药
  6476. // var chineseMedicineCostSelfTotal float64 = 0 //中成药
  6477. // var chineseMedicineCostPartSelfTotal float64 = 0 //中成药
  6478. //
  6479. // var commonlyTreatmentCostTotal float64 = 0 //一般诊疗费
  6480. // var commonlyTreatmentCostSelfTotal float64 = 0 //一般诊疗费
  6481. // var commonlyTreatmentCostPartSelfTotal float64 = 0 //一般诊疗费
  6482. //
  6483. // var registerCostTotal float64 = 0 //一般诊疗费
  6484. // var registerCostSelfTotal float64 = 0 //一般诊疗费
  6485. // var registerPartSelfTotal float64 = 0 //一般诊疗费
  6486. //
  6487. // var operationCostTotal float64 = 0 //手术费
  6488. // var operationCostSelfTotal float64 = 0 //手术费
  6489. // var operationCostPartSelfTotal float64 = 0 //手术费
  6490. //
  6491. // var otherCostTotal float64 = 0 //其他费用
  6492. // var otherCostSelfTotal float64 = 0 //其他费用
  6493. // var otherCostPartSelfTotal float64 = 0 //其他费用
  6494. //
  6495. // var materialCostTotal float64 = 0 //材料费
  6496. // var materialCostSelfTotal float64 = 0 //材料费
  6497. // var materialCostPartSelfTotal float64 = 0 //材料费
  6498. //
  6499. // var westernMedicineCostTotal float64 = 0 //西药费
  6500. // var westernMedicineCostSelfTotal float64 = 0 //西药费
  6501. // var westernMedicineCostPartSelfTotal float64 = 0 //西药费
  6502. //
  6503. // var chineseTraditionalMedicineCostTotal float64 = 0 //中成药
  6504. // var chineseTraditionalMedicineCostSelfTotal float64 = 0 //中成药
  6505. // var chineseTraditionalMedicineCostPartSelfTotal float64 = 0 //中成药
  6506. //
  6507. // var checkCostTotal float64 = 0 //检查费
  6508. // var checkCostSelfTotal float64 = 0 //检查费
  6509. // var checkCostPartSelfTotal float64 = 0 //检查费
  6510. //
  6511. // var laboratoryCostTotal float64 = 0 //化验费
  6512. // var laboratoryCostSelfTotal float64 = 0 //化验费
  6513. // var laboratoryCostPartSelfTotal float64 = 0 //化验费
  6514. //
  6515. // var treatCostTotal float64 = 0 //治疗费用
  6516. // var treatCostSelfTotal float64 = 0 //治疗费用
  6517. // var treatCostPartSelfTotal float64 = 0 //治疗费用
  6518. //
  6519. // decimal.DivisionPrecision = 2
  6520. //
  6521. // var bed_fulamt_ownpay_amt float64 = 0
  6522. //
  6523. // var examine_fulamt_ownpay_amt float64 = 0
  6524. //
  6525. // var nursing_fulamt_ownpay_amt float64 = 0
  6526. //
  6527. // var chinese_medicine_fulamt_ownpay_amt float64 = 0
  6528. //
  6529. // var commonly_treatment_fulamt_ownpay_amt float64 = 0
  6530. //
  6531. // var register_fulamt_ownpay_amt float64 = 0
  6532. //
  6533. // var operation_fulamt_ownpay_amt float64 = 0
  6534. // var other_fulamt_ownpay_amt float64 = 0
  6535. // var westernMedicine_fulamt_ownpay_amt float64 = 0
  6536. // var chineseTraditional_fulamt_ownpay_amt float64 = 0
  6537. // var check_fulamt_ownpay_amt float64 = 0
  6538. // var material_fulamt_ownpay_amt float64 = 0
  6539. // var laboratory_fulamt_ownpay_amt float64 = 0
  6540. // var treat_fulamt_ownpay_amt float64 = 0
  6541. //
  6542. // var bed_claa_sunmfee float64 = 0
  6543. // var bed_clab_amt float64 = 0
  6544. // var bed_other_amt float64 = 0
  6545. //
  6546. // var examine_claa_sunmfee float64 = 0
  6547. // var examine_clab_amt float64 = 0
  6548. // var examine_other_amt float64 = 0
  6549. //
  6550. // var nursing_claa_sunmfee float64 = 0
  6551. // var nursing_clab_amt float64 = 0
  6552. // var nursing_other_amt float64 = 0
  6553. //
  6554. // var chinese_medicine_claa_sunmfee float64 = 0
  6555. // var chinese_medicine_clab_amt float64 = 0
  6556. // var chinese_medicine_other_amt float64 = 0
  6557. //
  6558. // var commonly_treatment_claa_sunmfee float64 = 0
  6559. // var commonly_treatment_clab_amt float64 = 0
  6560. // var commonly_treatment_other_amt float64 = 0
  6561. //
  6562. // var operation_claa_sunmfee float64 = 0
  6563. // var operation_clab_amt float64 = 0
  6564. // var operation_other_amt float64 = 0
  6565. //
  6566. // var other_claa_sunmfee float64 = 0
  6567. // var other_clab_amt float64 = 0
  6568. // var other_other_amt float64 = 0
  6569. //
  6570. // var westernMedicine_claa_sunmfee float64 = 0
  6571. // var westernMedicine_clab_amt float64 = 0
  6572. // var westernMedicine_other_amt float64 = 0
  6573. //
  6574. // var chineseTraditional_claa_sunmfee float64 = 0
  6575. // var chineseTraditional_clab_amt float64 = 0
  6576. // var chineseTraditional_other_amt float64 = 0
  6577. //
  6578. // var check_claa_sunmfee float64 = 0
  6579. // var check_clab_amt float64 = 0
  6580. // var check_other_amt float64 = 0
  6581. //
  6582. // var material_claa_sunmfee float64 = 0
  6583. // var material_clab_amt float64 = 0
  6584. // var material_other_amt float64 = 0
  6585. //
  6586. // var laboratory_claa_sunmfee float64 = 0
  6587. // var laboratory_clab_amt float64 = 0
  6588. // var laboratory_other_amt float64 = 0
  6589. //
  6590. // var treat_claa_sunmfee float64 = 0
  6591. // var treat_clab_amt float64 = 0
  6592. // var treat_other_amt float64 = 0
  6593. //
  6594. // var register_claa_sunmfee float64 = 0
  6595. // var register_clab_amt float64 = 0
  6596. // var register_other_amt float64 = 0
  6597. //
  6598. // for _, item := range order.HisOrderInfo {
  6599. // if item.MedChrgitmType == "01" { //床位费
  6600. // bedCostTotal, _ = decimal.NewFromFloat(bedCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  6601. // bedCostSelfTotal, _ = decimal.NewFromFloat(bedCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  6602. // bedCostPartSelfTotal, _ = decimal.NewFromFloat(bedCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  6603. // bed_fulamt_ownpay_amt, _ = decimal.NewFromFloat(bed_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  6604. // if item.ChrgitmLv == "1" {
  6605. // bed_claa_sunmfee, _ = decimal.NewFromFloat(bed_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  6606. // }
  6607. // if item.ChrgitmLv == "2" {
  6608. // bed_clab_amt, _ = decimal.NewFromFloat(bed_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  6609. //
  6610. // }
  6611. // if item.ChrgitmLv == "3" {
  6612. // bed_other_amt, _ = decimal.NewFromFloat(bed_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  6613. // }
  6614. //
  6615. // }
  6616. //
  6617. // if item.MedChrgitmType == "02" { //诊查
  6618. // examineCostTotal, _ = decimal.NewFromFloat(examineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  6619. // examineCostSelfTotal, _ = decimal.NewFromFloat(examineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  6620. // examineCostPartSelfTotal, _ = decimal.NewFromFloat(examineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  6621. // examine_fulamt_ownpay_amt, _ = decimal.NewFromFloat(examine_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  6622. // if item.ChrgitmLv == "1" {
  6623. // examine_claa_sunmfee, _ = decimal.NewFromFloat(examine_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  6624. // }
  6625. // if item.ChrgitmLv == "2" {
  6626. // examine_clab_amt, _ = decimal.NewFromFloat(examine_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  6627. //
  6628. // }
  6629. // if item.ChrgitmLv == "3" {
  6630. // examine_other_amt, _ = decimal.NewFromFloat(examine_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  6631. // }
  6632. //
  6633. // }
  6634. //
  6635. // if item.MedChrgitmType == "03" { //检查费
  6636. // checkCostTotal, _ = decimal.NewFromFloat(checkCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  6637. // checkCostSelfTotal, _ = decimal.NewFromFloat(checkCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  6638. // checkCostPartSelfTotal, _ = decimal.NewFromFloat(checkCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  6639. // check_fulamt_ownpay_amt, _ = decimal.NewFromFloat(check_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  6640. // if item.ChrgitmLv == "1" {
  6641. //
  6642. // check_claa_sunmfee, _ = decimal.NewFromFloat(check_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  6643. //
  6644. // }
  6645. // if item.ChrgitmLv == "2" {
  6646. // check_clab_amt, _ = decimal.NewFromFloat(check_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  6647. //
  6648. // }
  6649. // if item.ChrgitmLv == "3" {
  6650. // check_other_amt, _ = decimal.NewFromFloat(check_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  6651. // }
  6652. // }
  6653. //
  6654. // if item.MedChrgitmType == "04" { //化验费
  6655. // laboratoryCostTotal, _ = decimal.NewFromFloat(laboratoryCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  6656. // laboratoryCostSelfTotal, _ = decimal.NewFromFloat(laboratoryCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  6657. // laboratoryCostPartSelfTotal, _ = decimal.NewFromFloat(laboratoryCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  6658. // laboratory_fulamt_ownpay_amt, _ = decimal.NewFromFloat(laboratory_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  6659. // if item.ChrgitmLv == "1" {
  6660. //
  6661. // laboratory_claa_sunmfee, _ = decimal.NewFromFloat(laboratory_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  6662. //
  6663. // }
  6664. // if item.ChrgitmLv == "2" {
  6665. // laboratory_clab_amt, _ = decimal.NewFromFloat(laboratory_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  6666. //
  6667. // }
  6668. // if item.ChrgitmLv == "3" {
  6669. // laboratory_other_amt, _ = decimal.NewFromFloat(laboratory_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  6670. // }
  6671. // }
  6672. //
  6673. // if item.MedChrgitmType == "05" { //治疗费
  6674. // treatCostTotal, _ = decimal.NewFromFloat(treatCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  6675. // treatCostSelfTotal, _ = decimal.NewFromFloat(treatCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  6676. // treatCostPartSelfTotal, _ = decimal.NewFromFloat(treatCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  6677. // treat_fulamt_ownpay_amt, _ = decimal.NewFromFloat(treat_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  6678. // if item.ChrgitmLv == "1" {
  6679. //
  6680. // treat_claa_sunmfee, _ = decimal.NewFromFloat(treat_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  6681. //
  6682. // }
  6683. // if item.ChrgitmLv == "2" {
  6684. // treat_clab_amt, _ = decimal.NewFromFloat(treat_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  6685. //
  6686. // }
  6687. // if item.ChrgitmLv == "3" {
  6688. // treat_other_amt, _ = decimal.NewFromFloat(treat_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  6689. // }
  6690. // }
  6691. //
  6692. // if item.MedChrgitmType == "06" { //手术费
  6693. // operationCostTotal, _ = decimal.NewFromFloat(operationCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  6694. // operationCostSelfTotal, _ = decimal.NewFromFloat(operationCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  6695. // operationCostPartSelfTotal, _ = decimal.NewFromFloat(operationCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  6696. // operation_fulamt_ownpay_amt, _ = decimal.NewFromFloat(operation_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  6697. //
  6698. // if item.ChrgitmLv == "1" {
  6699. //
  6700. // operation_claa_sunmfee, _ = decimal.NewFromFloat(operation_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  6701. //
  6702. // }
  6703. // if item.ChrgitmLv == "2" {
  6704. // operation_clab_amt, _ = decimal.NewFromFloat(operation_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  6705. //
  6706. // }
  6707. // if item.ChrgitmLv == "3" {
  6708. // operation_other_amt, _ = decimal.NewFromFloat(operation_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  6709. // }
  6710. // }
  6711. //
  6712. // if item.MedChrgitmType == "07" { //手术费
  6713. // nursingCostTotal, _ = decimal.NewFromFloat(nursingCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  6714. // nursingCostSelfTotal, _ = decimal.NewFromFloat(nursingCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  6715. // nursingCostPartSelfTotal, _ = decimal.NewFromFloat(nursingCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  6716. // nursing_fulamt_ownpay_amt, _ = decimal.NewFromFloat(nursing_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  6717. //
  6718. // if item.ChrgitmLv == "1" {
  6719. //
  6720. // nursing_claa_sunmfee, _ = decimal.NewFromFloat(nursing_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  6721. //
  6722. // }
  6723. // if item.ChrgitmLv == "2" {
  6724. // nursing_clab_amt, _ = decimal.NewFromFloat(nursing_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  6725. //
  6726. // }
  6727. // if item.ChrgitmLv == "3" {
  6728. // nursing_other_amt, _ = decimal.NewFromFloat(nursing_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  6729. // }
  6730. // }
  6731. //
  6732. // if item.MedChrgitmType == "08" { //材料费
  6733. // materialCostTotal, _ = decimal.NewFromFloat(materialCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  6734. // materialCostSelfTotal, _ = decimal.NewFromFloat(materialCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  6735. // materialCostPartSelfTotal, _ = decimal.NewFromFloat(materialCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  6736. // material_fulamt_ownpay_amt, _ = decimal.NewFromFloat(material_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  6737. // if item.ChrgitmLv == "1" {
  6738. //
  6739. // material_claa_sunmfee, _ = decimal.NewFromFloat(material_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  6740. //
  6741. // }
  6742. // if item.ChrgitmLv == "2" {
  6743. // material_clab_amt, _ = decimal.NewFromFloat(material_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  6744. //
  6745. // }
  6746. // if item.ChrgitmLv == "3" {
  6747. // material_other_amt, _ = decimal.NewFromFloat(material_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  6748. // }
  6749. // }
  6750. // if item.MedChrgitmType == "09" { //西药费
  6751. // westernMedicineCostTotal, _ = decimal.NewFromFloat(westernMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  6752. // westernMedicineCostSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  6753. // westernMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  6754. // westernMedicine_fulamt_ownpay_amt, _ = decimal.NewFromFloat(westernMedicine_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  6755. // if item.ChrgitmLv == "1" {
  6756. // westernMedicine_claa_sunmfee, _ = decimal.NewFromFloat(westernMedicine_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  6757. // }
  6758. // if item.ChrgitmLv == "2" {
  6759. // westernMedicine_clab_amt, _ = decimal.NewFromFloat(westernMedicine_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  6760. // }
  6761. // if item.ChrgitmLv == "3" {
  6762. // westernMedicine_other_amt, _ = decimal.NewFromFloat(westernMedicine_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  6763. // }
  6764. // }
  6765. // if item.MedChrgitmType == "10" { //中药饮片
  6766. // chineseMedicineCostTotal, _ = decimal.NewFromFloat(chineseMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  6767. // chineseMedicineCostSelfTotal, _ = decimal.NewFromFloat(chineseMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  6768. // chineseMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(chineseMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  6769. // chinese_medicine_fulamt_ownpay_amt, _ = decimal.NewFromFloat(chinese_medicine_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  6770. // if item.ChrgitmLv == "1" {
  6771. // chinese_medicine_claa_sunmfee, _ = decimal.NewFromFloat(chinese_medicine_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  6772. // }
  6773. // if item.ChrgitmLv == "2" {
  6774. // chinese_medicine_clab_amt, _ = decimal.NewFromFloat(chinese_medicine_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  6775. // }
  6776. // if item.ChrgitmLv == "3" {
  6777. // chinese_medicine_other_amt, _ = decimal.NewFromFloat(chinese_medicine_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  6778. // }
  6779. // }
  6780. //
  6781. // if item.MedChrgitmType == "11" { //中成费
  6782. // chineseTraditionalMedicineCostTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  6783. // chineseTraditionalMedicineCostSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  6784. // chineseTraditionalMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  6785. // chineseTraditional_fulamt_ownpay_amt, _ = decimal.NewFromFloat(chineseTraditional_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  6786. // if item.ChrgitmLv == "1" {
  6787. //
  6788. // chineseTraditional_claa_sunmfee, _ = decimal.NewFromFloat(chineseTraditional_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  6789. //
  6790. // }
  6791. // if item.ChrgitmLv == "2" {
  6792. // chineseTraditional_clab_amt, _ = decimal.NewFromFloat(chineseTraditional_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  6793. //
  6794. // }
  6795. // if item.ChrgitmLv == "3" {
  6796. // chineseTraditional_other_amt, _ = decimal.NewFromFloat(chineseTraditional_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  6797. // }
  6798. // }
  6799. //
  6800. // if item.MedChrgitmType == "12" { //中成费
  6801. // commonlyTreatmentCostTotal, _ = decimal.NewFromFloat(commonlyTreatmentCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  6802. // commonlyTreatmentCostSelfTotal, _ = decimal.NewFromFloat(commonlyTreatmentCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  6803. // commonlyTreatmentCostPartSelfTotal, _ = decimal.NewFromFloat(commonlyTreatmentCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  6804. // commonly_treatment_fulamt_ownpay_amt, _ = decimal.NewFromFloat(commonly_treatment_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  6805. // if item.ChrgitmLv == "1" {
  6806. //
  6807. // commonly_treatment_claa_sunmfee, _ = decimal.NewFromFloat(commonly_treatment_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  6808. //
  6809. // }
  6810. // if item.ChrgitmLv == "2" {
  6811. // commonly_treatment_clab_amt, _ = decimal.NewFromFloat(commonly_treatment_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  6812. //
  6813. // }
  6814. // if item.ChrgitmLv == "3" {
  6815. // commonly_treatment_other_amt, _ = decimal.NewFromFloat(commonly_treatment_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  6816. // }
  6817. // }
  6818. //
  6819. // if item.MedChrgitmType == "13" { //中成费
  6820. // registerCostTotal, _ = decimal.NewFromFloat(registerCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  6821. // registerCostSelfTotal, _ = decimal.NewFromFloat(registerCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  6822. // registerPartSelfTotal, _ = decimal.NewFromFloat(registerPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  6823. // register_fulamt_ownpay_amt, _ = decimal.NewFromFloat(register_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  6824. // if item.ChrgitmLv == "1" {
  6825. //
  6826. // register_claa_sunmfee, _ = decimal.NewFromFloat(register_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  6827. //
  6828. // }
  6829. // if item.ChrgitmLv == "2" {
  6830. // register_clab_amt, _ = decimal.NewFromFloat(register_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  6831. //
  6832. // }
  6833. // if item.ChrgitmLv == "3" {
  6834. // register_other_amt, _ = decimal.NewFromFloat(register_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  6835. // }
  6836. // }
  6837. //
  6838. // if item.MedChrgitmType == "14" { //其他费
  6839. // otherCostTotal, _ = decimal.NewFromFloat(otherCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  6840. // otherCostSelfTotal, _ = decimal.NewFromFloat(otherCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  6841. // otherCostPartSelfTotal, _ = decimal.NewFromFloat(otherCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  6842. // other_fulamt_ownpay_amt, _ = decimal.NewFromFloat(other_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  6843. // if item.ChrgitmLv == "1" {
  6844. // other_claa_sunmfee, _ = decimal.NewFromFloat(other_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  6845. //
  6846. // }
  6847. // if item.ChrgitmLv == "2" {
  6848. // other_clab_amt, _ = decimal.NewFromFloat(other_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  6849. //
  6850. // }
  6851. // if item.ChrgitmLv == "3" {
  6852. // other_other_amt, _ = decimal.NewFromFloat(other_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  6853. // }
  6854. // }
  6855. //
  6856. // }
  6857. //
  6858. // var iteminfoStructs []service.IteminfoStruct
  6859. //
  6860. // if bedCostTotal != 0 {
  6861. // iteminfo.MedChrgitm = "01"
  6862. // iteminfo.FulamtOwnpayAmt = bed_fulamt_ownpay_amt
  6863. // iteminfo.Amt = bedCostTotal
  6864. // iteminfo.ClaaSumfee = bed_claa_sunmfee
  6865. // iteminfo.ClabAmt = bed_clab_amt
  6866. // iteminfo.OthAmt = bed_other_amt
  6867. // iteminfoStructs = append(iteminfoStructs, iteminfo)
  6868. // }
  6869. //
  6870. // if examineCostTotal != 0 {
  6871. // iteminfo.MedChrgitm = "02"
  6872. // iteminfo.FulamtOwnpayAmt = examine_fulamt_ownpay_amt
  6873. // iteminfo.Amt = examineCostTotal
  6874. // iteminfo.ClaaSumfee = examine_claa_sunmfee
  6875. // iteminfo.ClabAmt = examine_clab_amt
  6876. // iteminfo.OthAmt = examine_other_amt
  6877. // //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  6878. // iteminfoStructs = append(iteminfoStructs, iteminfo)
  6879. // }
  6880. //
  6881. // if checkCostTotal != 0 {
  6882. // iteminfo.MedChrgitm = "03"
  6883. // iteminfo.FulamtOwnpayAmt = check_fulamt_ownpay_amt
  6884. // iteminfo.Amt = checkCostTotal
  6885. // iteminfo.ClaaSumfee = check_claa_sunmfee
  6886. // iteminfo.ClabAmt = check_clab_amt
  6887. // iteminfo.OthAmt = check_other_amt
  6888. // iteminfoStructs = append(iteminfoStructs, iteminfo)
  6889. //
  6890. // }
  6891. //
  6892. // if laboratoryCostTotal != 0 {
  6893. // iteminfo.MedChrgitm = "04"
  6894. // iteminfo.FulamtOwnpayAmt = laboratory_fulamt_ownpay_amt
  6895. // iteminfo.Amt = laboratoryCostTotal
  6896. // iteminfo.ClaaSumfee = laboratory_claa_sunmfee
  6897. // iteminfo.ClabAmt = laboratory_clab_amt
  6898. // iteminfo.OthAmt = laboratory_other_amt
  6899. // iteminfoStructs = append(iteminfoStructs, iteminfo)
  6900. //
  6901. // //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  6902. //
  6903. // }
  6904. //
  6905. // if treatCostTotal != 0 {
  6906. // iteminfo.MedChrgitm = "05"
  6907. // iteminfo.FulamtOwnpayAmt = treat_fulamt_ownpay_amt
  6908. // iteminfo.Amt = treatCostTotal
  6909. // iteminfo.ClaaSumfee = treat_claa_sunmfee
  6910. // iteminfo.ClabAmt = treat_clab_amt
  6911. // iteminfo.OthAmt = treat_other_amt
  6912. // iteminfoStructs = append(iteminfoStructs, iteminfo)
  6913. // //(struct4101.IteminfoStruct, iteminfo)
  6914. // //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  6915. // }
  6916. //
  6917. // if operationCostTotal != 0 {
  6918. // iteminfo.MedChrgitm = "06"
  6919. // iteminfo.FulamtOwnpayAmt = bed_fulamt_ownpay_amt
  6920. // iteminfo.Amt = operationCostTotal
  6921. // iteminfo.ClaaSumfee = operation_claa_sunmfee
  6922. // iteminfo.ClabAmt = operation_clab_amt
  6923. // iteminfo.OthAmt = operation_other_amt
  6924. // //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  6925. // iteminfoStructs = append(iteminfoStructs, iteminfo)
  6926. // }
  6927. //
  6928. // if nursingCostTotal != 0 {
  6929. // iteminfo.MedChrgitm = "07"
  6930. // iteminfo.FulamtOwnpayAmt = nursing_fulamt_ownpay_amt
  6931. // iteminfo.Amt = nursingCostTotal
  6932. // iteminfo.ClaaSumfee = nursing_claa_sunmfee
  6933. // iteminfo.ClabAmt = nursing_clab_amt
  6934. // iteminfo.OthAmt = nursing_other_amt
  6935. // iteminfoStructs = append(iteminfoStructs, iteminfo)
  6936. // }
  6937. //
  6938. // if materialCostTotal != 0 {
  6939. // iteminfo.MedChrgitm = "08"
  6940. // iteminfo.FulamtOwnpayAmt = material_fulamt_ownpay_amt
  6941. // iteminfo.Amt = materialCostTotal
  6942. // iteminfo.ClaaSumfee = material_claa_sunmfee
  6943. // iteminfo.ClabAmt = material_clab_amt
  6944. // iteminfo.OthAmt = material_other_amt
  6945. // //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  6946. // iteminfoStructs = append(iteminfoStructs, iteminfo)
  6947. // }
  6948. //
  6949. // if westernMedicineCostTotal != 0 {
  6950. // iteminfo.MedChrgitm = "09"
  6951. // iteminfo.FulamtOwnpayAmt = westernMedicine_fulamt_ownpay_amt
  6952. // iteminfo.Amt = westernMedicineCostTotal
  6953. // iteminfo.ClaaSumfee = westernMedicine_claa_sunmfee
  6954. // iteminfo.ClabAmt = westernMedicine_clab_amt
  6955. // iteminfo.OthAmt = westernMedicine_other_amt
  6956. // //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  6957. // iteminfoStructs = append(iteminfoStructs, iteminfo)
  6958. //
  6959. // }
  6960. //
  6961. // if chineseMedicineCostTotal != 0 {
  6962. // iteminfo.MedChrgitm = "10"
  6963. // iteminfo.FulamtOwnpayAmt = chinese_medicine_fulamt_ownpay_amt
  6964. // iteminfo.Amt = chineseMedicineCostTotal
  6965. // iteminfo.ClaaSumfee = chinese_medicine_claa_sunmfee
  6966. // iteminfo.ClabAmt = chinese_medicine_clab_amt
  6967. // iteminfo.OthAmt = chinese_medicine_other_amt
  6968. // //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  6969. // iteminfoStructs = append(iteminfoStructs, iteminfo)
  6970. //
  6971. // }
  6972. //
  6973. // if chineseTraditionalMedicineCostTotal != 0 {
  6974. // iteminfo.MedChrgitm = "11"
  6975. // iteminfo.FulamtOwnpayAmt = westernMedicine_fulamt_ownpay_amt
  6976. // iteminfo.Amt = westernMedicineCostTotal
  6977. // iteminfo.ClaaSumfee = westernMedicine_claa_sunmfee
  6978. // iteminfo.ClabAmt = westernMedicine_clab_amt
  6979. // iteminfo.OthAmt = westernMedicine_other_amt
  6980. // //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  6981. // iteminfoStructs = append(iteminfoStructs, iteminfo)
  6982. //
  6983. // }
  6984. //
  6985. // if commonlyTreatmentCostTotal != 0 {
  6986. // iteminfo.MedChrgitm = "12"
  6987. // iteminfo.FulamtOwnpayAmt = commonly_treatment_fulamt_ownpay_amt
  6988. // iteminfo.Amt = commonlyTreatmentCostTotal
  6989. // iteminfo.ClaaSumfee = commonly_treatment_claa_sunmfee
  6990. // iteminfo.ClabAmt = commonly_treatment_clab_amt
  6991. // iteminfo.OthAmt = commonly_treatment_other_amt
  6992. // //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  6993. // iteminfoStructs = append(iteminfoStructs, iteminfo)
  6994. //
  6995. // }
  6996. //
  6997. // if registerCostTotal != 0 {
  6998. // iteminfo.MedChrgitm = "13"
  6999. // iteminfo.FulamtOwnpayAmt = register_fulamt_ownpay_amt
  7000. // iteminfo.Amt = registerCostTotal
  7001. // iteminfo.ClaaSumfee = register_claa_sunmfee
  7002. // iteminfo.ClabAmt = register_clab_amt
  7003. // iteminfo.OthAmt = register_other_amt
  7004. // //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  7005. // iteminfoStructs = append(iteminfoStructs, iteminfo)
  7006. //
  7007. // }
  7008. //
  7009. // if otherCostTotal != 0 {
  7010. // iteminfo.MedChrgitm = "14"
  7011. // iteminfo.FulamtOwnpayAmt = other_fulamt_ownpay_amt
  7012. // iteminfo.Amt = otherCostTotal
  7013. // iteminfo.ClaaSumfee = other_claa_sunmfee
  7014. // iteminfo.ClabAmt = other_clab_amt
  7015. // iteminfo.OthAmt = other_other_amt
  7016. // //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  7017. // iteminfoStructs = append(iteminfoStructs, iteminfo)
  7018. //
  7019. // }
  7020. // struct4101.IteminfoStruct = iteminfoStructs
  7021. // time_arr := strings.Split(order.SetlTime, " ")
  7022. // struct4101.AdmTime = time_arr[0]
  7023. // struct4101.AdmEndTime = time_arr[0]
  7024. //
  7025. // struct4101.DoctorName = doctor.UserName
  7026. // struct4101.DoctorCode = doctor.DoctorNumber
  7027. //
  7028. // struct4101.Ntly = "中国"
  7029. // struct4101.AdmCaty = "A03.06"
  7030. // var res ResultSeventeen
  7031. // if miConfig.MdtrtareaAdmvs == "421300" {
  7032. // data := make(map[string]interface{})
  7033. // data["struct4101"] = struct4101
  7034. // data["secret_key"] = miConfig.SecretKey
  7035. // data["org_name"] = miConfig.OrgName
  7036. // data["opera"] = curRoles.UserName
  7037. // data["code"] = miConfig.Code
  7038. // data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  7039. // data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  7040. //
  7041. // client := &http.Client{}
  7042. // bytesData, _ := json.Marshal(data)
  7043. // req, _ := http.NewRequest("POST", "http://192.168.124.4:9532/"+"hbyb/4101", bytes.NewReader(bytesData))
  7044. // resp, _ := client.Do(req)
  7045. // defer resp.Body.Close()
  7046. // body, ioErr := ioutil.ReadAll(resp.Body)
  7047. // if ioErr != nil {
  7048. // utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  7049. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7050. // return
  7051. // }
  7052. // var respJSON map[string]interface{}
  7053. // if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  7054. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  7055. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7056. // return
  7057. // }
  7058. //
  7059. // respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  7060. // userJSONBytes, _ := json.Marshal(respJSON)
  7061. // if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  7062. // utils.ErrorLog("解析失败:%v", err)
  7063. // //c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7064. // adminUser := c.GetAdminUserInfo()
  7065. // errlog := &models.HisOrderError{
  7066. // UserOrgId: adminUser.CurrentOrgId,
  7067. // Ctime: time.Now().Unix(),
  7068. // Mtime: time.Now().Unix(),
  7069. // ErrMsg: res.ErrMsg + "解析失败",
  7070. // Status: 1,
  7071. // PatientId: order_id,
  7072. // Stage: 10088,
  7073. // }
  7074. // service.CreateErrMsgLog(errlog)
  7075. // continue
  7076. // }
  7077. //
  7078. // } else {
  7079. // result := service.Gdyb4101(struct4101, miConfig.SecretKey, miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, c.GetAdminUserInfo().CurrentOrgId)
  7080. // fmt.Println(result)
  7081. //
  7082. // var dat map[string]interface{}
  7083. // if err := json.Unmarshal([]byte(result), &dat); err == nil {
  7084. // fmt.Println(dat)
  7085. // } else {
  7086. // fmt.Println(err)
  7087. // }
  7088. // userJSONBytes, _ := json.Marshal(dat)
  7089. // if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  7090. // utils.ErrorLog("解析失败:%v", err)
  7091. // //c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7092. // adminUser := c.GetAdminUserInfo()
  7093. // errlog := &models.HisOrderError{
  7094. // UserOrgId: adminUser.CurrentOrgId,
  7095. // Ctime: time.Now().Unix(),
  7096. // Mtime: time.Now().Unix(),
  7097. // ErrMsg: res.ErrMsg + "解析失败",
  7098. // Status: 1,
  7099. // PatientId: order_id,
  7100. // Stage: 10106,
  7101. // }
  7102. // service.CreateErrMsgLog(errlog)
  7103. // continue
  7104. // }
  7105. // }
  7106. //
  7107. // if res.Infcode != 0 {
  7108. // adminUser := c.GetAdminUserInfo()
  7109. // errlog := &models.HisOrderError{
  7110. // UserOrgId: adminUser.CurrentOrgId,
  7111. // Ctime: time.Now().Unix(),
  7112. // Mtime: time.Now().Unix(),
  7113. // ErrMsg: res.ErrMsg,
  7114. // Status: 1,
  7115. // PatientId: order_id,
  7116. // Stage: 10106,
  7117. // }
  7118. // service.CreateErrMsgLog(errlog)
  7119. // continue
  7120. // } else {
  7121. // hisFundSettleListResult := &models.HisFundSettleListResult{
  7122. // Number: res.Output.SetlListId,
  7123. // Status: 1,
  7124. // Ctime: time.Now().Unix(),
  7125. // Mtime: time.Now().Unix(),
  7126. // UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  7127. // IsUpload: 1,
  7128. // OrderId: order_id,
  7129. // }
  7130. // service.CreateUploadRecord(hisFundSettleListResult)
  7131. // continue
  7132. // }
  7133. // }
  7134. //}
  7135. func (c *HisApiController) GetOrgInfo() {
  7136. miConfig, _ := service.FindMedicalInsuranceInfo(4)
  7137. service.Gdyb1201("", miConfig.OrgName, "1122", miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, 1, "")
  7138. }
  7139. func (c *HisApiController) GetHisPatientInfo() {
  7140. medical_insurance_card := c.GetString("medical_insurance_card")
  7141. id_card_type, _ := c.GetInt64("id_card_type")
  7142. id_card := c.GetString("id_card")
  7143. adminInfo := c.GetAdminUserInfo()
  7144. config, _ := service.GetMedicalInsuranceConfig(adminInfo.CurrentOrgId)
  7145. miConfig, _ := service.FindMedicalInsuranceInfo(adminInfo.CurrentOrgId)
  7146. appRole, _ := service.GetAppRole(adminInfo.CurrentOrgId)
  7147. IdCardNo := ""
  7148. if id_card_type == 1 {
  7149. IdCardNo = medical_insurance_card
  7150. } else if id_card_type == 2 {
  7151. IdCardNo = id_card
  7152. }
  7153. if config.IsOpen == 1 {
  7154. 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
  7155. resp, requestErr := http.Get(api)
  7156. if requestErr != nil {
  7157. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7158. return
  7159. }
  7160. defer resp.Body.Close()
  7161. body, ioErr := ioutil.ReadAll(resp.Body)
  7162. if ioErr != nil {
  7163. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  7164. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7165. return
  7166. }
  7167. var respJSON map[string]interface{}
  7168. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  7169. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  7170. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7171. return
  7172. }
  7173. userJSON := respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  7174. userJSONBytes, _ := json.Marshal(userJSON)
  7175. var res ResultTwo
  7176. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  7177. utils.ErrorLog("解析失败:%v", err)
  7178. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7179. return
  7180. }
  7181. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  7182. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  7183. infoStr := string(Iinfos)
  7184. idetinfoStr := string(Idetinfos)
  7185. if res.Infcode == 0 {
  7186. his := models.VMHisPatient{
  7187. Status: 1,
  7188. Ctime: time.Now().Unix(),
  7189. Mtime: time.Now().Unix(),
  7190. PsnNo: res.Output.Baseinfo.PsnNo,
  7191. PsnCertType: res.Output.Baseinfo.PsnCertType,
  7192. Certno: res.Output.Baseinfo.Certno,
  7193. PsnName: res.Output.Baseinfo.PsnName,
  7194. Gend: res.Output.Baseinfo.Gend,
  7195. Naty: res.Output.Baseinfo.Naty,
  7196. Brdy: res.Output.Baseinfo.Brdy,
  7197. Age: res.Output.Baseinfo.Age,
  7198. Iinfo: infoStr,
  7199. Idetinfo: idetinfoStr,
  7200. UserOrgId: adminInfo.CurrentOrgId,
  7201. IsReturn: 1,
  7202. IdCardType: id_card_type,
  7203. }
  7204. c.ServeSuccessJSON(map[string]interface{}{
  7205. "info": his,
  7206. })
  7207. } else {
  7208. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  7209. return
  7210. }
  7211. }
  7212. }
  7213. //func GetBasBaseInfo() (jsonStr string, err error) {
  7214. //
  7215. // handle := syscall.NewLazyDLL("SSCard.dll")
  7216. // add := handle.NewProc("ReadCardBas")
  7217. // str := make([]byte, 1024)
  7218. // str1 := make([]byte, 1024)
  7219. // ret, _, _ := add.Call((uintptr)(unsafe.Pointer(&str[0])), IntPtr(1024), (uintptr)(unsafe.Pointer(&str1[0])), IntPtr(1024))
  7220. // fmt.Println(ConvertToString(string(str), "gbk", "utf-8"))
  7221. //
  7222. // fmt.Println(ConvertToString(string(str1), "gbk", "utf-8"))
  7223. //
  7224. // fmt.Println("> Add(4,5)的结果为:", ret)
  7225. // handle.Release()
  7226. //
  7227. // return "", nil
  7228. //
  7229. //}
  7230. //func GetQRBaseInfo() (jsonStr string, err error) {
  7231. // handle := syscall.LoadDLL("SSCard.dll")
  7232. // ReadCardBas := handle.FindProc("GetQRBase")
  7233. //
  7234. // str := make([]byte, 256)
  7235. // str1 := make([]byte, 256)
  7236. // r, _, _ := ReadCardBas.Call((uintptr)(unsafe.Pointer(&str[0])), IntPtr(1024), (uintptr)(unsafe.Pointer(&str1[0])), IntPtr(1024))
  7237. //
  7238. // fmt.Println(string(str))
  7239. // fmt.Println(r)
  7240. // return string(str), nil
  7241. //}
  7242. //func CardInit() int {
  7243. // DllTestDef := syscall.MustLoadDLL("SSCard.dll")
  7244. // add := DllTestDef.MustFindProc("Init")
  7245. // ret, _, err := add.Call(StrPtr("http://igb.hsa.gdgov.cn/gdyb_inf/poc/api/card/initDll"), StrPtr("440200"))
  7246. // if err != nil {
  7247. // fmt.Println("SSCard的运算结果为:", ret)
  7248. // }
  7249. // result := int(ret)
  7250. // return result
  7251. //}
  7252. //func CardInit() int {
  7253. // ret, _, err := add.Call(StrPtr("http://igb.hsa.gdgov.cn/gdyb_inf/poc/api/card/initDll"), StrPtr("440200"))
  7254. // if err != nil {
  7255. // fmt.Println("SSCard的运算结果为:", ret)
  7256. // }
  7257. // fmt.Println(err)
  7258. // result := int(ret)
  7259. // return result
  7260. //}
  7261. func IntPtr(n int) uintptr {
  7262. return uintptr(n)
  7263. }
  7264. func StrPtr(s string) uintptr {
  7265. return uintptr(unsafe.Pointer(syscall.StringBytePtr(s)))
  7266. }
  7267. type Result2001 struct {
  7268. Cainfo interface{} `json:"cainfo"`
  7269. ErrMsg string `json:"err_msg"`
  7270. InfRefmsgid string `json:"inf_refmsgid"`
  7271. Infcode int64 `json:"infcode"`
  7272. Output struct {
  7273. Trtinfo struct {
  7274. PsnNo string `json:"psn_no"`
  7275. TrtChkType string `json:"trt_chk_type"`
  7276. FundPayType string `json:"fund_pay_type"`
  7277. TrtEnjymntFlag string `json:"trt_enjymnt_flag"`
  7278. Begndate string `json:"begndate"`
  7279. Enddate string `json:"enddate"`
  7280. TrtChkRslt string `json:"trt_chk_rslt"`
  7281. } `json:"trtinfo"`
  7282. } `json:"output"`
  7283. RefmsgTime string `json:"refmsg_time"`
  7284. RespondTime string `json:"respond_time"`
  7285. Signtype interface{} `json:"signtype"`
  7286. WarnMsg interface{} `json:"warn_msg"`
  7287. }
  7288. type Result2001Org10265 struct {
  7289. Cainfo interface{} `json:"cainfo"`
  7290. ErrMsg string `json:"err_msg"`
  7291. InfRefmsgid string `json:"inf_refmsgid"`
  7292. Infcode string `json:"infcode"`
  7293. Output struct {
  7294. Trtinfo struct {
  7295. PsnNo string `json:"psn_no"`
  7296. TrtChkType string `json:"trt_chk_type"`
  7297. FundPayType string `json:"fund_pay_type"`
  7298. TrtEnjymntFlag string `json:"trt_enjymnt_flag"`
  7299. Begndate string `json:"begndate"`
  7300. Enddate string `json:"enddate"`
  7301. TrtChkRslt string `json:"trt_chk_rslt"`
  7302. } `json:"trtinfo"`
  7303. } `json:"output"`
  7304. RefmsgTime string `json:"refmsg_time"`
  7305. RespondTime string `json:"respond_time"`
  7306. Signtype interface{} `json:"signtype"`
  7307. WarnMsg interface{} `json:"warn_msg"`
  7308. }
  7309. type ResultTwo struct {
  7310. ErrMsg string `json:"err_msg"`
  7311. InfRefmsgid string `json:"inf_refmsgid"`
  7312. Infcode int64 `json:"infcode"`
  7313. Output struct {
  7314. Baseinfo struct {
  7315. Age float64 `json:"age"`
  7316. Brdy string `json:"brdy"`
  7317. Certno string `json:"certno"`
  7318. Gend string `json:"gend"`
  7319. Naty string `json:"naty"`
  7320. PsnCertType string `json:"psn_cert_type"`
  7321. PsnName string `json:"psn_name"`
  7322. PsnNo string `json:"psn_no"`
  7323. } `json:"baseinfo"`
  7324. Idetinfo []interface{} `json:"idetinfo"`
  7325. Iinfo []struct {
  7326. Balc float64 `json:"balc"`
  7327. CvlservFlag string `json:"cvlserv_flag"`
  7328. EmpName string `json:"emp_name"`
  7329. InsuplcAdmdvs string `json:"insuplc_admdvs"`
  7330. Insutype string `json:"insutype"`
  7331. PausInsuDansuplcAdmdvs string `json:"paus_insu_dansuplc_admdvs"`
  7332. PausInsuDate string `json:"paus_insu_date"`
  7333. PsnInsuDate string `json:"psn_insu_date"`
  7334. PsnInsuStas string `json:"psn_insu_stas"`
  7335. PsnType string `json:"psn_type"`
  7336. } `json:"insuinfo"`
  7337. } `json:"output"`
  7338. RefmsgTime string `json:"refmsg_time"`
  7339. RespondTime string `json:"respond_time"`
  7340. Signtype interface{} `json:"signtype"`
  7341. WarnInfo interface{} `json:"warn_info"`
  7342. }
  7343. type ResultTwo10265 struct {
  7344. ErrMsg string `json:"err_msg"`
  7345. InfRefmsgid string `json:"inf_refmsgid"`
  7346. Infcode string `json:"infcode"`
  7347. Output struct {
  7348. Baseinfo struct {
  7349. Age float64 `json:"age"`
  7350. Brdy string `json:"brdy"`
  7351. Certno string `json:"certno"`
  7352. Gend string `json:"gend"`
  7353. Naty string `json:"naty"`
  7354. PsnCertType string `json:"psn_cert_type"`
  7355. PsnName string `json:"psn_name"`
  7356. PsnNo string `json:"psn_no"`
  7357. } `json:"baseinfo"`
  7358. Idetinfo []interface{} `json:"idetinfo"`
  7359. Iinfo []struct {
  7360. Balc float64 `json:"balc"`
  7361. CvlservFlag string `json:"cvlserv_flag"`
  7362. EmpName string `json:"emp_name"`
  7363. InsuplcAdmdvs string `json:"insuplc_admdvs"`
  7364. Insutype string `json:"insutype"`
  7365. PausInsuDansuplcAdmdvs string `json:"paus_insu_dansuplc_admdvs"`
  7366. PausInsuDate string `json:"paus_insu_date"`
  7367. PsnInsuDate string `json:"psn_insu_date"`
  7368. PsnInsuStas string `json:"psn_insu_stas"`
  7369. PsnType string `json:"psn_type"`
  7370. } `json:"insuinfo"`
  7371. } `json:"output"`
  7372. RefmsgTime string `json:"refmsg_time"`
  7373. RespondTime string `json:"respond_time"`
  7374. Signtype interface{} `json:"signtype"`
  7375. WarnInfo interface{} `json:"warn_info"`
  7376. }
  7377. type ResultThree struct {
  7378. Cainfo interface{} `json:"cainfo"`
  7379. ErrMsg string `json:"err_msg"`
  7380. InfRefmsgid string `json:"inf_refmsgid"`
  7381. Infcode int64 `json:"infcode"`
  7382. Output struct {
  7383. Data struct {
  7384. IptOtpNo string `json:"ipt_otp_no"`
  7385. MdtrtID string `json:"mdtrt_id"`
  7386. PsnNo string `json:"psn_no"`
  7387. } `json:"data"`
  7388. } `json:"output"`
  7389. RefmsgTime string `json:"refmsg_time"`
  7390. RespondTime string `json:"respond_time"`
  7391. Signtype interface{} `json:"signtype"`
  7392. WarnMsg interface{} `json:"warn_msg"`
  7393. }
  7394. type ResultThree10265 struct {
  7395. Cainfo interface{} `json:"cainfo"`
  7396. ErrMsg string `json:"err_msg"`
  7397. InfRefmsgid string `json:"inf_refmsgid"`
  7398. Infcode string `json:"infcode"`
  7399. Output struct {
  7400. Data struct {
  7401. IptOtpNo string `json:"ipt_otp_no"`
  7402. MdtrtID string `json:"mdtrt_id"`
  7403. PsnNo string `json:"psn_no"`
  7404. } `json:"data"`
  7405. } `json:"output"`
  7406. RefmsgTime string `json:"refmsg_time"`
  7407. RespondTime string `json:"respond_time"`
  7408. Signtype interface{} `json:"signtype"`
  7409. WarnMsg interface{} `json:"warn_msg"`
  7410. }
  7411. type ResultFour struct {
  7412. Cainfo string `json:"cainfo"`
  7413. ErrMsg string `json:"err_msg"`
  7414. InfRefmsgid string `json:"inf_refmsgid"`
  7415. Infcode int64 `json:"infcode"`
  7416. Output struct {
  7417. Result []struct {
  7418. BasMednFlag string `json:"bas_medn_flag"`
  7419. ChldMedcFlag string `json:"chld_medc_flag"`
  7420. ChrgitmLv string `json:"chrgitm_lv"`
  7421. Cnt float64 `json:"cnt"`
  7422. DetItemFeeSumamt float64 `json:"det_item_fee_sumamt"`
  7423. DrtReimFlag string `json:"drt_reim_flag"`
  7424. FeedetlSn string `json:"feedetl_sn"`
  7425. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  7426. HiNegoDrugFlag string `json:"hi_nego_drug_flag"`
  7427. InscpScpAmt float64 `json:"inscp_scp_amt"`
  7428. ListSpItemFlag string `json:"list_sp_item_flag"`
  7429. LmtUsedFlag string `json:"lmt_used_flag"`
  7430. MedChrgitmType string `json:"med_chrgitm_type"`
  7431. Memo string `json:"memo"`
  7432. OverlmtAmt float64 `json:"overlmt_amt"`
  7433. PreselfpayAmt float64 `json:"preselfpay_amt"`
  7434. Pric float64 `json:"pric"`
  7435. PricUplmtAmt float64 `json:"pric_uplmt_amt"`
  7436. SelfpayProp float64 `json:"selfpay_prop"`
  7437. } `json:"result"`
  7438. } `json:"output"`
  7439. RefmsgTime string `json:"refmsg_time"`
  7440. RespondTime string `json:"respond_time"`
  7441. Signtype string `json:"signtype"`
  7442. WarnMsg string `json:"warn_msg"`
  7443. }
  7444. type ResultFour10265 struct {
  7445. Cainfo string `json:"cainfo"`
  7446. ErrMsg string `json:"err_msg"`
  7447. InfRefmsgid string `json:"inf_refmsgid"`
  7448. Infcode string `json:"infcode"`
  7449. Output struct {
  7450. Result []struct {
  7451. BasMednFlag string `json:"bas_medn_flag"`
  7452. ChldMedcFlag string `json:"chld_medc_flag"`
  7453. ChrgitmLv string `json:"chrgitm_lv"`
  7454. Cnt float64 `json:"cnt"`
  7455. DetItemFeeSumamt float64 `json:"det_item_fee_sumamt"`
  7456. DrtReimFlag string `json:"drt_reim_flag"`
  7457. FeedetlSn string `json:"feedetl_sn"`
  7458. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  7459. HiNegoDrugFlag string `json:"hi_nego_drug_flag"`
  7460. InscpScpAmt float64 `json:"inscp_scp_amt"`
  7461. ListSpItemFlag string `json:"list_sp_item_flag"`
  7462. LmtUsedFlag string `json:"lmt_used_flag"`
  7463. MedChrgitmType string `json:"med_chrgitm_type"`
  7464. Memo string `json:"memo"`
  7465. OverlmtAmt float64 `json:"overlmt_amt"`
  7466. PreselfpayAmt float64 `json:"preselfpay_amt"`
  7467. Pric float64 `json:"pric"`
  7468. PricUplmtAmt float64 `json:"pric_uplmt_amt"`
  7469. SelfpayProp float64 `json:"selfpay_prop"`
  7470. } `json:"result"`
  7471. } `json:"output"`
  7472. RefmsgTime string `json:"refmsg_time"`
  7473. RespondTime string `json:"respond_time"`
  7474. Signtype string `json:"signtype"`
  7475. WarnMsg string `json:"warn_msg"`
  7476. }
  7477. type ResultMemo struct {
  7478. InsuAdmdvs string `json:"insuAdmdvs"`
  7479. }
  7480. // [{"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}]
  7481. type ResultIDInfo struct {
  7482. Begntime string `json:"begntime"`
  7483. Endtime string `json:"endtime"`
  7484. Memo string `json:"memo"`
  7485. }
  7486. type ResultFive struct {
  7487. Balc float64 `json:"balc"`
  7488. CvlservFlag string `json:"cvlserv_flag"`
  7489. EmpName string `json:"emp_name"`
  7490. InsuplcAdmdvs string `json:"insuplc_admdvs"`
  7491. Insutype string `json:"insutype"`
  7492. PausInsuDansuplcAdmdvs string `json:"paus_insu_dansuplc_admdvs"`
  7493. PausInsuDate string `json:"paus_insu_date"`
  7494. PsnInsuDate string `json:"psn_insu_date"`
  7495. PsnInsuStas string `json:"psn_insu_stas"`
  7496. PsnType string `json:"psn_type"`
  7497. }
  7498. type ResultSix struct {
  7499. Cainfo interface{} `json:"cainfo"`
  7500. ErrMsg string `json:"err_msg"`
  7501. InfRefmsgid string `json:"inf_refmsgid"`
  7502. Infcode int64 `json:"infcode"`
  7503. Output struct {
  7504. } `json:"output"`
  7505. RefmsgTime string `json:"refmsg_time"`
  7506. RespondTime string `json:"respond_time"`
  7507. Signtype interface{} `json:"signtype"`
  7508. WarnMsg interface{} `json:"warn_msg"`
  7509. }
  7510. type ResultSix10265 struct {
  7511. Cainfo interface{} `json:"cainfo"`
  7512. ErrMsg string `json:"err_msg"`
  7513. InfRefmsgid string `json:"inf_refmsgid"`
  7514. Infcode string `json:"infcode"`
  7515. Output struct {
  7516. } `json:"output"`
  7517. RefmsgTime string `json:"refmsg_time"`
  7518. RespondTime string `json:"respond_time"`
  7519. Signtype interface{} `json:"signtype"`
  7520. WarnMsg interface{} `json:"warn_msg"`
  7521. }
  7522. type ResultSeven struct {
  7523. Cainfo string `json:"cainfo"`
  7524. ErrMsg string `json:"err_msg"`
  7525. InfRefmsgid string `json:"inf_refmsgid"`
  7526. Infcode int64 `json:"infcode"`
  7527. Output struct {
  7528. Setldetail []interface{} `json:"setldetail"`
  7529. Setlinfo struct {
  7530. AcctMulaidPay float64 `json:"acct_mulaid_pay"`
  7531. AcctPay float64 `json:"acct_pay"`
  7532. ActPayDedc float64 `json:"act_pay_dedc"`
  7533. Age float64 `json:"age"`
  7534. Balc float64 `json:"balc"`
  7535. Brdy string `json:"brdy"`
  7536. Certno string `json:"certno"`
  7537. ClrOptins string `json:"clr_optins"`
  7538. ClrType string `json:"clr_type"`
  7539. ClrWay string `json:"clr_way"`
  7540. CvlservFlag string `json:"cvlserv_flag"`
  7541. CvlservPay float64 `json:"cvlserv_pay"`
  7542. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  7543. FundPaySumamt float64 `json:"fund_pay_sumamt"`
  7544. Gend string `json:"gend"`
  7545. HifesPay float64 `json:"hifes_pay"`
  7546. HifmiPay float64 `json:"hifmi_pay"`
  7547. HifpPay float64 `json:"hifp_pay"`
  7548. HospPartAmt float64 `json:"hosp_part_amt"`
  7549. InscpScpAmt float64 `json:"inscp_scp_amt"`
  7550. Insutype string `json:"insutype"`
  7551. MafPay float64 `json:"maf_pay"`
  7552. MdtrtCertType string `json:"mdtrt_cert_type"`
  7553. HifobPay float64 `json:"hifob_pay"`
  7554. MdtrtID string `json:"mdtrt_id"`
  7555. MedType string `json:"med_type"`
  7556. MedfeeSumamt float64 `json:"medfee_sumamt"`
  7557. MedinsSetlID string `json:"medins_setl_id"`
  7558. Naty string `json:"naty"`
  7559. OthPay float64 `json:"oth_pay"`
  7560. OverlmtSelfpay float64 `json:"overlmt_selfpay"`
  7561. PoolPropSelfpay float64 `json:"pool_prop_selfpay"`
  7562. PreselfpayAmt float64 `json:"preselfpay_amt"`
  7563. PsnCashPay float64 `json:"psn_cash_pay"`
  7564. PsnCertType string `json:"psn_cert_type"`
  7565. PsnName string `json:"psn_name"`
  7566. PsnNo string `json:"psn_no"`
  7567. PsnPartAmt float64 `json:"psn_part_amt"`
  7568. PsnType string `json:"psn_type"`
  7569. SetlID string `json:"setl_id"`
  7570. SetlTime string `json:"setl_time"`
  7571. } `json:"setlinfo"`
  7572. } `json:"output"`
  7573. RefmsgTime string `json:"refmsg_time"`
  7574. RespondTime string `json:"respond_time"`
  7575. Signtype interface{} `json:"signtype"`
  7576. WarnMsg interface{} `json:"warn_msg"`
  7577. }
  7578. type ResultSeven10265 struct {
  7579. Cainfo string `json:"cainfo"`
  7580. ErrMsg string `json:"err_msg"`
  7581. InfRefmsgid string `json:"inf_refmsgid"`
  7582. Infcode string `json:"infcode"`
  7583. Output struct {
  7584. Setldetail []interface{} `json:"setldetail"`
  7585. Setlinfo struct {
  7586. AcctMulaidPay float64 `json:"acct_mulaid_pay"`
  7587. AcctPay float64 `json:"acct_pay"`
  7588. ActPayDedc float64 `json:"act_pay_dedc"`
  7589. Age float64 `json:"age"`
  7590. Balc float64 `json:"balc"`
  7591. Brdy string `json:"brdy"`
  7592. Certno string `json:"certno"`
  7593. ClrOptins string `json:"clr_optins"`
  7594. ClrType string `json:"clr_type"`
  7595. ClrWay string `json:"clr_way"`
  7596. CvlservFlag string `json:"cvlserv_flag"`
  7597. CvlservPay float64 `json:"cvlserv_pay"`
  7598. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  7599. FundPaySumamt float64 `json:"fund_pay_sumamt"`
  7600. Gend string `json:"gend"`
  7601. HifesPay float64 `json:"hifes_pay"`
  7602. HifmiPay float64 `json:"hifmi_pay"`
  7603. HifpPay float64 `json:"hifp_pay"`
  7604. HospPartAmt float64 `json:"hosp_part_amt"`
  7605. InscpScpAmt float64 `json:"inscp_scp_amt"`
  7606. Insutype string `json:"insutype"`
  7607. MafPay float64 `json:"maf_pay"`
  7608. MdtrtCertType string `json:"mdtrt_cert_type"`
  7609. HifobPay float64 `json:"hifob_pay"`
  7610. MdtrtID string `json:"mdtrt_id"`
  7611. MedType string `json:"med_type"`
  7612. MedfeeSumamt float64 `json:"medfee_sumamt"`
  7613. MedinsSetlID string `json:"medins_setl_id"`
  7614. Naty string `json:"naty"`
  7615. OthPay float64 `json:"oth_pay"`
  7616. OverlmtSelfpay float64 `json:"overlmt_selfpay"`
  7617. PoolPropSelfpay float64 `json:"pool_prop_selfpay"`
  7618. PreselfpayAmt float64 `json:"preselfpay_amt"`
  7619. PsnCashPay float64 `json:"psn_cash_pay"`
  7620. PsnCertType string `json:"psn_cert_type"`
  7621. PsnName string `json:"psn_name"`
  7622. PsnNo string `json:"psn_no"`
  7623. PsnPartAmt float64 `json:"psn_part_amt"`
  7624. PsnType string `json:"psn_type"`
  7625. SetlID string `json:"setl_id"`
  7626. SetlTime string `json:"setl_time"`
  7627. } `json:"setlinfo"`
  7628. } `json:"output"`
  7629. RefmsgTime string `json:"refmsg_time"`
  7630. RespondTime string `json:"respond_time"`
  7631. Signtype interface{} `json:"signtype"`
  7632. WarnMsg interface{} `json:"warn_msg"`
  7633. }
  7634. type ResultEight struct {
  7635. Cainfo string `json:"cainfo"`
  7636. ErrMsg string `json:"err_msg"`
  7637. InfRefmsgid string `json:"inf_refmsgid"`
  7638. Infcode int64 `json:"infcode"`
  7639. Output struct {
  7640. Stmtinfo struct {
  7641. SetlOptins string `json:"setl_optins"`
  7642. StmtRslt string `json:"stmt_rslt"`
  7643. StmtRsltDscr string `json:"stmt_rslt_dscr"`
  7644. } `json:"stmtinfo"`
  7645. } `json:"output"`
  7646. RefmsgTime string `json:"refmsg_time"`
  7647. RespondTime string `json:"respond_time"`
  7648. Signtype interface{} `json:"signtype"`
  7649. WarnMsg interface{} `json:"warn_msg"`
  7650. }
  7651. type ResultEightFor10188 struct {
  7652. Cainfo string `json:"cainfo"`
  7653. ErrMsg string `json:"err_msg"`
  7654. InfRefmsgid string `json:"inf_refmsgid"`
  7655. Infcode string `json:"infcode"`
  7656. Output struct {
  7657. Stmtinfo struct {
  7658. SetlOptins string `json:"setl_optins"`
  7659. StmtRslt string `json:"stmt_rslt"`
  7660. StmtRsltDscr string `json:"stmt_rslt_dscr"`
  7661. } `json:"stmtinfo"`
  7662. } `json:"output"`
  7663. RefmsgTime string `json:"refmsg_time"`
  7664. RespondTime string `json:"respond_time"`
  7665. Signtype interface{} `json:"signtype"`
  7666. WarnMsg interface{} `json:"warn_msg"`
  7667. }
  7668. type ResultNine struct {
  7669. Cainfo string `json:"cainfo"`
  7670. ErrMsg string `json:"err_msg"`
  7671. InfRefmsgid string `json:"inf_refmsgid"`
  7672. Infcode int64 `json:"infcode"`
  7673. Output struct {
  7674. FileQuryNo string `json:"file_qury_no"`
  7675. } `json:"output"`
  7676. RefmsgTime string `json:"refmsg_time"`
  7677. RespondTime string `json:"respond_time"`
  7678. Signtype interface{} `json:"signtype"`
  7679. WarnMsg interface{} `json:"warn_msg"`
  7680. }
  7681. type ResultTen struct {
  7682. Cainfo string `json:"cainfo"`
  7683. ErrMsg string `json:"err_msg"`
  7684. InfRefmsgid string `json:"inf_refmsgid"`
  7685. Infcode int64 `json:"infcode"`
  7686. Output struct {
  7687. DldEndtime string `json:"dld_endtime"`
  7688. FileQuryNo string `json:"file_qury_no"`
  7689. Filename string `json:"filename"`
  7690. } `json:"output"`
  7691. RefmsgTime string `json:"refmsg_time"`
  7692. RespondTime string `json:"respond_time"`
  7693. Signtype interface{} `json:"signtype"`
  7694. WarnMsg interface{} `json:"warn_msg"`
  7695. }
  7696. //type Autogenerated struct {
  7697. // Output struct {
  7698. // Setlinfo struct {
  7699. // SetlTime string `json:"setl_time"`
  7700. // CvlservPay float64 `json:"cvlserv_pay"`
  7701. // Year string `json:"year"`
  7702. // MedType string `json:"med_type"`
  7703. // PsnPay float64 `json:"psn_pay"`
  7704. // OpterID string `json:"opter_id"`
  7705. // Begndate string `json:"begndate"`
  7706. // FlxempeFlag string `json:"flxempe_flag"`
  7707. // HifmiPay float64 `json:"hifmi_pay"`
  7708. // PsnNo string `json:"psn_no"`
  7709. // ActPayDedc float64 `json:"act_pay_dedc"`
  7710. // MedinsSetlID interface{} `json:"medins_setl_id"`
  7711. // AcctMulaidPay interface{} `json:"acct_mulaid_pay"`
  7712. // ClrWay string `json:"clr_way"`
  7713. // OthPay float64 `json:"oth_pay"`
  7714. // Gend string `json:"gend"`
  7715. // MdtrtID string `json:"mdtrt_id"`
  7716. // AcctPay float64 `json:"acct_pay"`
  7717. // InscpScpAmt float64 `json:"inscp_scp_amt"`
  7718. // Insutype string `json:"insutype"`
  7719. // Invono interface{} `json:"invono"`
  7720. // Enddate string `json:"enddate"`
  7721. // CashPayamt float64 `json:"cash_payamt"`
  7722. // PsnType string `json:"psn_type"`
  7723. // FixmedinsName string `json:"fixmedins_name"`
  7724. // HifpPay float64 `json:"hifp_pay"`
  7725. // NewFlag interface{} `json:"new_flag"`
  7726. // OverlmtSelfpay float64 `json:"overlmt_selfpay"`
  7727. // PreselfpayAmt float64 `json:"preselfpay_amt"`
  7728. // PayLoc string `json:"pay_loc"`
  7729. // ClrType string `json:"clr_type"`
  7730. // RefdSetlFlag string `json:"refd_setl_flag"`
  7731. // CvlservFlag string `json:"cvlserv_flag"`
  7732. // EmpName string `json:"emp_name"`
  7733. // Brdy string `json:"brdy"`
  7734. // Naty string `json:"naty"`
  7735. // Certno string `json:"certno"`
  7736. // DiseCode string `json:"dise_code"`
  7737. // FixmedinsCode string `json:"fixmedins_code"`
  7738. // DedcHospLv string `json:"dedc_hosp_lv"`
  7739. // OpterName string `json:"opter_name"`
  7740. // Balc float64 `json:"balc"`
  7741. // FixmedinsPoolarea string `json:"fixmedins_poolarea"`
  7742. // PsnCertType string `json:"psn_cert_type"`
  7743. // HifobPay float64 `json:"hifob_pay"`
  7744. // MedfeeSumamt float64 `json:"medfee_sumamt"`
  7745. // HifesPay float64 `json:"hifes_pay"`
  7746. // FundPaySumamt float64 `json:"fund_pay_sumamt"`
  7747. // OptTime string `json:"opt_time"`
  7748. // FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  7749. // SetlID string `json:"setl_id"`
  7750. // MafPay float64 `json:"maf_pay"`
  7751. // PsnName string `json:"psn_name"`
  7752. // InsuOptins interface{} `json:"insu_optins"`
  7753. // PrefFundPay interface{} `json:"pref_fund_pay"`
  7754. // ClrOptins string `json:"clr_optins"`
  7755. // PoolPropSelfpay float64 `json:"pool_prop_selfpay"`
  7756. // DiseName string `json:"dise_name"`
  7757. // LmtpricHospLv string `json:"lmtpric_hosp_lv"`
  7758. // Age float64 `json:"age"`
  7759. // DtrtCertType string `json:"dtrt_cert_type"`
  7760. // HospLv string `json:"hosp_lv"`
  7761. // } `json:"setlinfo"`
  7762. // Setldetail []struct {
  7763. // FundPayType string `json:"fund_pay_type"`
  7764. // FundPayamt float64 `json:"fund_payamt"`
  7765. // SetlProcInfo interface{} `json:"setl_proc_info"`
  7766. // CrtPaybLmtAmt interface{} `json:"crt_payb_lmt_amt"`
  7767. // InscpScpAmt interface{} `json:"inscp_scp_amt"`
  7768. // FundPayTypeName interface{} `json:"fund_pay_type_name"`
  7769. // PrefFundPay interface{} `json:"pref_fund_pay"`
  7770. // } `json:"setldetail"`
  7771. // } `json:"output"`
  7772. // Infcode int `json:"infcode"`
  7773. // WarnMsg interface{} `json:"warn_msg"`
  7774. // Cainfo interface{} `json:"cainfo"`
  7775. // ErrMsg interface{} `json:"err_msg"`
  7776. // RefmsgTime string `json:"refmsg_time"`
  7777. // Signtype interface{} `json:"signtype"`
  7778. // RespondTime string `json:"respond_time"`
  7779. // InfRefmsgid string `json:"inf_refmsgid"`
  7780. //}
  7781. type ResultEleven struct {
  7782. Cainfo string `json:"cainfo"`
  7783. ErrMsg string `json:"err_msg"`
  7784. InfRefmsgid string `json:"inf_refmsgid"`
  7785. Infcode int64 `json:"infcode"`
  7786. Output struct {
  7787. Setlinfo struct {
  7788. SetlTime string `json:"setl_time"`
  7789. CvlservPay float64 `json:"cvlserv_pay"`
  7790. Year string `json:"year"`
  7791. MedType string `json:"med_type"`
  7792. PsnPay float64 `json:"psn_pay"`
  7793. OpterID string `json:"opter_id"`
  7794. Begndate string `json:"begndate"`
  7795. FlxempeFlag string `json:"flxempe_flag"`
  7796. HifmiPay float64 `json:"hifmi_pay"`
  7797. PsnNo string `json:"psn_no"`
  7798. ActPayDedc float64 `json:"act_pay_dedc"`
  7799. MedinsSetlID interface{} `json:"medins_setl_id"`
  7800. AcctMulaidPay interface{} `json:"acct_mulaid_pay"`
  7801. ClrWay string `json:"clr_way"`
  7802. OthPay float64 `json:"oth_pay"`
  7803. Gend string `json:"gend"`
  7804. MdtrtID string `json:"mdtrt_id"`
  7805. AcctPay float64 `json:"acct_pay"`
  7806. InscpScpAmt float64 `json:"inscp_scp_amt"`
  7807. Insutype string `json:"insutype"`
  7808. Invono interface{} `json:"invono"`
  7809. Enddate string `json:"enddate"`
  7810. CashPayamt float64 `json:"cash_payamt"`
  7811. PsnType string `json:"psn_type"`
  7812. FixmedinsName string `json:"fixmedins_name"`
  7813. HifpPay float64 `json:"hifp_pay"`
  7814. NewFlag interface{} `json:"new_flag"`
  7815. OverlmtSelfpay float64 `json:"overlmt_selfpay"`
  7816. PreselfpayAmt float64 `json:"preselfpay_amt"`
  7817. PayLoc string `json:"pay_loc"`
  7818. ClrType string `json:"clr_type"`
  7819. RefdSetlFlag string `json:"refd_setl_flag"`
  7820. CvlservFlag string `json:"cvlserv_flag"`
  7821. EmpName string `json:"emp_name"`
  7822. Brdy string `json:"brdy"`
  7823. Naty string `json:"naty"`
  7824. Certno string `json:"certno"`
  7825. DiseCode string `json:"dise_code"`
  7826. FixmedinsCode string `json:"fixmedins_code"`
  7827. DedcHospLv string `json:"dedc_hosp_lv"`
  7828. OpterName string `json:"opter_name"`
  7829. Balc float64 `json:"balc"`
  7830. FixmedinsPoolarea string `json:"fixmedins_poolarea"`
  7831. PsnCertType string `json:"psn_cert_type"`
  7832. HifobPay float64 `json:"hifob_pay"`
  7833. MedfeeSumamt float64 `json:"medfee_sumamt"`
  7834. HifesPay float64 `json:"hifes_pay"`
  7835. FundPaySumamt float64 `json:"fund_pay_sumamt"`
  7836. OptTime string `json:"opt_time"`
  7837. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  7838. SetlID string `json:"setl_id"`
  7839. MafPay float64 `json:"maf_pay"`
  7840. PsnName string `json:"psn_name"`
  7841. InsuOptins interface{} `json:"insu_optins"`
  7842. PrefFundPay interface{} `json:"pref_fund_pay"`
  7843. ClrOptins string `json:"clr_optins"`
  7844. PoolPropSelfpay float64 `json:"pool_prop_selfpay"`
  7845. DiseName string `json:"dise_name"`
  7846. LmtpricHospLv string `json:"lmtpric_hosp_lv"`
  7847. Age float64 `json:"age"`
  7848. DtrtCertType string `json:"dtrt_cert_type"`
  7849. HospLv string `json:"hosp_lv"`
  7850. PsnCashPay float64
  7851. } `json:"setlinfo"`
  7852. } `json:"output"`
  7853. RefmsgTime string `json:"refmsg_time"`
  7854. RespondTime string `json:"respond_time"`
  7855. Signtype interface{} `json:"signtype"`
  7856. WarnMsg interface{} `json:"warn_msg"`
  7857. }
  7858. type ResultEleven10265 struct {
  7859. Cainfo string `json:"cainfo"`
  7860. ErrMsg string `json:"err_msg"`
  7861. InfRefmsgid string `json:"inf_refmsgid"`
  7862. Infcode string `json:"infcode"`
  7863. Output struct {
  7864. Setlinfo struct {
  7865. SetlTime string `json:"setl_time"`
  7866. CvlservPay float64 `json:"cvlserv_pay"`
  7867. Year string `json:"year"`
  7868. MedType string `json:"med_type"`
  7869. PsnPay float64 `json:"psn_pay"`
  7870. OpterID string `json:"opter_id"`
  7871. Begndate string `json:"begndate"`
  7872. FlxempeFlag string `json:"flxempe_flag"`
  7873. HifmiPay float64 `json:"hifmi_pay"`
  7874. PsnNo string `json:"psn_no"`
  7875. ActPayDedc float64 `json:"act_pay_dedc"`
  7876. MedinsSetlID interface{} `json:"medins_setl_id"`
  7877. AcctMulaidPay interface{} `json:"acct_mulaid_pay"`
  7878. ClrWay string `json:"clr_way"`
  7879. OthPay float64 `json:"oth_pay"`
  7880. Gend string `json:"gend"`
  7881. MdtrtID string `json:"mdtrt_id"`
  7882. AcctPay float64 `json:"acct_pay"`
  7883. InscpScpAmt float64 `json:"inscp_scp_amt"`
  7884. Insutype string `json:"insutype"`
  7885. Invono interface{} `json:"invono"`
  7886. Enddate string `json:"enddate"`
  7887. CashPayamt float64 `json:"cash_payamt"`
  7888. PsnType string `json:"psn_type"`
  7889. FixmedinsName string `json:"fixmedins_name"`
  7890. HifpPay float64 `json:"hifp_pay"`
  7891. NewFlag interface{} `json:"new_flag"`
  7892. OverlmtSelfpay float64 `json:"overlmt_selfpay"`
  7893. PreselfpayAmt float64 `json:"preselfpay_amt"`
  7894. PayLoc string `json:"pay_loc"`
  7895. ClrType string `json:"clr_type"`
  7896. RefdSetlFlag string `json:"refd_setl_flag"`
  7897. CvlservFlag string `json:"cvlserv_flag"`
  7898. EmpName string `json:"emp_name"`
  7899. Brdy string `json:"brdy"`
  7900. Naty string `json:"naty"`
  7901. Certno string `json:"certno"`
  7902. DiseCode string `json:"dise_code"`
  7903. FixmedinsCode string `json:"fixmedins_code"`
  7904. DedcHospLv string `json:"dedc_hosp_lv"`
  7905. OpterName string `json:"opter_name"`
  7906. Balc float64 `json:"balc"`
  7907. FixmedinsPoolarea string `json:"fixmedins_poolarea"`
  7908. PsnCertType string `json:"psn_cert_type"`
  7909. HifobPay float64 `json:"hifob_pay"`
  7910. MedfeeSumamt float64 `json:"medfee_sumamt"`
  7911. HifesPay float64 `json:"hifes_pay"`
  7912. FundPaySumamt float64 `json:"fund_pay_sumamt"`
  7913. OptTime string `json:"opt_time"`
  7914. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  7915. SetlID string `json:"setl_id"`
  7916. MafPay float64 `json:"maf_pay"`
  7917. PsnName string `json:"psn_name"`
  7918. InsuOptins interface{} `json:"insu_optins"`
  7919. PrefFundPay interface{} `json:"pref_fund_pay"`
  7920. ClrOptins string `json:"clr_optins"`
  7921. PoolPropSelfpay float64 `json:"pool_prop_selfpay"`
  7922. DiseName string `json:"dise_name"`
  7923. LmtpricHospLv string `json:"lmtpric_hosp_lv"`
  7924. Age float64 `json:"age"`
  7925. DtrtCertType string `json:"dtrt_cert_type"`
  7926. HospLv string `json:"hosp_lv"`
  7927. PsnCashPay float64
  7928. } `json:"setlinfo"`
  7929. } `json:"output"`
  7930. RefmsgTime string `json:"refmsg_time"`
  7931. RespondTime string `json:"respond_time"`
  7932. Signtype interface{} `json:"signtype"`
  7933. WarnMsg interface{} `json:"warn_msg"`
  7934. }
  7935. type ResultTwelve struct {
  7936. Cainfo string `json:"cainfo"`
  7937. ErrMsg string `json:"err_msg"`
  7938. InfRefmsgid string `json:"inf_refmsgid"`
  7939. Infcode int64 `json:"infcode"`
  7940. Output struct {
  7941. MdtrtId string `json:"mdtrt_id"`
  7942. ChrgBchno string `json:"chrg_bchno"`
  7943. PsnNo string `json:"psn_no"`
  7944. } `json:"output"`
  7945. RefmsgTime string `json:"refmsg_time"`
  7946. RespondTime string `json:"respond_time"`
  7947. Signtype interface{} `json:"signtype"`
  7948. WarnMsg interface{} `json:"warn_msg"`
  7949. }
  7950. type ResultThirteen struct {
  7951. ErrMsg string `json:"err_msg"`
  7952. InfRefmsgid string `json:"inf_refmsgid"`
  7953. Infcode int64 `json:"infcode"`
  7954. Output struct {
  7955. Result struct {
  7956. TrtDclaDetlSn string `json:"trt_dcla_detl_sn"`
  7957. } `json:"result"`
  7958. } `json:"output"`
  7959. RefmsgTime string `json:"refmsg_time"`
  7960. RespondTime string `json:"respond_time"`
  7961. Signtype interface{} `json:"signtype"`
  7962. WarnInfo interface{} `json:"warn_info"`
  7963. }
  7964. type ResultThirteen10265 struct {
  7965. ErrMsg string `json:"err_msg"`
  7966. InfRefmsgid string `json:"inf_refmsgid"`
  7967. Infcode string `json:"infcode"`
  7968. Output struct {
  7969. Result struct {
  7970. TrtDclaDetlSn string `json:"trt_dcla_detl_sn"`
  7971. } `json:"result"`
  7972. } `json:"output"`
  7973. RefmsgTime string `json:"refmsg_time"`
  7974. RespondTime string `json:"respond_time"`
  7975. Signtype interface{} `json:"signtype"`
  7976. WarnInfo interface{} `json:"warn_info"`
  7977. }
  7978. type ResultFourteen struct {
  7979. ErrMsg string `json:"err_msg"`
  7980. InfRefmsgid string `json:"inf_refmsgid"`
  7981. Infcode int64 `json:"infcode"`
  7982. Output struct {
  7983. } `json:"output"`
  7984. RefmsgTime string `json:"refmsg_time"`
  7985. RespondTime string `json:"respond_time"`
  7986. Signtype interface{} `json:"signtype"`
  7987. WarnInfo interface{} `json:"warn_info"`
  7988. }
  7989. type ResultFourteen10265 struct {
  7990. ErrMsg string `json:"err_msg"`
  7991. InfRefmsgid string `json:"inf_refmsgid"`
  7992. Infcode string `json:"infcode"`
  7993. Output struct {
  7994. } `json:"output"`
  7995. RefmsgTime string `json:"refmsg_time"`
  7996. RespondTime string `json:"respond_time"`
  7997. Signtype interface{} `json:"signtype"`
  7998. WarnInfo interface{} `json:"warn_info"`
  7999. }
  8000. type ResultSixteen struct {
  8001. Cainfo string `json:"cainfo"`
  8002. ErrMsg string `json:"err_msg"`
  8003. InfRefmsgid string `json:"inf_refmsgid"`
  8004. Infcode int64 `json:"infcode"`
  8005. Output struct {
  8006. Setldetail []interface{} `json:"setldetail"`
  8007. Setlinfo struct {
  8008. MdtrtID string `json:"mdtrt_id"`
  8009. SetlID string `json:"setl_id"`
  8010. ClrOptins string `json:"clr_optins"`
  8011. SetlTime string `json:"setl_time"`
  8012. MedfeeSumamt float64 `json:"medfee_sumamt"`
  8013. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  8014. OverlmtSelfpay float64 `json:"overlmt_selfpay"`
  8015. PreselfpayAmt float64 `json:"preselfpay_amt"`
  8016. InscpScpAmt float64 `json:"inscp_scp_amt"`
  8017. ActPayDedc float64 `json:"act_pay_dedc"`
  8018. HifpPay float64 `json:"hifp_pay"`
  8019. PoolPropSe float64 `json:"pool_prop_selfpay"`
  8020. Lfpay float64 `json:"selfpay"`
  8021. CvlservPay float64 `json:"cvlserv_pay"`
  8022. HifesPay float64 `json:"hifes_pay"`
  8023. HifmiPay float64 `json:"hifmi_pay"`
  8024. HifobPay float64 `json:"hifob_pay"`
  8025. MafPay float64 `json:"maf_pay"`
  8026. OthPay float64 `json:"oth_pay"`
  8027. FundPaySumamt float64 `json:"fund_pay_sumamt"`
  8028. PsnPartAmt float64 `json:"psn_part_amt"`
  8029. AcctPay float64 `json:"acct_pay"`
  8030. Balc float64 `json:"balc"`
  8031. AcctMulaidPay float64 `json:"acct_mulaid_pay"`
  8032. HospPartAmt float64 `json:"hosp_part_amt"`
  8033. MedinsSetlID string `json:"medins_setl_id"`
  8034. PdnCashPay string `json:"pdn_cash_pay"`
  8035. } `json:"setlinfo"`
  8036. } `json:"output"`
  8037. RefmsgTime string `json:"refmsg_time"`
  8038. RespondTime string `json:"respond_time"`
  8039. Signtype interface{} `json:"signtype"`
  8040. WarnMsg interface{} `json:"warn_msg"`
  8041. }
  8042. type ResultSixteen10265 struct {
  8043. Cainfo string `json:"cainfo"`
  8044. ErrMsg string `json:"err_msg"`
  8045. InfRefmsgid string `json:"inf_refmsgid"`
  8046. Infcode string `json:"infcode"`
  8047. Output struct {
  8048. Setldetail []interface{} `json:"setldetail"`
  8049. Setlinfo struct {
  8050. MdtrtID string `json:"mdtrt_id"`
  8051. SetlID string `json:"setl_id"`
  8052. ClrOptins string `json:"clr_optins"`
  8053. SetlTime string `json:"setl_time"`
  8054. MedfeeSumamt float64 `json:"medfee_sumamt"`
  8055. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  8056. OverlmtSelfpay float64 `json:"overlmt_selfpay"`
  8057. PreselfpayAmt float64 `json:"preselfpay_amt"`
  8058. InscpScpAmt float64 `json:"inscp_scp_amt"`
  8059. ActPayDedc float64 `json:"act_pay_dedc"`
  8060. HifpPay float64 `json:"hifp_pay"`
  8061. PoolPropSe float64 `json:"pool_prop_selfpay"`
  8062. Lfpay float64 `json:"selfpay"`
  8063. CvlservPay float64 `json:"cvlserv_pay"`
  8064. HifesPay float64 `json:"hifes_pay"`
  8065. HifmiPay float64 `json:"hifmi_pay"`
  8066. HifobPay float64 `json:"hifob_pay"`
  8067. MafPay float64 `json:"maf_pay"`
  8068. OthPay float64 `json:"oth_pay"`
  8069. FundPaySumamt float64 `json:"fund_pay_sumamt"`
  8070. PsnPartAmt float64 `json:"psn_part_amt"`
  8071. AcctPay float64 `json:"acct_pay"`
  8072. Balc float64 `json:"balc"`
  8073. AcctMulaidPay float64 `json:"acct_mulaid_pay"`
  8074. HospPartAmt float64 `json:"hosp_part_amt"`
  8075. MedinsSetlID string `json:"medins_setl_id"`
  8076. PdnCashPay string `json:"pdn_cash_pay"`
  8077. } `json:"setlinfo"`
  8078. } `json:"output"`
  8079. RefmsgTime string `json:"refmsg_time"`
  8080. RespondTime string `json:"respond_time"`
  8081. Signtype interface{} `json:"signtype"`
  8082. WarnMsg interface{} `json:"warn_msg"`
  8083. }
  8084. type ResultSeventeen struct {
  8085. ErrMsg string `json:"err_msg"`
  8086. InfRefmsgid string `json:"inf_refmsgid"`
  8087. Infcode int64 `json:"infcode"`
  8088. Output struct {
  8089. SetlListId string `json:"setl_list_id"`
  8090. } `json:"output"`
  8091. RefmsgTime string `json:"refmsg_time"`
  8092. RespondTime string `json:"respond_time"`
  8093. Signtype string `json:"signtype"`
  8094. WarnInfo string `json:"warn_info"`
  8095. }
  8096. type ResultSeventeenOther struct {
  8097. ErrMsg string `json:"err_msg"`
  8098. InfRefmsgid string `json:"inf_refmsgid"`
  8099. Infcode string `json:"infcode"`
  8100. Output struct {
  8101. SetlListId string `json:"setl_list_id"`
  8102. } `json:"output"`
  8103. RefmsgTime string `json:"refmsg_time"`
  8104. RespondTime string `json:"respond_time"`
  8105. Signtype string `json:"signtype"`
  8106. WarnInfo string `json:"warn_info"`
  8107. }
  8108. type Result90991 struct {
  8109. ErrMsg string `json:"err_msg"`
  8110. InfRefmsgid string `json:"inf_refmsgid"`
  8111. Infcode int64 `json:"infcode"`
  8112. Output struct {
  8113. Result struct {
  8114. PsnNo string `json:"psn_no"`
  8115. CardStat string `json:"card_stat"`
  8116. Certno string `json:"certno"`
  8117. PsnName string `json:"psn_name"`
  8118. CheckStat string `json:"check_stat"`
  8119. SscnoCheckStat string `json:"sscno_check_stat"`
  8120. } `json:"result"`
  8121. } `json:"output"`
  8122. RefmsgTime string `json:"refmsg_time"`
  8123. RespondTime string `json:"respond_time"`
  8124. Signtype interface{} `json:"signtype"`
  8125. WarnInfo interface{} `json:"warn_info"`
  8126. }
  8127. type Result90100 struct {
  8128. ErrMsg string `json:"err_msg"`
  8129. InfRefmsgid string `json:"inf_refmsgid"`
  8130. Infcode int64 `json:"infcode"`
  8131. Output struct {
  8132. PoolareaNo string `json:"poolarea_no"`
  8133. PoolareaNoName string `json:"poolarea_no_name"`
  8134. Insutype string `json:"insutype"`
  8135. InsutypeName string `json:"insutype_name"`
  8136. ClctType string `json:"clct_type"`
  8137. ClctTypeName string `json:"clct_type_name"`
  8138. ClctFlag string `json:"clct_flag"`
  8139. ClctFlagName string `json:"clct_flag_name"`
  8140. AccrymBegn string `json:"accrym_begn"`
  8141. AccrymEnd string `json:"accrym_end"`
  8142. ClctTime string `json:"clct_time"`
  8143. ClctstdCrtfRuleCodg string `json:"clctstd_crtf_rule_codg"`
  8144. } `json:"output"`
  8145. RefmsgTime string `json:"refmsg_time"`
  8146. RespondTime string `json:"respond_time"`
  8147. Signtype interface{} `json:"signtype"`
  8148. WarnInfo interface{} `json:"warn_info"`
  8149. }
  8150. type Custom struct {
  8151. DetItemFeeSumamt string
  8152. Cut string
  8153. FeedetlSn string
  8154. Price string
  8155. MedListCodg string
  8156. Type int64
  8157. AdviceId int64
  8158. ProjectId int64
  8159. ItemId int64
  8160. }
  8161. type Result5301 struct {
  8162. ErrMsg string `json:"err_msg"`
  8163. InfRefmsgid string `json:"inf_refmsgid"`
  8164. Infcode int64 `json:"infcode"`
  8165. Output struct {
  8166. Result []struct {
  8167. OpspDiseCode string `json:"opsp_dise_code"`
  8168. OpspDiseName string `json:"opsp_dise_name"`
  8169. Begndate string `json:"begndate"`
  8170. Enddate string `json:"enddate"`
  8171. } `json:"feedetail"`
  8172. } `json:"output"`
  8173. RefmsgTime string `json:"refmsg_time"`
  8174. RespondTime string `json:"respond_time"`
  8175. Signtype interface{} `json:"signtype"`
  8176. WarnInfo interface{} `json:"warn_info"`
  8177. }
  8178. type Result5301For10265 struct {
  8179. ErrMsg string `json:"err_msg"`
  8180. InfRefmsgid string `json:"inf_refmsgid"`
  8181. Infcode string `json:"infcode"`
  8182. Output struct {
  8183. Result []struct {
  8184. OpspDiseCode string `json:"opsp_dise_code"`
  8185. OpspDiseName string `json:"opsp_dise_name"`
  8186. Begndate string `json:"begndate"`
  8187. Enddate string `json:"enddate"`
  8188. } `json:"feedetail"`
  8189. } `json:"output"`
  8190. RefmsgTime string `json:"refmsg_time"`
  8191. RespondTime string `json:"respond_time"`
  8192. Signtype interface{} `json:"signtype"`
  8193. WarnInfo interface{} `json:"warn_info"`
  8194. }
  8195. //获取个人信息----挂号-----上传就诊信息
  8196. func (c *HisApiController) GetRegisterInfo() {
  8197. id, _ := c.GetInt64("id")
  8198. record_time := c.GetString("record_time")
  8199. settlementValue, _ := c.GetInt64("settlement_value")
  8200. medical_insurance_card := c.GetString("medical_insurance_card")
  8201. name := c.GetString("name")
  8202. id_card_type, _ := c.GetInt64("id_card_type")
  8203. certificates, _ := c.GetInt64("certificates")
  8204. medical_care, _ := c.GetInt64("medical_care")
  8205. birthday := c.GetString("birthday")
  8206. id_card := c.GetString("id_card")
  8207. register_type, _ := c.GetInt64("register")
  8208. doctor, _ := c.GetInt64("doctor")
  8209. department, _ := c.GetInt64("department")
  8210. gender, _ := c.GetInt64("sex")
  8211. registration_fee, _ := c.GetFloat("registration_fee")
  8212. medical_expenses, _ := c.GetFloat("medical_expenses")
  8213. social_type, _ := c.GetInt64("social_type")
  8214. admin_user_id, _ := c.GetInt64("admin_user_id")
  8215. insuplc_admdvs := c.GetString("insuplc_admdvs")
  8216. mdtrt_type := c.GetString("mdtrt_type")
  8217. timeLayout := "2006-01-02"
  8218. loc, _ := time.LoadLocation("Local")
  8219. birthdays, _ := time.ParseInLocation(timeLayout+" 15:04:05", birthday+" 00:00:00", loc)
  8220. birthUnix := birthdays.Unix()
  8221. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  8222. if err != nil {
  8223. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  8224. return
  8225. }
  8226. recordDateTime := theTime.Unix()
  8227. adminInfo := c.GetAdminUserInfo()
  8228. var patient service.Patients
  8229. if id == 0 {
  8230. patient, _ = service.GetPatientByIDCard(id_card, adminInfo.CurrentOrgId)
  8231. } else {
  8232. patient, _ = service.GetPatientByIDTwo(adminInfo.CurrentOrgId, id)
  8233. }
  8234. patientPrescription, _ := service.FindPatientPrescriptionInfo(adminInfo.CurrentOrgId, id, recordDateTime)
  8235. if patientPrescription.ID == 0 {
  8236. patientPrescription, _ = service.FindLastPatientPrescriptionInfo(adminInfo.CurrentOrgId, id, recordDateTime)
  8237. }
  8238. miConfig, _ := service.FindMedicalInsuranceInfo(adminInfo.CurrentOrgId)
  8239. if patient.ID == 0 {
  8240. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodePatientNoExist)
  8241. return
  8242. }
  8243. if len(patient.IdCardNo) == 0 {
  8244. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeIDCartNo)
  8245. return
  8246. }
  8247. config, _ := service.GetMedicalInsuranceConfig(adminInfo.CurrentOrgId)
  8248. roles, _ := service.GetAdminUserInfoByID(adminInfo.CurrentOrgId, admin_user_id)
  8249. doctor_info, _ := service.GetAdminUserInfoByID(adminInfo.CurrentOrgId, doctor)
  8250. //就诊结算未完成,不能进行二次挂号
  8251. his, _ := service.GetHisPatientInfoTwo(adminInfo.CurrentOrgId, patient.ID, recordDateTime)
  8252. if len(his) >= 1 {
  8253. order, _ := service.GetNewHisOrderTwo(adminInfo.CurrentOrgId, his[len(his)-1].Number, his[len(his)-1].PatientId, recordDateTime)
  8254. if len(his) >= 1 && order.ID == 0 {
  8255. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisPatientParamWrong)
  8256. return
  8257. }
  8258. }
  8259. //var register_log string
  8260. if config.IsOpen == 1 {
  8261. var res ResultTwo
  8262. var res10265 ResultTwo10265
  8263. var PsnNo string
  8264. var PsnCertType string
  8265. var Certno string
  8266. var PsnName string
  8267. var Gend string
  8268. var Naty string
  8269. var Brdy string
  8270. var Age float64
  8271. var infoStr string
  8272. var idetinfoStr string
  8273. var infocode int64
  8274. var verify_number string
  8275. fmt.Println(verify_number)
  8276. if miConfig.MdtrtareaAdmvs == "421300" {
  8277. psn_info, _ := service.GetPsnByPatientId(id)
  8278. PsnNo = psn_info.PsnNo
  8279. PsnCertType = psn_info.PsnCertType
  8280. Certno = psn_info.Certno
  8281. PsnName = psn_info.PsnName
  8282. Gend = psn_info.Gend
  8283. Naty = psn_info.Naty
  8284. Brdy = psn_info.Brdy
  8285. Age = psn_info.Age
  8286. infoStr = psn_info.Insuinfo
  8287. idetinfoStr = psn_info.Idetinfo
  8288. infocode = 0
  8289. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  8290. psn_info, _ := service.GetPsnByPatientId(id)
  8291. PsnNo = psn_info.PsnNo
  8292. PsnCertType = psn_info.PsnCertType
  8293. Certno = psn_info.Certno
  8294. PsnName = psn_info.PsnName
  8295. Gend = psn_info.Gend
  8296. Naty = psn_info.Naty
  8297. Brdy = psn_info.Brdy
  8298. Age = psn_info.Age
  8299. infoStr = psn_info.Insuinfo
  8300. idetinfoStr = psn_info.Idetinfo
  8301. infocode = 0
  8302. verify_number = psn_info.VerifyNumber
  8303. } else if miConfig.MdtrtareaAdmvs == "350500" {
  8304. if id_card_type == 1 {
  8305. psn_info, _ := service.GetPsnByPatientId(id)
  8306. PsnNo = psn_info.PsnNo
  8307. PsnCertType = psn_info.PsnCertType
  8308. Certno = psn_info.Certno
  8309. PsnName = psn_info.PsnName
  8310. Gend = psn_info.Gend
  8311. Naty = psn_info.Naty
  8312. Brdy = psn_info.Brdy
  8313. Age = psn_info.Age
  8314. infoStr = psn_info.Insuinfo
  8315. idetinfoStr = psn_info.Idetinfo
  8316. infocode = 0
  8317. verify_number = psn_info.VerifyNumber
  8318. } else if id_card_type == 2 {
  8319. 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)
  8320. fmt.Println(errMsgLog)
  8321. saveLog(result, requestLog, "1101", "人员基本信息获取")
  8322. if err := json.Unmarshal([]byte(result), &res); err != nil {
  8323. utils.ErrorLog("解析失败:%v", err)
  8324. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8325. return
  8326. }
  8327. PsnNo = res.Output.Baseinfo.PsnNo
  8328. PsnCertType = res.Output.Baseinfo.PsnCertType
  8329. Certno = res.Output.Baseinfo.Certno
  8330. PsnName = res.Output.Baseinfo.PsnName
  8331. Gend = res.Output.Baseinfo.Gend
  8332. Naty = res.Output.Baseinfo.Naty
  8333. Brdy = res.Output.Baseinfo.Brdy
  8334. Age = res.Output.Baseinfo.Age
  8335. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  8336. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  8337. infoStr = string(Iinfos)
  8338. idetinfoStr = string(Idetinfos)
  8339. infocode = res.Infcode
  8340. }
  8341. } else if miConfig.MdtrtareaAdmvs == "360399" {
  8342. if id_card_type == 1 {
  8343. psn_info, _ := service.GetPsnByPatientId(id)
  8344. PsnNo = psn_info.PsnNo
  8345. PsnCertType = psn_info.PsnCertType
  8346. Certno = psn_info.Certno
  8347. PsnName = psn_info.PsnName
  8348. Gend = psn_info.Gend
  8349. Naty = psn_info.Naty
  8350. Brdy = psn_info.Brdy
  8351. Age = psn_info.Age
  8352. infoStr = psn_info.Insuinfo
  8353. idetinfoStr = psn_info.Idetinfo
  8354. infocode = 0
  8355. verify_number = psn_info.VerifyNumber
  8356. } else if id_card_type == 2 {
  8357. 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, "")
  8358. saveLog(result, requestLog, "1101", "人员基本信息获取")
  8359. if err := json.Unmarshal([]byte(result), &res); err != nil {
  8360. utils.ErrorLog("解析失败:%v", err)
  8361. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8362. return
  8363. }
  8364. PsnNo = res.Output.Baseinfo.PsnNo
  8365. PsnCertType = res.Output.Baseinfo.PsnCertType
  8366. Certno = res.Output.Baseinfo.Certno
  8367. PsnName = res.Output.Baseinfo.PsnName
  8368. Gend = res.Output.Baseinfo.Gend
  8369. Naty = res.Output.Baseinfo.Naty
  8370. Brdy = res.Output.Baseinfo.Brdy
  8371. Age = res.Output.Baseinfo.Age
  8372. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  8373. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  8374. infoStr = string(Iinfos)
  8375. idetinfoStr = string(Idetinfos)
  8376. infocode = res.Infcode
  8377. }
  8378. } else if miConfig.MdtrtareaAdmvs == "430800" {
  8379. if id_card_type == 1 {
  8380. psn_info, _ := service.GetPsnByPatientId(id)
  8381. PsnNo = psn_info.PsnNo
  8382. PsnCertType = psn_info.PsnCertType
  8383. Certno = psn_info.Certno
  8384. PsnName = psn_info.PsnName
  8385. Gend = psn_info.Gend
  8386. Naty = psn_info.Naty
  8387. Brdy = psn_info.Brdy
  8388. Age = psn_info.Age
  8389. infoStr = psn_info.Insuinfo
  8390. idetinfoStr = psn_info.Idetinfo
  8391. infocode = 0
  8392. verify_number = psn_info.VerifyNumber
  8393. } else if id_card_type == 2 {
  8394. 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)
  8395. saveLog(result, requestLog, "1101", "人员基本信息获取")
  8396. if err := json.Unmarshal([]byte(result), &res); err != nil {
  8397. utils.ErrorLog("解析失败:%v", err)
  8398. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8399. return
  8400. }
  8401. PsnNo = res.Output.Baseinfo.PsnNo
  8402. PsnCertType = res.Output.Baseinfo.PsnCertType
  8403. Certno = res.Output.Baseinfo.Certno
  8404. PsnName = res.Output.Baseinfo.PsnName
  8405. Gend = res.Output.Baseinfo.Gend
  8406. Naty = res.Output.Baseinfo.Naty
  8407. Brdy = res.Output.Baseinfo.Brdy
  8408. Age = res.Output.Baseinfo.Age
  8409. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  8410. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  8411. infoStr = string(Iinfos)
  8412. idetinfoStr = string(Idetinfos)
  8413. infocode = res.Infcode
  8414. } else if id_card_type == 4 {
  8415. psn_info, _ := service.GetPsnByPatientId(id)
  8416. PsnNo = psn_info.PsnNo
  8417. PsnCertType = psn_info.PsnCertType
  8418. Certno = psn_info.Certno
  8419. PsnName = psn_info.PsnName
  8420. Gend = psn_info.Gend
  8421. Naty = psn_info.Naty
  8422. Brdy = psn_info.Brdy
  8423. Age = psn_info.Age
  8424. infoStr = psn_info.Insuinfo
  8425. idetinfoStr = psn_info.Idetinfo
  8426. infocode = 0
  8427. verify_number = psn_info.VerifyNumber
  8428. }
  8429. } else if miConfig.MdtrtareaAdmvs == "131023" {
  8430. var result string
  8431. var requestLog string
  8432. 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), "")
  8433. if id_card_type == 4 {
  8434. psn_info, _ := service.GetPsnByPatientId(id)
  8435. PsnNo = psn_info.PsnNo
  8436. PsnCertType = psn_info.PsnCertType
  8437. Certno = psn_info.Certno
  8438. PsnName = psn_info.PsnName
  8439. Gend = psn_info.Gend
  8440. Naty = psn_info.Naty
  8441. Brdy = psn_info.Brdy
  8442. Age = psn_info.Age
  8443. infoStr = psn_info.Insuinfo
  8444. idetinfoStr = psn_info.Idetinfo
  8445. infocode = 0
  8446. verify_number = psn_info.VerifyNumber
  8447. } else {
  8448. saveLog(result, requestLog, "1101", "人员基本信息获取")
  8449. if miConfig.Code == "H15049901371" {
  8450. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  8451. utils.ErrorLog("解析失败:%v", err)
  8452. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8453. return
  8454. }
  8455. res.ErrMsg = res10265.ErrMsg
  8456. res.Output = res10265.Output
  8457. res.InfRefmsgid = res10265.InfRefmsgid
  8458. } else {
  8459. if err := json.Unmarshal([]byte(result), &res); err != nil {
  8460. utils.ErrorLog("解析失败:%v", err)
  8461. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8462. return
  8463. }
  8464. }
  8465. PsnNo = res.Output.Baseinfo.PsnNo
  8466. PsnCertType = res.Output.Baseinfo.PsnCertType
  8467. Certno = res.Output.Baseinfo.Certno
  8468. PsnName = res.Output.Baseinfo.PsnName
  8469. Gend = res.Output.Baseinfo.Gend
  8470. Naty = res.Output.Baseinfo.Naty
  8471. Brdy = res.Output.Baseinfo.Brdy
  8472. Age = res.Output.Baseinfo.Age
  8473. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  8474. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  8475. infoStr = string(Iinfos)
  8476. idetinfoStr = string(Idetinfos)
  8477. if miConfig.Code == "H15049901371" {
  8478. infocode, _ = strconv.ParseInt(res10265.Infcode, 10, 64)
  8479. } else {
  8480. infocode = res.Infcode
  8481. }
  8482. }
  8483. } else {
  8484. var result string
  8485. var requestLog string
  8486. if miConfig.UserOrgId == 10138 {
  8487. if id_card_type != 4 || id_card_type != 1 {
  8488. var insa string
  8489. if len(patient.InsuplcAdmdvs) > 0 {
  8490. insa = patient.InsuplcAdmdvs
  8491. } else {
  8492. insa = miConfig.InsuplcAdmdvs
  8493. }
  8494. //psn_info, _ := service.GetPsnByPatientId(id)
  8495. //result, requestLog = service.Gdyb1101ForEleCert(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, psn_info.VerifyNumber)
  8496. 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)
  8497. }
  8498. }
  8499. //else {
  8500. // var insa string
  8501. // if len(patient.InsuplcAdmdvs) > 0 {
  8502. // insa = patient.InsuplcAdmdvs
  8503. // } else {
  8504. // insa = miConfig.InsuplcAdmdvs
  8505. // }
  8506. // 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)
  8507. //}
  8508. if id_card_type == 4 || id_card_type == 1 {
  8509. psn_info, _ := service.GetPsnByPatientId(id)
  8510. PsnNo = psn_info.PsnNo
  8511. PsnCertType = psn_info.PsnCertType
  8512. Certno = psn_info.Certno
  8513. PsnName = psn_info.PsnName
  8514. Gend = psn_info.Gend
  8515. Naty = psn_info.Naty
  8516. Brdy = psn_info.Brdy
  8517. Age = psn_info.Age
  8518. infoStr = psn_info.Insuinfo
  8519. idetinfoStr = psn_info.Idetinfo
  8520. infocode = 0
  8521. verify_number = psn_info.VerifyNumber
  8522. } else {
  8523. saveLog(result, requestLog, "1101", "人员基本信息获取")
  8524. if miConfig.Code == "H15049901371" {
  8525. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  8526. utils.ErrorLog("解析失败:%v", err)
  8527. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8528. return
  8529. }
  8530. res.ErrMsg = res10265.ErrMsg
  8531. res.Output = res10265.Output
  8532. res.InfRefmsgid = res10265.InfRefmsgid
  8533. } else {
  8534. if err := json.Unmarshal([]byte(result), &res); err != nil {
  8535. utils.ErrorLog("解析失败:%v", err)
  8536. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8537. return
  8538. }
  8539. }
  8540. PsnNo = res.Output.Baseinfo.PsnNo
  8541. PsnCertType = res.Output.Baseinfo.PsnCertType
  8542. Certno = res.Output.Baseinfo.Certno
  8543. PsnName = res.Output.Baseinfo.PsnName
  8544. Gend = res.Output.Baseinfo.Gend
  8545. Naty = res.Output.Baseinfo.Naty
  8546. Brdy = res.Output.Baseinfo.Brdy
  8547. Age = res.Output.Baseinfo.Age
  8548. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  8549. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  8550. infoStr = string(Iinfos)
  8551. idetinfoStr = string(Idetinfos)
  8552. if miConfig.Code == "H15049901371" {
  8553. infocode, _ = strconv.ParseInt(res10265.Infcode, 10, 64)
  8554. } else {
  8555. infocode = res.Infcode
  8556. }
  8557. }
  8558. }
  8559. if infocode == 0 {
  8560. his := models.VMHisPatient{
  8561. Name: name,
  8562. Gender: gender,
  8563. Birthday: birthUnix,
  8564. MedicalTreatmentType: medical_care,
  8565. IdType: certificates,
  8566. IdCardNo: id_card,
  8567. BalanceAccountsType: settlementValue,
  8568. SocialType: social_type,
  8569. MedicalInsuranceNumber: medical_insurance_card,
  8570. RegisterType: register_type,
  8571. RegisterCost: registration_fee,
  8572. TreatmentCost: medical_expenses,
  8573. Status: 1,
  8574. Ctime: time.Now().Unix(),
  8575. Mtime: time.Now().Unix(),
  8576. PsnNo: PsnNo,
  8577. PsnCertType: PsnCertType,
  8578. Certno: Certno,
  8579. PsnName: PsnName,
  8580. Gend: Gend,
  8581. Naty: Naty,
  8582. Brdy: Brdy,
  8583. Age: Age,
  8584. Iinfo: infoStr,
  8585. Idetinfo: idetinfoStr,
  8586. PatientId: patient.ID,
  8587. RecordDate: theTime.Unix(),
  8588. UserOrgId: adminInfo.CurrentOrgId,
  8589. AdminUserId: admin_user_id,
  8590. IsReturn: 1,
  8591. IdCardType: id_card_type,
  8592. Doctor: doctor,
  8593. Departments: department,
  8594. MdtrtGrpType: mdtrt_type,
  8595. }
  8596. timestamp := time.Now().Unix()
  8597. tempTime := time.Unix(timestamp, 0)
  8598. timeFormat := tempTime.Format("20060102150405")
  8599. chrgBchno := rand.Intn(100000) + 10000
  8600. ipt_otp_no := timeFormat + strconv.FormatInt(int64(chrgBchno), 10) + strconv.FormatInt(his.PatientId, 10)
  8601. his.Number = ipt_otp_no
  8602. //count, _ := service.FindHisRegisterRecord(theTime.Unix(), patient.ID, adminInfo.CurrentOrgId)
  8603. department, _ := service.GetDepartMentDetail(department)
  8604. //doctor_id := strconv.FormatInt(patientPrescription., 10)
  8605. IdCardNo := ""
  8606. if id_card_type == 1 {
  8607. // IdCardNo = medical_insurance_card
  8608. IdCardNo = patient.IdCardNo
  8609. } else {
  8610. IdCardNo = patient.IdCardNo
  8611. }
  8612. var rf []*ResultFive
  8613. json.Unmarshal([]byte(his.Iinfo), &rf)
  8614. var insutypes []*ResultFive
  8615. var insutype string
  8616. var insuplc_admdvs_temp string
  8617. var is390 int = 0
  8618. var is310 int = 0
  8619. for _, item := range rf {
  8620. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  8621. insutypes = append(insutypes, item)
  8622. }
  8623. }
  8624. if len(insutypes) == 1 {
  8625. insutype = insutypes[0].Insutype
  8626. insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  8627. } else {
  8628. for _, i := range insutypes {
  8629. if i.Insutype == "390" {
  8630. is390 = 1
  8631. }
  8632. if i.Insutype == "310" {
  8633. is310 = 1
  8634. }
  8635. }
  8636. }
  8637. if is390 == 1 {
  8638. insutype = "390"
  8639. }
  8640. if is310 == 1 {
  8641. insutype = "310"
  8642. }
  8643. fmt.Println(social_type)
  8644. if social_type > 0 {
  8645. insutype = strconv.FormatInt(social_type, 10)
  8646. }
  8647. var infocode int64
  8648. var resThree ResultThree
  8649. var resThree10265 ResultThree10265
  8650. if len(insuplc_admdvs) == 0 {
  8651. insuplc_admdvs_temp = miConfig.InsuplcAdmdvs
  8652. } else {
  8653. insuplc_admdvs_temp = insuplc_admdvs
  8654. }
  8655. if miConfig.MdtrtareaAdmvs == "421300" {
  8656. hb_doctor_info, _ := service.GetAdminUserInfoByID(adminInfo.CurrentOrgId, patientPrescription.DoctorId)
  8657. api := "http://192.168.124.4:9532/" + "hbyb/2201?psn_no=" + PsnNo + "&insutype=" + insutype + "&cert_no=" + Certno + "&ipt_otp_no=" + ipt_otp_no +
  8658. "&org_name=" + miConfig.OrgName + "&doctor=" + hb_doctor_info.UserName + "&fixmedins_code=" + miConfig.Code +
  8659. "&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
  8660. resp, requestErr := http.Get(api)
  8661. if requestErr != nil {
  8662. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8663. return
  8664. }
  8665. body, ioErr := ioutil.ReadAll(resp.Body)
  8666. if ioErr != nil {
  8667. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  8668. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8669. return
  8670. }
  8671. var respJSON map[string]interface{}
  8672. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  8673. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  8674. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8675. return
  8676. }
  8677. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  8678. result, _ := json.Marshal(respJSON)
  8679. if err := json.Unmarshal([]byte(result), &resThree); err != nil {
  8680. utils.ErrorLog("解析失败:%v", err)
  8681. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8682. return
  8683. }
  8684. infocode = resThree.Infcode
  8685. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  8686. psn_info, _ := service.GetPsnByPatientId(id)
  8687. his.PsnNo = psn_info.PsnNo
  8688. psn_info.VerifyNumber = strings.Replace(psn_info.VerifyNumber, "+", "%2B", -1)
  8689. var cert_no string
  8690. if id_card_type == 3 {
  8691. psn_info.VerifyNumber = IdCardNo + "|" + psn_info.VerifyNumber
  8692. cert_no = IdCardNo
  8693. } else if id_card_type == 4 {
  8694. cert_no = IdCardNo
  8695. psn_info.VerifyNumber = psn_info.VerifyNumber
  8696. } else {
  8697. bas := strings.Split(psn_info.CardInfo, "|")
  8698. cert_no = bas[2]
  8699. }
  8700. var hisPrescription []*models.HisPrescription
  8701. for _, item := range rf {
  8702. if item.Insutype == insutype {
  8703. //insuplc_admdvs = item.InsuplcAdmdvs
  8704. his.InsuplcAdmdvs = insuplc_admdvs
  8705. }
  8706. }
  8707. his.Insutype = insutype
  8708. res3101 := Check3101ForOne(c, patient.ID, his, admin_user_id, "1", record_time, hisPrescription)
  8709. fmt.Println(res3101)
  8710. fmt.Println(res3101.Infcode)
  8711. if res3101.Infcode == "0" {
  8712. fmt.Println("33333333")
  8713. if len(res3101.Output.Result) > 0 {
  8714. fmt.Println("222222")
  8715. for _, item := range res3101.Output.Result {
  8716. if len(res3101.ErrMsg) == 0 {
  8717. res3101.ErrMsg = item.VolaCont
  8718. } else {
  8719. res3101.ErrMsg = res3101.ErrMsg + "\n" + item.VolaCont
  8720. }
  8721. }
  8722. c.ServeSuccessJSON(map[string]interface{}{
  8723. "failed_code": -10,
  8724. "msg": res3101.ErrMsg,
  8725. })
  8726. return
  8727. } else {
  8728. fmt.Println("11111")
  8729. var api string
  8730. if miConfig.MdtrtareaAdmvs == "320921" {
  8731. api = "http://192.168.2.3:9532/" + "jsyb/2201?psn_no=" + PsnNo + "&insutype=" + insutype + "&cert_no=" + cert_no + "&ipt_otp_no=" + ipt_otp_no +
  8732. "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&doctor_name=" + doctor_info.UserName + "&fixmedins_code=" + miConfig.Code +
  8733. "&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
  8734. } else {
  8735. api = "http://192.168.5.251:9532/" + "jsyb/2201?psn_no=" + PsnNo + "&insutype=" + insutype + "&cert_no=" + cert_no + "&ipt_otp_no=" + ipt_otp_no +
  8736. "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&doctor_name=" + doctor_info.UserName + "&fixmedins_code=" + miConfig.Code +
  8737. "&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
  8738. }
  8739. resp, requestErr := http.Get(api)
  8740. if requestErr != nil {
  8741. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8742. return
  8743. }
  8744. body, ioErr := ioutil.ReadAll(resp.Body)
  8745. if ioErr != nil {
  8746. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  8747. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8748. return
  8749. }
  8750. var respJSON map[string]interface{}
  8751. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  8752. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  8753. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8754. return
  8755. }
  8756. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  8757. result, _ := json.Marshal(respJSON)
  8758. if err := json.Unmarshal([]byte(result), &resThree10265); err != nil {
  8759. utils.ErrorLog("解析失败:%v", err)
  8760. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8761. return
  8762. }
  8763. resThree.ErrMsg = resThree10265.ErrMsg
  8764. resThree.Output = resThree10265.Output
  8765. resThree.InfRefmsgid = resThree10265.InfRefmsgid
  8766. infocode, _ = strconv.ParseInt(resThree10265.Infcode, 10, 64)
  8767. }
  8768. } else if res3101.Infcode != "0" {
  8769. c.ServeSuccessJSON(map[string]interface{}{
  8770. "failed_code": -10,
  8771. "msg": res3101.ErrMsg,
  8772. })
  8773. return
  8774. }
  8775. } else if miConfig.MdtrtareaAdmvs == "350500" {
  8776. psn_info, _ := service.GetPsnByPatientId(id)
  8777. var cert_no string
  8778. if id_card_type == 1 {
  8779. cert_no = strings.Split(psn_info.CardInfo, "|")[0]
  8780. insuplc_admdvs_temp = psn_info.InsuplcAdmdvs
  8781. } else if id_card_type == 4 {
  8782. cert_no = psn_info.VerifyNumber
  8783. insuplc_admdvs_temp = psn_info.InsuplcAdmdvs
  8784. } else {
  8785. insuplc_admdvs_temp = psn_info.InsuplcAdmdvs
  8786. cert_no = psn_info.VerifyNumber
  8787. }
  8788. 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)
  8789. saveLog(result, requestLog, "2201", "挂号")
  8790. if miConfig.Code == "H15049901371" {
  8791. if err := json.Unmarshal([]byte(result), &resThree10265); err != nil {
  8792. utils.ErrorLog("解析失败:%v", err)
  8793. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8794. return
  8795. }
  8796. resThree.ErrMsg = resThree10265.ErrMsg
  8797. resThree.Output = resThree10265.Output
  8798. resThree.InfRefmsgid = resThree10265.InfRefmsgid
  8799. } else {
  8800. if err := json.Unmarshal([]byte(result), &resThree); err != nil {
  8801. utils.ErrorLog("解析失败:%v", err)
  8802. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8803. return
  8804. }
  8805. }
  8806. infocode, _ = strconv.ParseInt(resThree10265.Infcode, 10, 64)
  8807. } else if miConfig.MdtrtareaAdmvs == "360399" { //江西萍乡
  8808. psn_info, _ := service.GetPsnByPatientId(id)
  8809. var result string
  8810. var requestLog string
  8811. if id_card_type == 1 {
  8812. bas := strings.Split(psn_info.CardInfo, "|")
  8813. basNumber := bas[2]
  8814. card_sn := bas[3]
  8815. 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)
  8816. saveLog(result, requestLog, "2201A", "挂号")
  8817. } else if id_card_type == 2 {
  8818. 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, "", "")
  8819. saveLog(result, requestLog, "2201A", "挂号")
  8820. } else {
  8821. 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, "", "")
  8822. saveLog(result, requestLog, "2201A", "挂号")
  8823. }
  8824. if err := json.Unmarshal([]byte(result), &resThree); err != nil {
  8825. utils.ErrorLog("解析失败:%v", err)
  8826. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8827. return
  8828. }
  8829. infocode = resThree.Infcode
  8830. } else if miConfig.MdtrtareaAdmvs == "430800" { //江西萍乡
  8831. psn_info, _ := service.GetPsnByPatientId(id)
  8832. var result string
  8833. var requestLog string
  8834. if id_card_type == 1 {
  8835. bas := strings.Split(psn_info.CardInfo, "|")
  8836. basNumber := bas[2]
  8837. card_sn := bas[3]
  8838. 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)
  8839. saveLog(result, requestLog, "2201A", "挂号")
  8840. } else if id_card_type == 2 {
  8841. 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, "", "")
  8842. saveLog(result, requestLog, "2201A", "挂号")
  8843. } else {
  8844. 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, "", "")
  8845. saveLog(result, requestLog, "2201A", "挂号")
  8846. }
  8847. if err := json.Unmarshal([]byte(result), &resThree); err != nil {
  8848. utils.ErrorLog("解析失败:%v", err)
  8849. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8850. return
  8851. }
  8852. infocode = resThree.Infcode
  8853. } else if miConfig.MdtrtareaAdmvs == "131023" {
  8854. psn_info, _ := service.GetPsnByPatientId(id)
  8855. 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)
  8856. saveLog(result, requestLog, "2201A", "挂号")
  8857. if miConfig.Code == "H15049901371" {
  8858. if err := json.Unmarshal([]byte(result), &resThree10265); err != nil {
  8859. utils.ErrorLog("解析失败:%v", err)
  8860. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8861. return
  8862. }
  8863. resThree.ErrMsg = resThree10265.ErrMsg
  8864. resThree.Output = resThree10265.Output
  8865. resThree.InfRefmsgid = resThree10265.InfRefmsgid
  8866. } else {
  8867. if err := json.Unmarshal([]byte(result), &resThree); err != nil {
  8868. utils.ErrorLog("解析失败:%v", err)
  8869. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8870. return
  8871. }
  8872. }
  8873. if miConfig.Code == "H15049901371" {
  8874. infocode, _ = strconv.ParseInt(resThree10265.Infcode, 10, 64)
  8875. } else {
  8876. infocode = resThree.Infcode
  8877. }
  8878. } else {
  8879. psn_info, _ := service.GetPsnByPatientId(id)
  8880. if id_card_type == 4 || id_card_type == 1 {
  8881. insuplc_admdvs_temp = psn_info.InsuplcAdmdvs
  8882. }
  8883. var rf []*ResultFive
  8884. json.Unmarshal([]byte(psn_info.Insuinfo), &rf)
  8885. var insutypes []*ResultFive
  8886. var insutype string
  8887. var is390 int = 0
  8888. var is310 int = 0
  8889. for _, item := range rf {
  8890. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  8891. insutypes = append(insutypes, item)
  8892. }
  8893. }
  8894. if len(insutypes) == 1 {
  8895. insutype = insutypes[0].Insutype
  8896. insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  8897. } else {
  8898. for _, i := range insutypes {
  8899. if i.Insutype == "390" {
  8900. is390 = 1
  8901. }
  8902. if i.Insutype == "310" {
  8903. is310 = 1
  8904. }
  8905. }
  8906. }
  8907. if is390 == 1 {
  8908. insutype = "390"
  8909. }
  8910. if is310 == 1 {
  8911. insutype = "310"
  8912. }
  8913. fmt.Println(len(insutypes))
  8914. if len(insutypes) == 0 {
  8915. for index, item := range rf {
  8916. if index == 0 {
  8917. insutype = item.Insutype
  8918. insuplc_admdvs = item.InsuplcAdmdvs
  8919. }
  8920. }
  8921. fmt.Println(insutype)
  8922. fmt.Println(insuplc_admdvs)
  8923. }
  8924. if social_type > 0 {
  8925. insutype = strconv.FormatInt(social_type, 10)
  8926. }
  8927. 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)
  8928. saveLog(result, requestLog, "2201A", "挂号")
  8929. if miConfig.Code == "H15049901371" {
  8930. if err := json.Unmarshal([]byte(result), &resThree10265); err != nil {
  8931. utils.ErrorLog("解析失败:%v", err)
  8932. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8933. return
  8934. }
  8935. resThree.ErrMsg = resThree10265.ErrMsg
  8936. resThree.Output = resThree10265.Output
  8937. resThree.InfRefmsgid = resThree10265.InfRefmsgid
  8938. } else {
  8939. if err := json.Unmarshal([]byte(result), &resThree); err != nil {
  8940. utils.ErrorLog("解析失败:%v", err)
  8941. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8942. return
  8943. }
  8944. }
  8945. if miConfig.Code == "H15049901371" {
  8946. infocode, _ = strconv.ParseInt(resThree10265.Infcode, 10, 64)
  8947. } else {
  8948. infocode = resThree.Infcode
  8949. }
  8950. }
  8951. if infocode != 0 {
  8952. adminUser := c.GetAdminUserInfo()
  8953. errlog := &models.HisOrderError{
  8954. UserOrgId: adminUser.CurrentOrgId,
  8955. Ctime: time.Now().Unix(),
  8956. Mtime: time.Now().Unix(),
  8957. ErrMsg: resThree.ErrMsg,
  8958. Status: 1,
  8959. PatientId: id,
  8960. RecordTime: recordDateTime,
  8961. Stage: 2,
  8962. }
  8963. service.CreateErrMsgLog(errlog)
  8964. c.ServeSuccessJSON(map[string]interface{}{
  8965. "failed_code": -10,
  8966. "msg": resThree.ErrMsg,
  8967. })
  8968. return
  8969. }
  8970. his.Number = resThree.Output.Data.MdtrtID
  8971. his.PsnNo = resThree.Output.Data.PsnNo
  8972. his.IptOtpNo = resThree.Output.Data.IptOtpNo
  8973. his.IdCardNo = patient.IdCardNo
  8974. his.PhoneNumber = patient.Phone
  8975. his.UserOrgId = adminInfo.CurrentOrgId
  8976. his.Insutype = insutype
  8977. his.Ctime = time.Now().Unix()
  8978. his.Mtime = time.Now().Unix()
  8979. his.InsuplcAdmdvs = insuplc_admdvs_temp
  8980. his.Status = 1
  8981. his.MdtrtGrpType = mdtrt_type
  8982. service.UpdateHisPatientStatus(&his)
  8983. service.UpdateHisPrescriptionHisID(his.ID, patient.ID, recordDateTime, adminInfo.CurrentOrgId)
  8984. c.ServeSuccessJSON(map[string]interface{}{
  8985. "his_info": his,
  8986. })
  8987. } else {
  8988. adminUser := c.GetAdminUserInfo()
  8989. errlog := &models.HisOrderError{
  8990. UserOrgId: adminUser.CurrentOrgId,
  8991. Ctime: time.Now().Unix(),
  8992. Mtime: time.Now().Unix(),
  8993. ErrMsg: res.ErrMsg,
  8994. Status: 1,
  8995. PatientId: id,
  8996. RecordTime: recordDateTime,
  8997. Stage: 1,
  8998. }
  8999. service.CreateErrMsgLog(errlog)
  9000. c.ServeSuccessJSON(map[string]interface{}{
  9001. "failed_code": -10,
  9002. "msg": res.ErrMsg,
  9003. })
  9004. return
  9005. //c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeGdybOneException)
  9006. }
  9007. }
  9008. }
  9009. func (c *HisApiController) GetUploadInfo() {
  9010. id, _ := c.GetInt64("id")
  9011. record_time := c.GetString("record_time")
  9012. his_patient_id, _ := c.GetInt64("his_patient_id")
  9013. order_id, _ := c.GetInt64("order_id")
  9014. pay_way, _ := c.GetInt64("pay_way")
  9015. pay_ways := c.GetString("pay_ways")
  9016. oth_desc := c.GetString("oth_desc")
  9017. pay_price, _ := c.GetFloat("pay_price")
  9018. pay_card_no := c.GetString("pay_card_no")
  9019. discount_price, _ := c.GetFloat("discount_price")
  9020. preferential_price, _ := c.GetFloat("preferential_price")
  9021. reality_price, _ := c.GetFloat("reality_price")
  9022. found_price, _ := c.GetFloat("found_price")
  9023. medical_insurance_price, _ := c.GetFloat("medical_insurance_price")
  9024. private_price, _ := c.GetFloat("private_price")
  9025. settle_accounts_type, _ := c.GetInt64("settle_accounts_type")
  9026. admin_user_id, _ := c.GetInt64("admin_user_id")
  9027. fapiao_code := c.GetString("fapiao_code")
  9028. fapiao_number := c.GetString("fapiao_number")
  9029. diagnosis_id := c.GetString("diagnosis")
  9030. sick_type, _ := c.GetInt64("sick_type")
  9031. reg_type, _ := c.GetInt64("p_type")
  9032. begin_time := c.GetString("begin_time")
  9033. acct_used_flag_num, _ := c.GetInt64("acct_used_flag")
  9034. cash_pay := c.GetString("cash_pay")
  9035. band_card_pay := c.GetString("band_card_pay")
  9036. wechat_pay := c.GetString("wechat_pay")
  9037. ali_pay := c.GetString("ali_pay")
  9038. jifen_pay := c.GetString("jifen_pay")
  9039. acct_used_flag := strconv.FormatInt(acct_used_flag_num, 10)
  9040. fmt.Println(acct_used_flag)
  9041. id_str := c.GetString("ids")
  9042. ids_arr := strings.Split(id_str, ",")
  9043. timeLayout := "2006-01-02"
  9044. loc, _ := time.LoadLocation("Local")
  9045. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  9046. if err != nil {
  9047. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  9048. return
  9049. }
  9050. recordDateTime := theTime.Unix()
  9051. adminUser := c.GetAdminUserInfo()
  9052. var tempOrder models.HisOrder
  9053. tempOrder, _ = service.GetHisOrderByID(order_id)
  9054. var prescriptions []*models.HisPrescription
  9055. var start_time int64
  9056. var end_time int64
  9057. //押金模块
  9058. dec_way := c.GetString("dec_way") //是否使用押金支付bool类型
  9059. tmp_decimal := c.GetString("tmp_decimal")
  9060. var decimal float64 //本次使用的押金
  9061. var errmsg error
  9062. if dec_way == "true" && tmp_decimal == "0" || dec_way == "true" && tmp_decimal == "" {
  9063. c.ServeFailJsonSend(enums.ErrorCodeParamWrong, "押金不能为0")
  9064. return
  9065. }
  9066. if len(tmp_decimal) > 0 {
  9067. if tmp_decimal[0] == 45 {
  9068. c.ServeFailJsonSend(enums.ErrorCodeParamWrong, "押金不能为负数")
  9069. return
  9070. }
  9071. }
  9072. tt, errs := strconv.ParseFloat(tmp_decimal, 64)
  9073. fmt.Println(errs)
  9074. decimal = tt
  9075. //if adminUser.CurrentOrgId == 10106{
  9076. // if len(fapiao_code) == 0{
  9077. // fapiao_code = "144072080589"
  9078. // }
  9079. // if len(fapiao_number) == 0{
  9080. // order, _ := service.GetLastHisOrder(adminUser.CurrentOrgId)
  9081. // if order.ID == 0{
  9082. // fapiao_number = "00001520"
  9083. // }else{
  9084. // //fapiao_code = "00001520"
  9085. // fpNumber, _ := strconv.Atoi(order.FaPiaoNumber)
  9086. // var zero string
  9087. // if fpNumber >= 1000{
  9088. // zero = "0000" + strconv.Itoa(fpNumber)
  9089. // }else if fpNumber >= 10000{
  9090. // zero = "000" + strconv.Itoa(fpNumber)
  9091. // } else if fpNumber >= 100000{
  9092. // zero = "00" + strconv.Itoa(fpNumber)
  9093. // } else if fpNumber >= 1000000{
  9094. // zero = "0" + strconv.Itoa(fpNumber)
  9095. // }else {
  9096. // zero = strconv.Itoa(fpNumber)
  9097. // }
  9098. // fapiao_number = zero
  9099. // }
  9100. // }
  9101. //}
  9102. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  9103. his, _ := service.GetNewHisPatientInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  9104. var patientPrescription models.HisPrescriptionInfo
  9105. patientPrescription, _ = service.FindHisPatientPrescriptionInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  9106. if patientPrescription.ID == 0 {
  9107. patientPrescription, _ = service.FindLastPatientPrescriptionInfo(adminUser.CurrentOrgId, id, recordDateTime)
  9108. }
  9109. //if patientPrescription.Do
  9110. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  9111. department, _ := service.GetDepartMentDetail(patientPrescription.Departments)
  9112. doctor_info, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, patientPrescription.DoctorId)
  9113. diagnosis_ids := strings.Split(diagnosis_id, ",")
  9114. var config []*models.HisXtDiagnoseConfig
  9115. for _, item := range diagnosis_ids {
  9116. id, _ := strconv.ParseInt(item, 10, 64)
  9117. diagnosisConfig, _ := service.FindDiagnoseById(id)
  9118. config = append(config, &diagnosisConfig)
  9119. }
  9120. sickConfig, _ := service.FindSickById(sick_type)
  9121. //if tempOrder.ID == 0 {
  9122. // tempOrder, _ = service.GetTodayHisOrder(adminUser.CurrentOrgId, id, recordDateTime, his.Number)
  9123. //}
  9124. if tempOrder.ID == 0 {
  9125. var result string
  9126. var requestLog string
  9127. var res2 ResultSix
  9128. var ressix10265 ResultSix10265
  9129. if miConfig.MdtrtareaAdmvs == "421300" {
  9130. data := make(map[string]interface{})
  9131. client := &http.Client{}
  9132. data["psn_no"] = his.PsnNo
  9133. data["mdtrt_id"] = his.Number
  9134. data["opter"] = roles.UserName
  9135. data["org_name"] = miConfig.OrgName
  9136. data["med_type"] = strconv.FormatInt(reg_type, 10)
  9137. data["doctor_id"] = doctor_info.DoctorNumber
  9138. data["doctor_name"] = doctor_info.UserName
  9139. data["department"] = department.Name
  9140. data["fixmedins_code"] = miConfig.Code
  9141. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  9142. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  9143. data["secret_key"] = miConfig.SecretKey
  9144. data["sick_code"] = sickConfig.CountryCode
  9145. data["sick_name"] = sickConfig.ClassName
  9146. data["dept"] = strconv.FormatInt(department.ID, 10)
  9147. data["config"] = config
  9148. data["begin_time"] = begin_time
  9149. bytesData, _ := json.Marshal(data)
  9150. req, _ := http.NewRequest("POST", "http://192.168.124.4:9532/"+"hbyb/2203", bytes.NewReader(bytesData))
  9151. resp, _ := client.Do(req)
  9152. defer resp.Body.Close()
  9153. body, ioErr := ioutil.ReadAll(resp.Body)
  9154. if ioErr != nil {
  9155. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  9156. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9157. return
  9158. }
  9159. var respJSON map[string]interface{}
  9160. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  9161. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  9162. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9163. return
  9164. }
  9165. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  9166. userJSONBytes, _ := json.Marshal(respJSON)
  9167. fmt.Println("log")
  9168. fmt.Println(string(userJSONBytes))
  9169. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  9170. utils.ErrorLog("解析失败:%v", err)
  9171. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9172. return
  9173. }
  9174. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  9175. data := make(map[string]interface{})
  9176. client := &http.Client{}
  9177. data["psn_no"] = his.PsnNo
  9178. data["mdtrt_id"] = his.Number
  9179. data["doctor"] = roles.UserName
  9180. data["department"] = department.Name
  9181. data["org_name"] = miConfig.OrgName
  9182. data["med_type"] = strconv.FormatInt(reg_type, 10)
  9183. data["doctor_id"] = doctor_info.DoctorNumber
  9184. data["new_doctor_name"] = doctor_info.UserName
  9185. data["fixmedins_code"] = miConfig.Code
  9186. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  9187. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  9188. data["secret_key"] = miConfig.SecretKey
  9189. data["sick_code"] = sickConfig.CountryCode
  9190. data["sick_name"] = sickConfig.ClassName
  9191. data["url"] = miConfig.Url
  9192. data["ak"] = miConfig.AccessKey
  9193. data["begin_time"] = begin_time
  9194. data["cainfo"] = miConfig.Cainfo
  9195. data["dept"] = strconv.FormatInt(department.ID, 10)
  9196. data["config"] = config
  9197. bytesData, _ := json.Marshal(data)
  9198. var req *http.Request
  9199. if miConfig.MdtrtareaAdmvs == "320921" {
  9200. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/2203", bytes.NewReader(bytesData))
  9201. //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 +
  9202. // "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&cainfo=" + miConfig.Cainfo
  9203. } else {
  9204. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2203", bytes.NewReader(bytesData))
  9205. }
  9206. resp, _ := client.Do(req)
  9207. defer resp.Body.Close()
  9208. body, ioErr := ioutil.ReadAll(resp.Body)
  9209. if ioErr != nil {
  9210. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  9211. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9212. return
  9213. }
  9214. var respJSON map[string]interface{}
  9215. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  9216. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  9217. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9218. return
  9219. }
  9220. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  9221. userJSONBytes, _ := json.Marshal(respJSON)
  9222. fmt.Println("log")
  9223. fmt.Println(string(userJSONBytes))
  9224. if err := json.Unmarshal(userJSONBytes, &ressix10265); err != nil {
  9225. utils.ErrorLog("解析失败:%v", err)
  9226. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9227. return
  9228. }
  9229. res2.InfRefmsgid = ressix10265.InfRefmsgid
  9230. res2.Output = ressix10265.Output
  9231. res2.ErrMsg = ressix10265.ErrMsg
  9232. res2.Cainfo = ressix10265.Cainfo
  9233. res2.WarnMsg = ressix10265.WarnMsg
  9234. infocode, _ := strconv.ParseInt(ressix10265.Infcode, 10, 64)
  9235. res2.Infcode = infocode
  9236. } else if miConfig.MdtrtareaAdmvs == "350500" {
  9237. 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)
  9238. saveLog(result, requestLog, "2203", "上传就诊信息")
  9239. var respJSON2 map[string]interface{}
  9240. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  9241. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  9242. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9243. return
  9244. }
  9245. userJSONBytes2, _ := json.Marshal(respJSON2)
  9246. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  9247. utils.ErrorLog("解析失败:%v", err)
  9248. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9249. return
  9250. }
  9251. 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)
  9252. fmt.Println(result2)
  9253. fmt.Println(src_request)
  9254. } else {
  9255. if miConfig.MdtrtareaAdmvs == "440781" { //
  9256. 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)
  9257. } else {
  9258. if miConfig.Code == "H15049901371" {
  9259. //赤峰地区国家医保医疗类别
  9260. //职工透析:医疗类别选特殊情况门诊990502
  9261. //居民定额血透门慢: 医疗类别选门诊慢病140104
  9262. var med_type string
  9263. if his.Insutype == "390" {
  9264. if reg_type == 14 {
  9265. med_type = "9933"
  9266. } else if reg_type == 11 {
  9267. med_type = "11"
  9268. }
  9269. } else if his.Insutype == "310" {
  9270. if reg_type == 14 {
  9271. med_type = "990502"
  9272. } else if reg_type == 11 {
  9273. med_type = "11"
  9274. }
  9275. }
  9276. 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)
  9277. } else {
  9278. 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)
  9279. }
  9280. }
  9281. saveLog(result, requestLog, "2203", "上传就诊信息")
  9282. var respJSON2 map[string]interface{}
  9283. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  9284. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  9285. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9286. return
  9287. }
  9288. userJSONBytes2, _ := json.Marshal(respJSON2)
  9289. if miConfig.Code == "H15049901371" {
  9290. if err := json.Unmarshal(userJSONBytes2, &ressix10265); err != nil {
  9291. utils.ErrorLog("解析失败:%v", err)
  9292. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9293. return
  9294. }
  9295. res2.InfRefmsgid = ressix10265.InfRefmsgid
  9296. res2.Output = ressix10265.Output
  9297. res2.ErrMsg = ressix10265.ErrMsg
  9298. res2.Cainfo = ressix10265.Cainfo
  9299. res2.WarnMsg = ressix10265.WarnMsg
  9300. infocode, _ := strconv.ParseInt(ressix10265.Infcode, 10, 64)
  9301. res2.Infcode = infocode
  9302. } else {
  9303. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  9304. utils.ErrorLog("解析失败:%v", err)
  9305. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9306. return
  9307. }
  9308. }
  9309. }
  9310. if res2.Infcode != 0 {
  9311. adminUser := c.GetAdminUserInfo()
  9312. errlog := &models.HisOrderError{
  9313. UserOrgId: adminUser.CurrentOrgId,
  9314. Ctime: time.Now().Unix(),
  9315. Mtime: time.Now().Unix(),
  9316. ErrMsg: res2.ErrMsg,
  9317. Status: 1,
  9318. PatientId: id,
  9319. RecordTime: recordDateTime,
  9320. Stage: 3,
  9321. }
  9322. service.CreateErrMsgLog(errlog)
  9323. c.ServeSuccessJSON(map[string]interface{}{
  9324. "failed_code": -10,
  9325. "msg": res2.ErrMsg,
  9326. })
  9327. return
  9328. } else {
  9329. his.Diagnosis = diagnosis_id
  9330. his.SickType = sickConfig.ID
  9331. //var p_type int64
  9332. //if reg_type == 1111 || reg_type == 1112 {
  9333. // p_type = 11
  9334. //
  9335. //}
  9336. his.PType = fmt.Sprintf("%d", reg_type)
  9337. service.UpdateHisPatientThree(&his)
  9338. data := make(map[string]interface{})
  9339. if settle_accounts_type == 1 { //日结
  9340. if reg_type == 11 || reg_type == 1111 || reg_type == 1112 {
  9341. prescriptions, _ = service.GetPrescriptionByIds(ids_arr, adminUser.CurrentOrgId)
  9342. } else {
  9343. prescriptions, _ = service.GetNewHisPrescription(adminUser.CurrentOrgId, his_patient_id, recordDateTime, strconv.Itoa(int(reg_type)))
  9344. }
  9345. //prescriptions, _ = service.GetNewHisPrescriptionTwo(adminUser.CurrentOrgId, his_patient_id, recordDateTime, reg_type)
  9346. data["pre"] = prescriptions
  9347. } else { //月结
  9348. start_time_str := c.GetString("start_time")
  9349. end_time_str := c.GetString("end_time")
  9350. timeLayout := "2006-01-02"
  9351. loc, _ := time.LoadLocation("Local")
  9352. theStartTime, err := time.ParseInLocation(timeLayout+" 15:04:05", start_time_str+" 00:00:00", loc)
  9353. if err != nil {
  9354. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  9355. return
  9356. }
  9357. recordStartTime := theStartTime.Unix()
  9358. start_time = recordStartTime
  9359. theEndTime, err := time.ParseInLocation(timeLayout+" 15:04:05", end_time_str+" 00:00:00", loc)
  9360. if err != nil {
  9361. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  9362. return
  9363. }
  9364. recordEndTime := theEndTime.Unix()
  9365. end_time = recordEndTime
  9366. prescriptions, _ = service.GetMonthHisPrescriptionTwo(adminUser.CurrentOrgId, id, recordStartTime, recordEndTime, reg_type)
  9367. data["pre"] = prescriptions
  9368. }
  9369. timestamp := time.Now().Unix()
  9370. tempTime := time.Unix(timestamp, 0)
  9371. timeFormat := tempTime.Format("20060102150405")
  9372. chrgBchno := rand.Intn(100000) + 10000
  9373. chrg_bchno := timeFormat + strconv.FormatInt(int64(chrgBchno), 10) + strconv.FormatInt(his.PatientId, 10)
  9374. strconv.FormatInt(his.PatientId, 10)
  9375. client := &http.Client{}
  9376. data["psn_no"] = his.PsnNo
  9377. data["mdtrt_id"] = his.Number
  9378. data["chrg_bchno"] = chrg_bchno
  9379. data["org_name"] = miConfig.OrgName
  9380. data["doctor"] = doctor_info.UserName
  9381. data["doctor_id"] = doctor_info.DoctorNumber
  9382. data["dept"] = strconv.FormatInt(patientPrescription.Departments, 10)
  9383. data["fixmedins_code"] = miConfig.Code
  9384. data["opter"] = roles.UserName
  9385. data["dept_code"] = department.Number
  9386. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  9387. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  9388. data["secret_key"] = miConfig.SecretKey
  9389. data["balance_accounts_type"] = strconv.FormatInt(his.BalanceAccountsType, 10)
  9390. data["url"] = miConfig.Url
  9391. data["ak"] = miConfig.AccessKey
  9392. data["new_doctor_name"] = patientPrescription.Doctor
  9393. data["diag_code"] = sickConfig.CountryCode
  9394. data["cainfo"] = miConfig.Cainfo
  9395. data["opter"] = roles.UserName
  9396. var ids []int64
  9397. for _, item := range prescriptions {
  9398. ids = append(ids, item.ID)
  9399. }
  9400. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  9401. if config.IsOpen == 1 { //对接了医保,走医保流程
  9402. var res ResultFour
  9403. var resFour10265 ResultFour10265
  9404. if miConfig.MdtrtareaAdmvs == "421300" {
  9405. bytesData, _ := json.Marshal(data)
  9406. req, _ := http.NewRequest("POST", "http://192.168.124.4:9532/"+"hbyb/2204", bytes.NewReader(bytesData))
  9407. resp, _ := client.Do(req)
  9408. defer resp.Body.Close()
  9409. body, ioErr := ioutil.ReadAll(resp.Body)
  9410. if ioErr != nil {
  9411. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  9412. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9413. return
  9414. }
  9415. var respJSON map[string]interface{}
  9416. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  9417. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  9418. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9419. return
  9420. }
  9421. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  9422. userJSONBytes, _ := json.Marshal(respJSON)
  9423. fmt.Println("log")
  9424. fmt.Println(string(userJSONBytes))
  9425. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  9426. utils.ErrorLog("解析失败:%v", err)
  9427. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9428. return
  9429. }
  9430. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  9431. result3101 := Check3101(c, id, his_patient_id, admin_user_id, "2", record_time, prescriptions)
  9432. if result3101.Infcode == "0" {
  9433. if len(result3101.Output.Result) > 0 {
  9434. var errMsgs []string
  9435. for _, item := range result3101.Output.Result {
  9436. errMsgs = append(errMsgs, item.VolaCont)
  9437. }
  9438. c.ServeSuccessJSON(map[string]interface{}{
  9439. "failed_code": -10,
  9440. "msg": errMsgs,
  9441. })
  9442. return
  9443. }
  9444. }
  9445. if miConfig.MdtrtareaAdmvs == "320921" {
  9446. data["doctor_id"] = "D320923012139"
  9447. } else {
  9448. data["doctor_id"] = "D371621008686"
  9449. }
  9450. bytesData, _ := json.Marshal(data)
  9451. var req *http.Request
  9452. if miConfig.MdtrtareaAdmvs == "320921" {
  9453. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  9454. } else {
  9455. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  9456. }
  9457. resp, _ := client.Do(req)
  9458. defer resp.Body.Close()
  9459. body, ioErr := ioutil.ReadAll(resp.Body)
  9460. if ioErr != nil {
  9461. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  9462. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9463. return
  9464. }
  9465. var respJSON map[string]interface{}
  9466. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  9467. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  9468. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9469. return
  9470. }
  9471. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  9472. userJSONBytes, _ := json.Marshal(respJSON)
  9473. fmt.Println("log")
  9474. fmt.Println(string(userJSONBytes))
  9475. if err := json.Unmarshal(userJSONBytes, &resFour10265); err != nil {
  9476. utils.ErrorLog("解析失败:%v", err)
  9477. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9478. return
  9479. }
  9480. res.InfRefmsgid = resFour10265.InfRefmsgid
  9481. res.Output = resFour10265.Output
  9482. res.ErrMsg = resFour10265.ErrMsg
  9483. res.Cainfo = resFour10265.Cainfo
  9484. res.WarnMsg = resFour10265.WarnMsg
  9485. infocode, _ := strconv.ParseInt(resFour10265.Infcode, 10, 64)
  9486. res.Infcode = infocode
  9487. } else if miConfig.MdtrtareaAdmvs == "350500" {
  9488. 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)
  9489. var dat map[string]interface{}
  9490. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  9491. fmt.Println(dat)
  9492. } else {
  9493. fmt.Println(err)
  9494. }
  9495. saveLog(result, request_log, "2204", "上传费用明细")
  9496. userJSONBytes, _ := json.Marshal(dat)
  9497. if err := json.Unmarshal(userJSONBytes, &resFour10265); err != nil {
  9498. utils.ErrorLog("解析失败:%v", err)
  9499. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9500. return
  9501. }
  9502. res.InfRefmsgid = resFour10265.InfRefmsgid
  9503. res.Output = resFour10265.Output
  9504. res.ErrMsg = resFour10265.ErrMsg
  9505. res.Cainfo = resFour10265.Cainfo
  9506. res.WarnMsg = resFour10265.WarnMsg
  9507. infocode, _ := strconv.ParseInt(resFour10265.Infcode, 10, 64)
  9508. res.Infcode = infocode
  9509. } else {
  9510. if miConfig.Code == "H15049901371" {
  9511. 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)
  9512. var dat map[string]interface{}
  9513. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  9514. fmt.Println(dat)
  9515. } else {
  9516. fmt.Println(err)
  9517. }
  9518. saveLog(result, request_log, "2204", "上传费用明细")
  9519. userJSONBytes, _ := json.Marshal(dat)
  9520. if err := json.Unmarshal(userJSONBytes, &resFour10265); err != nil {
  9521. utils.ErrorLog("解析失败:%v", err)
  9522. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9523. return
  9524. }
  9525. res.InfRefmsgid = resFour10265.InfRefmsgid
  9526. res.Output = resFour10265.Output
  9527. res.ErrMsg = resFour10265.ErrMsg
  9528. res.Cainfo = resFour10265.Cainfo
  9529. res.WarnMsg = resFour10265.WarnMsg
  9530. infocode, _ := strconv.ParseInt(resFour10265.Infcode, 10, 64)
  9531. res.Infcode = infocode
  9532. } else {
  9533. 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)
  9534. var dat map[string]interface{}
  9535. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  9536. fmt.Println(dat)
  9537. } else {
  9538. fmt.Println(err)
  9539. }
  9540. saveLog(result, request_log, "2204", "上传费用明细")
  9541. userJSONBytes, _ := json.Marshal(dat)
  9542. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  9543. utils.ErrorLog("解析失败:%v", err)
  9544. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9545. return
  9546. }
  9547. }
  9548. }
  9549. if res.Infcode == 0 {
  9550. order := &models.HisOrder{
  9551. UserOrgId: adminUser.CurrentOrgId,
  9552. HisPatientId: his.ID,
  9553. PatientId: his.PatientId,
  9554. SettleAccountsDate: recordDateTime,
  9555. MdtrtId: his.Number,
  9556. PsnNo: his.PsnNo,
  9557. MedType: strconv.FormatInt(reg_type, 10),
  9558. Ctime: time.Now().Unix(),
  9559. Mtime: time.Now().Unix(),
  9560. Status: 1,
  9561. Number: chrg_bchno,
  9562. Infcode: res.Infcode,
  9563. WarnMsg: res.WarnMsg,
  9564. Cainfo: res.Cainfo,
  9565. ErrMsg: res.ErrMsg,
  9566. RespondTime: res.RefmsgTime,
  9567. InfRefmsgid: res.InfRefmsgid,
  9568. OrderStatus: 1,
  9569. PayWay: pay_way,
  9570. PayWays: pay_ways,
  9571. OthDesc: oth_desc,
  9572. PayPrice: pay_price,
  9573. PayCardNo: pay_card_no,
  9574. DiscountPrice: discount_price,
  9575. PreferentialPrice: preferential_price,
  9576. RealityPrice: reality_price,
  9577. FoundPrice: found_price,
  9578. MedicalInsurancePrice: medical_insurance_price,
  9579. PrivatePrice: private_price,
  9580. IsMedicineInsurance: 1,
  9581. SettleType: settle_accounts_type,
  9582. SettleStartTime: start_time,
  9583. SettleEndTime: end_time,
  9584. Creator: roles.AdminUserId,
  9585. Modify: roles.AdminUserId,
  9586. FaPiaoNumber: fapiao_number,
  9587. FaPiaoCode: fapiao_code,
  9588. PType: 2,
  9589. Diagnosis: diagnosis_id,
  9590. CashPay: cash_pay,
  9591. WechatPay: wechat_pay,
  9592. AliPay: ali_pay,
  9593. JifenPay: jifen_pay,
  9594. BandCardPay: band_card_pay,
  9595. }
  9596. err = service.CreateOrder(order)
  9597. if err != nil {
  9598. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCreatePreOrderException)
  9599. return
  9600. }
  9601. for _, item := range res.Output.Result {
  9602. temp := strings.Split(item.FeedetlSn, "-")
  9603. var advice_id int64 = 0
  9604. var project_id int64 = 0
  9605. var types int64 = 0
  9606. id, _ := strconv.ParseInt(temp[2], 10, 64)
  9607. types, _ = strconv.ParseInt(temp[1], 10, 64)
  9608. if temp[1] == "1" {
  9609. advice_id = id
  9610. project_id = 0
  9611. } else if temp[1] == "2" {
  9612. advice_id = 0
  9613. project_id = id
  9614. }
  9615. if item.MedChrgitmType == "9" {
  9616. item.MedChrgitmType = "09"
  9617. }
  9618. info := &models.HisOrderInfo{
  9619. OrderNumber: order.Number,
  9620. FeedetlSn: item.FeedetlSn,
  9621. UploadDate: time.Now().Unix(),
  9622. AdviceId: advice_id,
  9623. DetItemFeeSumamt: item.DetItemFeeSumamt,
  9624. Cnt: item.Cnt,
  9625. Pric: float64(item.Pric),
  9626. PatientId: his.PatientId,
  9627. PricUplmtAmt: item.PricUplmtAmt,
  9628. SelfpayProp: item.SelfpayProp,
  9629. FulamtOwnpayAmt: item.FulamtOwnpayAmt,
  9630. OverlmtAmt: item.OverlmtAmt,
  9631. PreselfpayAmt: item.PreselfpayAmt,
  9632. BasMednFlag: item.BasMednFlag,
  9633. MedChrgitmType: item.MedChrgitmType,
  9634. HiNegoDrugFlag: item.HiNegoDrugFlag,
  9635. Status: 1,
  9636. Memo: item.Memo,
  9637. Mtime: time.Now().Unix(),
  9638. InscpScpAmt: item.InscpScpAmt,
  9639. DrtReimFlag: item.DrtReimFlag,
  9640. Ctime: time.Now().Unix(),
  9641. ListSpItemFlag: item.ListSpItemFlag,
  9642. ChldMedcFlag: item.ChldMedcFlag,
  9643. LmtUsedFlag: item.LmtUsedFlag,
  9644. ChrgitmLv: item.ChrgitmLv,
  9645. UserOrgId: adminUser.CurrentOrgId,
  9646. HisPatientId: his.ID,
  9647. OrderId: order.ID,
  9648. ProjectId: project_id,
  9649. Type: types,
  9650. }
  9651. service.CreateOrderInfo(info)
  9652. }
  9653. service.UpDatePrescriptionNumber(adminUser.CurrentOrgId, ids, chrg_bchno)
  9654. service.UpDateHisPrescriptionInfoNumber(adminUser.CurrentOrgId, his_patient_id, chrg_bchno, recordDateTime)
  9655. var total float64
  9656. for _, item := range prescriptions {
  9657. if item.Type == 1 { //药品
  9658. for _, subItem := range item.HisDoctorAdviceInfo {
  9659. price, _ := strconv.ParseFloat(fmt.Sprintf("%.2f", subItem.Price), 64)
  9660. total_one := price * subItem.PrescribingNumber
  9661. total = total + total_one
  9662. }
  9663. }
  9664. if item.Type == 2 { //项目
  9665. for _, subItem := range item.HisPrescriptionProject {
  9666. cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  9667. price, _ := strconv.ParseFloat(fmt.Sprintf("%.2f", subItem.Price), 64)
  9668. total_one := price * cnt
  9669. total = total + total_one
  9670. }
  9671. }
  9672. }
  9673. allTotal := fmt.Sprintf("%f", total)
  9674. //if adminUser.CurrentOrgId == 9919 {
  9675. //
  9676. // allTotal = fmt.Sprintf("%.2f", total)
  9677. //
  9678. //} else {
  9679. //
  9680. // allTotal = fmt.Sprintf("%.2f", total)
  9681. //
  9682. //}
  9683. if res.Infcode == 0 {
  9684. var rf []*ResultFive
  9685. json.Unmarshal([]byte(his.Iinfo), &rf)
  9686. chrg_bchno := chrg_bchno
  9687. cert_no := his.Certno
  9688. var insutypes []string
  9689. var insutype string
  9690. var is390 int = 0
  9691. var is310 int = 0
  9692. for _, item := range rf {
  9693. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  9694. insutypes = append(insutypes, item.Insutype)
  9695. }
  9696. }
  9697. if len(insutypes) == 1 {
  9698. insutype = insutypes[0]
  9699. } else {
  9700. for _, i := range insutypes {
  9701. if i == "390" {
  9702. is390 = 1
  9703. }
  9704. if i == "310" {
  9705. is310 = 1
  9706. }
  9707. }
  9708. }
  9709. if is390 == 1 {
  9710. insutype = "390"
  9711. }
  9712. if is310 == 1 {
  9713. insutype = "310"
  9714. }
  9715. if len(insutypes) == 0 {
  9716. insutype = "310"
  9717. }
  9718. if len(insutypes) == 2 {
  9719. insutype = strconv.FormatInt(his.SocialType, 10)
  9720. }
  9721. insutype = strconv.FormatInt(his.SocialType, 10)
  9722. //insutype = "390"
  9723. if his.IdCardType == 1 {
  9724. // cert_no = his.MedicalInsuranceNumber
  9725. cert_no = his.Certno
  9726. } else {
  9727. cert_no = his.Certno
  9728. }
  9729. var res ResultSeven
  9730. var resSeven10265 ResultSeven10265
  9731. var src_resquest string
  9732. var result2 string
  9733. if miConfig.MdtrtareaAdmvs == "421300" {
  9734. api := "http://192.168.124.4:9532/" + "hbyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  9735. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  9736. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  9737. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  9738. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  9739. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  9740. "&insutype=" + insutype + "&total=" + allTotal + "&med_type=" + strconv.FormatInt(reg_type, 10) + "&acct_used_flag=" + acct_used_flag
  9741. resp, requestErr := http.Get(api)
  9742. if requestErr != nil {
  9743. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9744. return
  9745. }
  9746. body, ioErr := ioutil.ReadAll(resp.Body)
  9747. if ioErr != nil {
  9748. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  9749. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9750. return
  9751. }
  9752. var respJSON map[string]interface{}
  9753. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  9754. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  9755. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9756. return
  9757. }
  9758. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  9759. result, _ := json.Marshal(respJSON)
  9760. if miConfig.Code == "H15049901371" {
  9761. if err := json.Unmarshal([]byte(result), &resSeven10265); err != nil {
  9762. utils.ErrorLog("解析失败:%v", err)
  9763. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9764. return
  9765. }
  9766. res.InfRefmsgid = resSeven10265.InfRefmsgid
  9767. res.Output = resSeven10265.Output
  9768. res.ErrMsg = resSeven10265.ErrMsg
  9769. res.Cainfo = resSeven10265.Cainfo
  9770. res.WarnMsg = resSeven10265.WarnMsg
  9771. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  9772. res.Infcode = infocode
  9773. } else {
  9774. if err := json.Unmarshal([]byte(result), &res); err != nil {
  9775. utils.ErrorLog("解析失败:%v", err)
  9776. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9777. return
  9778. }
  9779. }
  9780. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  9781. result3101 := Check3102(c, id, his_patient_id, admin_user_id, "7", order.ID)
  9782. if result3101.Infcode == "0" {
  9783. if len(result3101.Output.Result) > 0 {
  9784. var errMsgs []string
  9785. for _, item := range result3101.Output.Result {
  9786. errMsgs = append(errMsgs, item.VolaCont)
  9787. }
  9788. c.ServeSuccessJSON(map[string]interface{}{
  9789. "failed_code": -10,
  9790. "msg": errMsgs,
  9791. })
  9792. return
  9793. } else {
  9794. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  9795. psn_info.VerifyNumber = strings.Replace(psn_info.VerifyNumber, "+", "%2B", -1)
  9796. bas := strings.Split(psn_info.CardInfo, "|")
  9797. if his.IdCardType == 1 {
  9798. cert_no = bas[2]
  9799. } else if his.IdCardType == 3 {
  9800. cert_no = his.Certno
  9801. psn_info.VerifyNumber = his.Certno + "|" + psn_info.VerifyNumber
  9802. } else if his.IdCardType == 4 {
  9803. cert_no = his.Certno
  9804. psn_info.VerifyNumber = psn_info.VerifyNumber
  9805. }
  9806. var api string
  9807. if miConfig.MdtrtareaAdmvs == "320921" {
  9808. api = "http://192.168.2.3:9532/" + "jsyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  9809. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  9810. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  9811. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  9812. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  9813. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  9814. "&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
  9815. } else {
  9816. api = "http://192.168.5.251:9532/" + "jsyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  9817. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  9818. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  9819. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  9820. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  9821. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  9822. "&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
  9823. }
  9824. resp, requestErr := http.Get(api)
  9825. if requestErr != nil {
  9826. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9827. return
  9828. }
  9829. body, ioErr := ioutil.ReadAll(resp.Body)
  9830. if ioErr != nil {
  9831. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  9832. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9833. return
  9834. }
  9835. var respJSON map[string]interface{}
  9836. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  9837. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  9838. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9839. return
  9840. }
  9841. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  9842. result, _ := json.Marshal(respJSON)
  9843. if err := json.Unmarshal([]byte(result), &resSeven10265); err != nil {
  9844. utils.ErrorLog("解析失败:%v", err)
  9845. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9846. return
  9847. }
  9848. res.InfRefmsgid = resSeven10265.InfRefmsgid
  9849. res.Output = resSeven10265.Output
  9850. res.ErrMsg = resSeven10265.ErrMsg
  9851. res.Cainfo = resSeven10265.Cainfo
  9852. res.WarnMsg = resSeven10265.WarnMsg
  9853. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  9854. res.Infcode = infocode
  9855. }
  9856. }
  9857. } else if miConfig.MdtrtareaAdmvs == "350500" {
  9858. var cert_no string
  9859. if his.IdCardType == 4 {
  9860. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  9861. cert_no = psn_info.VerifyNumber
  9862. 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)
  9863. } else if his.IdCardType == 1 {
  9864. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  9865. cert_no = strings.Split(psn_info.CardInfo, "|")[0]
  9866. 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)
  9867. }
  9868. //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)
  9869. var dat map[string]interface{}
  9870. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  9871. fmt.Println(dat)
  9872. } else {
  9873. fmt.Println(err)
  9874. }
  9875. saveLog(result2, src_resquest, "2207", "结算")
  9876. userJSONBytes, _ := json.Marshal(dat)
  9877. if err := json.Unmarshal(userJSONBytes, &resSeven10265); err != nil {
  9878. utils.ErrorLog("解析失败:%v", err)
  9879. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9880. return
  9881. }
  9882. res.InfRefmsgid = resSeven10265.InfRefmsgid
  9883. res.Output = resSeven10265.Output
  9884. res.ErrMsg = resSeven10265.ErrMsg
  9885. res.Cainfo = resSeven10265.Cainfo
  9886. res.WarnMsg = resSeven10265.WarnMsg
  9887. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  9888. res.Infcode = infocode
  9889. } else {
  9890. if miConfig.Code == "H15049901371" {
  9891. //赤峰地区国家医保医疗类别
  9892. //职工透析:医疗类别选特殊情况门诊990502
  9893. //居民定额血透门慢: 医疗类别选门诊慢病140104
  9894. var med_type string
  9895. if his.Insutype == "390" {
  9896. if reg_type == 14 {
  9897. med_type = "9933"
  9898. } else if reg_type == 11 {
  9899. med_type = "11"
  9900. }
  9901. } else if his.Insutype == "310" {
  9902. if reg_type == 14 {
  9903. med_type = "990502"
  9904. } else if reg_type == 11 {
  9905. med_type = "11"
  9906. }
  9907. }
  9908. 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, "")
  9909. } else {
  9910. if his.IdCardType == 4 {
  9911. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  9912. var token string
  9913. token = psn_info.VerifyNumber
  9914. 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)
  9915. } else {
  9916. 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, "")
  9917. }
  9918. }
  9919. //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)
  9920. var dat map[string]interface{}
  9921. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  9922. fmt.Println(dat)
  9923. } else {
  9924. fmt.Println(err)
  9925. }
  9926. saveLog(result2, src_resquest, "2207", "结算")
  9927. userJSONBytes, _ := json.Marshal(dat)
  9928. if miConfig.Code == "H15049901371" {
  9929. if err := json.Unmarshal(userJSONBytes, &resSeven10265); err != nil {
  9930. utils.ErrorLog("解析失败:%v", err)
  9931. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9932. return
  9933. }
  9934. res.InfRefmsgid = resSeven10265.InfRefmsgid
  9935. res.Output = resSeven10265.Output
  9936. res.ErrMsg = resSeven10265.ErrMsg
  9937. res.Cainfo = resSeven10265.Cainfo
  9938. res.WarnMsg = resSeven10265.WarnMsg
  9939. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  9940. res.Infcode = infocode
  9941. } else {
  9942. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  9943. utils.ErrorLog("解析失败:%v", err)
  9944. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9945. return
  9946. }
  9947. }
  9948. }
  9949. if res.Infcode != 0 {
  9950. errlog := &models.HisOrderError{
  9951. UserOrgId: adminUser.CurrentOrgId,
  9952. Ctime: time.Now().Unix(),
  9953. Mtime: time.Now().Unix(),
  9954. Number: chrg_bchno,
  9955. ErrMsg: res.ErrMsg,
  9956. Status: 1,
  9957. PatientId: id,
  9958. RecordTime: recordDateTime,
  9959. Stage: 6,
  9960. }
  9961. service.CreateErrMsgLog(errlog)
  9962. c.ServeSuccessJSON(map[string]interface{}{
  9963. "failed_code": -10,
  9964. "msg": res.ErrMsg,
  9965. })
  9966. return
  9967. } else {
  9968. order, _ := service.GetHisOrderTwo(adminUser.CurrentOrgId, chrg_bchno, id)
  9969. order.OrderStatus = 2
  9970. order.Status = 1
  9971. order.MdtrtId = res.Output.Setlinfo.MdtrtID
  9972. order.SetlId = res.Output.Setlinfo.SetlID
  9973. order.PsnNo = res.Output.Setlinfo.PsnNo
  9974. order.PsnName = res.Output.Setlinfo.PsnName
  9975. order.PsnCertType = res.Output.Setlinfo.PsnCertType
  9976. order.Certno = res.Output.Setlinfo.Certno
  9977. order.Gend = res.Output.Setlinfo.Gend
  9978. order.Naty = res.Output.Setlinfo.Naty
  9979. order.Age = res.Output.Setlinfo.Age
  9980. order.Insutype = res.Output.Setlinfo.Insutype
  9981. order.PsnType = res.Output.Setlinfo.PsnType
  9982. order.CvlservFlag = res.Output.Setlinfo.CvlservFlag
  9983. order.SetlTime = res.Output.Setlinfo.SetlTime
  9984. order.MdtrtCertType = res.Output.Setlinfo.MdtrtCertType
  9985. if res.Output.Setlinfo.MedType == "140101" {
  9986. order.MedType = "14"
  9987. } else {
  9988. order.MedType = res.Output.Setlinfo.MedType
  9989. }
  9990. if reg_type == 1112 {
  9991. order.MedType = "1112"
  9992. }
  9993. if reg_type == 1111 {
  9994. order.MedType = "1111"
  9995. }
  9996. order.MedfeeSumamt = res.Output.Setlinfo.MedfeeSumamt
  9997. order.FulamtOwnpayAmt = res.Output.Setlinfo.FulamtOwnpayAmt
  9998. order.OverlmtSelfPay = res.Output.Setlinfo.OverlmtSelfpay
  9999. order.PreselfpayAmt = res.Output.Setlinfo.PreselfpayAmt
  10000. order.InscpScpAmt = res.Output.Setlinfo.InscpScpAmt
  10001. order.ActPayDedc = res.Output.Setlinfo.ActPayDedc
  10002. order.HifpPay = res.Output.Setlinfo.HifpPay
  10003. order.CvlservPay = res.Output.Setlinfo.CvlservPay
  10004. order.PoolPropSelfpay = res.Output.Setlinfo.PoolPropSelfpay
  10005. order.HifesPay = res.Output.Setlinfo.HifesPay
  10006. order.HifobPay = res.Output.Setlinfo.HifobPay
  10007. order.MafPay = res.Output.Setlinfo.MafPay
  10008. order.HifmiPay = res.Output.Setlinfo.HifmiPay
  10009. order.OthPay = res.Output.Setlinfo.OthPay
  10010. order.FundPaySumamt = res.Output.Setlinfo.FundPaySumamt
  10011. order.PsnPartAmt = res.Output.Setlinfo.PsnPartAmt
  10012. order.AcctPay = res.Output.Setlinfo.AcctPay
  10013. order.PsnCashPay = res.Output.Setlinfo.PsnCashPay
  10014. order.HospPartAmt = res.Output.Setlinfo.HospPartAmt
  10015. order.Balc = res.Output.Setlinfo.Balc
  10016. order.AcctMulaidPay = res.Output.Setlinfo.AcctMulaidPay
  10017. order.MedinsSetlId = res.Output.Setlinfo.MedinsSetlID
  10018. order.ClrOptins = res.Output.Setlinfo.ClrOptins
  10019. order.ClrType = res.Output.Setlinfo.ClrType
  10020. order.ClrWay = res.Output.Setlinfo.ClrWay
  10021. order.Creator = order.Creator
  10022. order.Modify = roles.AdminUserId
  10023. order.RequestLog = src_resquest
  10024. setlDetail, _ := json.Marshal(res.Output.Setldetail)
  10025. detailStr := string(setlDetail)
  10026. order.SetlDetail = detailStr
  10027. err := service.UpdataOrderStatusTwo(chrg_bchno, adminUser.CurrentOrgId)
  10028. err = service.UpDateOrder(order)
  10029. if err == nil {
  10030. //判断是否使用了押金
  10031. if dec_way == "true" {
  10032. tmpstring := strconv.FormatInt(order.ID, 10)
  10033. order.Decimal = decimal
  10034. service.UpDateOrder(order)
  10035. //扣押金
  10036. errmsg = service.SpendDeposit(c.GetAdminUserInfo().CurrentOrgId, id, c.GetAdminUserInfo().AdminUser.Id, tmpstring, decimal)
  10037. if errmsg != nil {
  10038. c.ServeFailJsonSend(enums.ErrorCodeParamWrong, errmsg.Error())
  10039. return
  10040. }
  10041. }
  10042. c.ServeSuccessJSON(map[string]interface{}{
  10043. "msg": "结算成功",
  10044. })
  10045. } else {
  10046. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeAmountAccountException)
  10047. return
  10048. }
  10049. }
  10050. } else {
  10051. adminUser := c.GetAdminUserInfo()
  10052. errlog := &models.HisOrderError{
  10053. UserOrgId: adminUser.CurrentOrgId,
  10054. Ctime: time.Now().Unix(),
  10055. Mtime: time.Now().Unix(),
  10056. ErrMsg: res.ErrMsg,
  10057. Status: 1,
  10058. PatientId: id,
  10059. RecordTime: recordDateTime,
  10060. Stage: 4,
  10061. }
  10062. service.CreateErrMsgLog(errlog)
  10063. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeRegisterRepeatException)
  10064. return
  10065. }
  10066. } else {
  10067. adminUser := c.GetAdminUserInfo()
  10068. errlog := &models.HisOrderError{
  10069. UserOrgId: adminUser.CurrentOrgId,
  10070. Ctime: time.Now().Unix(),
  10071. Mtime: time.Now().Unix(),
  10072. ErrMsg: res.ErrMsg,
  10073. Status: 1,
  10074. PatientId: id,
  10075. RecordTime: recordDateTime,
  10076. Stage: 4,
  10077. }
  10078. service.CreateErrMsgLog(errlog)
  10079. c.ServeSuccessJSON(map[string]interface{}{
  10080. "failed_code": -10,
  10081. "msg": res.ErrMsg,
  10082. })
  10083. return
  10084. //c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCalOrderException)
  10085. //return
  10086. }
  10087. }
  10088. }
  10089. } else if tempOrder.ID > 0 {
  10090. if tempOrder.IsPre == 1 {
  10091. allTotal := fmt.Sprintf("%.2f", tempOrder.MedfeeSumamt)
  10092. var rf []*ResultFive
  10093. json.Unmarshal([]byte(his.Iinfo), &rf)
  10094. chrg_bchno := tempOrder.Number
  10095. cert_no := his.Certno
  10096. var insutypes []string
  10097. var insutype string
  10098. var is390 int = 0
  10099. var is310 int = 0
  10100. for _, item := range rf {
  10101. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  10102. insutypes = append(insutypes, item.Insutype)
  10103. }
  10104. }
  10105. if len(insutypes) == 1 {
  10106. insutype = insutypes[0]
  10107. } else {
  10108. for _, i := range insutypes {
  10109. if i == "390" {
  10110. is390 = 1
  10111. }
  10112. if i == "310" {
  10113. is310 = 1
  10114. }
  10115. }
  10116. }
  10117. if is390 == 1 {
  10118. insutype = "390"
  10119. }
  10120. if is310 == 1 {
  10121. insutype = "310"
  10122. }
  10123. if len(insutypes) == 0 {
  10124. insutype = "310"
  10125. }
  10126. if len(insutypes) == 2 {
  10127. insutype = strconv.FormatInt(his.SocialType, 10)
  10128. }
  10129. //insutype = "390"
  10130. if his.IdCardType == 1 {
  10131. // cert_no = his.MedicalInsuranceNumber
  10132. cert_no = his.Certno
  10133. } else {
  10134. cert_no = his.Certno
  10135. }
  10136. var res ResultSeven
  10137. var resSeven10265 ResultSeven10265
  10138. var src_resquest string
  10139. var result2 string
  10140. if miConfig.MdtrtareaAdmvs == "421300" {
  10141. api := "http://192.168.124.4:9532/" + "hbyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  10142. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  10143. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  10144. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  10145. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  10146. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  10147. "&insutype=" + insutype + "&total=" + allTotal + "&med_type=" + strconv.FormatInt(reg_type, 10) + "&acct_used_flag=" + acct_used_flag
  10148. resp, requestErr := http.Get(api)
  10149. if requestErr != nil {
  10150. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10151. return
  10152. }
  10153. body, ioErr := ioutil.ReadAll(resp.Body)
  10154. if ioErr != nil {
  10155. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  10156. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10157. return
  10158. }
  10159. var respJSON map[string]interface{}
  10160. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  10161. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  10162. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10163. return
  10164. }
  10165. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  10166. result, _ := json.Marshal(respJSON)
  10167. fmt.Println("log")
  10168. fmt.Println(string(result))
  10169. if err := json.Unmarshal([]byte(result), &res); err != nil {
  10170. utils.ErrorLog("解析失败:%v", err)
  10171. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10172. return
  10173. }
  10174. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  10175. result3101 := Check3102(c, id, his_patient_id, admin_user_id, "7", tempOrder.ID)
  10176. if result3101.Infcode == "0" {
  10177. if len(result3101.Output.Result) > 0 {
  10178. var errMsgs []string
  10179. for _, item := range result3101.Output.Result {
  10180. errMsgs = append(errMsgs, item.VolaCont)
  10181. }
  10182. c.ServeSuccessJSON(map[string]interface{}{
  10183. "failed_code": -10,
  10184. "msg": errMsgs,
  10185. })
  10186. return
  10187. } else {
  10188. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  10189. psn_info.VerifyNumber = strings.Replace(psn_info.VerifyNumber, "+", "%2B", -1)
  10190. bas := strings.Split(psn_info.CardInfo, "|")
  10191. if his.IdCardType == 1 {
  10192. cert_no = bas[2]
  10193. } else if his.IdCardType == 3 {
  10194. cert_no = his.Certno
  10195. psn_info.VerifyNumber = his.Certno + "|" + psn_info.VerifyNumber
  10196. } else if his.IdCardType == 4 {
  10197. cert_no = his.Certno
  10198. psn_info.VerifyNumber = psn_info.VerifyNumber
  10199. }
  10200. //江苏地区国家医保医疗类别
  10201. //职工透析:医疗类别选特殊情况门诊9933
  10202. //居民血透门慢: 医疗类别选门诊慢病1402
  10203. //var med_type string
  10204. //if his.Insutype == "310" {
  10205. // if reg_type == 14 {
  10206. // med_type = "9933"
  10207. // } else if reg_type == 11 {
  10208. // med_type = "11"
  10209. //
  10210. // }
  10211. //} else if his.Insutype == "390" {
  10212. // if reg_type == 14 {
  10213. // med_type = "1402"
  10214. // } else if reg_type == 11 {
  10215. // med_type = "11"
  10216. // }
  10217. //}
  10218. var api string
  10219. if miConfig.MdtrtareaAdmvs == "320921" {
  10220. api = "http://192.168.2.3:9532/" + "jsyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  10221. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  10222. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  10223. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  10224. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  10225. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  10226. "&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
  10227. //req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  10228. } else {
  10229. //req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  10230. api = "http://192.168.5.251:9532/" + "jsyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  10231. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  10232. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  10233. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  10234. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  10235. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  10236. "&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
  10237. }
  10238. resp, requestErr := http.Get(api)
  10239. if requestErr != nil {
  10240. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10241. return
  10242. }
  10243. body, ioErr := ioutil.ReadAll(resp.Body)
  10244. if ioErr != nil {
  10245. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  10246. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10247. return
  10248. }
  10249. var respJSON map[string]interface{}
  10250. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  10251. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  10252. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10253. return
  10254. }
  10255. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  10256. result, _ := json.Marshal(respJSON)
  10257. fmt.Println("log")
  10258. fmt.Println(string(result))
  10259. if err := json.Unmarshal([]byte(result), &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. }
  10272. }
  10273. } else if miConfig.MdtrtareaAdmvs == "350500" {
  10274. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  10275. var cert_no string
  10276. if his.IdCardType == 1 {
  10277. cert_no = strings.Split(psn_info.CardInfo, "|")[0]
  10278. } else {
  10279. cert_no = psn_info.VerifyNumber
  10280. }
  10281. 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)
  10282. var dat map[string]interface{}
  10283. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  10284. fmt.Println(dat)
  10285. } else {
  10286. fmt.Println(err)
  10287. }
  10288. saveLog(result2, src_resquest, "2207", "结算")
  10289. userJSONBytes, _ := json.Marshal(dat)
  10290. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  10291. utils.ErrorLog("解析失败:%v", err)
  10292. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10293. return
  10294. }
  10295. } else if miConfig.MdtrtareaAdmvs == "360399" {
  10296. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  10297. var cert_no string
  10298. if his.IdCardType == 1 {
  10299. cert_no = strings.Split(psn_info.CardInfo, "|")[0]
  10300. } else if his.IdCardType == 2 {
  10301. cert_no = his.IdCardNo
  10302. } else {
  10303. cert_no = psn_info.VerifyNumber
  10304. }
  10305. 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, "")
  10306. var dat map[string]interface{}
  10307. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  10308. fmt.Println(dat)
  10309. } else {
  10310. fmt.Println(err)
  10311. }
  10312. saveLog(result2, src_resquest, "2207", "结算")
  10313. userJSONBytes, _ := json.Marshal(dat)
  10314. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  10315. utils.ErrorLog("解析失败:%v", err)
  10316. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10317. return
  10318. }
  10319. } else if miConfig.MdtrtareaAdmvs == "430800" {
  10320. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  10321. var cert_no string
  10322. if his.IdCardType == 1 {
  10323. cert_no = strings.Split(psn_info.CardInfo, "|")[0]
  10324. } else if his.IdCardType == 2 {
  10325. cert_no = his.IdCardNo
  10326. } else {
  10327. cert_no = psn_info.VerifyNumber
  10328. }
  10329. 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, "")
  10330. var dat map[string]interface{}
  10331. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  10332. fmt.Println(dat)
  10333. } else {
  10334. fmt.Println(err)
  10335. }
  10336. saveLog(result2, src_resquest, "2207", "结算")
  10337. userJSONBytes, _ := json.Marshal(dat)
  10338. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  10339. utils.ErrorLog("解析失败:%v", err)
  10340. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10341. return
  10342. }
  10343. } else {
  10344. var src_resquest string
  10345. if miConfig.Code == "H15049901371" {
  10346. //赤峰地区国家医保医疗类别
  10347. //职工透析:医疗类别选特殊情况门诊990502
  10348. //居民定额血透门慢: 医疗类别选门诊慢病140104
  10349. var med_type string
  10350. if his.Insutype == "390" {
  10351. if reg_type == 14 {
  10352. med_type = "9933"
  10353. } else if reg_type == 11 {
  10354. med_type = "11"
  10355. }
  10356. } else if his.Insutype == "310" {
  10357. if reg_type == 14 {
  10358. med_type = "990502"
  10359. } else if reg_type == 11 {
  10360. med_type = "11"
  10361. }
  10362. }
  10363. 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, "")
  10364. } else {
  10365. if his.IdCardType == 4 {
  10366. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  10367. token := psn_info.VerifyNumber
  10368. result2, src_resquest = service.Gdyb2207(his.PsnNo, his.Number, chrg_bchno, cert_no, insutype, allTotal, miConfig.OrgName, roles.UserName, miConfig.Code, his.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, strconv.FormatInt(reg_type, 10), his.IdCardType, tempOrder.FulamtOwnpayAmt, tempOrder.OverlmtSelfPay, tempOrder.PreselfpayAmt, tempOrder.InscpScpAmt, his.IdType, acct_used_flag, token)
  10369. } else {
  10370. 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, "")
  10371. }
  10372. }
  10373. var dat map[string]interface{}
  10374. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  10375. fmt.Println(dat)
  10376. } else {
  10377. fmt.Println(err)
  10378. }
  10379. saveLog(result2, src_resquest, "2207", "结算")
  10380. userJSONBytes, _ := json.Marshal(dat)
  10381. if miConfig.Code == "H15049901371" {
  10382. if err := json.Unmarshal(userJSONBytes, &resSeven10265); err != nil {
  10383. utils.ErrorLog("解析失败:%v", err)
  10384. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10385. return
  10386. }
  10387. res.InfRefmsgid = resSeven10265.InfRefmsgid
  10388. res.Output = resSeven10265.Output
  10389. res.ErrMsg = resSeven10265.ErrMsg
  10390. res.Cainfo = resSeven10265.Cainfo
  10391. res.WarnMsg = resSeven10265.WarnMsg
  10392. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  10393. res.Infcode = infocode
  10394. } else {
  10395. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  10396. utils.ErrorLog("解析失败:%v", err)
  10397. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10398. return
  10399. }
  10400. }
  10401. }
  10402. if res.Infcode != 0 {
  10403. errlog := &models.HisOrderError{
  10404. UserOrgId: adminUser.CurrentOrgId,
  10405. Ctime: time.Now().Unix(),
  10406. Mtime: time.Now().Unix(),
  10407. Number: chrg_bchno,
  10408. ErrMsg: res.ErrMsg,
  10409. Status: 1,
  10410. PatientId: id,
  10411. RecordTime: recordDateTime,
  10412. Stage: 6,
  10413. }
  10414. service.CreateErrMsgLog(errlog)
  10415. c.ServeSuccessJSON(map[string]interface{}{
  10416. "failed_code": -10,
  10417. "msg": res.ErrMsg,
  10418. })
  10419. return
  10420. } else {
  10421. order, _ := service.GetHisOrderTwo(adminUser.CurrentOrgId, chrg_bchno, id)
  10422. order.OrderStatus = 2
  10423. order.MdtrtId = res.Output.Setlinfo.MdtrtID
  10424. order.SetlId = res.Output.Setlinfo.SetlID
  10425. order.PsnNo = res.Output.Setlinfo.PsnNo
  10426. order.PsnName = res.Output.Setlinfo.PsnName
  10427. order.PsnCertType = res.Output.Setlinfo.PsnCertType
  10428. order.Certno = res.Output.Setlinfo.Certno
  10429. order.Gend = res.Output.Setlinfo.Gend
  10430. order.Naty = res.Output.Setlinfo.Naty
  10431. order.Age = res.Output.Setlinfo.Age
  10432. order.Insutype = res.Output.Setlinfo.Insutype
  10433. order.PsnType = res.Output.Setlinfo.PsnType
  10434. order.CvlservFlag = res.Output.Setlinfo.CvlservFlag
  10435. order.SetlTime = res.Output.Setlinfo.SetlTime
  10436. order.MdtrtCertType = res.Output.Setlinfo.MdtrtCertType
  10437. order.PayWays = pay_ways
  10438. order.AcctUsedFlag = acct_used_flag
  10439. order.WechatPay = wechat_pay
  10440. order.AliPay = ali_pay
  10441. order.JifenPay = jifen_pay
  10442. order.BandCardPay = band_card_pay
  10443. order.CashPay = cash_pay
  10444. order.OthDesc = oth_desc
  10445. //order.MedType = res.Output.Setlinfo.MedType
  10446. if reg_type == 1112 {
  10447. order.MedType = "1112"
  10448. }
  10449. if reg_type == 1111 {
  10450. order.MedType = "1111"
  10451. }
  10452. order.MedfeeSumamt = res.Output.Setlinfo.MedfeeSumamt
  10453. order.FulamtOwnpayAmt = res.Output.Setlinfo.FulamtOwnpayAmt
  10454. order.OverlmtSelfPay = res.Output.Setlinfo.OverlmtSelfpay
  10455. order.PreselfpayAmt = res.Output.Setlinfo.PreselfpayAmt
  10456. order.InscpScpAmt = res.Output.Setlinfo.InscpScpAmt
  10457. order.ActPayDedc = res.Output.Setlinfo.ActPayDedc
  10458. order.HifpPay = res.Output.Setlinfo.HifpPay
  10459. order.CvlservPay = res.Output.Setlinfo.CvlservPay
  10460. order.PoolPropSelfpay = res.Output.Setlinfo.PoolPropSelfpay
  10461. order.HifesPay = res.Output.Setlinfo.HifesPay
  10462. order.HifobPay = res.Output.Setlinfo.HifobPay
  10463. order.MafPay = res.Output.Setlinfo.MafPay
  10464. order.HifmiPay = res.Output.Setlinfo.HifmiPay
  10465. order.OthPay = res.Output.Setlinfo.OthPay
  10466. order.FundPaySumamt = res.Output.Setlinfo.FundPaySumamt
  10467. order.PsnPartAmt = res.Output.Setlinfo.PsnPartAmt
  10468. order.AcctPay = res.Output.Setlinfo.AcctPay
  10469. order.PsnCashPay = res.Output.Setlinfo.PsnCashPay
  10470. order.HospPartAmt = res.Output.Setlinfo.HospPartAmt
  10471. order.Balc = res.Output.Setlinfo.Balc
  10472. order.AcctMulaidPay = res.Output.Setlinfo.AcctMulaidPay
  10473. order.MedinsSetlId = res.Output.Setlinfo.MedinsSetlID
  10474. order.ClrOptins = res.Output.Setlinfo.ClrOptins
  10475. order.ClrWay = res.Output.Setlinfo.ClrWay
  10476. order.Creator = order.Creator
  10477. order.Modify = roles.AdminUserId
  10478. order.RequestLog = src_resquest
  10479. order.Diagnosis = diagnosis_id
  10480. setlDetail, _ := json.Marshal(res.Output.Setldetail)
  10481. detailStr := string(setlDetail)
  10482. order.SetlDetail = detailStr
  10483. err := service.UpdataOrderStatusTwo(chrg_bchno, adminUser.CurrentOrgId)
  10484. err = service.UpDateOrder(order)
  10485. if err == nil {
  10486. //判断是否使用了押金
  10487. if dec_way == "true" {
  10488. tmpstring := strconv.FormatInt(order.ID, 10)
  10489. //扣押金
  10490. order.Decimal = decimal
  10491. service.UpDateOrder(order)
  10492. errmsg = service.SpendDeposit(c.GetAdminUserInfo().CurrentOrgId, id, c.GetAdminUserInfo().AdminUser.Id, tmpstring, decimal)
  10493. if errmsg != nil {
  10494. c.ServeFailJsonSend(enums.ErrorCodeParamWrong, errmsg.Error())
  10495. return
  10496. }
  10497. }
  10498. c.ServeSuccessJSON(map[string]interface{}{
  10499. "msg": "结算成功",
  10500. })
  10501. } else {
  10502. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeAmountAccountException)
  10503. return
  10504. }
  10505. }
  10506. }
  10507. }
  10508. }
  10509. //func (c *HisApiController) GetPreUploadInfo() {
  10510. // id, _ := c.GetInt64("id")
  10511. // record_time := c.GetString("record_time")
  10512. // settle_accounts_type, _ := c.GetInt64("settle_accounts_type")
  10513. // admin_user_id, _ := c.GetInt64("admin_user_id")
  10514. //
  10515. // timeLayout := "2006-01-02"
  10516. // loc, _ := time.LoadLocation("Local")
  10517. // theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  10518. // if err != nil {
  10519. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  10520. // return
  10521. // }
  10522. // recordDateTime := theTime.Unix()
  10523. // adminUser := c.GetAdminUserInfo()
  10524. //
  10525. // var prescriptions []*models.HisPrescription
  10526. //
  10527. // var start_time int64
  10528. // var end_time int64
  10529. //
  10530. // data := make(map[string]interface{})
  10531. // if settle_accounts_type == 1 { //日结
  10532. // prescriptions, _ = service.GetHisPrescription(adminUser.CurrentOrgId, id, recordDateTime)
  10533. // data["pre"] = prescriptions
  10534. //
  10535. // } else { //月结
  10536. // start_time_str := c.GetString("start_time")
  10537. // end_time_str := c.GetString("end_time")
  10538. // timeLayout := "2006-01-02"
  10539. // loc, _ := time.LoadLocation("Local")
  10540. // theStartTime, err := time.ParseInLocation(timeLayout+" 15:04:05", start_time_str+" 00:00:00", loc)
  10541. // if err != nil {
  10542. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  10543. // return
  10544. // }
  10545. // recordStartTime := theStartTime.Unix()
  10546. // start_time = recordStartTime
  10547. // theEndTime, err := time.ParseInLocation(timeLayout+" 15:04:05", end_time_str+" 00:00:00", loc)
  10548. // if err != nil {
  10549. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  10550. // return
  10551. // }
  10552. // recordEndTime := theEndTime.Unix()
  10553. // end_time = recordEndTime
  10554. // prescriptions, _ = service.GetMonthHisPrescription(adminUser.CurrentOrgId, id, recordStartTime, recordEndTime)
  10555. // data["pre"] = prescriptions
  10556. //
  10557. // }
  10558. //
  10559. // roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  10560. //
  10561. // his, _ := service.GetVMHisPatientInfo(adminUser.CurrentOrgId, id, recordDateTime)
  10562. // timestamp := time.Now().Unix()
  10563. // tempTime := time.Unix(timestamp, 0)
  10564. // timeFormat := tempTime.Format("20060102150405")
  10565. // chrgBchno := rand.Intn(100000) + 10000
  10566. // chrg_bchno := timeFormat + strconv.FormatInt(int64(chrgBchno), 10) + strconv.FormatInt(his.PatientId, 10)
  10567. // miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  10568. // patientPrescription, _ := service.FindPatientPrescriptionInfo(adminUser.CurrentOrgId, id, recordDateTime)
  10569. // department, _ := service.GetDepartMentDetail(patientPrescription.Departments)
  10570. // strconv.FormatInt(his.PatientId, 10)
  10571. // client := &http.Client{}
  10572. // data["psn_no"] = his.PsnNo
  10573. // data["mdtrt_id"] = his.Number
  10574. // data["chrg_bchno"] = chrg_bchno
  10575. // data["org_name"] = miConfig.OrgName
  10576. // data["doctor"] = roles.UserName
  10577. // data["doctor_id"] = strconv.FormatInt(roles.AdminUserId, 10)
  10578. // data["dept"] = strconv.FormatInt(patientPrescription.Departments, 10)
  10579. // data["fixmedins_code"] = miConfig.Code
  10580. // data["dept_code"] = department.Number
  10581. // data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  10582. // data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  10583. // data["secret_key"] = miConfig.SecretKey
  10584. // var ids []int64
  10585. //
  10586. // for _, item := range prescriptions {
  10587. // ids = append(ids, item.ID)
  10588. // }
  10589. // config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  10590. // if config.IsOpen == 1 { //对接了医保,走医保流程
  10591. // bytesData, _ := json.Marshal(data)
  10592. // req, _ := http.NewRequest("POST", "http://127.0.0.1:9532/"+"gdyb/five", bytes.NewReader(bytesData))
  10593. // resp, _ := client.Do(req)
  10594. // defer resp.Body.Close()
  10595. // body, ioErr := ioutil.ReadAll(resp.Body)
  10596. // if ioErr != nil {
  10597. // utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  10598. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10599. // return
  10600. // }
  10601. // var respJSON map[string]interface{}
  10602. // if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  10603. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  10604. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10605. // return
  10606. // }
  10607. //
  10608. // respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  10609. // userJSONBytes, _ := json.Marshal(respJSON)
  10610. // var res ResultFour
  10611. // if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  10612. // utils.ErrorLog("解析失败:%v", err)
  10613. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10614. // return
  10615. // }
  10616. //
  10617. // if res.Infcode == 0 {
  10618. // order := &models.HisOrder{
  10619. // UserOrgId: adminUser.CurrentOrgId,
  10620. // HisPatientId: his.ID,
  10621. // PatientId: his.PatientId,
  10622. // SettleAccountsDate: recordDateTime,
  10623. // Ctime: time.Now().Unix(),
  10624. // Mtime: time.Now().Unix(),
  10625. // Status: 1,
  10626. // Number: chrg_bchno,
  10627. // Infcode: res.Infcode,
  10628. // WarnMsg: res.WarnMsg,
  10629. // Cainfo: res.Cainfo,
  10630. // ErrMsg: res.ErrMsg,
  10631. // RespondTime: res.RefmsgTime,
  10632. // InfRefmsgid: res.InfRefmsgid,
  10633. // OrderStatus: 1,
  10634. // IsMedicineInsurance: 1,
  10635. // SettleType: settle_accounts_type,
  10636. // SettleStartTime: start_time,
  10637. // SettleEndTime: end_time,
  10638. // Creator: roles.ID,
  10639. // Modify: roles.ID,
  10640. // PType: 2,
  10641. // }
  10642. // err = service.CreateOrder(order)
  10643. // if err != nil {
  10644. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCreatePreOrderException)
  10645. // return
  10646. // }
  10647. //
  10648. // for _, item := range res.Output.Result {
  10649. // temp := strings.Split(item.FeedetlSn, "-")
  10650. // var advice_id int64 = 0
  10651. // var project_id int64 = 0
  10652. // var types int64 = 0
  10653. //
  10654. // id, _ := strconv.ParseInt(temp[2], 10, 64)
  10655. // types, _ = strconv.ParseInt(temp[1], 10, 64)
  10656. //
  10657. // if temp[1] == "1" {
  10658. // advice_id = id
  10659. // project_id = 0
  10660. // } else if temp[1] == "2" {
  10661. // advice_id = 0
  10662. // project_id = id
  10663. // }
  10664. //
  10665. // info := &models.HisOrderInfo{
  10666. // OrderNumber: order.Number,
  10667. // FeedetlSn: item.FeedetlSn,
  10668. // UploadDate: time.Now().Unix(),
  10669. // AdviceId: advice_id,
  10670. // DetItemFeeSumamt: item.DetItemFeeSumamt,
  10671. // Cnt: item.Cnt,
  10672. // Pric: float64(item.Pric),
  10673. // PatientId: his.PatientId,
  10674. // PricUplmtAmt: item.PricUplmtAmt,
  10675. // SelfpayProp: item.SelfpayProp,
  10676. // FulamtOwnpayAmt: item.FulamtOwnpayAmt,
  10677. // OverlmtAmt: item.OverlmtAmt,
  10678. // PreselfpayAmt: item.PreselfpayAmt,
  10679. // BasMednFlag: item.BasMednFlag,
  10680. // MedChrgitmType: item.MedChrgitmType,
  10681. // HiNegoDrugFlag: item.HiNegoDrugFlag,
  10682. // Status: 1,
  10683. // Memo: item.Memo,
  10684. // Mtime: time.Now().Unix(),
  10685. // InscpScpAmt: item.InscpScpAmt,
  10686. // DrtReimFlag: item.DrtReimFlag,
  10687. // Ctime: time.Now().Unix(),
  10688. // ListSpItemFlag: item.ListSpItemFlag,
  10689. // ChldMedcFlag: item.ChldMedcFlag,
  10690. // LmtUsedFlag: item.LmtUsedFlag,
  10691. // ChrgitmLv: item.ChrgitmLv,
  10692. // UserOrgId: adminUser.CurrentOrgId,
  10693. // HisPatientId: his.ID,
  10694. // OrderId: order.ID,
  10695. // ProjectId: project_id,
  10696. // Type: types,
  10697. // }
  10698. // service.CreateOrderInfo(info)
  10699. //
  10700. // }
  10701. // service.UpDatePrescriptionNumber(adminUser.CurrentOrgId, ids, chrg_bchno)
  10702. // service.UpDatePrescriptionInfoNumber(adminUser.CurrentOrgId, patientPrescription.PatientId, chrg_bchno, recordDateTime)
  10703. //
  10704. // var total float64
  10705. // for _, item := range prescriptions {
  10706. // if item.Type == 1 { //药品
  10707. // for _, subItem := range item.HisDoctorAdviceInfo {
  10708. // total = total + (subItem.Price * subItem.PrescribingNumber)
  10709. // }
  10710. // }
  10711. // if item.Type == 2 { //项目
  10712. // for _, subItem := range item.HisPrescriptionProject {
  10713. // total = total + (subItem.Price * float64(subItem.Count))
  10714. // }
  10715. // }
  10716. // }
  10717. //
  10718. // for _, item := range prescriptions {
  10719. // for _, subItem := range item.HisAdditionalCharge {
  10720. // total = total + (subItem.Price * float64(subItem.Count))
  10721. // }
  10722. // }
  10723. //
  10724. // allTotal := fmt.Sprintf("%.2f", total)
  10725. // if res.Infcode == 0 {
  10726. // var rf []*ResultFive
  10727. // json.Unmarshal([]byte(his.Iinfo), &rf)
  10728. // psn_no := his.PsnNo
  10729. // mdtrt_id := his.Number
  10730. // chrg_bchno := chrg_bchno
  10731. // cert_no := his.Certno
  10732. // insutype := rf[0].Insutype
  10733. //
  10734. // if his.IdCardType == 1 {
  10735. // cert_no = his.MedicalInsuranceNumber
  10736. //
  10737. // } else {
  10738. //
  10739. // cert_no = his.Certno
  10740. //
  10741. // }
  10742. //
  10743. // api := "http://127.0.0.1:9532/" + "gdyb/seven?cert_no=" + cert_no + "&insutype=" +
  10744. // insutype + "&psn_no=" + psn_no + "&chrg_bchno=" + chrg_bchno + "&mdtrt_id=" + mdtrt_id +
  10745. // "&total=" + allTotal + "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code + "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" +
  10746. // miConfig.SecretKey + "&med_type=" + strconv.FormatInt(patientPrescription.RegisterType, 10) + "&id_card_type=" + strconv.FormatInt(int64(his.IdCardType), 10)
  10747. // resp, requestErr := http.Get(api)
  10748. // if requestErr != nil {
  10749. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10750. // return
  10751. // }
  10752. // defer resp.Body.Close()
  10753. // body, ioErr := ioutil.ReadAll(resp.Body)
  10754. // if ioErr != nil {
  10755. // utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  10756. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10757. // return
  10758. // }
  10759. // var respJSON map[string]interface{}
  10760. // if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  10761. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  10762. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10763. // return
  10764. // }
  10765. // fmt.Println(respJSON)
  10766. // respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  10767. // userJSONBytes, _ := json.Marshal(respJSON)
  10768. // var res ResultSeven
  10769. // if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  10770. // utils.ErrorLog("解析失败:%v", err)
  10771. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10772. // return
  10773. // }
  10774. // if res.Infcode != 0 {
  10775. // errlog := &models.HisOrderError{
  10776. // UserOrgId: adminUser.CurrentOrgId,
  10777. // Ctime: time.Now().Unix(),
  10778. // Mtime: time.Now().Unix(),
  10779. // Number: chrg_bchno,
  10780. // ErrMsg: res.ErrMsg,
  10781. // Status: 1,
  10782. // PatientId: id,
  10783. // RecordTime: recordDateTime,
  10784. // Stage: 7,
  10785. // }
  10786. // service.CreateErrMsgLog(errlog)
  10787. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeRegisterRepeatException)
  10788. // return
  10789. // } else {
  10790. // order, _ := service.GetHisOrderTwo(adminUser.CurrentOrgId, chrg_bchno, id)
  10791. // order.OrderStatus = 1
  10792. // order.MdtrtId = res.Output.Setlinfo.MdtrtID
  10793. // order.SetlId = res.Output.Setlinfo.SetlID
  10794. // order.PsnNo = res.Output.Setlinfo.PsnNo
  10795. // order.PsnName = res.Output.Setlinfo.PsnName
  10796. // order.PsnCertType = res.Output.Setlinfo.PsnCertType
  10797. // order.Certno = res.Output.Setlinfo.Certno
  10798. // order.Gend = res.Output.Setlinfo.Gend
  10799. // order.Naty = res.Output.Setlinfo.Naty
  10800. // order.Age = res.Output.Setlinfo.Age
  10801. // order.Insutype = res.Output.Setlinfo.Insutype
  10802. // order.PsnType = res.Output.Setlinfo.PsnType
  10803. // order.CvlservFlag = res.Output.Setlinfo.CvlservFlag
  10804. // order.SetlTime = res.Output.Setlinfo.SetlTime
  10805. // order.MdtrtCertType = res.Output.Setlinfo.MdtrtCertType
  10806. // order.MedType = res.Output.Setlinfo.MedType
  10807. // order.MedfeeSumamt = res.Output.Setlinfo.MedfeeSumamt
  10808. // order.FulamtOwnpayAmt = res.Output.Setlinfo.FulamtOwnpayAmt
  10809. // order.OverlmtSelfPay = res.Output.Setlinfo.OverlmtSelfpay
  10810. // order.PreselfpayAmt = res.Output.Setlinfo.PreselfpayAmt
  10811. // order.InscpScpAmt = res.Output.Setlinfo.InscpScpAmt
  10812. // order.ActPayDedc = res.Output.Setlinfo.ActPayDedc
  10813. // order.HifpPay = res.Output.Setlinfo.HifpPay
  10814. // order.CvlservPay = res.Output.Setlinfo.CvlservPay
  10815. // order.PoolPropSelfpay = res.Output.Setlinfo.PoolPropSelfpay
  10816. // order.HifesPay = res.Output.Setlinfo.HifesPay
  10817. // order.HifobPay = res.Output.Setlinfo.HifobPay
  10818. // order.MafPay = res.Output.Setlinfo.MafPay
  10819. // order.OthPay = res.Output.Setlinfo.OthPay
  10820. // order.FundPaySumamt = res.Output.Setlinfo.FundPaySumamt
  10821. // order.PsnPartAmt = res.Output.Setlinfo.PsnPartAmt
  10822. // order.AcctPay = res.Output.Setlinfo.AcctPay
  10823. // order.PsnCashPay = res.Output.Setlinfo.PsnCashPay
  10824. // order.HospPartAmt = res.Output.Setlinfo.HospPartAmt
  10825. // order.Balc = res.Output.Setlinfo.Balc
  10826. // order.AcctMulaidPay = res.Output.Setlinfo.AcctMulaidPay
  10827. // order.MedinsSetlId = res.Output.Setlinfo.MedinsSetlID
  10828. // order.ClrOptins = res.Output.Setlinfo.ClrOptins
  10829. // order.ClrWay = res.Output.Setlinfo.ClrWay
  10830. // order.Creator = order.Creator
  10831. // order.Modify = roles.ID
  10832. // setlDetail, _ := json.Marshal(res.Output.Setldetail)
  10833. // detailStr := string(setlDetail)
  10834. // order.SetlDetail = detailStr
  10835. // //err := service.UpdataOrderStatusTwo(chrg_bchno, adminUser.CurrentOrgId)
  10836. // err = service.UpDateOrder(order)
  10837. // if err == nil {
  10838. // c.ServeSuccessJSON(map[string]interface{}{
  10839. // "msg": "预结算成功",
  10840. // })
  10841. // } else {
  10842. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeAmountAccountException)
  10843. // return
  10844. // }
  10845. // }
  10846. // } else {
  10847. // adminUser := c.GetAdminUserInfo()
  10848. // errlog := &models.HisOrderError{
  10849. // UserOrgId: adminUser.CurrentOrgId,
  10850. // Ctime: time.Now().Unix(),
  10851. // Mtime: time.Now().Unix(),
  10852. // ErrMsg: res.ErrMsg,
  10853. // Status: 1,
  10854. // PatientId: id,
  10855. // RecordTime: recordDateTime,
  10856. // Stage: 4,
  10857. // }
  10858. // service.CreateErrMsgLog(errlog)
  10859. //
  10860. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeRegisterRepeatException)
  10861. // return
  10862. // }
  10863. // } else {
  10864. // adminUser := c.GetAdminUserInfo()
  10865. // errlog := &models.HisOrderError{
  10866. // UserOrgId: adminUser.CurrentOrgId,
  10867. // Ctime: time.Now().Unix(),
  10868. // Mtime: time.Now().Unix(),
  10869. // ErrMsg: res.ErrMsg,
  10870. // Status: 1,
  10871. // PatientId: id,
  10872. // RecordTime: recordDateTime,
  10873. // Stage: 4,
  10874. // }
  10875. // service.CreateErrMsgLog(errlog)
  10876. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCalOrderException)
  10877. // return
  10878. // }
  10879. //
  10880. // } else {
  10881. // var total float64
  10882. // for _, item := range prescriptions {
  10883. // if item.Type == 1 { //药品
  10884. // for _, subItem := range item.HisDoctorAdviceInfo {
  10885. // total = total + (subItem.Price * subItem.PrescribingNumber)
  10886. // }
  10887. // }
  10888. // if item.Type == 2 { //项目
  10889. // for _, subItem := range item.HisPrescriptionProject {
  10890. // total = total + (subItem.Price * float64(subItem.Count))
  10891. // }
  10892. // }
  10893. //
  10894. // for _, subItem := range item.HisAdditionalCharge {
  10895. // total = total + (subItem.Price * float64(subItem.Count))
  10896. // }
  10897. // }
  10898. //
  10899. // allTotal := fmt.Sprintf("%.2f", total)
  10900. // totals, _ := strconv.ParseFloat(allTotal, 64)
  10901. // order := &models.HisOrder{
  10902. // UserOrgId: adminUser.CurrentOrgId,
  10903. // HisPatientId: his.ID,
  10904. // PatientId: id,
  10905. // SettleAccountsDate: recordDateTime,
  10906. // Ctime: time.Now().Unix(),
  10907. // Mtime: time.Now().Unix(),
  10908. // Status: 1,
  10909. // OrderStatus: 2,
  10910. // Number: chrg_bchno,
  10911. // MedfeeSumamt: totals,
  10912. // }
  10913. // err = service.CreateOrder(order)
  10914. // if err != nil {
  10915. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCreatePreOrderException)
  10916. // return
  10917. // }
  10918. //
  10919. // var customs []*Custom
  10920. // for _, item := range prescriptions {
  10921. //
  10922. // if item.Type == 1 { //药品
  10923. // for _, subItem := range item.HisDoctorAdviceInfo {
  10924. // cus := &Custom{
  10925. // AdviceId: subItem.ID,
  10926. // ProjectId: 0,
  10927. // DetItemFeeSumamt: fmt.Sprintf("%.2f", subItem.Price*subItem.PrescribingNumber),
  10928. // Cut: fmt.Sprintf("%.2f", subItem.PrescribingNumber),
  10929. // FeedetlSn: subItem.FeedetlSn,
  10930. // Price: fmt.Sprintf("%.2f", subItem.Price),
  10931. // MedListCodg: subItem.MedListCodg,
  10932. // Type: 1,
  10933. // }
  10934. // customs = append(customs, cus)
  10935. // }
  10936. // }
  10937. //
  10938. // if item.Type == 2 { //项目
  10939. // for _, subItem := range item.HisPrescriptionProject {
  10940. //
  10941. // cus := &Custom{
  10942. // AdviceId: 0,
  10943. // ProjectId: subItem.ID,
  10944. // DetItemFeeSumamt: fmt.Sprintf("%.2f", subItem.Price*float64(subItem.Count)),
  10945. // Cut: fmt.Sprintf("%.2f", float64(subItem.Count)),
  10946. // FeedetlSn: subItem.FeedetlSn,
  10947. // Price: fmt.Sprintf("%.2f", float64(subItem.Price)),
  10948. // MedListCodg: subItem.MedListCodg,
  10949. // Type: 2,
  10950. // }
  10951. //
  10952. // customs = append(customs, cus)
  10953. // }
  10954. // }
  10955. //
  10956. // for _, item := range item.HisAdditionalCharge {
  10957. // cus := &Custom{
  10958. // ItemId: item.ID,
  10959. // AdviceId: 0,
  10960. // ProjectId: 0,
  10961. // DetItemFeeSumamt: fmt.Sprintf("%.2f", item.Price),
  10962. // Cut: fmt.Sprintf("%.2f", float64(item.Count)),
  10963. // FeedetlSn: item.FeedetlSn,
  10964. // Price: fmt.Sprintf("%.2f", float64(item.Price)),
  10965. // MedListCodg: item.XtHisAddtionConfig.Code,
  10966. // Type: 3,
  10967. // }
  10968. //
  10969. // customs = append(customs, cus)
  10970. // }
  10971. //
  10972. // }
  10973. //
  10974. // for _, item := range customs {
  10975. // var advice_id int64 = 0
  10976. // var project_id int64 = 0
  10977. // var item_id int64 = 0
  10978. //
  10979. // var types int64 = 0
  10980. //
  10981. // if item.Type == 1 {
  10982. // advice_id = item.AdviceId
  10983. // project_id = 0
  10984. // item_id = 0
  10985. // } else if item.Type == 2 {
  10986. // advice_id = 0
  10987. // item_id = 0
  10988. //
  10989. // project_id = item.ProjectId
  10990. // } else if item.Type == 3 {
  10991. // advice_id = 0
  10992. // item_id = item.ItemId
  10993. // project_id = 0
  10994. // }
  10995. //
  10996. // detItemFeeSumamt, _ := strconv.ParseFloat(item.DetItemFeeSumamt, 32)
  10997. // cut, _ := strconv.ParseFloat(item.Cut, 32)
  10998. // pric, _ := strconv.ParseFloat(item.Price, 32)
  10999. //
  11000. // info := &models.HisOrderInfo{
  11001. // OrderNumber: order.Number,
  11002. // UploadDate: time.Now().Unix(),
  11003. // AdviceId: advice_id,
  11004. // DetItemFeeSumamt: detItemFeeSumamt,
  11005. // Cnt: cut,
  11006. // Pric: pric,
  11007. // PatientId: id,
  11008. // Status: 1,
  11009. // Mtime: time.Now().Unix(),
  11010. // Ctime: time.Now().Unix(),
  11011. // UserOrgId: adminUser.CurrentOrgId,
  11012. // HisPatientId: his.ID,
  11013. // OrderId: order.ID,
  11014. // ProjectId: project_id,
  11015. // Type: types,
  11016. // ItemId: item_id,
  11017. // }
  11018. // service.CreateOrderInfo(info)
  11019. // }
  11020. // //err := service.UpDateAddtionNumber(adminUser.CurrentOrgId, ids, chrg_bchno)
  11021. // err = service.UpDatePrescriptionNumber(adminUser.CurrentOrgId, ids, chrg_bchno)
  11022. // err = service.UpDatePrescriptionInfoNumber(adminUser.CurrentOrgId, id, chrg_bchno, recordDateTime)
  11023. // err = service.UpdataOrderStatusTwo(chrg_bchno, adminUser.CurrentOrgId)
  11024. // if err == nil {
  11025. // c.ServeSuccessJSON(map[string]interface{}{
  11026. // "msg": "结算成功",
  11027. // })
  11028. // } else {
  11029. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeAmountAccountException)
  11030. // return
  11031. // }
  11032. // }
  11033. //}
  11034. // 上传明细-预结算-
  11035. func (c *HisApiController) GetPreUploadInfo() {
  11036. id, _ := c.GetInt64("id")
  11037. record_time := c.GetString("record_time")
  11038. his_patient_id, _ := c.GetInt64("his_patient_id")
  11039. settle_accounts_type, _ := c.GetInt64("settle_accounts_type")
  11040. admin_user_id, _ := c.GetInt64("admin_user_id")
  11041. diagnosis_id := c.GetString("diagnosis")
  11042. sick_type, _ := c.GetInt64("sick_type")
  11043. reg_type, _ := c.GetInt64("p_type")
  11044. begin_time := c.GetString("begin_time")
  11045. acct_used_flag := c.GetString("acct_used_flag")
  11046. id_str := c.GetString("ids")
  11047. ids_arr := strings.Split(id_str, ",")
  11048. timeLayout := "2006-01-02"
  11049. loc, _ := time.LoadLocation("Local")
  11050. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  11051. if err != nil {
  11052. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  11053. return
  11054. }
  11055. recordDateTime := theTime.Unix()
  11056. adminUser := c.GetAdminUserInfo()
  11057. diagnosis_ids := strings.Split(diagnosis_id, ",")
  11058. var config []*models.HisXtDiagnoseConfig
  11059. for _, item := range diagnosis_ids {
  11060. id, _ := strconv.ParseInt(item, 10, 64)
  11061. diagnosisConfig, _ := service.FindDiagnoseById(id)
  11062. config = append(config, &diagnosisConfig)
  11063. }
  11064. //diagnosisConfig, _ := service.FindDiagnoseById(diagnosis_id)
  11065. sickConfig, _ := service.FindSickById(sick_type)
  11066. var prescriptions []*models.HisPrescription
  11067. var start_time int64
  11068. var end_time int64
  11069. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  11070. fmt.Println(his_patient_id)
  11071. his, _ := service.GetNewHisPatientInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  11072. timestamp := time.Now().Unix()
  11073. tempTime := time.Unix(timestamp, 0)
  11074. timeFormat := tempTime.Format("20060102150405")
  11075. chrgBchno := rand.Intn(100000) + 10000
  11076. chrg_bchno := timeFormat + strconv.FormatInt(int64(chrgBchno), 10) + strconv.FormatInt(his.PatientId, 10)
  11077. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  11078. var patientPrescription models.HisPrescriptionInfo
  11079. patientPrescription, _ = service.FindHisPatientPrescriptionInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  11080. if patientPrescription.ID == 0 {
  11081. patientPrescription, _ = service.FindLastPatientPrescriptionInfo(adminUser.CurrentOrgId, id, recordDateTime)
  11082. }
  11083. //miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  11084. department, _ := service.GetDepartMentDetail(patientPrescription.Departments)
  11085. doctor_info, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, patientPrescription.DoctorId)
  11086. strconv.FormatInt(his.PatientId, 10)
  11087. var res2 ResultSix
  11088. var resSix10265 ResultSix10265
  11089. //var time_stamp string
  11090. if miConfig.MdtrtareaAdmvs == "421300" {
  11091. data := make(map[string]interface{})
  11092. client := &http.Client{}
  11093. data["psn_no"] = his.PsnNo
  11094. data["mdtrt_id"] = his.Number
  11095. data["department"] = department.Name
  11096. data["org_name"] = miConfig.OrgName
  11097. data["med_type"] = strconv.FormatInt(reg_type, 10)
  11098. data["doctor_id"] = doctor_info.DoctorNumber
  11099. data["doctor_name"] = roles.UserName
  11100. data["fixmedins_code"] = miConfig.Code
  11101. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  11102. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  11103. data["secret_key"] = miConfig.SecretKey
  11104. data["sick_code"] = sickConfig.CountryCode
  11105. data["sick_name"] = sickConfig.ClassName
  11106. data["begin_time"] = begin_time
  11107. data["dept"] = strconv.FormatInt(department.ID, 10)
  11108. data["config"] = config
  11109. data["opter"] = roles.UserName
  11110. fmt.Println(data)
  11111. bytesData, _ := json.Marshal(data)
  11112. req, _ := http.NewRequest("POST", "http://192.168.124.4:9532/"+"hbyb/2203", bytes.NewReader(bytesData))
  11113. resp, _ := client.Do(req)
  11114. defer resp.Body.Close()
  11115. body, ioErr := ioutil.ReadAll(resp.Body)
  11116. if ioErr != nil {
  11117. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  11118. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11119. return
  11120. }
  11121. var respJSON map[string]interface{}
  11122. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  11123. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  11124. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11125. return
  11126. }
  11127. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  11128. userJSONBytes, _ := json.Marshal(respJSON)
  11129. fmt.Println("log")
  11130. fmt.Println(string(userJSONBytes))
  11131. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  11132. utils.ErrorLog("解析失败:%v", err)
  11133. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11134. return
  11135. }
  11136. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  11137. data := make(map[string]interface{})
  11138. client := &http.Client{}
  11139. data["psn_no"] = his.PsnNo
  11140. data["mdtrt_id"] = his.Number
  11141. data["doctor"] = roles.UserName
  11142. data["department"] = department.Name
  11143. data["org_name"] = miConfig.OrgName
  11144. data["med_type"] = strconv.FormatInt(reg_type, 10)
  11145. data["doctor_id"] = strconv.FormatInt(doctor_info.AdminUserId, 10)
  11146. data["fixmedins_code"] = miConfig.Code
  11147. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  11148. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  11149. data["secret_key"] = miConfig.SecretKey
  11150. data["sick_code"] = sickConfig.CountryCode
  11151. data["sick_name"] = sickConfig.ClassName
  11152. data["begin_time"] = begin_time
  11153. data["dept"] = strconv.FormatInt(department.ID, 10)
  11154. data["config"] = config
  11155. data["url"] = miConfig.Url
  11156. data["ak"] = miConfig.AccessKey
  11157. data["cainfo"] = miConfig.Cainfo
  11158. bytesData, _ := json.Marshal(data)
  11159. var req *http.Request
  11160. if miConfig.MdtrtareaAdmvs == "320921" {
  11161. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/2203", bytes.NewReader(bytesData))
  11162. } else {
  11163. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2203", bytes.NewReader(bytesData))
  11164. }
  11165. resp, _ := client.Do(req)
  11166. defer resp.Body.Close()
  11167. body, ioErr := ioutil.ReadAll(resp.Body)
  11168. if ioErr != nil {
  11169. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  11170. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11171. return
  11172. }
  11173. var respJSON map[string]interface{}
  11174. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  11175. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  11176. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11177. return
  11178. }
  11179. //time_stamp := strconv.FormatInt(int64(respJSON["data"].(map[string]interface{})["time_stamp"].(float64)), 10)
  11180. //fmt.Println(respJSON["data"].(map[string]interface{})["time_stamp"].(string))
  11181. //time_stamp = respJSON["data"].(map[string]interface{})["time_stamp"].(string)
  11182. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  11183. userJSONBytes, _ := json.Marshal(respJSON)
  11184. fmt.Println("log")
  11185. fmt.Println(string(userJSONBytes))
  11186. if err := json.Unmarshal(userJSONBytes, &resSix10265); err != nil {
  11187. utils.ErrorLog("解析失败:%v", err)
  11188. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11189. return
  11190. }
  11191. res2.InfRefmsgid = resSix10265.InfRefmsgid
  11192. res2.Output = resSix10265.Output
  11193. res2.ErrMsg = resSix10265.ErrMsg
  11194. res2.Cainfo = resSix10265.Cainfo
  11195. res2.WarnMsg = resSix10265.WarnMsg
  11196. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  11197. res2.Infcode = infocode
  11198. } else if miConfig.MdtrtareaAdmvs == "350500" {
  11199. 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)
  11200. saveLog(result, requestLog, "2203", "上传就诊信息")
  11201. var respJSON2 map[string]interface{}
  11202. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  11203. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  11204. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11205. return
  11206. }
  11207. userJSONBytes2, _ := json.Marshal(respJSON2)
  11208. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  11209. utils.ErrorLog("解析失败:%v", err)
  11210. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11211. return
  11212. }
  11213. } else if miConfig.MdtrtareaAdmvs == "360399" {
  11214. var result string
  11215. var requestLog string
  11216. 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, "")
  11217. saveLog(result, requestLog, "2203", "上传就诊信息")
  11218. var respJSON2 map[string]interface{}
  11219. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  11220. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  11221. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11222. return
  11223. }
  11224. userJSONBytes2, _ := json.Marshal(respJSON2)
  11225. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  11226. utils.ErrorLog("解析失败:%v", err)
  11227. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11228. return
  11229. }
  11230. } else if miConfig.MdtrtareaAdmvs == "430800" {
  11231. var result string
  11232. var requestLog string
  11233. 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, "")
  11234. saveLog(result, requestLog, "2203", "上传就诊信息")
  11235. var respJSON2 map[string]interface{}
  11236. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  11237. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  11238. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11239. return
  11240. }
  11241. userJSONBytes2, _ := json.Marshal(respJSON2)
  11242. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  11243. utils.ErrorLog("解析失败:%v", err)
  11244. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11245. return
  11246. }
  11247. } else {
  11248. var result string
  11249. var requestLog string
  11250. if miConfig.MdtrtareaAdmvs == "440781" { //
  11251. 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)
  11252. } else {
  11253. if miConfig.Code == "H15049901371" {
  11254. //赤峰地区国家医保医疗类别
  11255. //职工透析:医疗类别选特殊情况门诊990502
  11256. //居民定额血透门慢: 医疗类别选门诊慢病140104
  11257. var med_type string
  11258. if his.Insutype == "390" {
  11259. if reg_type == 14 {
  11260. med_type = "9933"
  11261. } else if reg_type == 11 {
  11262. med_type = "11"
  11263. }
  11264. } else if his.Insutype == "310" {
  11265. if reg_type == 14 {
  11266. med_type = "990502"
  11267. } else if reg_type == 11 {
  11268. med_type = "11"
  11269. }
  11270. }
  11271. 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)
  11272. } else {
  11273. 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)
  11274. }
  11275. saveLog(result, requestLog, "2203", "上传就诊信息")
  11276. var respJSON2 map[string]interface{}
  11277. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  11278. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  11279. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11280. return
  11281. }
  11282. userJSONBytes2, _ := json.Marshal(respJSON2)
  11283. if miConfig.Code == "H15049901371" {
  11284. if err := json.Unmarshal(userJSONBytes2, &resSix10265); err != nil {
  11285. utils.ErrorLog("解析失败:%v", err)
  11286. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11287. return
  11288. }
  11289. res2.InfRefmsgid = resSix10265.InfRefmsgid
  11290. res2.Output = resSix10265.Output
  11291. res2.ErrMsg = resSix10265.ErrMsg
  11292. res2.Cainfo = resSix10265.Cainfo
  11293. res2.WarnMsg = resSix10265.WarnMsg
  11294. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  11295. res2.Infcode = infocode
  11296. } else {
  11297. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  11298. utils.ErrorLog("解析失败:%v", err)
  11299. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11300. return
  11301. }
  11302. }
  11303. }
  11304. }
  11305. if res2.Infcode != 0 {
  11306. adminUser := c.GetAdminUserInfo()
  11307. errlog := &models.HisOrderError{
  11308. UserOrgId: adminUser.CurrentOrgId,
  11309. Ctime: time.Now().Unix(),
  11310. Mtime: time.Now().Unix(),
  11311. ErrMsg: res2.ErrMsg,
  11312. Status: 1,
  11313. PatientId: id,
  11314. RecordTime: recordDateTime,
  11315. Stage: 3,
  11316. }
  11317. service.CreateErrMsgLog(errlog)
  11318. c.ServeSuccessJSON(map[string]interface{}{
  11319. "failed_code": -10,
  11320. "msg": res2.ErrMsg,
  11321. })
  11322. return
  11323. } else {
  11324. his.Diagnosis = diagnosis_id
  11325. his.SickType = sickConfig.ID
  11326. his.PType = fmt.Sprintf("%d", reg_type)
  11327. service.UpdateHisPatientThree(&his)
  11328. data := make(map[string]interface{})
  11329. if settle_accounts_type == 1 { //日结
  11330. if reg_type == 11 || reg_type == 1111 || reg_type == 1112 {
  11331. prescriptions, _ = service.GetPrescriptionByIds(ids_arr, adminUser.CurrentOrgId)
  11332. } else {
  11333. prescriptions, _ = service.GetNewHisPrescription(adminUser.CurrentOrgId, his_patient_id, recordDateTime, strconv.Itoa(int(reg_type)))
  11334. }
  11335. data["pre"] = prescriptions
  11336. } else { //月结
  11337. start_time_str := c.GetString("start_time")
  11338. end_time_str := c.GetString("end_time")
  11339. timeLayout := "2006-01-02"
  11340. loc, _ := time.LoadLocation("Local")
  11341. theStartTime, err := time.ParseInLocation(timeLayout+" 15:04:05", start_time_str+" 00:00:00", loc)
  11342. if err != nil {
  11343. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  11344. return
  11345. }
  11346. recordStartTime := theStartTime.Unix()
  11347. start_time = recordStartTime
  11348. theEndTime, err := time.ParseInLocation(timeLayout+" 15:04:05", end_time_str+" 00:00:00", loc)
  11349. if err != nil {
  11350. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  11351. return
  11352. }
  11353. recordEndTime := theEndTime.Unix()
  11354. end_time = recordEndTime
  11355. prescriptions, _ = service.GetMonthHisPrescriptionTwo(adminUser.CurrentOrgId, id, recordStartTime, recordEndTime, reg_type)
  11356. data["pre"] = prescriptions
  11357. }
  11358. client := &http.Client{}
  11359. data["psn_no"] = his.PsnNo
  11360. data["mdtrt_id"] = his.Number
  11361. data["chrg_bchno"] = chrg_bchno
  11362. data["org_name"] = miConfig.OrgName
  11363. data["doctor"] = doctor_info.UserName
  11364. data["doctor_id"] = doctor_info.DoctorNumber
  11365. data["dept"] = department.Name
  11366. data["fixmedins_code"] = miConfig.Code
  11367. data["opter"] = roles.UserName
  11368. data["dept_code"] = department.Number
  11369. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  11370. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  11371. data["secret_key"] = miConfig.SecretKey
  11372. data["balance_accounts_type"] = strconv.FormatInt(his.BalanceAccountsType, 10)
  11373. data["url"] = miConfig.Url
  11374. data["ak"] = miConfig.AccessKey
  11375. data["new_doctor_name"] = patientPrescription.Doctor
  11376. data["diag_code"] = sickConfig.CountryCode
  11377. data["cainfo"] = miConfig.Cainfo
  11378. data["opter"] = roles.UserName
  11379. var ids []int64
  11380. for _, item := range prescriptions {
  11381. ids = append(ids, item.ID)
  11382. }
  11383. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  11384. if config.IsOpen == 1 { //对接了医保,走医保流程
  11385. var res ResultFour
  11386. var resFour10265 ResultFour10265
  11387. if miConfig.MdtrtareaAdmvs == "421300" {
  11388. bytesData, _ := json.Marshal(data)
  11389. req, _ := http.NewRequest("POST", "http://192.168.124.4:9532/"+"hbyb/2204", bytes.NewReader(bytesData))
  11390. resp, _ := client.Do(req)
  11391. defer resp.Body.Close()
  11392. body, ioErr := ioutil.ReadAll(resp.Body)
  11393. if ioErr != nil {
  11394. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  11395. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11396. return
  11397. }
  11398. var respJSON map[string]interface{}
  11399. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  11400. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  11401. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11402. return
  11403. }
  11404. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  11405. userJSONBytes, _ := json.Marshal(respJSON)
  11406. fmt.Println("log")
  11407. fmt.Println(string(userJSONBytes))
  11408. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  11409. utils.ErrorLog("解析失败:%v", err)
  11410. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11411. return
  11412. }
  11413. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  11414. result3101 := Check3101(c, id, his_patient_id, admin_user_id, "2", record_time, prescriptions)
  11415. if result3101.Infcode == "0" {
  11416. if len(result3101.Output.Result) > 0 {
  11417. var errMsgs []string
  11418. for _, item := range result3101.Output.Result {
  11419. errMsgs = append(errMsgs, item.VolaCont)
  11420. }
  11421. c.ServeSuccessJSON(map[string]interface{}{
  11422. "failed_code": -10,
  11423. "msg": errMsgs,
  11424. })
  11425. return
  11426. } else {
  11427. if miConfig.MdtrtareaAdmvs == "320921" {
  11428. data["doctor_id"] = "D320923012139"
  11429. } else {
  11430. data["doctor_id"] = "D371621008686"
  11431. }
  11432. bytesData, _ := json.Marshal(data)
  11433. var req *http.Request
  11434. if miConfig.MdtrtareaAdmvs == "320921" {
  11435. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  11436. } else {
  11437. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  11438. }
  11439. resp, _ := client.Do(req)
  11440. defer resp.Body.Close()
  11441. body, ioErr := ioutil.ReadAll(resp.Body)
  11442. if ioErr != nil {
  11443. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  11444. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11445. return
  11446. }
  11447. var respJSON map[string]interface{}
  11448. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  11449. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  11450. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11451. return
  11452. }
  11453. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  11454. userJSONBytes, _ := json.Marshal(respJSON)
  11455. fmt.Println("log")
  11456. fmt.Println(string(userJSONBytes))
  11457. if err := json.Unmarshal(userJSONBytes, &resFour10265); err != nil {
  11458. utils.ErrorLog("解析失败:%v", err)
  11459. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11460. return
  11461. }
  11462. res.InfRefmsgid = resFour10265.InfRefmsgid
  11463. res.Output = resFour10265.Output
  11464. res.ErrMsg = resFour10265.ErrMsg
  11465. res.Cainfo = resFour10265.Cainfo
  11466. res.WarnMsg = resFour10265.WarnMsg
  11467. infocode, _ := strconv.ParseInt(resFour10265.Infcode, 10, 64)
  11468. res.Infcode = infocode
  11469. }
  11470. }
  11471. } else if miConfig.MdtrtareaAdmvs == "350500" {
  11472. 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)
  11473. var dat map[string]interface{}
  11474. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  11475. fmt.Println(dat)
  11476. } else {
  11477. fmt.Println(err)
  11478. }
  11479. saveLog(result, request_log, "2204", "上传费用明细")
  11480. userJSONBytes, _ := json.Marshal(dat)
  11481. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  11482. utils.ErrorLog("解析失败:%v", err)
  11483. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11484. return
  11485. }
  11486. } else if miConfig.MdtrtareaAdmvs == "360399" {
  11487. 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, "", "")
  11488. var dat map[string]interface{}
  11489. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  11490. fmt.Println(dat)
  11491. } else {
  11492. fmt.Println(err)
  11493. }
  11494. saveLog(result, request_log, "2204", "上传费用明细")
  11495. userJSONBytes, _ := json.Marshal(dat)
  11496. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  11497. utils.ErrorLog("解析失败:%v", err)
  11498. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11499. return
  11500. }
  11501. } else if miConfig.MdtrtareaAdmvs == "430800" {
  11502. 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, "", "")
  11503. var dat map[string]interface{}
  11504. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  11505. fmt.Println(dat)
  11506. } else {
  11507. fmt.Println(err)
  11508. }
  11509. saveLog(result, request_log, "2204", "上传费用明细")
  11510. userJSONBytes, _ := json.Marshal(dat)
  11511. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  11512. utils.ErrorLog("解析失败:%v", err)
  11513. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11514. return
  11515. }
  11516. } else {
  11517. if miConfig.Code == "H15049901371" {
  11518. 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)
  11519. var dat map[string]interface{}
  11520. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  11521. fmt.Println(dat)
  11522. } else {
  11523. fmt.Println(err)
  11524. }
  11525. saveLog(result, request_log, "2204", "上传费用明细")
  11526. userJSONBytes, _ := json.Marshal(dat)
  11527. if err := json.Unmarshal(userJSONBytes, &resFour10265); err != nil {
  11528. utils.ErrorLog("解析失败:%v", err)
  11529. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11530. return
  11531. }
  11532. res.InfRefmsgid = resFour10265.InfRefmsgid
  11533. res.Output = resFour10265.Output
  11534. res.ErrMsg = resFour10265.ErrMsg
  11535. res.Cainfo = resFour10265.Cainfo
  11536. res.WarnMsg = resFour10265.WarnMsg
  11537. infocode, _ := strconv.ParseInt(resFour10265.Infcode, 10, 64)
  11538. res.Infcode = infocode
  11539. } else {
  11540. 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)
  11541. var dat map[string]interface{}
  11542. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  11543. fmt.Println(dat)
  11544. } else {
  11545. fmt.Println(err)
  11546. }
  11547. saveLog(result, request_log, "2204", "上传费用明细")
  11548. userJSONBytes, _ := json.Marshal(dat)
  11549. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  11550. utils.ErrorLog("解析失败:%v", err)
  11551. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11552. return
  11553. }
  11554. }
  11555. }
  11556. var total_two float64
  11557. if res.Infcode == 0 {
  11558. order := &models.HisOrder{
  11559. UserOrgId: adminUser.CurrentOrgId,
  11560. HisPatientId: his.ID,
  11561. PatientId: his.PatientId,
  11562. SettleAccountsDate: recordDateTime,
  11563. Ctime: time.Now().Unix(),
  11564. Mtime: time.Now().Unix(),
  11565. MdtrtId: his.Number,
  11566. PsnNo: his.PsnNo,
  11567. MedType: strconv.FormatInt(reg_type, 10),
  11568. Status: 1,
  11569. Number: chrg_bchno,
  11570. Infcode: res.Infcode,
  11571. WarnMsg: res.WarnMsg,
  11572. Cainfo: res.Cainfo,
  11573. ErrMsg: res.ErrMsg,
  11574. RespondTime: res.RefmsgTime,
  11575. InfRefmsgid: res.InfRefmsgid,
  11576. OrderStatus: 1,
  11577. IsMedicineInsurance: 1,
  11578. SettleType: settle_accounts_type,
  11579. SettleStartTime: start_time,
  11580. SettleEndTime: end_time,
  11581. Creator: roles.AdminUserId,
  11582. Modify: roles.AdminUserId,
  11583. PType: 2,
  11584. Diagnosis: diagnosis_id,
  11585. }
  11586. err = service.CreateOrder(order)
  11587. if err != nil {
  11588. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCreatePreOrderException)
  11589. return
  11590. }
  11591. for _, item := range res.Output.Result {
  11592. temp := strings.Split(item.FeedetlSn, "-")
  11593. var advice_id int64 = 0
  11594. var project_id int64 = 0
  11595. var types int64 = 0
  11596. id, _ := strconv.ParseInt(temp[2], 10, 64)
  11597. types, _ = strconv.ParseInt(temp[1], 10, 64)
  11598. if temp[1] == "1" {
  11599. advice_id = id
  11600. project_id = 0
  11601. } else if temp[1] == "2" {
  11602. advice_id = 0
  11603. project_id = id
  11604. }
  11605. total_two = total_two + item.DetItemFeeSumamt
  11606. info := &models.HisOrderInfo{
  11607. OrderNumber: order.Number,
  11608. FeedetlSn: item.FeedetlSn,
  11609. UploadDate: time.Now().Unix(),
  11610. AdviceId: advice_id,
  11611. DetItemFeeSumamt: item.DetItemFeeSumamt,
  11612. Cnt: item.Cnt,
  11613. Pric: float64(item.Pric),
  11614. PatientId: his.PatientId,
  11615. PricUplmtAmt: item.PricUplmtAmt,
  11616. SelfpayProp: item.SelfpayProp,
  11617. FulamtOwnpayAmt: item.FulamtOwnpayAmt,
  11618. OverlmtAmt: item.OverlmtAmt,
  11619. PreselfpayAmt: item.PreselfpayAmt,
  11620. BasMednFlag: item.BasMednFlag,
  11621. MedChrgitmType: item.MedChrgitmType,
  11622. HiNegoDrugFlag: item.HiNegoDrugFlag,
  11623. Status: 1,
  11624. Memo: item.Memo,
  11625. Mtime: time.Now().Unix(),
  11626. InscpScpAmt: item.InscpScpAmt,
  11627. DrtReimFlag: item.DrtReimFlag,
  11628. Ctime: time.Now().Unix(),
  11629. ListSpItemFlag: item.ListSpItemFlag,
  11630. ChldMedcFlag: item.ChldMedcFlag,
  11631. LmtUsedFlag: item.LmtUsedFlag,
  11632. ChrgitmLv: item.ChrgitmLv,
  11633. UserOrgId: adminUser.CurrentOrgId,
  11634. HisPatientId: his.ID,
  11635. OrderId: order.ID,
  11636. ProjectId: project_id,
  11637. Type: types,
  11638. }
  11639. service.CreateOrderInfo(info)
  11640. }
  11641. service.UpDatePrescriptionNumber(adminUser.CurrentOrgId, ids, chrg_bchno)
  11642. service.UpDateHisPrescriptionInfoNumber(adminUser.CurrentOrgId, his_patient_id, chrg_bchno, recordDateTime)
  11643. var total float64
  11644. for _, item := range prescriptions {
  11645. if item.Type == 1 { //药品
  11646. for _, subItem := range item.HisDoctorAdviceInfo {
  11647. price, _ := strconv.ParseFloat(fmt.Sprintf("%.2f", subItem.Price), 64)
  11648. total_one := price * subItem.PrescribingNumber
  11649. fmt.Println("subItem")
  11650. fmt.Println(subItem.Price)
  11651. fmt.Println("price")
  11652. fmt.Println(price)
  11653. fmt.Println("total_one")
  11654. fmt.Println(total_one)
  11655. total = total + total_one
  11656. fmt.Println(total)
  11657. }
  11658. }
  11659. if item.Type == 2 { //项目
  11660. for _, subItem := range item.HisPrescriptionProject {
  11661. cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  11662. price, _ := strconv.ParseFloat(fmt.Sprintf("%.2f", subItem.Price), 64)
  11663. total_one := price * cnt
  11664. total = total + total_one
  11665. }
  11666. }
  11667. }
  11668. allTotal := fmt.Sprintf("%2f", total)
  11669. if res.Infcode == 0 {
  11670. var rf []*ResultFive
  11671. json.Unmarshal([]byte(his.Iinfo), &rf)
  11672. chrg_bchno := chrg_bchno
  11673. cert_no := his.Certno
  11674. var insutypes []string
  11675. var insutype string
  11676. var is390 int = 0
  11677. var is310 int = 0
  11678. for _, item := range rf {
  11679. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  11680. insutypes = append(insutypes, item.Insutype)
  11681. }
  11682. }
  11683. if len(insutypes) == 1 {
  11684. insutype = insutypes[0]
  11685. } else {
  11686. for _, i := range insutypes {
  11687. if i == "390" {
  11688. is390 = 1
  11689. }
  11690. if i == "310" {
  11691. is310 = 1
  11692. }
  11693. }
  11694. }
  11695. if is390 == 1 {
  11696. insutype = "390"
  11697. }
  11698. if is310 == 1 {
  11699. insutype = "310"
  11700. }
  11701. if len(insutypes) == 0 {
  11702. insutype = "390"
  11703. }
  11704. if len(insutypes) == 2 {
  11705. insutype = strconv.FormatInt(his.SocialType, 10)
  11706. }
  11707. //insutype = "390"
  11708. if his.IdCardType == 1 {
  11709. cert_no = his.MedicalInsuranceNumber
  11710. } else {
  11711. cert_no = his.Certno
  11712. }
  11713. var res ResultSeven
  11714. var resSeven10265 ResultSeven10265
  11715. if miConfig.MdtrtareaAdmvs == "421300" {
  11716. api := "http://192.168.124.4:9532/" + "hbyb/2206?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  11717. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  11718. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  11719. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  11720. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  11721. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  11722. "&insutype=" + insutype + "&total=" + allTotal + "&med_type=" + strconv.FormatInt(reg_type, 10)
  11723. resp, requestErr := http.Get(api)
  11724. if requestErr != nil {
  11725. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11726. return
  11727. }
  11728. body, ioErr := ioutil.ReadAll(resp.Body)
  11729. if ioErr != nil {
  11730. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  11731. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11732. return
  11733. }
  11734. var respJSON map[string]interface{}
  11735. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  11736. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  11737. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11738. return
  11739. }
  11740. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  11741. result, _ := json.Marshal(respJSON)
  11742. fmt.Println("log")
  11743. fmt.Println(string(result))
  11744. if err := json.Unmarshal([]byte(result), &res); err != nil {
  11745. utils.ErrorLog("解析失败:%v", err)
  11746. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11747. return
  11748. }
  11749. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  11750. result3101 := Check3102(c, id, his_patient_id, admin_user_id, "6", order.ID)
  11751. if result3101.Infcode == "0" {
  11752. if len(result3101.Output.Result) > 0 {
  11753. var errMsgs []string
  11754. for _, item := range result3101.Output.Result {
  11755. errMsgs = append(errMsgs, item.VolaCont)
  11756. }
  11757. c.ServeSuccessJSON(map[string]interface{}{
  11758. "failed_code": -10,
  11759. "msg": errMsgs,
  11760. })
  11761. return
  11762. } else {
  11763. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  11764. if his.IdCardType != 4 {
  11765. psn_info.VerifyNumber = strings.Replace(psn_info.VerifyNumber, "+", "%2B", -1)
  11766. bas := strings.Split(psn_info.CardInfo, "|")
  11767. if his.IdCardType == 1 {
  11768. cert_no = bas[2]
  11769. } else {
  11770. cert_no = bas[1]
  11771. }
  11772. } else {
  11773. cert_no = his.Certno
  11774. }
  11775. //江苏地区国家医保医疗类别
  11776. //职工透析:医疗类别选特殊情况门诊9933
  11777. //居民血透门慢: 医疗类别选门诊慢病1402
  11778. //var med_type string
  11779. //if his.Insutype == "310" {
  11780. // if reg_type == 14 {
  11781. // med_type = "9933"
  11782. // } else if reg_type == 11 {
  11783. // med_type = "11"
  11784. //
  11785. // }
  11786. //} else if his.Insutype == "390" {
  11787. // if reg_type == 14 {
  11788. // med_type = "1402"
  11789. // } else if reg_type == 11 {
  11790. // med_type = "11"
  11791. // }
  11792. //}
  11793. var api string
  11794. if miConfig.MdtrtareaAdmvs == "320921" {
  11795. api = "http://192.168.2.3:9532/" + "jsyb/2206?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  11796. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  11797. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  11798. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  11799. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  11800. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  11801. "&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
  11802. //req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  11803. } else {
  11804. //req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  11805. api = "http://192.168.5.251:9532/" + "jsyb/2206?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  11806. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  11807. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  11808. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  11809. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  11810. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  11811. "&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
  11812. }
  11813. resp, requestErr := http.Get(api)
  11814. if requestErr != nil {
  11815. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11816. return
  11817. }
  11818. body, ioErr := ioutil.ReadAll(resp.Body)
  11819. if ioErr != nil {
  11820. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  11821. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11822. return
  11823. }
  11824. var respJSON map[string]interface{}
  11825. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  11826. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  11827. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11828. return
  11829. }
  11830. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  11831. result, _ := json.Marshal(respJSON)
  11832. fmt.Println("log")
  11833. fmt.Println(string(result))
  11834. if err := json.Unmarshal([]byte(result), &resSeven10265); err != nil {
  11835. utils.ErrorLog("解析失败:%v", err)
  11836. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11837. return
  11838. }
  11839. res.InfRefmsgid = resSeven10265.InfRefmsgid
  11840. res.Output = resSeven10265.Output
  11841. res.ErrMsg = resSeven10265.ErrMsg
  11842. res.Cainfo = resSeven10265.Cainfo
  11843. res.WarnMsg = resSeven10265.WarnMsg
  11844. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  11845. res.Infcode = infocode
  11846. }
  11847. }
  11848. } else if miConfig.MdtrtareaAdmvs == "350500" {
  11849. acct_used_flag := "1"
  11850. psn_info, _ := service.GetPsnByPatientIdTwo(his.PatientId)
  11851. var result string
  11852. var request_log string
  11853. if his.IdCardType == 4 && len(psn_info.VerifyNumber) > 0 {
  11854. 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)
  11855. } else {
  11856. 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)
  11857. }
  11858. var dat map[string]interface{}
  11859. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  11860. fmt.Println(dat)
  11861. } else {
  11862. fmt.Println(err)
  11863. }
  11864. saveLog(result, request_log, "2206", "预结算")
  11865. userJSONBytes, _ := json.Marshal(dat)
  11866. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  11867. utils.ErrorLog("解析失败:%v", err)
  11868. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11869. return
  11870. }
  11871. } else if miConfig.MdtrtareaAdmvs == "360399" {
  11872. var result string
  11873. var request_log string
  11874. if his.IdCardType == 2 {
  11875. 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, "")
  11876. } else if his.IdCardType == 1 {
  11877. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  11878. bas := strings.Split(psn_info.CardInfo, "|")
  11879. basNumber := bas[2]
  11880. card_sn := bas[3]
  11881. 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)
  11882. } else {
  11883. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  11884. 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, "")
  11885. }
  11886. var dat map[string]interface{}
  11887. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  11888. fmt.Println(dat)
  11889. } else {
  11890. fmt.Println(err)
  11891. }
  11892. saveLog(result, request_log, "2206", "预结算")
  11893. userJSONBytes, _ := json.Marshal(dat)
  11894. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  11895. utils.ErrorLog("解析失败:%v", err)
  11896. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11897. return
  11898. }
  11899. } else if miConfig.MdtrtareaAdmvs == "430800" {
  11900. var result string
  11901. var request_log string
  11902. if his.IdCardType == 2 {
  11903. 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")
  11904. } else if his.IdCardType == 1 {
  11905. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  11906. bas := strings.Split(psn_info.CardInfo, "|")
  11907. basNumber := bas[2]
  11908. card_sn := bas[3]
  11909. 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")
  11910. } else {
  11911. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  11912. 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")
  11913. }
  11914. var dat map[string]interface{}
  11915. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  11916. fmt.Println(dat)
  11917. } else {
  11918. fmt.Println(err)
  11919. }
  11920. saveLog(result, request_log, "2206", "预结算")
  11921. userJSONBytes, _ := json.Marshal(dat)
  11922. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  11923. utils.ErrorLog("解析失败:%v", err)
  11924. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11925. return
  11926. }
  11927. } else {
  11928. var result string
  11929. var request_log string
  11930. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  11931. allTotal = fmt.Sprintf("%2f", total_two)
  11932. if his.IdCardType == 4 {
  11933. 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)
  11934. } else {
  11935. 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)
  11936. }
  11937. var dat map[string]interface{}
  11938. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  11939. fmt.Println(dat)
  11940. } else {
  11941. fmt.Println(err)
  11942. }
  11943. saveLog(result, request_log, "2206", "预结算")
  11944. //userJSONBytes, _ := json.Marshal(dat)
  11945. //
  11946. //if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  11947. // utils.ErrorLog("解析失败:%v", err)
  11948. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11949. // return
  11950. //}
  11951. userJSONBytes, _ := json.Marshal(dat)
  11952. if miConfig.Code == "H15049901371" {
  11953. if err := json.Unmarshal(userJSONBytes, &resSeven10265); err != nil {
  11954. utils.ErrorLog("解析失败:%v", err)
  11955. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11956. return
  11957. }
  11958. res.InfRefmsgid = resSeven10265.InfRefmsgid
  11959. res.Output = resSeven10265.Output
  11960. res.ErrMsg = resSeven10265.ErrMsg
  11961. res.Cainfo = resSeven10265.Cainfo
  11962. res.WarnMsg = resSeven10265.WarnMsg
  11963. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  11964. res.Infcode = infocode
  11965. } else {
  11966. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  11967. utils.ErrorLog("解析失败:%v", err)
  11968. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11969. return
  11970. }
  11971. }
  11972. }
  11973. if res.Infcode != 0 {
  11974. errlog := &models.HisOrderError{
  11975. UserOrgId: adminUser.CurrentOrgId,
  11976. Ctime: time.Now().Unix(),
  11977. Mtime: time.Now().Unix(),
  11978. Number: chrg_bchno,
  11979. ErrMsg: res.ErrMsg,
  11980. Status: 1,
  11981. PatientId: id,
  11982. RecordTime: recordDateTime,
  11983. Stage: 20,
  11984. }
  11985. service.CreateErrMsgLog(errlog)
  11986. c.ServeSuccessJSON(map[string]interface{}{
  11987. "failed_code": -10,
  11988. "msg": res.ErrMsg,
  11989. })
  11990. return
  11991. } else {
  11992. order, _ := service.GetHisOrderTwo(adminUser.CurrentOrgId, chrg_bchno, id)
  11993. order.OrderStatus = 1
  11994. order.IsPre = 1
  11995. order.Status = 1
  11996. order.MdtrtId = res.Output.Setlinfo.MdtrtID
  11997. order.SetlId = res.Output.Setlinfo.SetlID
  11998. order.PsnNo = res.Output.Setlinfo.PsnNo
  11999. order.PsnName = res.Output.Setlinfo.PsnName
  12000. order.PsnCertType = res.Output.Setlinfo.PsnCertType
  12001. order.Certno = res.Output.Setlinfo.Certno
  12002. order.Gend = res.Output.Setlinfo.Gend
  12003. order.Naty = res.Output.Setlinfo.Naty
  12004. order.Age = res.Output.Setlinfo.Age
  12005. order.Insutype = res.Output.Setlinfo.Insutype
  12006. order.PsnType = res.Output.Setlinfo.PsnType
  12007. order.CvlservFlag = res.Output.Setlinfo.CvlservFlag
  12008. order.SetlTime = res.Output.Setlinfo.SetlTime
  12009. order.AcctUsedFlag = acct_used_flag
  12010. order.MdtrtCertType = res.Output.Setlinfo.MdtrtCertType
  12011. if res.Output.Setlinfo.MedType == "140101" {
  12012. order.MedType = "14"
  12013. } else {
  12014. order.MedType = res.Output.Setlinfo.MedType
  12015. }
  12016. if reg_type == 1112 {
  12017. order.MedType = "1112"
  12018. }
  12019. if reg_type == 1111 {
  12020. order.MedType = "1111"
  12021. }
  12022. order.MedfeeSumamt = res.Output.Setlinfo.MedfeeSumamt
  12023. order.FulamtOwnpayAmt = res.Output.Setlinfo.FulamtOwnpayAmt
  12024. order.OverlmtSelfPay = res.Output.Setlinfo.OverlmtSelfpay
  12025. order.PreselfpayAmt = res.Output.Setlinfo.PreselfpayAmt
  12026. order.InscpScpAmt = res.Output.Setlinfo.InscpScpAmt
  12027. order.ActPayDedc = res.Output.Setlinfo.ActPayDedc
  12028. order.HifpPay = res.Output.Setlinfo.HifpPay
  12029. order.CvlservPay = res.Output.Setlinfo.CvlservPay
  12030. order.PoolPropSelfpay = res.Output.Setlinfo.PoolPropSelfpay
  12031. order.HifesPay = res.Output.Setlinfo.HifesPay
  12032. order.HifobPay = res.Output.Setlinfo.HifobPay
  12033. order.MafPay = res.Output.Setlinfo.MafPay
  12034. order.HifmiPay = res.Output.Setlinfo.HifmiPay
  12035. order.OthPay = res.Output.Setlinfo.OthPay
  12036. order.FundPaySumamt = res.Output.Setlinfo.FundPaySumamt
  12037. order.PsnPartAmt = res.Output.Setlinfo.PsnPartAmt
  12038. order.AcctPay = res.Output.Setlinfo.AcctPay
  12039. order.PsnCashPay = res.Output.Setlinfo.PsnCashPay
  12040. order.HospPartAmt = res.Output.Setlinfo.HospPartAmt
  12041. order.Balc = res.Output.Setlinfo.Balc
  12042. order.AcctMulaidPay = res.Output.Setlinfo.AcctMulaidPay
  12043. order.MedinsSetlId = res.Output.Setlinfo.MedinsSetlID
  12044. order.ClrOptins = res.Output.Setlinfo.ClrOptins
  12045. order.ClrWay = res.Output.Setlinfo.ClrWay
  12046. order.Creator = order.Creator
  12047. order.Modify = roles.AdminUserId
  12048. setlDetail, _ := json.Marshal(res.Output.Setldetail)
  12049. detailStr := string(setlDetail)
  12050. order.SetlDetail = detailStr
  12051. //err := service.UpdataOrderStatusTwo(chrg_bchno, adminUser.CurrentOrgId)
  12052. err = service.UpDateOrder(order)
  12053. if err == nil {
  12054. c.ServeSuccessJSON(map[string]interface{}{
  12055. "msg": "预结算成功",
  12056. })
  12057. } else {
  12058. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeAmountAccountException)
  12059. return
  12060. }
  12061. }
  12062. } else {
  12063. adminUser := c.GetAdminUserInfo()
  12064. errlog := &models.HisOrderError{
  12065. UserOrgId: adminUser.CurrentOrgId,
  12066. Ctime: time.Now().Unix(),
  12067. Mtime: time.Now().Unix(),
  12068. ErrMsg: res.ErrMsg,
  12069. Status: 1,
  12070. PatientId: id,
  12071. RecordTime: recordDateTime,
  12072. Stage: 4,
  12073. }
  12074. service.CreateErrMsgLog(errlog)
  12075. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeRegisterRepeatException)
  12076. return
  12077. }
  12078. } else {
  12079. adminUser := c.GetAdminUserInfo()
  12080. errlog := &models.HisOrderError{
  12081. UserOrgId: adminUser.CurrentOrgId,
  12082. Ctime: time.Now().Unix(),
  12083. Mtime: time.Now().Unix(),
  12084. ErrMsg: res.ErrMsg,
  12085. Status: 1,
  12086. PatientId: id,
  12087. RecordTime: recordDateTime,
  12088. Stage: 4,
  12089. }
  12090. service.CreateErrMsgLog(errlog)
  12091. c.ServeSuccessJSON(map[string]interface{}{
  12092. "failed_code": -10,
  12093. "msg": res.ErrMsg,
  12094. })
  12095. return
  12096. }
  12097. }
  12098. }
  12099. }
  12100. // 退款
  12101. func (c *HisApiController) Refund() {
  12102. order_id, _ := c.GetInt64("order_id")
  12103. admin_user_id, _ := c.GetInt64("admin_user_id")
  12104. adminUser := c.GetAdminUserInfo()
  12105. var order models.HisOrder
  12106. order, _ = service.GetHisOrderByID(order_id)
  12107. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  12108. if order.ID == 0 {
  12109. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  12110. return
  12111. }
  12112. his, _ := service.GetHisPatientByNumber(order.MdtrtId)
  12113. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  12114. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  12115. if config.IsOpen == 1 { //对接了医保,走医保流程
  12116. var res ResultSixteen
  12117. var resSixteen10265 ResultSixteen10265
  12118. var src_resquest string
  12119. var result string
  12120. if miConfig.MdtrtareaAdmvs == "421300" {
  12121. api3 := "http://192.168.124.4:9532/" + "hbyb/2208?psn_no=" + order.PsnNo +
  12122. "&mdtrt_id=" + order.MdtrtId + "&setl_id=" + order.SetlId + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  12123. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  12124. resp3, requestErr3 := http.Get(api3)
  12125. if requestErr3 != nil {
  12126. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12127. return
  12128. }
  12129. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  12130. if ioErr3 != nil {
  12131. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  12132. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12133. return
  12134. }
  12135. var respJSON3 map[string]interface{}
  12136. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  12137. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  12138. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12139. return
  12140. }
  12141. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  12142. userJSONBytes3, _ := json.Marshal(respJSON3)
  12143. fmt.Println("log")
  12144. fmt.Println(string(userJSONBytes3))
  12145. if err := json.Unmarshal(userJSONBytes3, &res); err != nil {
  12146. utils.ErrorLog("解析失败:%v", err)
  12147. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12148. return
  12149. }
  12150. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  12151. var api3 string
  12152. if miConfig.MdtrtareaAdmvs == "320921" {
  12153. api3 = "http://192.168.2.3:9532/" + "jsyb/2208?psn_no=" + order.PsnNo +
  12154. "&mdtrt_id=" + order.MdtrtId + "&setl_id=" + order.SetlId + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  12155. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  12156. //req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  12157. } else {
  12158. //req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  12159. api3 = "http://192.168.5.251:9532/" + "jsyb/2208?psn_no=" + order.PsnNo +
  12160. "&mdtrt_id=" + order.MdtrtId + "&setl_id=" + order.SetlId + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  12161. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  12162. }
  12163. resp3, requestErr3 := http.Get(api3)
  12164. if requestErr3 != nil {
  12165. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12166. return
  12167. }
  12168. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  12169. if ioErr3 != nil {
  12170. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  12171. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12172. return
  12173. }
  12174. var respJSON3 map[string]interface{}
  12175. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  12176. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  12177. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12178. return
  12179. }
  12180. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  12181. userJSONBytes3, _ := json.Marshal(respJSON3)
  12182. if err := json.Unmarshal(userJSONBytes3, &resSixteen10265); err != nil {
  12183. utils.ErrorLog("解析失败:%v", err)
  12184. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12185. return
  12186. }
  12187. res.InfRefmsgid = resSixteen10265.InfRefmsgid
  12188. res.Output = resSixteen10265.Output
  12189. res.ErrMsg = resSixteen10265.ErrMsg
  12190. res.Cainfo = resSixteen10265.Cainfo
  12191. res.WarnMsg = resSixteen10265.WarnMsg
  12192. infocode, _ := strconv.ParseInt(resSixteen10265.Infcode, 10, 64)
  12193. res.Infcode = infocode
  12194. } else if miConfig.MdtrtareaAdmvs == "350500" {
  12195. 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)
  12196. var dat map[string]interface{}
  12197. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  12198. fmt.Println(dat)
  12199. } else {
  12200. fmt.Println(err)
  12201. }
  12202. saveLog(result, src_resquest, "2208", "退费")
  12203. userJSONBytes, _ := json.Marshal(dat)
  12204. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  12205. utils.ErrorLog("解析失败:%v", err)
  12206. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12207. return
  12208. }
  12209. } else if miConfig.MdtrtareaAdmvs == "360399" {
  12210. 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, "")
  12211. var dat map[string]interface{}
  12212. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  12213. fmt.Println(dat)
  12214. } else {
  12215. fmt.Println(err)
  12216. }
  12217. saveLog(result, src_resquest, "2208", "退费")
  12218. userJSONBytes, _ := json.Marshal(dat)
  12219. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  12220. utils.ErrorLog("解析失败:%v", err)
  12221. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12222. return
  12223. }
  12224. } else if miConfig.MdtrtareaAdmvs == "430800" {
  12225. 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, "")
  12226. var dat map[string]interface{}
  12227. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  12228. fmt.Println(dat)
  12229. } else {
  12230. fmt.Println(err)
  12231. }
  12232. saveLog(result, src_resquest, "2208", "退费")
  12233. userJSONBytes, _ := json.Marshal(dat)
  12234. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  12235. utils.ErrorLog("解析失败:%v", err)
  12236. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12237. return
  12238. }
  12239. } else {
  12240. if miConfig.Code == "H15049901371" {
  12241. result, src_resquest = service.Gdyb2208(order.PsnNo, order.MdtrtId, order.SetlId, miConfig.OrgName, roles.UserName, miConfig.SecretKey, miConfig.Code, his.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs)
  12242. var dat map[string]interface{}
  12243. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  12244. fmt.Println(dat)
  12245. } else {
  12246. fmt.Println(err)
  12247. }
  12248. saveLog(result, src_resquest, "2208", "退费")
  12249. userJSONBytes, _ := json.Marshal(dat)
  12250. if err := json.Unmarshal(userJSONBytes, &resSixteen10265); err != nil {
  12251. utils.ErrorLog("解析失败:%v", err)
  12252. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12253. return
  12254. }
  12255. res.InfRefmsgid = resSixteen10265.InfRefmsgid
  12256. res.Output = resSixteen10265.Output
  12257. res.ErrMsg = resSixteen10265.ErrMsg
  12258. res.Cainfo = resSixteen10265.Cainfo
  12259. res.WarnMsg = resSixteen10265.WarnMsg
  12260. infocode, _ := strconv.ParseInt(resSixteen10265.Infcode, 10, 64)
  12261. res.Infcode = infocode
  12262. } else {
  12263. result, src_resquest = service.Gdyb2208(order.PsnNo, order.MdtrtId, order.SetlId, miConfig.OrgName, roles.UserName, miConfig.SecretKey, miConfig.Code, his.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs)
  12264. var dat map[string]interface{}
  12265. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  12266. fmt.Println(dat)
  12267. } else {
  12268. fmt.Println(err)
  12269. }
  12270. saveLog(result, src_resquest, "2208", "退费")
  12271. userJSONBytes, _ := json.Marshal(dat)
  12272. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  12273. utils.ErrorLog("解析失败:%v", err)
  12274. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12275. return
  12276. }
  12277. }
  12278. }
  12279. if res.Infcode == 0 {
  12280. var res2 ResultSix
  12281. var resSix10265 ResultSix10265
  12282. if miConfig.MdtrtareaAdmvs == "421300" {
  12283. api3 := "http://192.168.124.4:9532/" + "hbyb/2205?psn_no=" + order.PsnNo +
  12284. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  12285. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  12286. resp3, requestErr3 := http.Get(api3)
  12287. if requestErr3 != nil {
  12288. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12289. return
  12290. }
  12291. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  12292. if ioErr3 != nil {
  12293. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  12294. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12295. return
  12296. }
  12297. var respJSON3 map[string]interface{}
  12298. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  12299. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  12300. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12301. return
  12302. }
  12303. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  12304. userJSONBytes3, _ := json.Marshal(respJSON3)
  12305. fmt.Println("log")
  12306. fmt.Println(string(userJSONBytes3))
  12307. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  12308. utils.ErrorLog("解析失败:%v", err)
  12309. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12310. return
  12311. }
  12312. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  12313. var api3 string
  12314. if miConfig.MdtrtareaAdmvs == "320921" {
  12315. api3 = "http://192.168.2.3:9532/" + "jsyb/2205?psn_no=" + order.PsnNo +
  12316. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  12317. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  12318. //req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  12319. } else {
  12320. //req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  12321. api3 = "http://192.168.5.251:9532/" + "jsyb/2205?psn_no=" + order.PsnNo +
  12322. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  12323. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  12324. }
  12325. resp3, requestErr3 := http.Get(api3)
  12326. if requestErr3 != nil {
  12327. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12328. return
  12329. }
  12330. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  12331. if ioErr3 != nil {
  12332. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  12333. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12334. return
  12335. }
  12336. var respJSON3 map[string]interface{}
  12337. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  12338. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  12339. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12340. return
  12341. }
  12342. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  12343. userJSONBytes3, _ := json.Marshal(respJSON3)
  12344. fmt.Println("log")
  12345. fmt.Println(string(userJSONBytes3))
  12346. if err := json.Unmarshal(userJSONBytes3, &resSix10265); err != nil {
  12347. utils.ErrorLog("解析失败:%v", err)
  12348. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12349. return
  12350. }
  12351. res2.InfRefmsgid = resSix10265.InfRefmsgid
  12352. res2.Output = resSix10265.Output
  12353. res2.ErrMsg = resSix10265.ErrMsg
  12354. res2.Cainfo = resSix10265.Cainfo
  12355. res2.WarnMsg = resSix10265.WarnMsg
  12356. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  12357. res2.Infcode = infocode
  12358. } else if miConfig.MdtrtareaAdmvs == "350500" {
  12359. 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)
  12360. var dat map[string]interface{}
  12361. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  12362. fmt.Println(dat)
  12363. } else {
  12364. fmt.Println(err)
  12365. }
  12366. saveLog(result2, src_request, "2205", "撤销明细")
  12367. userJSONBytes, _ := json.Marshal(dat)
  12368. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  12369. utils.ErrorLog("解析失败:%v", err)
  12370. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12371. return
  12372. }
  12373. } else if miConfig.MdtrtareaAdmvs == "360399" {
  12374. 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, "")
  12375. var dat map[string]interface{}
  12376. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  12377. fmt.Println(dat)
  12378. } else {
  12379. fmt.Println(err)
  12380. }
  12381. saveLog(result2, src_request, "2205", "撤销明细")
  12382. userJSONBytes, _ := json.Marshal(dat)
  12383. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  12384. utils.ErrorLog("解析失败:%v", err)
  12385. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12386. return
  12387. }
  12388. } else if miConfig.MdtrtareaAdmvs == "430800" {
  12389. 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, "")
  12390. var dat map[string]interface{}
  12391. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  12392. fmt.Println(dat)
  12393. } else {
  12394. fmt.Println(err)
  12395. }
  12396. saveLog(result2, src_request, "2205", "撤销明细")
  12397. userJSONBytes, _ := json.Marshal(dat)
  12398. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  12399. utils.ErrorLog("解析失败:%v", err)
  12400. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12401. return
  12402. }
  12403. } else {
  12404. if miConfig.Code == "H15049901371" {
  12405. result2, src_request := service.Gdyb2205(order.PsnNo, order.MdtrtId, order.Number, miConfig.OrgName, roles.UserName, his.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, miConfig.Code)
  12406. var dat map[string]interface{}
  12407. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  12408. fmt.Println(dat)
  12409. } else {
  12410. fmt.Println(err)
  12411. }
  12412. saveLog(result2, src_request, "2205", "撤销明细")
  12413. userJSONBytes, _ := json.Marshal(dat)
  12414. if err := json.Unmarshal(userJSONBytes, &resSix10265); err != nil {
  12415. utils.ErrorLog("解析失败:%v", err)
  12416. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12417. return
  12418. }
  12419. res2.InfRefmsgid = resSix10265.InfRefmsgid
  12420. res2.Output = resSix10265.Output
  12421. res2.ErrMsg = resSix10265.ErrMsg
  12422. res2.Cainfo = resSix10265.Cainfo
  12423. res2.WarnMsg = resSix10265.WarnMsg
  12424. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  12425. res2.Infcode = infocode
  12426. } else {
  12427. result2, src_request := service.Gdyb2205(order.PsnNo, order.MdtrtId, order.Number, miConfig.OrgName, roles.UserName, his.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, miConfig.Code)
  12428. var dat map[string]interface{}
  12429. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  12430. fmt.Println(dat)
  12431. } else {
  12432. fmt.Println(err)
  12433. }
  12434. saveLog(result2, src_request, "2205", "撤销明细")
  12435. userJSONBytes, _ := json.Marshal(dat)
  12436. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  12437. utils.ErrorLog("解析失败:%v", err)
  12438. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12439. return
  12440. }
  12441. }
  12442. }
  12443. if res2.Infcode == 0 {
  12444. err := service.UpdataOrderStatus(order_id, order.Number, adminUser.CurrentOrgId, src_resquest, result)
  12445. if err == nil {
  12446. //当押金不为零时产生退费记录
  12447. if order.Decimal != 0 {
  12448. tmp := strconv.FormatInt(order.ID, 10)
  12449. err = service.MoneyIncrease(adminUser.CurrentOrgId, order.PatientId, tmp, order.Decimal)
  12450. if err != nil {
  12451. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12452. return
  12453. }
  12454. }
  12455. c.ServeSuccessJSON(map[string]interface{}{
  12456. "msg": "退费成功",
  12457. })
  12458. } else {
  12459. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12460. return
  12461. }
  12462. } else {
  12463. c.ServeSuccessJSON(map[string]interface{}{
  12464. "code": -10,
  12465. "msg": res2.ErrMsg,
  12466. })
  12467. }
  12468. } else {
  12469. c.ServeSuccessJSON(map[string]interface{}{
  12470. "code": -10,
  12471. "msg": res.ErrMsg,
  12472. })
  12473. }
  12474. }
  12475. }
  12476. func (c *HisApiController) RefundNumber() {
  12477. record_time := c.GetString("record_time")
  12478. //patient_id, _ := c.GetInt64("patient_id")
  12479. admin_user_id, _ := c.GetInt64("admin_user_id")
  12480. his_patient_id, _ := c.GetInt64("id")
  12481. timeLayout := "2006-01-02"
  12482. loc, _ := time.LoadLocation("Local")
  12483. adminUser := c.GetAdminUserInfo()
  12484. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  12485. fmt.Println(err)
  12486. if err != nil {
  12487. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  12488. return
  12489. }
  12490. recordDateTime := theTime.Unix()
  12491. //his, _ := service.GetVMHisPatientInfo(adminUser.CurrentOrgId, patient_id, recordDateTime)
  12492. his, _ := service.GetHisPatientRecord(adminUser.CurrentOrgId, his_patient_id)
  12493. //patientPrescription, _ := service.FindPatientPrescriptionInfo(adminUser.CurrentOrgId, patient_id, recordDateTime)
  12494. //order, _ := service.GetHisOrderByID(order_id)
  12495. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  12496. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  12497. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  12498. count, _ := service.GetOrderCountByNumber(adminUser.CurrentOrgId, his.PatientId, recordDateTime, his.Number)
  12499. if count > 0 {
  12500. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeOrderParamWrong)
  12501. return
  12502. }
  12503. if config.IsOpen == 1 { //对接了医保,走医保流程
  12504. var res2 ResultSix
  12505. var resSix10265 ResultSix10265
  12506. if miConfig.MdtrtareaAdmvs == "421300" {
  12507. api3 := "http://192.168.124.4:9532/" + "hbyb/2202?psn_no=" + his.PsnNo +
  12508. "&mdtrt_id=" + his.Number + "&ipt_otp_no=" + his.IptOtpNo + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  12509. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  12510. resp3, requestErr3 := http.Get(api3)
  12511. if requestErr3 != nil {
  12512. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12513. return
  12514. }
  12515. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  12516. if ioErr3 != nil {
  12517. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  12518. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12519. return
  12520. }
  12521. var respJSON3 map[string]interface{}
  12522. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  12523. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  12524. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12525. return
  12526. }
  12527. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  12528. userJSONBytes3, _ := json.Marshal(respJSON3)
  12529. fmt.Println("log")
  12530. fmt.Println(string(userJSONBytes3))
  12531. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  12532. utils.ErrorLog("解析失败:%v", err)
  12533. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12534. return
  12535. }
  12536. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  12537. var api3 string
  12538. if miConfig.MdtrtareaAdmvs == "320921" {
  12539. api3 = "http://192.168.2.3:9532/" + "jsyb/2202?psn_no=" + his.PsnNo +
  12540. "&mdtrt_id=" + his.Number + "&ipt_otp_no=" + his.IptOtpNo + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  12541. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  12542. //req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  12543. } else {
  12544. //req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  12545. api3 = "http://192.168.5.251:9532/" + "jsyb/2202?psn_no=" + his.PsnNo +
  12546. "&mdtrt_id=" + his.Number + "&ipt_otp_no=" + his.IptOtpNo + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  12547. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  12548. }
  12549. resp3, requestErr3 := http.Get(api3)
  12550. if requestErr3 != nil {
  12551. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12552. return
  12553. }
  12554. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  12555. if ioErr3 != nil {
  12556. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  12557. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12558. return
  12559. }
  12560. var respJSON3 map[string]interface{}
  12561. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  12562. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  12563. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12564. return
  12565. }
  12566. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  12567. userJSONBytes3, _ := json.Marshal(respJSON3)
  12568. if err := json.Unmarshal(userJSONBytes3, &resSix10265); err != nil {
  12569. utils.ErrorLog("解析失败:%v", err)
  12570. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12571. return
  12572. }
  12573. res2.InfRefmsgid = resSix10265.InfRefmsgid
  12574. res2.Output = resSix10265.Output
  12575. res2.ErrMsg = resSix10265.ErrMsg
  12576. res2.Cainfo = resSix10265.Cainfo
  12577. res2.WarnMsg = resSix10265.WarnMsg
  12578. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  12579. res2.Infcode = infocode
  12580. } else if miConfig.MdtrtareaAdmvs == "350500" {
  12581. 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)
  12582. var dat map[string]interface{}
  12583. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  12584. fmt.Println(dat)
  12585. } else {
  12586. fmt.Println(err)
  12587. }
  12588. saveLog(result, request, "2202", "退号")
  12589. userJSONBytes, _ := json.Marshal(dat)
  12590. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  12591. utils.ErrorLog("解析失败:%v", err)
  12592. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12593. return
  12594. }
  12595. } else if miConfig.MdtrtareaAdmvs == "360399" {
  12596. 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, "")
  12597. var dat map[string]interface{}
  12598. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  12599. fmt.Println(dat)
  12600. } else {
  12601. fmt.Println(err)
  12602. }
  12603. saveLog(result, request, "2202", "退号")
  12604. userJSONBytes, _ := json.Marshal(dat)
  12605. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  12606. utils.ErrorLog("解析失败:%v", err)
  12607. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12608. return
  12609. }
  12610. } else if miConfig.MdtrtareaAdmvs == "430800" {
  12611. 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, "")
  12612. var dat map[string]interface{}
  12613. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  12614. fmt.Println(dat)
  12615. } else {
  12616. fmt.Println(err)
  12617. }
  12618. saveLog(result, request, "2202", "退号")
  12619. userJSONBytes, _ := json.Marshal(dat)
  12620. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  12621. utils.ErrorLog("解析失败:%v", err)
  12622. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12623. return
  12624. }
  12625. } else {
  12626. var api3 string
  12627. if miConfig.Code == "H15049901371" {
  12628. api3 = "http://127.0.0.1:9532/" + "gdyb/three?psn_no=" + his.PsnNo +
  12629. "&mdtrt_id=" + his.Number + "&ipt_otp_no=" + his.IptOtpNo + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  12630. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  12631. } else {
  12632. api3 = "http://127.0.0.1:9532/" + "gdyb/three?psn_no=" + his.PsnNo +
  12633. "&mdtrt_id=" + his.Number + "&ipt_otp_no=" + his.IptOtpNo + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  12634. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  12635. }
  12636. resp3, requestErr3 := http.Get(api3)
  12637. if requestErr3 != nil {
  12638. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12639. return
  12640. }
  12641. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  12642. if ioErr3 != nil {
  12643. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  12644. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12645. return
  12646. }
  12647. var respJSON3 map[string]interface{}
  12648. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  12649. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  12650. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12651. return
  12652. }
  12653. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  12654. userJSONBytes3, _ := json.Marshal(respJSON3)
  12655. if miConfig.Code == "H15049901371" {
  12656. if err := json.Unmarshal(userJSONBytes3, &resSix10265); err != nil {
  12657. utils.ErrorLog("解析失败:%v", err)
  12658. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12659. return
  12660. }
  12661. res2.InfRefmsgid = resSix10265.InfRefmsgid
  12662. res2.Output = resSix10265.Output
  12663. res2.ErrMsg = resSix10265.ErrMsg
  12664. res2.Cainfo = resSix10265.Cainfo
  12665. res2.WarnMsg = resSix10265.WarnMsg
  12666. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  12667. res2.Infcode = infocode
  12668. } else {
  12669. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  12670. utils.ErrorLog("解析失败:%v", err)
  12671. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12672. return
  12673. }
  12674. }
  12675. }
  12676. if res2.Infcode == 0 {
  12677. if err == nil {
  12678. c.ServeSuccessJSON(map[string]interface{}{
  12679. "msg": "退号成功",
  12680. })
  12681. service.UpdataRegStatusTwo(his_patient_id, recordDateTime, adminUser.CurrentOrgId)
  12682. } else {
  12683. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12684. return
  12685. }
  12686. } else {
  12687. c.ServeSuccessJSON(map[string]interface{}{
  12688. "code": -10,
  12689. "msg": res2.ErrMsg,
  12690. })
  12691. }
  12692. } else {
  12693. //err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId)
  12694. //if err == nil {
  12695. // c.ServeSuccessJSON(map[string]interface{}{
  12696. // "msg": "退费成功",
  12697. // })
  12698. //} else {
  12699. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12700. // return
  12701. //}
  12702. }
  12703. }
  12704. func (c *HisApiController) RefundDetail() {
  12705. order_id, _ := c.GetInt64("order_id")
  12706. admin_user_id, _ := c.GetInt64("admin_user_id")
  12707. //his_patient_id, _ := c.GetInt64("his_patient_id")
  12708. number := c.GetString("number")
  12709. record_time := c.GetString("record_time")
  12710. patient_id, _ := c.GetInt64("patient_id")
  12711. //med_type, _ := c.GetInt64("med_type")
  12712. timeLayout := "2006-01-02"
  12713. loc, _ := time.LoadLocation("Local")
  12714. adminUser := c.GetAdminUserInfo()
  12715. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  12716. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  12717. fmt.Println(err)
  12718. if err != nil {
  12719. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  12720. return
  12721. }
  12722. recordDateTime := theTime.Unix()
  12723. //his, _ := service.GetNewVMHisPatientInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  12724. patientPrescription, _ := service.FindPatientPrescriptionInfo(adminUser.CurrentOrgId, patient_id, recordDateTime)
  12725. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  12726. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  12727. var order models.HisOrder
  12728. order, _ = service.GetHisOrderByID(order_id)
  12729. his, _ := service.GetHisPatientByNumber(order.MdtrtId)
  12730. if config.IsOpen == 1 { //对接了医保,走医保流程
  12731. var res2 ResultSix
  12732. if miConfig.MdtrtareaAdmvs == "421300" {
  12733. api3 := "http://192.168.124.4:9532/" + "hbyb/2205?psn_no=" + order.PsnNo +
  12734. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + patientPrescription.Doctor + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  12735. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  12736. resp3, requestErr3 := http.Get(api3)
  12737. if requestErr3 != nil {
  12738. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12739. return
  12740. }
  12741. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  12742. if ioErr3 != nil {
  12743. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  12744. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12745. return
  12746. }
  12747. var respJSON3 map[string]interface{}
  12748. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  12749. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  12750. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12751. return
  12752. }
  12753. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  12754. userJSONBytes3, _ := json.Marshal(respJSON3)
  12755. fmt.Println("log")
  12756. fmt.Println(string(userJSONBytes3))
  12757. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  12758. utils.ErrorLog("解析失败:%v", err)
  12759. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12760. return
  12761. }
  12762. err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId, "", "")
  12763. if err == nil {
  12764. c.ServeSuccessJSON(map[string]interface{}{
  12765. "msg": "撤销明细成功",
  12766. })
  12767. return
  12768. } else {
  12769. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12770. return
  12771. }
  12772. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  12773. var resSix10265 ResultSix10265
  12774. var api3 string
  12775. if miConfig.MdtrtareaAdmvs == "320921" {
  12776. api3 = "http://192.168.2.3:9532/" + "jsyb/2205?psn_no=" + order.PsnNo +
  12777. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + patientPrescription.Doctor + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  12778. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  12779. //req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  12780. } else {
  12781. //req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  12782. api3 = "http://192.168.5.251:9532/" + "jsyb/2205?psn_no=" + order.PsnNo +
  12783. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + patientPrescription.Doctor + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  12784. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  12785. }
  12786. resp3, requestErr3 := http.Get(api3)
  12787. if requestErr3 != nil {
  12788. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12789. return
  12790. }
  12791. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  12792. if ioErr3 != nil {
  12793. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  12794. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12795. return
  12796. }
  12797. var respJSON3 map[string]interface{}
  12798. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  12799. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  12800. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12801. return
  12802. }
  12803. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  12804. userJSONBytes3, _ := json.Marshal(respJSON3)
  12805. fmt.Println("log")
  12806. fmt.Println(string(userJSONBytes3))
  12807. if err := json.Unmarshal(userJSONBytes3, &resSix10265); err != nil {
  12808. utils.ErrorLog("解析失败:%v", err)
  12809. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12810. return
  12811. }
  12812. res2.InfRefmsgid = resSix10265.InfRefmsgid
  12813. res2.Output = resSix10265.Output
  12814. res2.ErrMsg = resSix10265.ErrMsg
  12815. res2.Cainfo = resSix10265.Cainfo
  12816. res2.WarnMsg = resSix10265.WarnMsg
  12817. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  12818. res2.Infcode = infocode
  12819. err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId, "", "")
  12820. if err == nil {
  12821. c.ServeSuccessJSON(map[string]interface{}{
  12822. "msg": "撤销明细成功",
  12823. })
  12824. return
  12825. } else {
  12826. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12827. return
  12828. }
  12829. } else if miConfig.MdtrtareaAdmvs == "350500" {
  12830. 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)
  12831. var dat map[string]interface{}
  12832. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  12833. fmt.Println(dat)
  12834. } else {
  12835. fmt.Println(err)
  12836. }
  12837. saveLog(result2, src_request, "2205", "撤销明细")
  12838. userJSONBytes, _ := json.Marshal(dat)
  12839. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  12840. utils.ErrorLog("解析失败:%v", err)
  12841. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12842. return
  12843. }
  12844. if res2.Infcode == 0 {
  12845. err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId, "", "")
  12846. if err == nil {
  12847. c.ServeSuccessJSON(map[string]interface{}{
  12848. "msg": "撤销明细成功",
  12849. })
  12850. return
  12851. } else {
  12852. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12853. return
  12854. }
  12855. } else {
  12856. c.ServeSuccessJSON(map[string]interface{}{
  12857. "code": -10,
  12858. "msg": res2.ErrMsg,
  12859. })
  12860. }
  12861. } else if miConfig.MdtrtareaAdmvs == "360399" {
  12862. 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, "")
  12863. var dat map[string]interface{}
  12864. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  12865. fmt.Println(dat)
  12866. } else {
  12867. fmt.Println(err)
  12868. }
  12869. saveLog(result2, src_request, "2205", "撤销明细")
  12870. userJSONBytes, _ := json.Marshal(dat)
  12871. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  12872. utils.ErrorLog("解析失败:%v", err)
  12873. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12874. return
  12875. }
  12876. if res2.Infcode == 0 {
  12877. err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId, "", "")
  12878. if err == nil {
  12879. c.ServeSuccessJSON(map[string]interface{}{
  12880. "msg": "撤销明细成功",
  12881. })
  12882. return
  12883. } else {
  12884. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12885. return
  12886. }
  12887. } else {
  12888. c.ServeSuccessJSON(map[string]interface{}{
  12889. "code": -10,
  12890. "msg": res2.ErrMsg,
  12891. })
  12892. }
  12893. } else if miConfig.MdtrtareaAdmvs == "430800" {
  12894. 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, "")
  12895. var dat map[string]interface{}
  12896. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  12897. fmt.Println(dat)
  12898. } else {
  12899. fmt.Println(err)
  12900. }
  12901. saveLog(result2, src_request, "2205", "撤销明细")
  12902. userJSONBytes, _ := json.Marshal(dat)
  12903. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  12904. utils.ErrorLog("解析失败:%v", err)
  12905. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12906. return
  12907. }
  12908. if res2.Infcode == 0 {
  12909. err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId, "", "")
  12910. if err == nil {
  12911. c.ServeSuccessJSON(map[string]interface{}{
  12912. "msg": "撤销明细成功",
  12913. })
  12914. return
  12915. } else {
  12916. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12917. return
  12918. }
  12919. } else {
  12920. c.ServeSuccessJSON(map[string]interface{}{
  12921. "code": -10,
  12922. "msg": res2.ErrMsg,
  12923. })
  12924. }
  12925. } else {
  12926. api2 := "http://127.0.0.1:9532/" + "gdyb/six?psn_no=" + his.PsnNo +
  12927. "&mdtrt_id=" + his.Number + "&chrg_bchno=" + order.Number + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  12928. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  12929. resp2, requestErr2 := http.Get(api2)
  12930. if requestErr2 != nil {
  12931. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12932. return
  12933. }
  12934. body2, ioErr2 := ioutil.ReadAll(resp2.Body)
  12935. if ioErr2 != nil {
  12936. utils.ErrorLog("接口返回数据读取失败: %v", ioErr2)
  12937. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12938. return
  12939. }
  12940. var respJSON2 map[string]interface{}
  12941. if err := json.Unmarshal([]byte(string(body2)), &respJSON2); err != nil {
  12942. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  12943. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12944. return
  12945. }
  12946. err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId, "", "")
  12947. if err == nil {
  12948. c.ServeSuccessJSON(map[string]interface{}{
  12949. "msg": "撤销明细成功",
  12950. })
  12951. return
  12952. } else {
  12953. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12954. return
  12955. }
  12956. }
  12957. } else {
  12958. err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId, "", "")
  12959. if err == nil {
  12960. c.ServeSuccessJSON(map[string]interface{}{
  12961. "msg": "退费成功",
  12962. })
  12963. } else {
  12964. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12965. return
  12966. }
  12967. }
  12968. }
  12969. // 对账
  12970. func (c *HisApiController) GetCheckAccount() {
  12971. start_time := c.GetString("start_time")
  12972. end_time := c.GetString("end_time")
  12973. insutype := c.GetString("insutype")
  12974. clr_type := c.GetString("clr_type")
  12975. clr_org := c.GetString("clr_optins")
  12976. admin_user_id, _ := c.GetInt64("admin_user_id")
  12977. adminUser := c.GetAdminUserInfo()
  12978. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  12979. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  12980. if len(clr_org) == 0 {
  12981. clr_org = miConfig.MdtrtareaAdmvs
  12982. }
  12983. timeLayout := "2006-01-02"
  12984. loc, _ := time.LoadLocation("Local")
  12985. startime, _ := time.ParseInLocation(timeLayout+" 15:04:05", start_time+" 00:00:00", loc)
  12986. endtime, _ := time.ParseInLocation(timeLayout+" 15:04:05", end_time+" 23:59:59", loc)
  12987. orders, _ := service.GetOrderByTime(startime.Unix(), endtime.Unix(), adminUser.CurrentOrgId, insutype, "", clr_type, miConfig.MdtrtareaAdmvs)
  12988. orders_two, _ := service.GetOrderByTimeFive(startime.Unix(), endtime.Unix(), adminUser.CurrentOrgId, insutype, "", clr_type, miConfig.MdtrtareaAdmvs)
  12989. fixmedins_setl_cnt := int64(len(orders))
  12990. var medfee_sumamt float64
  12991. var acct_pay float64
  12992. var fund_pay_sumamt float64
  12993. for _, item := range orders {
  12994. medfee_sumamt = medfee_sumamt + item.MedfeeSumamt
  12995. acct_pay = acct_pay + item.AcctPay
  12996. fund_pay_sumamt = fund_pay_sumamt + item.FundPaySumamt
  12997. }
  12998. var user_name string
  12999. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  13000. if role.ID == 0 {
  13001. user_name = "xxx"
  13002. } else {
  13003. user_name = role.UserName
  13004. }
  13005. var res ResultEight
  13006. var res10188 ResultEightFor10188
  13007. if config.IsOpen == 1 {
  13008. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  13009. api := "http://192.168.2.3:9532/" + "jsyb/3201?" +
  13010. "insutype=" + insutype +
  13011. "&clr_type=" + clr_type +
  13012. "&setl_optins=" + clr_org +
  13013. "&stmt_begndate=" + start_time +
  13014. "&stm_enddate=" + end_time +
  13015. "&medfee_sumamt=" + fmt.Sprintf("%.4f", medfee_sumamt) +
  13016. "&fund_pay_sumamt=" + fmt.Sprintf("%.4f", fund_pay_sumamt) +
  13017. "&acct_pay=" + fmt.Sprintf("%.4f", acct_pay) +
  13018. "&fixmedins_setl_cnt=" + strconv.FormatInt(fixmedins_setl_cnt+int64(len(orders_two)*2), 10) +
  13019. "&fixmedins_code=" + miConfig.Code +
  13020. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs +
  13021. "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  13022. "&secret_key=" + miConfig.SecretKey +
  13023. "&org_name=" + miConfig.OrgName +
  13024. "&doctor=" + user_name +
  13025. "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  13026. fmt.Println(api)
  13027. resp, requestErr := http.Get(api)
  13028. if requestErr != nil {
  13029. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13030. return
  13031. }
  13032. body, ioErr := ioutil.ReadAll(resp.Body)
  13033. fmt.Println(body)
  13034. if ioErr != nil {
  13035. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  13036. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13037. return
  13038. }
  13039. var respJSON map[string]interface{}
  13040. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  13041. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  13042. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13043. return
  13044. }
  13045. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  13046. userJSONBytes, _ := json.Marshal(respJSON)
  13047. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  13048. utils.ErrorLog("解析失败:%v", err)
  13049. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13050. return
  13051. }
  13052. res.InfRefmsgid = res10188.InfRefmsgid
  13053. res.Output = res10188.Output
  13054. res.ErrMsg = res10188.ErrMsg
  13055. res.Cainfo = res10188.Cainfo
  13056. res.WarnMsg = res10188.WarnMsg
  13057. infocode, _ := strconv.ParseInt(res10188.Infcode, 10, 64)
  13058. res.Infcode = infocode
  13059. } else if miConfig.MdtrtareaAdmvs == "150499" {
  13060. if clr_type == "11" {
  13061. fixmedins_setl_cnt = 2
  13062. }
  13063. //if clr_type == "21" {
  13064. // clr_type = "22"
  13065. //}
  13066. api := "http://172.16.13.254:9532/" + "nmyb/3201?" +
  13067. "insutype=" + insutype +
  13068. "&clr_type=" + clr_type +
  13069. "&setl_optins=" + clr_org +
  13070. "&stmt_begndate=" + start_time +
  13071. "&stm_enddate=" + end_time +
  13072. "&medfee_sumamt=" + fmt.Sprintf("%.4f", medfee_sumamt) +
  13073. "&fund_pay_sumamt=" + fmt.Sprintf("%.4f", fund_pay_sumamt) +
  13074. "&acct_pay=" + fmt.Sprintf("%.4f", acct_pay) +
  13075. "&fixmedins_setl_cnt=" + strconv.FormatInt(fixmedins_setl_cnt+int64(len(orders_two)*2), 10) +
  13076. "&fixmedins_code=" + miConfig.Code +
  13077. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs +
  13078. "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  13079. "&secret_key=" + miConfig.SecretKey +
  13080. "&org_name=" + miConfig.OrgName +
  13081. "&doctor=" + user_name
  13082. resp, requestErr := http.Get(api)
  13083. if requestErr != nil {
  13084. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13085. return
  13086. }
  13087. body, ioErr := ioutil.ReadAll(resp.Body)
  13088. if ioErr != nil {
  13089. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  13090. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13091. return
  13092. }
  13093. var respJSON map[string]interface{}
  13094. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  13095. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  13096. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13097. return
  13098. }
  13099. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  13100. result, _ := json.Marshal(respJSON)
  13101. fmt.Println("log")
  13102. fmt.Println(string(result))
  13103. if err := json.Unmarshal([]byte(result), &res10188); err != nil {
  13104. utils.ErrorLog("解析失败:%v", err)
  13105. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13106. return
  13107. }
  13108. res.InfRefmsgid = res10188.InfRefmsgid
  13109. res.Output = res10188.Output
  13110. res.ErrMsg = res10188.ErrMsg
  13111. res.Cainfo = res10188.Cainfo
  13112. res.WarnMsg = res10188.WarnMsg
  13113. infocode, _ := strconv.ParseInt(res10188.Infcode, 10, 64)
  13114. res.Infcode = infocode
  13115. } else if miConfig.MdtrtareaAdmvs == "350500" {
  13116. var baseParams models.BaseParams
  13117. baseParams.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  13118. baseParams.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  13119. baseParams.SecretKey = miConfig.SecretKey
  13120. baseParams.OrgName = miConfig.OrgName
  13121. baseParams.FixmedinsCode = miConfig.Code
  13122. baseParams.EncKey = miConfig.EncKey
  13123. baseParams.AppSecret = miConfig.AppSecret
  13124. baseParams.SignKey = miConfig.SignKey
  13125. baseParams.AppID = miConfig.Code
  13126. baseParams.Doctor = role.UserName
  13127. baseParams.RequestUrl = miConfig.Url
  13128. businessParams := models.BusinessParams{
  13129. Insutype: insutype,
  13130. ClrType: clr_type,
  13131. SetlOptins: clr_org,
  13132. StmtBegndate: start_time,
  13133. StmtEnddate: end_time,
  13134. MedfeeSumamt: medfee_sumamt,
  13135. FundPaySumamt: fund_pay_sumamt,
  13136. AcctPay: acct_pay,
  13137. FixmedinsSetlCnt: fixmedins_setl_cnt,
  13138. }
  13139. result, requestLog, err_msg := service.FJyb3201(baseParams, businessParams, fmt.Sprintf("%.4f", medfee_sumamt), fmt.Sprintf("%.4f", fund_pay_sumamt))
  13140. fmt.Println(requestLog)
  13141. fmt.Println(result)
  13142. fmt.Println(err_msg)
  13143. var dat map[string]interface{}
  13144. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  13145. fmt.Println(dat)
  13146. } else {
  13147. fmt.Println(err)
  13148. }
  13149. userJSONBytes, _ := json.Marshal(dat)
  13150. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  13151. utils.ErrorLog("解析失败:%v", err)
  13152. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13153. return
  13154. }
  13155. } else if miConfig.MdtrtareaAdmvs == "430800" {
  13156. var baseParams models.BaseParams
  13157. baseParams.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  13158. baseParams.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  13159. baseParams.SecretKey = miConfig.SecretKey
  13160. baseParams.OrgName = miConfig.OrgName
  13161. baseParams.FixmedinsCode = miConfig.Code
  13162. baseParams.EncKey = miConfig.EncKey
  13163. baseParams.AppSecret = miConfig.AppSecret
  13164. baseParams.SignKey = miConfig.SignKey
  13165. baseParams.AppID = miConfig.Code
  13166. baseParams.Doctor = role.UserName
  13167. baseParams.RequestUrl = miConfig.Url
  13168. baseParams.AccessKey = miConfig.AccessKey
  13169. businessParams := models.BusinessParams{
  13170. Insutype: insutype,
  13171. ClrType: clr_type,
  13172. SetlOptins: "430822",
  13173. StmtBegndate: start_time,
  13174. StmtEnddate: end_time,
  13175. MedfeeSumamt: medfee_sumamt,
  13176. FundPaySumamt: fund_pay_sumamt,
  13177. AcctPay: acct_pay,
  13178. FixmedinsSetlCnt: fixmedins_setl_cnt,
  13179. }
  13180. 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)
  13181. fmt.Println(requestLog)
  13182. fmt.Println(result)
  13183. var dat map[string]interface{}
  13184. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  13185. fmt.Println(dat)
  13186. } else {
  13187. fmt.Println(err)
  13188. }
  13189. userJSONBytes, _ := json.Marshal(dat)
  13190. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  13191. utils.ErrorLog("解析失败:%v", err)
  13192. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13193. return
  13194. }
  13195. } else if miConfig.MdtrtareaAdmvs == "350500" {
  13196. var baseParams models.BaseParams
  13197. baseParams.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  13198. baseParams.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  13199. baseParams.SecretKey = miConfig.SecretKey
  13200. baseParams.OrgName = miConfig.OrgName
  13201. baseParams.FixmedinsCode = miConfig.Code
  13202. baseParams.EncKey = miConfig.EncKey
  13203. baseParams.AppSecret = miConfig.AppSecret
  13204. baseParams.SignKey = miConfig.SignKey
  13205. baseParams.AppID = miConfig.Code
  13206. baseParams.Doctor = role.UserName
  13207. baseParams.RequestUrl = miConfig.Url
  13208. businessParams := models.BusinessParams{
  13209. Insutype: insutype,
  13210. ClrType: clr_type,
  13211. SetlOptins: clr_org,
  13212. StmtBegndate: start_time,
  13213. StmtEnddate: end_time,
  13214. MedfeeSumamt: medfee_sumamt,
  13215. FundPaySumamt: fund_pay_sumamt,
  13216. AcctPay: acct_pay,
  13217. FixmedinsSetlCnt: fixmedins_setl_cnt,
  13218. }
  13219. result, requestLog, err_msg := service.FJyb3201(baseParams, businessParams, fmt.Sprintf("%.4f", medfee_sumamt), fmt.Sprintf("%.4f", fund_pay_sumamt))
  13220. fmt.Println(requestLog)
  13221. fmt.Println(result)
  13222. fmt.Println(err_msg)
  13223. var dat map[string]interface{}
  13224. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  13225. fmt.Println(dat)
  13226. } else {
  13227. fmt.Println(err)
  13228. }
  13229. userJSONBytes, _ := json.Marshal(dat)
  13230. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  13231. utils.ErrorLog("解析失败:%v", err)
  13232. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13233. return
  13234. }
  13235. } else {
  13236. if len(clr_type) == 0 {
  13237. clr_type = "11"
  13238. }
  13239. api := "http://127.0.0.1:9532/" + "gdyb/ten?" +
  13240. "insutype=" + insutype +
  13241. "&clr_type=" + clr_type +
  13242. "&setl_optins=" + clr_org +
  13243. "&stmt_begndate=" + start_time +
  13244. "&stm_enddate=" + end_time +
  13245. "&medfee_sumamt=" + fmt.Sprintf("%.4f", medfee_sumamt) +
  13246. "&fund_pay_sumamt=" + fmt.Sprintf("%.4f", fund_pay_sumamt) +
  13247. "&acct_pay=" + fmt.Sprintf("%.4f", acct_pay) +
  13248. "&fixmedins_setl_cnt=" + strconv.FormatInt(fixmedins_setl_cnt, 10) +
  13249. "&fixmedins_code=" + miConfig.Code +
  13250. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs +
  13251. "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  13252. "&secret_key=" + miConfig.SecretKey +
  13253. "&org_name=" + miConfig.OrgName +
  13254. "&doctor=" + user_name
  13255. fmt.Println(api)
  13256. resp, requestErr := http.Get(api)
  13257. if requestErr != nil {
  13258. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13259. return
  13260. }
  13261. body, ioErr := ioutil.ReadAll(resp.Body)
  13262. fmt.Println(body)
  13263. if ioErr != nil {
  13264. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  13265. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13266. return
  13267. }
  13268. var respJSON map[string]interface{}
  13269. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  13270. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  13271. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13272. return
  13273. }
  13274. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  13275. userJSONBytes, _ := json.Marshal(respJSON)
  13276. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  13277. utils.ErrorLog("解析失败:%v", err)
  13278. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13279. return
  13280. }
  13281. }
  13282. if res.Infcode == 0 {
  13283. if res.Output.Stmtinfo.StmtRslt == "0" {
  13284. micc := &models.MedicalInsuranceCostCompare{
  13285. StartTime: startime.Unix(),
  13286. EndTime: endtime.Unix(),
  13287. Insutype: insutype,
  13288. CheckType: 1,
  13289. Num: fixmedins_setl_cnt,
  13290. Mtime: time.Now().Unix(),
  13291. Status: 1,
  13292. UserOrgId: adminUser.CurrentOrgId,
  13293. CostTotal: medfee_sumamt,
  13294. FuncTotal: fund_pay_sumamt,
  13295. PsnPay: acct_pay,
  13296. Creator: admin_user_id,
  13297. Ctime: time.Now().Unix(),
  13298. ClrType: clr_type,
  13299. }
  13300. err := service.CreateMedicalInsuranceCostCompareRecord(micc)
  13301. if err == nil {
  13302. c.ServeSuccessJSON(map[string]interface{}{
  13303. "stmt_rslt": res.Output.Stmtinfo.StmtRslt,
  13304. "stmt_rslt_dscr": res.Output.Stmtinfo.StmtRsltDscr,
  13305. })
  13306. } else {
  13307. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13308. }
  13309. } else {
  13310. c.ServeSuccessJSON(map[string]interface{}{
  13311. "stmt_rslt": res.Output.Stmtinfo.StmtRslt,
  13312. "stmt_rslt_dscr": res.Output.Stmtinfo.StmtRsltDscr,
  13313. })
  13314. }
  13315. } else {
  13316. c.ServeSuccessJSON(map[string]interface{}{
  13317. "code": -10,
  13318. "msg": res.ErrMsg,
  13319. })
  13320. }
  13321. }
  13322. }
  13323. func (c *HisApiController) Check310() {
  13324. adminUser := c.GetAdminUserInfo()
  13325. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  13326. var user_name string
  13327. user_name = "高慧裕"
  13328. api := "http://127.0.0.1:9532/" + "gdyb/ten?" +
  13329. "insutype=" + "310" +
  13330. "&clr_type=" + "" +
  13331. "&setl_optins=" + "441202" +
  13332. "&stmt_begndate=" + "2022-03-01" +
  13333. "&stm_enddate=" + "2022-03-31" +
  13334. "&medfee_sumamt=" + "194930.12" +
  13335. "&fund_pay_sumamt=" + "188741.46" +
  13336. "&acct_pay=" + "0" +
  13337. "&fixmedins_setl_cnt=" + "452" +
  13338. "&fixmedins_code=" + miConfig.Code +
  13339. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs +
  13340. "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  13341. "&secret_key=" + miConfig.SecretKey +
  13342. "&org_name=" + miConfig.OrgName +
  13343. "&doctor=" + user_name
  13344. fmt.Println(api)
  13345. resp, requestErr := http.Get(api)
  13346. if requestErr != nil {
  13347. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13348. return
  13349. }
  13350. body, ioErr := ioutil.ReadAll(resp.Body)
  13351. fmt.Println(body)
  13352. if ioErr != nil {
  13353. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  13354. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13355. return
  13356. }
  13357. var respJSON map[string]interface{}
  13358. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  13359. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  13360. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13361. return
  13362. }
  13363. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  13364. userJSONBytes, _ := json.Marshal(respJSON)
  13365. var res ResultEight
  13366. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  13367. utils.ErrorLog("解析失败:%v", err)
  13368. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13369. return
  13370. }
  13371. }
  13372. func (c *HisApiController) Check390() {
  13373. adminUser := c.GetAdminUserInfo()
  13374. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  13375. var user_name string
  13376. user_name = "高慧裕"
  13377. api := "http://127.0.0.1:9532/" + "gdyb/ten?" +
  13378. "insutype=" + "390" +
  13379. "&clr_type=" + "" +
  13380. "&setl_optins=" + "441202" +
  13381. "&stmt_begndate=" + "2022-03-01" +
  13382. "&stm_enddate=" + "2022-03-31" +
  13383. "&medfee_sumamt=" + "1068448.89" +
  13384. "&fund_pay_sumamt=" + "1014677.62" +
  13385. "&acct_pay=" + "0" +
  13386. "&fixmedins_setl_cnt=" + "1950" +
  13387. "&fixmedins_code=" + miConfig.Code +
  13388. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs +
  13389. "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  13390. "&secret_key=" + miConfig.SecretKey +
  13391. "&org_name=" + miConfig.OrgName +
  13392. "&doctor=" + user_name
  13393. fmt.Println(api)
  13394. resp, requestErr := http.Get(api)
  13395. if requestErr != nil {
  13396. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13397. return
  13398. }
  13399. body, ioErr := ioutil.ReadAll(resp.Body)
  13400. fmt.Println(body)
  13401. if ioErr != nil {
  13402. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  13403. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13404. return
  13405. }
  13406. var respJSON map[string]interface{}
  13407. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  13408. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  13409. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13410. return
  13411. }
  13412. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  13413. userJSONBytes, _ := json.Marshal(respJSON)
  13414. var res ResultEight
  13415. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  13416. utils.ErrorLog("解析失败:%v", err)
  13417. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13418. return
  13419. }
  13420. }
  13421. // 对账明细
  13422. func (c *HisApiController) GetCheckDetailAccount() {
  13423. start_time := c.GetString("start_time")
  13424. end_time := c.GetString("end_time")
  13425. admin_user_id, _ := c.GetInt64("admin_user_id")
  13426. adminUser := c.GetAdminUserInfo()
  13427. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  13428. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  13429. timeLayout := "2006-01-02"
  13430. loc, _ := time.LoadLocation("Local")
  13431. startime, _ := time.ParseInLocation(timeLayout+" 15:04:05", start_time+" 00:00:00", loc)
  13432. endtime, _ := time.ParseInLocation(timeLayout+" 15:04:05", end_time+" 23:59:59", loc)
  13433. orders, _ := service.GetOrderByTimeTwo(startime.Unix(), endtime.Unix(), adminUser.CurrentOrgId)
  13434. rand.Seed(time.Now().UnixNano())
  13435. num := rand.Intn(30000)
  13436. Mkdir(miConfig.OrgName)
  13437. file := strconv.FormatInt(int64(num), 10)
  13438. file_name := file + ".txt"
  13439. zip_name := file + ".zip"
  13440. zip_path := miConfig.OrgName + "/" + zip_name
  13441. file_path := miConfig.OrgName + "/" + file_name
  13442. decimal.DivisionPrecision = 2
  13443. var medfee_sumamt float64
  13444. var psn_cash_pay float64
  13445. var fund_pay_sumamt float64
  13446. fixmedins_setl_cnt := int64(len(orders))
  13447. for _, item := range orders {
  13448. medfee_sumamt = medfee_sumamt + item.MedfeeSumamt
  13449. psn_cash_pay = psn_cash_pay + item.PsnCashPay
  13450. fund_pay_sumamt = fund_pay_sumamt + item.FundPaySumamt
  13451. }
  13452. f, err := os.Create(miConfig.OrgName + "/" + file_name)
  13453. defer f.Close()
  13454. if err != nil {
  13455. fmt.Println(err.Error())
  13456. } else {
  13457. for _, item := range orders {
  13458. var refd_setl_flag string
  13459. if item.OrderStatus == 2 {
  13460. refd_setl_flag = "0"
  13461. var str string
  13462. str = item.SetlId + " " +
  13463. item.MdtrtId + " " +
  13464. item.PsnNo + " " +
  13465. fmt.Sprintf("%.4f", item.MedfeeSumamt) + " " +
  13466. fmt.Sprintf("%.4f", item.FundPaySumamt) + " " +
  13467. fmt.Sprintf("%.4f", item.AcctPay) + " " + refd_setl_flag + "\r\n"
  13468. _, err = f.Write([]byte(str))
  13469. }
  13470. if item.OrderStatus == 3 {
  13471. var str string
  13472. str = item.SetlId + " " +
  13473. item.MdtrtId + " " +
  13474. item.PsnNo + " " +
  13475. fmt.Sprintf("%.4f", item.MedfeeSumamt) + " " +
  13476. fmt.Sprintf("%.4f", item.FundPaySumamt) + " " +
  13477. fmt.Sprintf("%.4f", item.AcctPay) + " " + "1" + "\r\n"
  13478. _, err = f.Write([]byte(str))
  13479. var str2 string
  13480. str2 = item.SetlId + " " +
  13481. item.MdtrtId + " " +
  13482. item.PsnNo + " " +
  13483. fmt.Sprintf("%.4f", 0-item.MedfeeSumamt) + " " +
  13484. fmt.Sprintf("%.4f", 0-item.FundPaySumamt) + " " +
  13485. fmt.Sprintf("%.4f", 0-item.AcctPay) + " " + "1" + "\r\n"
  13486. _, err = f.Write([]byte(str2))
  13487. }
  13488. }
  13489. }
  13490. Zip(file_path, zip_path)
  13491. fmt.Println(ReadFile(zip_path))
  13492. fmt.Println(string(ReadFile(zip_path)))
  13493. if config.IsOpen == 1 {
  13494. var user_name string
  13495. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  13496. if role.ID == 0 {
  13497. user_name = "管理员"
  13498. } else {
  13499. user_name = role.UserName
  13500. }
  13501. baseParams := models.BaseParams{
  13502. SecretKey: miConfig.SecretKey,
  13503. FixmedinsCode: miConfig.Code,
  13504. InsuplcAdmdvs: miConfig.InsuplcAdmdvs,
  13505. MdtrtareaAdmvs: miConfig.MdtrtareaAdmvs,
  13506. OrgName: miConfig.OrgName,
  13507. Doctor: user_name,
  13508. }
  13509. result := service.Gdyb9101(baseParams, file_name, ReadFile(file_path))
  13510. var dat map[string]interface{}
  13511. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  13512. fmt.Println(dat)
  13513. } else {
  13514. fmt.Println(err)
  13515. }
  13516. userJSONBytes, _ := json.Marshal(dat)
  13517. var res ResultNine
  13518. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  13519. utils.ErrorLog("解析失败:%v", err)
  13520. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13521. return
  13522. }
  13523. if res.Infcode == 0 {
  13524. fileNo := res.Output.FileQuryNo
  13525. api := "http://127.0.0.1:9532/" + "gdyb/twelve?" +
  13526. "file_qury_no=" + fileNo +
  13527. "&setl_optins=" + "定点医保中心" +
  13528. "&stmt_begndate=" + start_time +
  13529. "&stm_enddate=" + end_time +
  13530. "&medfee_sumamt=" + fmt.Sprintf("%.4f", medfee_sumamt) +
  13531. "&fund_pay_sumamt=" + fmt.Sprintf("%.4f", fund_pay_sumamt) +
  13532. "&cash_payamt=" + fmt.Sprintf("%.4f", psn_cash_pay) +
  13533. "&fixmedins_setl_cnt=" + strconv.FormatInt(fixmedins_setl_cnt, 10) +
  13534. "&fixmedins_code=" + miConfig.Code +
  13535. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs +
  13536. "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  13537. "&secret_key=" + miConfig.SecretKey +
  13538. "&org_name=" + miConfig.OrgName +
  13539. "&doctor=" + user_name
  13540. resp, requestErr := http.Get(api)
  13541. if requestErr != nil {
  13542. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13543. return
  13544. }
  13545. body, ioErr := ioutil.ReadAll(resp.Body)
  13546. if ioErr != nil {
  13547. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  13548. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13549. return
  13550. }
  13551. var respJSON map[string]interface{}
  13552. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  13553. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  13554. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13555. return
  13556. }
  13557. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  13558. userJSONBytes, _ := json.Marshal(respJSON)
  13559. var res ResultTen
  13560. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  13561. utils.ErrorLog("解析失败:%v", err)
  13562. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13563. return
  13564. }
  13565. if res.Infcode == 0 {
  13566. service.Gdyb9102(baseParams, zip_name, fileNo)
  13567. micc := &models.MedicalInsuranceCostCompare{
  13568. StartTime: startime.Unix(),
  13569. EndTime: endtime.Unix(),
  13570. Insutype: "0",
  13571. CheckType: 2,
  13572. Num: fixmedins_setl_cnt,
  13573. Mtime: time.Now().Unix(),
  13574. Status: 1,
  13575. UserOrgId: adminUser.CurrentOrgId,
  13576. CostTotal: medfee_sumamt,
  13577. FuncTotal: fund_pay_sumamt,
  13578. PsnPay: psn_cash_pay,
  13579. Creator: admin_user_id,
  13580. Ctime: time.Now().Unix(),
  13581. }
  13582. service.CreateMedicalInsuranceCostCompareRecord(micc)
  13583. c.ServeSuccessJSON(map[string]interface{}{
  13584. "msg": "明细对账成功",
  13585. })
  13586. }
  13587. } else {
  13588. }
  13589. }
  13590. }
  13591. type CustomOrderInfo struct {
  13592. Name string
  13593. Spec string
  13594. Unit string
  13595. Count float64
  13596. Price float64
  13597. Total float64
  13598. }
  13599. func (c *HisApiController) GetBatchSettleAccounts() {
  13600. admin_user_id, _ := c.GetInt64("admin_user_id")
  13601. order_ids := c.GetString("order_ids")
  13602. order_ids_arr := strings.Split(order_ids, ",")
  13603. data3 := []map[string]interface{}{}
  13604. for _, item := range order_ids_arr {
  13605. id, _ := strconv.ParseInt(item, 10, 64)
  13606. order_id := id
  13607. adminUser := c.GetAdminUserInfo()
  13608. order, _ := service.GetHisOrderByID(order_id)
  13609. his, _ := service.GetHisPatientByNumber(order.MdtrtId)
  13610. orderInfos, _ := service.GetHisOrderInfoByNumber(order.Number)
  13611. orderInfos_two, _ := service.GetHisOrderInfoByNumberTwo(order.Number)
  13612. orderInfos = append(orderInfos, orderInfos_two...)
  13613. his_hospital, _ := service.GetInHospitalRecordByNumber(order.MdtrtId)
  13614. //diagnosisConfig, _ := service.FindDiagnoseById(his.Diagnosis)
  13615. var diagnosis_ids []string
  13616. if his.ID > 0 {
  13617. diagnosis_ids = strings.Split(his.Diagnosis, ",")
  13618. } else {
  13619. diagnosis_ids = strings.Split(his_hospital.Diagnosis, ",")
  13620. }
  13621. patient, _ := service.GetPatientByIDTwo(adminUser.CurrentOrgId, order.PatientId)
  13622. var dia_config []*models.HisXtDiagnoseConfig
  13623. var name string
  13624. for _, item := range diagnosis_ids {
  13625. id, _ := strconv.ParseInt(item, 10, 64)
  13626. diagnosisConfig, _ := service.FindDiagnoseById(id)
  13627. dia_config = append(dia_config, &diagnosisConfig)
  13628. if len(name) == 0 {
  13629. name = diagnosisConfig.ClassName
  13630. } else {
  13631. name = name + "," + diagnosisConfig.ClassName
  13632. }
  13633. }
  13634. var bedCostTotal float64 = 0 //床位总费
  13635. var bedCostSelfTotal float64 = 0 //床位自费
  13636. var bedCostPartSelfTotal float64 = 0 //床位部分项目自费
  13637. var bedSelfTotal float64 = 0 //床位部分项目自费
  13638. var bedInscpTotal float64 = 0 //床位部分项目自费
  13639. var operationCostTotal float64 = 0 //手术费
  13640. var operationCostSelfTotal float64 = 0 //手术费
  13641. var operationCostPartSelfTotal float64 = 0 //手术费
  13642. var operationSelfTotal float64 = 0 //床位部分项目自费
  13643. var operationInscpTotal float64 = 0 //床位部分项目自费
  13644. var otherCostTotal float64 = 0 //其他费用
  13645. var otherCostSelfTotal float64 = 0 //其他费用
  13646. var otherCostPartSelfTotal float64 = 0 //其他费用
  13647. var otherSelfTotal float64 = 0 //床位部分项目自费
  13648. var otherInscpTotal float64 = 0 //床位部分项目自费
  13649. var materialCostTotal float64 = 0 //材料费
  13650. var materialCostSelfTotal float64 = 0 //材料费
  13651. var materialCostPartSelfTotal float64 = 0 //材料费
  13652. var materialSelfTotal float64 = 0 //床位部分项目自费
  13653. var materialInscpTotal float64 = 0 //床位部分项目自费
  13654. var westernMedicineCostTotal float64 = 0 //西药费
  13655. var westernMedicineCostSelfTotal float64 = 0 //西药费
  13656. var westernMedicineCostPartSelfTotal float64 = 0 //西药费
  13657. var westernMedicineSelfTotal float64 = 0 //床位部分项目自费
  13658. var westernMedicineInscpTotal float64 = 0 //床位部分项目自费
  13659. var chineseTraditionalMedicineCostTotal float64 = 0 //中成药
  13660. var chineseTraditionalMedicineCostSelfTotal float64 = 0 //中成药
  13661. var chineseTraditionalMedicineCostPartSelfTotal float64 = 0 //中成药
  13662. var chineseTraditionalSelfTotal float64 = 0 //床位部分项目自费
  13663. var chineseTraditionalInscpTotal float64 = 0 //床位部分项目自费
  13664. var checkCostTotal float64 = 0 //检查费
  13665. var checkCostSelfTotal float64 = 0 //检查费
  13666. var checkCostPartSelfTotal float64 = 0 //检查费
  13667. var checkSelfTotal float64 = 0 //床位部分项目自费
  13668. var checkInscpTotal float64 = 0 //床位部分项目自费
  13669. var laboratoryCostTotal float64 = 0 //化验费
  13670. var laboratoryCostSelfTotal float64 = 0 //化验费
  13671. var laboratoryCostPartSelfTotal float64 = 0 //化验费
  13672. var laboratorySelfTotal float64 = 0 //床位部分项目自费
  13673. var laboratoryInscpTotal float64 = 0 //床位部分项目自费
  13674. var treatCostTotal float64 = 0 //治疗费用
  13675. var treatCostSelfTotal float64 = 0 //治疗费用
  13676. var treatCostPartSelfTotal float64 = 0 //治疗费用
  13677. var treatSelfTotal float64 = 0 //床位部分项目自费
  13678. var treatInscpTotal float64 = 0 //床位部分项目自费
  13679. decimal.DivisionPrecision = 2
  13680. for _, item := range orderInfos {
  13681. if item.MedChrgitmType == "01" { //床位费
  13682. bedCostTotal, _ = decimal.NewFromFloat(bedCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  13683. bedCostSelfTotal, _ = decimal.NewFromFloat(bedCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  13684. bedCostPartSelfTotal, _ = decimal.NewFromFloat(bedCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  13685. bedSelfTotal, _ = decimal.NewFromFloat(bedSelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  13686. bedInscpTotal, _ = decimal.NewFromFloat(bedInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
  13687. }
  13688. if c.GetAdminUserInfo().CurrentOrgId == 10188 || c.GetAdminUserInfo().CurrentOrgId == 10217 {
  13689. if item.MedChrgitmType == "03" { //检查费
  13690. laboratoryCostTotal, _ = decimal.NewFromFloat(laboratoryCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  13691. laboratoryCostSelfTotal, _ = decimal.NewFromFloat(laboratoryCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  13692. laboratoryCostPartSelfTotal, _ = decimal.NewFromFloat(laboratoryCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  13693. laboratorySelfTotal, _ = decimal.NewFromFloat(laboratorySelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  13694. laboratoryInscpTotal, _ = decimal.NewFromFloat(laboratoryInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
  13695. }
  13696. } else {
  13697. if item.MedChrgitmType == "03" { //检查费
  13698. checkCostTotal, _ = decimal.NewFromFloat(checkCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  13699. checkCostSelfTotal, _ = decimal.NewFromFloat(checkCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  13700. checkCostPartSelfTotal, _ = decimal.NewFromFloat(checkCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  13701. checkSelfTotal, _ = decimal.NewFromFloat(checkSelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  13702. checkInscpTotal, _ = decimal.NewFromFloat(checkInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
  13703. }
  13704. }
  13705. if item.MedChrgitmType == "04" { //化验费
  13706. laboratoryCostTotal, _ = decimal.NewFromFloat(laboratoryCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  13707. laboratoryCostSelfTotal, _ = decimal.NewFromFloat(laboratoryCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  13708. laboratoryCostPartSelfTotal, _ = decimal.NewFromFloat(laboratoryCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  13709. laboratorySelfTotal, _ = decimal.NewFromFloat(laboratorySelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  13710. laboratoryInscpTotal, _ = decimal.NewFromFloat(laboratoryInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
  13711. }
  13712. if item.MedChrgitmType == "05" || item.MedChrgitmType == "1402" || item.MedChrgitmType == "1403" { //治疗费
  13713. treatCostTotal, _ = decimal.NewFromFloat(treatCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  13714. treatCostSelfTotal, _ = decimal.NewFromFloat(treatCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  13715. treatCostPartSelfTotal, _ = decimal.NewFromFloat(treatCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  13716. treatSelfTotal, _ = decimal.NewFromFloat(treatSelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  13717. treatInscpTotal, _ = decimal.NewFromFloat(treatInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
  13718. }
  13719. if item.MedChrgitmType == "06" { //手术费
  13720. operationCostTotal, _ = decimal.NewFromFloat(operationCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  13721. operationCostSelfTotal, _ = decimal.NewFromFloat(operationCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  13722. operationCostPartSelfTotal, _ = decimal.NewFromFloat(operationCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  13723. operationSelfTotal, _ = decimal.NewFromFloat(operationSelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  13724. operationInscpTotal, _ = decimal.NewFromFloat(operationInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
  13725. }
  13726. if item.MedChrgitmType == "08" { //材料费
  13727. materialCostTotal, _ = decimal.NewFromFloat(materialCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  13728. materialCostSelfTotal, _ = decimal.NewFromFloat(materialCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  13729. materialCostPartSelfTotal, _ = decimal.NewFromFloat(materialCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  13730. materialSelfTotal, _ = decimal.NewFromFloat(materialSelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  13731. materialInscpTotal, _ = decimal.NewFromFloat(materialInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
  13732. }
  13733. if item.MedChrgitmType == "09" { //西药费
  13734. westernMedicineCostTotal, _ = decimal.NewFromFloat(westernMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  13735. westernMedicineCostSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  13736. westernMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  13737. westernMedicineSelfTotal, _ = decimal.NewFromFloat(westernMedicineSelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  13738. westernMedicineInscpTotal, _ = decimal.NewFromFloat(westernMedicineInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
  13739. }
  13740. if item.MedChrgitmType == "11" { //中成费
  13741. chineseTraditionalMedicineCostTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  13742. chineseTraditionalMedicineCostSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  13743. chineseTraditionalMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  13744. chineseTraditionalSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalSelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  13745. chineseTraditionalInscpTotal, _ = decimal.NewFromFloat(chineseTraditionalInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
  13746. }
  13747. if item.MedChrgitmType == "14" || item.MedChrgitmType == "0" || item.MedChrgitmType == "12" || item.MedChrgitmType == "02" { //其他费
  13748. otherCostTotal, _ = decimal.NewFromFloat(otherCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  13749. otherCostSelfTotal, _ = decimal.NewFromFloat(otherCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  13750. otherCostPartSelfTotal, _ = decimal.NewFromFloat(otherCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  13751. otherSelfTotal, _ = decimal.NewFromFloat(otherSelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  13752. otherInscpTotal, _ = decimal.NewFromFloat(otherInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
  13753. }
  13754. }
  13755. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  13756. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  13757. var user_name string
  13758. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  13759. if role.ID == 0 {
  13760. user_name = "管理员"
  13761. } else {
  13762. user_name = role.UserName
  13763. }
  13764. baseParams := models.BaseParams{
  13765. SecretKey: miConfig.SecretKey,
  13766. FixmedinsCode: miConfig.Code,
  13767. InsuplcAdmdvs: miConfig.InsuplcAdmdvs,
  13768. MdtrtareaAdmvs: miConfig.MdtrtareaAdmvs,
  13769. OrgName: miConfig.OrgName,
  13770. Doctor: user_name,
  13771. RequestUrl: miConfig.Url,
  13772. AccessKey: miConfig.AccessKey,
  13773. }
  13774. businessParams := models.BusinessParams{
  13775. PsnNo: order.PsnNo,
  13776. MdtrtId: order.MdtrtId,
  13777. SetlId: order.SetlId,
  13778. }
  13779. var res ResultEleven
  13780. var resEleven10265 ResultEleven10265
  13781. if config.IsOpen == 1 {
  13782. baseParams.InsuplcAdmdvs = his.InsuplcAdmdvs
  13783. result := service.Gdyb5203(baseParams, businessParams)
  13784. //service.Gdyb5204(baseParams, businessParams)
  13785. //service.Gdyb5302(businessParams.PsnNo, baseParams.OrgName, baseParams.Doctor, baseParams.FixmedinsCode, baseParams.InsuplcAdmdvs, baseParams.MdtrtareaAdmvs, baseParams.SecretKey)
  13786. var dat map[string]interface{}
  13787. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  13788. fmt.Println(dat)
  13789. } else {
  13790. fmt.Println(err)
  13791. }
  13792. userJSONBytes, _ := json.Marshal(dat)
  13793. if miConfig.Code == "H15049901371" {
  13794. if err := json.Unmarshal(userJSONBytes, &resEleven10265); err != nil {
  13795. utils.ErrorLog("解析失败:%v", err)
  13796. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13797. return
  13798. }
  13799. res.InfRefmsgid = resEleven10265.InfRefmsgid
  13800. res.Output = resEleven10265.Output
  13801. res.ErrMsg = resEleven10265.ErrMsg
  13802. res.Cainfo = resEleven10265.Cainfo
  13803. res.WarnMsg = resEleven10265.WarnMsg
  13804. infocode, _ := strconv.ParseInt(resEleven10265.Infcode, 10, 64)
  13805. res.Infcode = infocode
  13806. } else {
  13807. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  13808. utils.ErrorLog("解析失败:%v", err)
  13809. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13810. return
  13811. }
  13812. }
  13813. printor_admin, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  13814. charge_admin, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, order.Creator)
  13815. patientPrescription, _ := service.FindPatientPrescriptionInfo(adminUser.CurrentOrgId, order.PatientId, order.SettleAccountsDate)
  13816. adminRole_two, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, patientPrescription.DoctorId)
  13817. doctor_info, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, his_hospital.Doctor)
  13818. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  13819. var doctor_name string
  13820. if roles.ID == 0 {
  13821. doctor_name = "管理员"
  13822. } else {
  13823. doctor_name = roles.UserName
  13824. }
  13825. yiliao_leibie := ""
  13826. switch order.MedType {
  13827. case "11":
  13828. yiliao_leibie = "普通门诊"
  13829. break
  13830. case "12":
  13831. yiliao_leibie = "门诊挂号"
  13832. break
  13833. case "13":
  13834. yiliao_leibie = "急诊"
  13835. break
  13836. case "14":
  13837. yiliao_leibie = "门诊特殊病"
  13838. break
  13839. case "15":
  13840. yiliao_leibie = "门诊统筹"
  13841. break
  13842. case "16":
  13843. yiliao_leibie = "门诊慢性病"
  13844. break
  13845. case "21":
  13846. yiliao_leibie = "普通住院"
  13847. break
  13848. }
  13849. departments, _ := service.GetDepartMentDetail(patientPrescription.Departments)
  13850. res.Output.Setlinfo.PsnCashPay = res.Output.Setlinfo.CashPayamt
  13851. if res.Infcode == 0 {
  13852. data2 := map[string]interface{}{
  13853. "diagnosis": name,
  13854. "order_infos": orderInfos,
  13855. "number": order.MdtrtId,
  13856. "date": order.SettleAccountsDate,
  13857. "charge_admin": charge_admin,
  13858. "printor_admin": printor_admin,
  13859. "info": res.Output.Setlinfo,
  13860. "order": order,
  13861. "bedCostTotal": bedCostTotal,
  13862. "bedCostSelfTotal": bedCostSelfTotal,
  13863. "bedCostPartSelfTotal": bedCostPartSelfTotal,
  13864. "bedSelfTotal": bedSelfTotal,
  13865. "bedInscpTotal": bedInscpTotal,
  13866. "operationCostTotal": operationCostTotal,
  13867. "operationCostSelfTotal": operationCostSelfTotal,
  13868. "operationCostPartSelfTotal": operationCostPartSelfTotal,
  13869. "operationSelfTotal": operationSelfTotal,
  13870. "operationInscpTotal": operationInscpTotal,
  13871. "otherCostTotal": otherCostTotal,
  13872. "otherCostSelfTotal": otherCostSelfTotal,
  13873. "otherCostPartSelfTotal": otherCostPartSelfTotal,
  13874. "otherSelfTotal": otherSelfTotal,
  13875. "otherInscpTotal": otherInscpTotal,
  13876. "materialCostTotal": materialCostTotal,
  13877. "materialCostSelfTotal": materialCostSelfTotal,
  13878. "materialCostPartSelfTotal": materialCostPartSelfTotal,
  13879. "materialSelfTotal": materialSelfTotal,
  13880. "materialInscpTotal": materialInscpTotal,
  13881. "westernMedicineCostTotal": westernMedicineCostTotal,
  13882. "westernMedicineCostSelfTotal": westernMedicineCostSelfTotal,
  13883. "westernMedicineCostPartSelfTotal": westernMedicineCostPartSelfTotal,
  13884. "westernMedicineSelfTotal": westernMedicineSelfTotal,
  13885. "westernMedicineInscpTotal": westernMedicineInscpTotal,
  13886. "chineseTraditionalMedicineCostTotal": chineseTraditionalMedicineCostTotal,
  13887. "chineseTraditionalMedicineCostSelfTotal": chineseTraditionalMedicineCostSelfTotal,
  13888. "chineseTraditionalMedicineCostPartSelfTotal": chineseTraditionalMedicineCostPartSelfTotal,
  13889. "chineseTraditionalSelfTotal": chineseTraditionalSelfTotal,
  13890. "chineseTraditionalInscpTotal": chineseTraditionalInscpTotal,
  13891. "checkCostTotal": checkCostTotal,
  13892. "checkCostSelfTotal": checkCostSelfTotal,
  13893. "checkCostPartSelfTotal": checkCostPartSelfTotal,
  13894. "checkSelfTotal": checkSelfTotal,
  13895. "checkInscpTotal": checkInscpTotal,
  13896. "laboratoryCostTotal": laboratoryCostTotal,
  13897. "laboratoryCostSelfTotal": laboratoryCostSelfTotal,
  13898. "laboratoryCostPartSelfTotal": laboratoryCostPartSelfTotal,
  13899. "laboratorySelfTotal": laboratorySelfTotal,
  13900. "laboratoryInscpTotal": laboratoryInscpTotal,
  13901. "treatCostTotal": treatCostTotal,
  13902. "treatCostSelfTotal": treatCostSelfTotal,
  13903. "treatCostPartSelfTotal": treatCostPartSelfTotal,
  13904. "treatSelfTotal": treatSelfTotal,
  13905. "treatInscpTotal": treatInscpTotal,
  13906. "doctor_info": doctor_info,
  13907. "doctor_code": adminRole_two.DoctorCode,
  13908. "doctor_name": doctor_name,
  13909. "health_card_no": order.PsnNo,
  13910. "department": departments.Name,
  13911. "yiliao_leibie": yiliao_leibie,
  13912. "after_money": order.AccountPrice,
  13913. "patient": patient,
  13914. "org_name": miConfig.OrgName,
  13915. "org_code": miConfig.Code,
  13916. "order_number": order.Number,
  13917. "his_hospital": his_hospital,
  13918. "his": his,
  13919. "dia_config": dia_config,
  13920. "psn_cash_pay": order.PsnCashPay,
  13921. //"check_order_info": cus_slice,
  13922. }
  13923. data3 = append(data3, data2)
  13924. }
  13925. }
  13926. }
  13927. c.ServeSuccessJSON(map[string]interface{}{
  13928. "infos": data3,
  13929. })
  13930. }
  13931. func (c *HisApiController) GetSettleAccounts() {
  13932. //id, _ := c.GetInt64("id")
  13933. //record_time := c.GetString("record_time")
  13934. order_id, _ := c.GetInt64("order_id")
  13935. admin_user_id, _ := c.GetInt64("admin_user_id")
  13936. //timeLayout := "2006-01-02"
  13937. //loc, _ := time.LoadLocation("Local")
  13938. //
  13939. //theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  13940. //if err != nil {
  13941. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  13942. // return
  13943. //}
  13944. //recordDateTime := theTime.Unix()
  13945. adminUser := c.GetAdminUserInfo()
  13946. order, _ := service.GetHisOrderByID(order_id)
  13947. his, _ := service.GetHisPatientByNumber(order.MdtrtId)
  13948. orderInfos, _ := service.GetHisOrderInfoByNumber(order.Number)
  13949. orderInfos_two, _ := service.GetHisOrderInfoByNumberTwo(order.Number)
  13950. orderInfos = append(orderInfos, orderInfos_two...)
  13951. his_hospital, _ := service.GetInHospitalRecordByNumber(order.MdtrtId)
  13952. //diagnosisConfig, _ := service.FindDiagnoseById(his.Diagnosis)
  13953. var diagnosis_ids []string
  13954. if his.ID > 0 {
  13955. diagnosis_ids = strings.Split(his.Diagnosis, ",")
  13956. } else {
  13957. diagnosis_ids = strings.Split(his_hospital.Diagnosis, ",")
  13958. }
  13959. patient, _ := service.GetPatientByIDTwo(adminUser.CurrentOrgId, order.PatientId)
  13960. var dia_config []*models.HisXtDiagnoseConfig
  13961. var name string
  13962. for _, item := range diagnosis_ids {
  13963. id, _ := strconv.ParseInt(item, 10, 64)
  13964. diagnosisConfig, _ := service.FindDiagnoseById(id)
  13965. dia_config = append(dia_config, &diagnosisConfig)
  13966. if len(name) == 0 {
  13967. name = diagnosisConfig.ClassName
  13968. } else {
  13969. name = name + "," + diagnosisConfig.ClassName
  13970. }
  13971. }
  13972. var bedCostTotal float64 = 0 //床位总费
  13973. var bedCostSelfTotal float64 = 0 //床位自费
  13974. var bedCostPartSelfTotal float64 = 0 //床位部分项目自费
  13975. var bedSelfTotal float64 = 0 //床位部分项目自费
  13976. var bedInscpTotal float64 = 0 //床位部分项目自费
  13977. var operationCostTotal float64 = 0 //手术费
  13978. var operationCostSelfTotal float64 = 0 //手术费
  13979. var operationCostPartSelfTotal float64 = 0 //手术费
  13980. var operationSelfTotal float64 = 0 //床位部分项目自费
  13981. var operationInscpTotal float64 = 0 //床位部分项目自费
  13982. var otherCostTotal float64 = 0 //其他费用
  13983. var otherCostSelfTotal float64 = 0 //其他费用
  13984. var otherCostPartSelfTotal float64 = 0 //其他费用
  13985. var otherSelfTotal float64 = 0 //床位部分项目自费
  13986. var otherInscpTotal float64 = 0 //床位部分项目自费
  13987. var materialCostTotal float64 = 0 //材料费
  13988. var materialCostSelfTotal float64 = 0 //材料费
  13989. var materialCostPartSelfTotal float64 = 0 //材料费
  13990. var materialSelfTotal float64 = 0 //床位部分项目自费
  13991. var materialInscpTotal float64 = 0 //床位部分项目自费
  13992. var westernMedicineCostTotal float64 = 0 //西药费
  13993. var westernMedicineCostSelfTotal float64 = 0 //西药费
  13994. var westernMedicineCostPartSelfTotal float64 = 0 //西药费
  13995. var westernMedicineSelfTotal float64 = 0 //床位部分项目自费
  13996. var westernMedicineInscpTotal float64 = 0 //床位部分项目自费
  13997. var chineseTraditionalMedicineCostTotal float64 = 0 //中成药
  13998. var chineseTraditionalMedicineCostSelfTotal float64 = 0 //中成药
  13999. var chineseTraditionalMedicineCostPartSelfTotal float64 = 0 //中成药
  14000. var chineseTraditionalSelfTotal float64 = 0 //床位部分项目自费
  14001. var chineseTraditionalInscpTotal float64 = 0 //床位部分项目自费
  14002. var checkCostTotal float64 = 0 //检查费
  14003. var checkCostSelfTotal float64 = 0 //检查费
  14004. var checkCostPartSelfTotal float64 = 0 //检查费
  14005. var checkSelfTotal float64 = 0 //床位部分项目自费
  14006. var checkInscpTotal float64 = 0 //床位部分项目自费
  14007. var laboratoryCostTotal float64 = 0 //化验费
  14008. var laboratoryCostSelfTotal float64 = 0 //化验费
  14009. var laboratoryCostPartSelfTotal float64 = 0 //化验费
  14010. var laboratorySelfTotal float64 = 0 //床位部分项目自费
  14011. var laboratoryInscpTotal float64 = 0 //床位部分项目自费
  14012. var treatCostTotal float64 = 0 //治疗费用
  14013. var treatCostSelfTotal float64 = 0 //治疗费用
  14014. var treatCostPartSelfTotal float64 = 0 //治疗费用
  14015. var treatSelfTotal float64 = 0 //床位部分项目自费
  14016. var treatInscpTotal float64 = 0 //床位部分项目自费
  14017. decimal.DivisionPrecision = 2
  14018. for _, item := range orderInfos {
  14019. if item.MedChrgitmType == "01" { //床位费
  14020. bedCostTotal, _ = decimal.NewFromFloat(bedCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  14021. bedCostSelfTotal, _ = decimal.NewFromFloat(bedCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  14022. bedCostPartSelfTotal, _ = decimal.NewFromFloat(bedCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  14023. bedSelfTotal, _ = decimal.NewFromFloat(bedSelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  14024. bedInscpTotal, _ = decimal.NewFromFloat(bedInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
  14025. }
  14026. if c.GetAdminUserInfo().CurrentOrgId == 10188 || c.GetAdminUserInfo().CurrentOrgId == 10217 {
  14027. if item.MedChrgitmType == "03" { //检查费
  14028. laboratoryCostTotal, _ = decimal.NewFromFloat(laboratoryCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  14029. laboratoryCostSelfTotal, _ = decimal.NewFromFloat(laboratoryCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  14030. laboratoryCostPartSelfTotal, _ = decimal.NewFromFloat(laboratoryCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  14031. laboratorySelfTotal, _ = decimal.NewFromFloat(laboratorySelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  14032. laboratoryInscpTotal, _ = decimal.NewFromFloat(laboratoryInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
  14033. }
  14034. } else {
  14035. if item.MedChrgitmType == "03" { //检查费
  14036. checkCostTotal, _ = decimal.NewFromFloat(checkCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  14037. checkCostSelfTotal, _ = decimal.NewFromFloat(checkCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  14038. checkCostPartSelfTotal, _ = decimal.NewFromFloat(checkCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  14039. checkSelfTotal, _ = decimal.NewFromFloat(checkSelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  14040. checkInscpTotal, _ = decimal.NewFromFloat(checkInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
  14041. }
  14042. }
  14043. if item.MedChrgitmType == "04" { //化验费
  14044. laboratoryCostTotal, _ = decimal.NewFromFloat(laboratoryCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  14045. laboratoryCostSelfTotal, _ = decimal.NewFromFloat(laboratoryCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  14046. laboratoryCostPartSelfTotal, _ = decimal.NewFromFloat(laboratoryCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  14047. laboratorySelfTotal, _ = decimal.NewFromFloat(laboratorySelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  14048. laboratoryInscpTotal, _ = decimal.NewFromFloat(laboratoryInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
  14049. }
  14050. if item.MedChrgitmType == "05" || item.MedChrgitmType == "1402" || item.MedChrgitmType == "1403" { //治疗费
  14051. treatCostTotal, _ = decimal.NewFromFloat(treatCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  14052. treatCostSelfTotal, _ = decimal.NewFromFloat(treatCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  14053. treatCostPartSelfTotal, _ = decimal.NewFromFloat(treatCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  14054. treatSelfTotal, _ = decimal.NewFromFloat(treatSelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  14055. treatInscpTotal, _ = decimal.NewFromFloat(treatInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
  14056. }
  14057. if item.MedChrgitmType == "06" { //手术费
  14058. operationCostTotal, _ = decimal.NewFromFloat(operationCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  14059. operationCostSelfTotal, _ = decimal.NewFromFloat(operationCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  14060. operationCostPartSelfTotal, _ = decimal.NewFromFloat(operationCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  14061. operationSelfTotal, _ = decimal.NewFromFloat(operationSelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  14062. operationInscpTotal, _ = decimal.NewFromFloat(operationInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
  14063. }
  14064. if item.MedChrgitmType == "08" { //材料费
  14065. materialCostTotal, _ = decimal.NewFromFloat(materialCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  14066. materialCostSelfTotal, _ = decimal.NewFromFloat(materialCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  14067. materialCostPartSelfTotal, _ = decimal.NewFromFloat(materialCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  14068. materialSelfTotal, _ = decimal.NewFromFloat(materialSelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  14069. materialInscpTotal, _ = decimal.NewFromFloat(materialInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
  14070. }
  14071. if item.MedChrgitmType == "09" { //西药费
  14072. westernMedicineCostTotal, _ = decimal.NewFromFloat(westernMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  14073. westernMedicineCostSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  14074. westernMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  14075. westernMedicineSelfTotal, _ = decimal.NewFromFloat(westernMedicineSelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  14076. westernMedicineInscpTotal, _ = decimal.NewFromFloat(westernMedicineInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
  14077. }
  14078. if item.MedChrgitmType == "11" { //中成费
  14079. chineseTraditionalMedicineCostTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  14080. chineseTraditionalMedicineCostSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  14081. chineseTraditionalMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  14082. chineseTraditionalSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalSelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  14083. chineseTraditionalInscpTotal, _ = decimal.NewFromFloat(chineseTraditionalInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
  14084. }
  14085. if item.MedChrgitmType == "14" || item.MedChrgitmType == "0" || item.MedChrgitmType == "12" || item.MedChrgitmType == "02" { //其他费
  14086. otherCostTotal, _ = decimal.NewFromFloat(otherCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  14087. otherCostSelfTotal, _ = decimal.NewFromFloat(otherCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  14088. otherCostPartSelfTotal, _ = decimal.NewFromFloat(otherCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  14089. otherSelfTotal, _ = decimal.NewFromFloat(otherSelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  14090. otherInscpTotal, _ = decimal.NewFromFloat(otherInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
  14091. }
  14092. }
  14093. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  14094. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  14095. var user_name string
  14096. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  14097. if role.ID == 0 {
  14098. user_name = "管理员"
  14099. } else {
  14100. user_name = role.UserName
  14101. }
  14102. baseParams := models.BaseParams{
  14103. SecretKey: miConfig.SecretKey,
  14104. FixmedinsCode: miConfig.Code,
  14105. InsuplcAdmdvs: miConfig.InsuplcAdmdvs,
  14106. MdtrtareaAdmvs: miConfig.MdtrtareaAdmvs,
  14107. OrgName: miConfig.OrgName,
  14108. Doctor: user_name,
  14109. RequestUrl: miConfig.Url,
  14110. AccessKey: miConfig.AccessKey,
  14111. }
  14112. businessParams := models.BusinessParams{
  14113. PsnNo: order.PsnNo,
  14114. MdtrtId: order.MdtrtId,
  14115. SetlId: order.SetlId,
  14116. }
  14117. var res ResultEleven
  14118. var resEleven10265 ResultEleven10265
  14119. if config.IsOpen == 1 {
  14120. if miConfig.MdtrtareaAdmvs == "421300" {
  14121. api := "http://192.168.124.4:9532/" + "hbyb/5203?psn_no=" + businessParams.PsnNo + "&mdtrt_id=" + businessParams.MdtrtId + "&setl_id=" + businessParams.SetlId +
  14122. "&org_name=" + miConfig.OrgName + "&doctor=" + baseParams.Doctor + "&fixmedins_code=" + miConfig.Code +
  14123. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  14124. resp, requestErr := http.Get(api)
  14125. if requestErr != nil {
  14126. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14127. return
  14128. }
  14129. body, ioErr := ioutil.ReadAll(resp.Body)
  14130. if ioErr != nil {
  14131. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  14132. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14133. return
  14134. }
  14135. var respJSON map[string]interface{}
  14136. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  14137. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  14138. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14139. return
  14140. }
  14141. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  14142. result, _ := json.Marshal(respJSON)
  14143. fmt.Println("log")
  14144. fmt.Println(string(result))
  14145. if err := json.Unmarshal([]byte(result), &res); err != nil {
  14146. utils.ErrorLog("解析失败:%v", err)
  14147. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14148. return
  14149. }
  14150. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  14151. var api string
  14152. if miConfig.MdtrtareaAdmvs == "320921" {
  14153. api = "http://192.168.2.3:9532/" + "jsyb/5203?psn_no=" + businessParams.PsnNo + "&mdtrt_id=" + businessParams.MdtrtId + "&setl_id=" + businessParams.SetlId +
  14154. "&org_name=" + miConfig.OrgName + "&doctor=" + baseParams.Doctor + "&fixmedins_code=" + miConfig.Code +
  14155. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  14156. //req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  14157. } else {
  14158. //req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  14159. api = "http://192.168.5.251:9532/" + "jsyb/5203?psn_no=" + businessParams.PsnNo + "&mdtrt_id=" + businessParams.MdtrtId + "&setl_id=" + businessParams.SetlId +
  14160. "&org_name=" + miConfig.OrgName + "&doctor=" + baseParams.Doctor + "&fixmedins_code=" + miConfig.Code +
  14161. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  14162. }
  14163. resp, requestErr := http.Get(api)
  14164. if requestErr != nil {
  14165. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14166. return
  14167. }
  14168. body, ioErr := ioutil.ReadAll(resp.Body)
  14169. if ioErr != nil {
  14170. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  14171. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14172. return
  14173. }
  14174. var respJSON map[string]interface{}
  14175. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  14176. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  14177. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14178. return
  14179. }
  14180. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  14181. result, _ := json.Marshal(respJSON)
  14182. fmt.Println("log")
  14183. fmt.Println(string(result))
  14184. if err := json.Unmarshal([]byte(result), &resEleven10265); err != nil {
  14185. utils.ErrorLog("解析失败:%v", err)
  14186. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14187. return
  14188. }
  14189. res.InfRefmsgid = resEleven10265.InfRefmsgid
  14190. res.Output = resEleven10265.Output
  14191. res.ErrMsg = resEleven10265.ErrMsg
  14192. res.Cainfo = resEleven10265.Cainfo
  14193. res.WarnMsg = resEleven10265.WarnMsg
  14194. infocode, _ := strconv.ParseInt(resEleven10265.Infcode, 10, 64)
  14195. res.Infcode = infocode
  14196. } else if miConfig.MdtrtareaAdmvs == "350500" {
  14197. result, requestLog, _ := service.FJyb5203(baseParams, businessParams, miConfig.Url, miConfig.Code, miConfig.AppSecret, miConfig.SignKey, miConfig.EncKey)
  14198. saveLog(result, requestLog, "5203", "结算单")
  14199. var dat map[string]interface{}
  14200. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  14201. fmt.Println(dat)
  14202. } else {
  14203. fmt.Println(err)
  14204. }
  14205. userJSONBytes, _ := json.Marshal(dat)
  14206. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  14207. utils.ErrorLog("解析失败:%v", err)
  14208. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14209. return
  14210. }
  14211. } else if miConfig.MdtrtareaAdmvs == "360399" {
  14212. result, requestLog := service.Jxyb5203(baseParams, businessParams)
  14213. saveLog(result, requestLog, "5203", "结算单")
  14214. var dat map[string]interface{}
  14215. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  14216. fmt.Println(dat)
  14217. } else {
  14218. fmt.Println(err)
  14219. }
  14220. userJSONBytes, _ := json.Marshal(dat)
  14221. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  14222. utils.ErrorLog("解析失败:%v", err)
  14223. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14224. return
  14225. }
  14226. } else if miConfig.MdtrtareaAdmvs == "430800" {
  14227. result, requestLog := service.Hnyb5203(baseParams, businessParams)
  14228. saveLog(result, requestLog, "5203", "结算单")
  14229. var dat map[string]interface{}
  14230. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  14231. fmt.Println(dat)
  14232. } else {
  14233. fmt.Println(err)
  14234. }
  14235. userJSONBytes, _ := json.Marshal(dat)
  14236. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  14237. utils.ErrorLog("解析失败:%v", err)
  14238. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14239. return
  14240. }
  14241. } else if miConfig.MdtrtareaAdmvs == "150499" {
  14242. api := "http://172.16.13.254:9532/" + "nmyb/5203?psn_no=" + businessParams.PsnNo + "&mdtrt_id=" + businessParams.MdtrtId + "&setl_id=" + businessParams.SetlId +
  14243. "&org_name=" + miConfig.OrgName + "&doctor=" + baseParams.Doctor + "&fixmedins_code=" + miConfig.Code +
  14244. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  14245. resp, requestErr := http.Get(api)
  14246. if requestErr != nil {
  14247. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14248. return
  14249. }
  14250. body, ioErr := ioutil.ReadAll(resp.Body)
  14251. if ioErr != nil {
  14252. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  14253. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14254. return
  14255. }
  14256. var respJSON map[string]interface{}
  14257. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  14258. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  14259. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14260. return
  14261. }
  14262. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  14263. result, _ := json.Marshal(respJSON)
  14264. fmt.Println("log")
  14265. fmt.Println(string(result))
  14266. if err := json.Unmarshal([]byte(result), &resEleven10265); err != nil {
  14267. utils.ErrorLog("解析失败:%v", err)
  14268. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14269. return
  14270. }
  14271. res.InfRefmsgid = resEleven10265.InfRefmsgid
  14272. res.Output = resEleven10265.Output
  14273. res.ErrMsg = resEleven10265.ErrMsg
  14274. res.Cainfo = resEleven10265.Cainfo
  14275. res.WarnMsg = resEleven10265.WarnMsg
  14276. infocode, _ := strconv.ParseInt(resEleven10265.Infcode, 10, 64)
  14277. res.Infcode = infocode
  14278. } else {
  14279. baseParams.InsuplcAdmdvs = his.InsuplcAdmdvs
  14280. result := service.Gdyb5203(baseParams, businessParams)
  14281. //service.Gdyb5204(baseParams, businessParams)
  14282. //service.Gdyb5302(businessParams.PsnNo, baseParams.OrgName, baseParams.Doctor, baseParams.FixmedinsCode, baseParams.InsuplcAdmdvs, baseParams.MdtrtareaAdmvs, baseParams.SecretKey)
  14283. var dat map[string]interface{}
  14284. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  14285. fmt.Println(dat)
  14286. } else {
  14287. fmt.Println(err)
  14288. }
  14289. userJSONBytes, _ := json.Marshal(dat)
  14290. if miConfig.Code == "H15049901371" {
  14291. if err := json.Unmarshal(userJSONBytes, &resEleven10265); err != nil {
  14292. utils.ErrorLog("解析失败:%v", err)
  14293. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14294. return
  14295. }
  14296. res.InfRefmsgid = resEleven10265.InfRefmsgid
  14297. res.Output = resEleven10265.Output
  14298. res.ErrMsg = resEleven10265.ErrMsg
  14299. res.Cainfo = resEleven10265.Cainfo
  14300. res.WarnMsg = resEleven10265.WarnMsg
  14301. infocode, _ := strconv.ParseInt(resEleven10265.Infcode, 10, 64)
  14302. res.Infcode = infocode
  14303. } else {
  14304. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  14305. utils.ErrorLog("解析失败:%v", err)
  14306. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14307. return
  14308. }
  14309. }
  14310. }
  14311. printor_admin, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  14312. charge_admin, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, order.Creator)
  14313. patientPrescription, _ := service.FindPatientPrescriptionInfo(adminUser.CurrentOrgId, order.PatientId, order.SettleAccountsDate)
  14314. adminRole_two, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, patientPrescription.DoctorId)
  14315. doctor_info, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, his_hospital.Doctor)
  14316. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  14317. var doctor_name string
  14318. if roles.ID == 0 {
  14319. doctor_name = "管理员"
  14320. } else {
  14321. doctor_name = roles.UserName
  14322. }
  14323. yiliao_leibie := ""
  14324. switch order.MedType {
  14325. case "11":
  14326. yiliao_leibie = "普通门诊"
  14327. break
  14328. case "12":
  14329. yiliao_leibie = "门诊挂号"
  14330. break
  14331. case "13":
  14332. yiliao_leibie = "急诊"
  14333. break
  14334. case "14":
  14335. yiliao_leibie = "门诊特殊病"
  14336. break
  14337. case "15":
  14338. yiliao_leibie = "门诊统筹"
  14339. break
  14340. case "16":
  14341. yiliao_leibie = "门诊慢性病"
  14342. break
  14343. case "21":
  14344. yiliao_leibie = "普通住院"
  14345. break
  14346. }
  14347. departments, _ := service.GetDepartMentDetail(patientPrescription.Departments)
  14348. res.Output.Setlinfo.PsnCashPay = res.Output.Setlinfo.CashPayamt
  14349. if res.Infcode == 0 {
  14350. c.ServeSuccessJSON(map[string]interface{}{
  14351. "diagnosis": name,
  14352. "order_infos": orderInfos,
  14353. "number": order.MdtrtId,
  14354. "date": order.SettleAccountsDate,
  14355. "charge_admin": charge_admin,
  14356. "printor_admin": printor_admin,
  14357. "info": res.Output.Setlinfo,
  14358. "order": order,
  14359. "bedCostTotal": bedCostTotal,
  14360. "bedCostSelfTotal": bedCostSelfTotal,
  14361. "bedCostPartSelfTotal": bedCostPartSelfTotal,
  14362. "bedSelfTotal": bedSelfTotal,
  14363. "bedInscpTotal": bedInscpTotal,
  14364. "operationCostTotal": operationCostTotal,
  14365. "operationCostSelfTotal": operationCostSelfTotal,
  14366. "operationCostPartSelfTotal": operationCostPartSelfTotal,
  14367. "operationSelfTotal": operationSelfTotal,
  14368. "operationInscpTotal": operationInscpTotal,
  14369. "otherCostTotal": otherCostTotal,
  14370. "otherCostSelfTotal": otherCostSelfTotal,
  14371. "otherCostPartSelfTotal": otherCostPartSelfTotal,
  14372. "otherSelfTotal": otherSelfTotal,
  14373. "otherInscpTotal": otherInscpTotal,
  14374. "materialCostTotal": materialCostTotal,
  14375. "materialCostSelfTotal": materialCostSelfTotal,
  14376. "materialCostPartSelfTotal": materialCostPartSelfTotal,
  14377. "materialSelfTotal": materialSelfTotal,
  14378. "materialInscpTotal": materialInscpTotal,
  14379. "westernMedicineCostTotal": westernMedicineCostTotal,
  14380. "westernMedicineCostSelfTotal": westernMedicineCostSelfTotal,
  14381. "westernMedicineCostPartSelfTotal": westernMedicineCostPartSelfTotal,
  14382. "westernMedicineSelfTotal": westernMedicineSelfTotal,
  14383. "westernMedicineInscpTotal": westernMedicineInscpTotal,
  14384. "chineseTraditionalMedicineCostTotal": chineseTraditionalMedicineCostTotal,
  14385. "chineseTraditionalMedicineCostSelfTotal": chineseTraditionalMedicineCostSelfTotal,
  14386. "chineseTraditionalMedicineCostPartSelfTotal": chineseTraditionalMedicineCostPartSelfTotal,
  14387. "chineseTraditionalSelfTotal": chineseTraditionalSelfTotal,
  14388. "chineseTraditionalInscpTotal": chineseTraditionalInscpTotal,
  14389. "checkCostTotal": checkCostTotal,
  14390. "checkCostSelfTotal": checkCostSelfTotal,
  14391. "checkCostPartSelfTotal": checkCostPartSelfTotal,
  14392. "checkSelfTotal": checkSelfTotal,
  14393. "checkInscpTotal": checkInscpTotal,
  14394. "laboratoryCostTotal": laboratoryCostTotal,
  14395. "laboratoryCostSelfTotal": laboratoryCostSelfTotal,
  14396. "laboratoryCostPartSelfTotal": laboratoryCostPartSelfTotal,
  14397. "laboratorySelfTotal": laboratorySelfTotal,
  14398. "laboratoryInscpTotal": laboratoryInscpTotal,
  14399. "treatCostTotal": treatCostTotal,
  14400. "treatCostSelfTotal": treatCostSelfTotal,
  14401. "treatCostPartSelfTotal": treatCostPartSelfTotal,
  14402. "treatSelfTotal": treatSelfTotal,
  14403. "treatInscpTotal": treatInscpTotal,
  14404. "doctor_info": doctor_info,
  14405. "doctor_code": adminRole_two.DoctorCode,
  14406. "doctor_name": doctor_name,
  14407. "health_card_no": order.PsnNo,
  14408. "department": departments.Name,
  14409. "yiliao_leibie": yiliao_leibie,
  14410. "after_money": order.AccountPrice,
  14411. "patient": patient,
  14412. "org_name": miConfig.OrgName,
  14413. "org_code": miConfig.Code,
  14414. "order_number": order.Number,
  14415. "his_hospital": his_hospital,
  14416. "his": his,
  14417. "dia_config": dia_config,
  14418. "psn_cash_pay": order.PsnCashPay,
  14419. //"check_order_info": cus_slice,
  14420. })
  14421. }
  14422. }
  14423. }
  14424. func (c *HisApiController) CheckTreatment() {
  14425. patient_id, _ := c.GetInt64("patient_id")
  14426. id_card_no := c.GetString("id_card_no")
  14427. insutype := c.GetString("insutype")
  14428. med_type := c.GetString("med_type")
  14429. admin_user_id, _ := c.GetInt64("admin_user_id")
  14430. adminUser := c.GetAdminUserInfo()
  14431. patient, _ := service.GetPatientByID(adminUser.CurrentOrgId, patient_id)
  14432. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  14433. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  14434. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  14435. if miConfig.MdtrtareaAdmvs == "421300" {
  14436. var res ResultTwo
  14437. api := "http://192.168.124.4:9532/" + "hbyb/1101?cert_no=" + "" +
  14438. "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  14439. "&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)
  14440. resp, requestErr := http.Get(api)
  14441. if requestErr != nil {
  14442. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14443. return
  14444. }
  14445. body, ioErr := ioutil.ReadAll(resp.Body)
  14446. if ioErr != nil {
  14447. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  14448. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14449. return
  14450. }
  14451. var respJSON map[string]interface{}
  14452. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  14453. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  14454. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14455. return
  14456. }
  14457. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  14458. result, _ := json.Marshal(respJSON)
  14459. if err := json.Unmarshal([]byte(result), &res); err != nil {
  14460. utils.ErrorLog("解析失败:%v", err)
  14461. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14462. return
  14463. }
  14464. if res.Infcode == 0 {
  14465. api := "http://192.168.124.4:9532/" + "hbyb/2001?cert_no=" + "" +
  14466. "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  14467. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&psn_no=" + res.Output.Baseinfo.PsnNo + "&insutype=" + insutype + "&med_type=" + med_type
  14468. resp, requestErr := http.Get(api)
  14469. if requestErr != nil {
  14470. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14471. return
  14472. }
  14473. body, ioErr := ioutil.ReadAll(resp.Body)
  14474. if ioErr != nil {
  14475. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  14476. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14477. return
  14478. }
  14479. var respJSON map[string]interface{}
  14480. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  14481. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  14482. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14483. return
  14484. }
  14485. var res Result2001
  14486. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  14487. result2, _ := json.Marshal(respJSON)
  14488. if err := json.Unmarshal([]byte(result2), &res); err != nil {
  14489. utils.ErrorLog("解析失败:%v", err)
  14490. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14491. return
  14492. }
  14493. if res.Infcode == 0 {
  14494. c.ServeSuccessJSON(map[string]interface{}{
  14495. "msg": res.Output.Trtinfo,
  14496. })
  14497. }
  14498. } else {
  14499. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  14500. return
  14501. }
  14502. } else {
  14503. result := service.Gdyb1101A(id_card_no, miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, patient.Name)
  14504. var dat map[string]interface{}
  14505. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  14506. fmt.Println(dat)
  14507. } else {
  14508. fmt.Println(err)
  14509. }
  14510. userJSONBytes, _ := json.Marshal(dat)
  14511. var res ResultTwo
  14512. var res10265 ResultTwo10265
  14513. if miConfig.Code == "H15049901371" {
  14514. if err := json.Unmarshal(userJSONBytes, &res10265); err != nil {
  14515. utils.ErrorLog("解析失败:%v", err)
  14516. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14517. return
  14518. }
  14519. res.ErrMsg = res10265.ErrMsg
  14520. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  14521. res.Infcode = infocode
  14522. res.Output = res10265.Output
  14523. res.InfRefmsgid = res10265.InfRefmsgid
  14524. } else {
  14525. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  14526. utils.ErrorLog("解析失败:%v", err)
  14527. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14528. return
  14529. }
  14530. }
  14531. var user_name string
  14532. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, adminUser.AdminUser.Id)
  14533. if role.ID == 0 {
  14534. user_name = "xxx"
  14535. } else {
  14536. user_name = role.UserName
  14537. }
  14538. baseParams := models.BaseParams{
  14539. SecretKey: miConfig.SecretKey,
  14540. FixmedinsCode: miConfig.Code,
  14541. InsuplcAdmdvs: miConfig.InsuplcAdmdvs,
  14542. MdtrtareaAdmvs: miConfig.MdtrtareaAdmvs,
  14543. OrgName: miConfig.OrgName,
  14544. Doctor: user_name,
  14545. }
  14546. if config.IsOpen == 1 {
  14547. if miConfig.Code == "H15049901371" {
  14548. if med_type == "14" {
  14549. if insutype == "390" {
  14550. med_type = "9933"
  14551. } else if insutype == "310" {
  14552. med_type = "990502"
  14553. }
  14554. } else if med_type == "11" {
  14555. med_type = "11"
  14556. }
  14557. }
  14558. result := service.Gdyb2001(baseParams, res.Output.Baseinfo.PsnNo, insutype, med_type)
  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. var res Result2001
  14566. var res10265 Result2001Org10265
  14567. if miConfig.Code == "H15049901371" {
  14568. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  14569. utils.ErrorLog("解析失败:%v", err)
  14570. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14571. return
  14572. }
  14573. res.ErrMsg = res10265.ErrMsg
  14574. res.Output = res10265.Output
  14575. res.InfRefmsgid = res10265.InfRefmsgid
  14576. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  14577. res.Infcode = infocode
  14578. } else {
  14579. if err := json.Unmarshal([]byte(result), &res); err != nil {
  14580. utils.ErrorLog("解析失败:%v", err)
  14581. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14582. return
  14583. }
  14584. }
  14585. if res.Infcode == 0 {
  14586. c.ServeSuccessJSON(map[string]interface{}{
  14587. "msg": res.Output.Trtinfo,
  14588. })
  14589. }
  14590. }
  14591. }
  14592. }
  14593. //func (c *HisApiController) PutRecord() {
  14594. // id, _ := c.GetInt64("id")
  14595. // record_time := c.GetString("record_time")
  14596. // timeLayout := "2006-01-02"
  14597. // loc, _ := time.LoadLocation("Local")
  14598. // theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  14599. // if err != nil {
  14600. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  14601. // return
  14602. // }
  14603. // recordDateTime := theTime.Unix()
  14604. //
  14605. // adminInfo := c.GetAdminUserInfo()
  14606. // patient, _ := service.GetPatientByID(adminInfo.CurrentOrgId, id)
  14607. // patientPrescription, _ := service.FindPatientPrescriptionInfo(adminInfo.CurrentOrgId, id, recordDateTime)
  14608. //
  14609. // miConfig, _ := service.FindMedicalInsuranceInfo(adminInfo.CurrentOrgId)
  14610. //
  14611. // fmt.Println(miConfig.SecretKey)
  14612. //
  14613. // if patient == nil {
  14614. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodePatientNoExist)
  14615. // return
  14616. // }
  14617. // if len(patient.IdCardNo) == 0 {
  14618. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeIDCartNo)
  14619. // return
  14620. // }
  14621. // config, _ := service.GetMedicalInsuranceConfig(adminInfo.CurrentOrgId)
  14622. // if config.IsOpen == 1 {
  14623. // 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
  14624. // resp, requestErr := http.Get(api)
  14625. // if requestErr != nil {
  14626. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14627. // return
  14628. // }
  14629. // defer resp.Body.Close()
  14630. // body, ioErr := ioutil.ReadAll(resp.Body)
  14631. // if ioErr != nil {
  14632. // utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  14633. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14634. // return
  14635. // }
  14636. // var respJSON map[string]interface{}
  14637. //
  14638. // if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  14639. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  14640. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14641. // return
  14642. // }
  14643. //
  14644. // userJSON := respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  14645. // userJSONBytes, _ := json.Marshal(userJSON)
  14646. // var res ResultTwo
  14647. // if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  14648. // utils.ErrorLog("解析失败:%v", err)
  14649. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14650. // return
  14651. // }
  14652. // Iinfos, _ := json.Marshal(res.Output.Iinfo)
  14653. // Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  14654. // infoStr := string(Iinfos)
  14655. // idetinfoStr := string(Idetinfos)
  14656. //
  14657. // if res.Infcode == 0 {
  14658. // his := models.VMHisPatient{
  14659. // Status: 1,
  14660. // Ctime: time.Now().Unix(),
  14661. // Mtime: time.Now().Unix(),
  14662. // PsnNo: res.Output.Baseinfo.PsnNo,
  14663. // PsnCertType: res.Output.Baseinfo.PsnCertType,
  14664. // Certno: res.Output.Baseinfo.Certno,
  14665. // PsnName: res.Output.Baseinfo.PsnName,
  14666. // Gend: res.Output.Baseinfo.Gend,
  14667. // Naty: res.Output.Baseinfo.Naty,
  14668. // Brdy: res.Output.Baseinfo.Brdy,
  14669. // Age: res.Output.Baseinfo.Age,
  14670. // Iinfo: infoStr,
  14671. // Idetinfo: idetinfoStr,
  14672. // PatientId: patient.ID,
  14673. // RecordDate: theTime.Unix(),
  14674. // UserOrgId: adminInfo.CurrentOrgId,
  14675. // AdminUserId: adminInfo.AdminUser.Id,
  14676. // IsReturn: 1,
  14677. // }
  14678. //
  14679. // //doctor_id := strconv.FormatInt(patientPrescription.DoctorId, 10)
  14680. // //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")
  14681. // //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")
  14682. //
  14683. // //var dat map[string]interface{}
  14684. // //if err := json.Unmarshal([]byte(result), &dat); err == nil {
  14685. // // fmt.Println(dat)
  14686. // //} else {
  14687. // // fmt.Println(err)
  14688. // //}
  14689. //
  14690. // var dat2 map[string]interface{}
  14691. // if err := json.Unmarshal([]byte(result2), &dat2); err == nil {
  14692. // fmt.Println(dat2)
  14693. // } else {
  14694. // fmt.Println(err)
  14695. // }
  14696. //
  14697. // } else {
  14698. // adminUser := c.GetAdminUserInfo()
  14699. // errlog := &models.HisOrderError{
  14700. // UserOrgId: adminUser.CurrentOrgId,
  14701. // Ctime: time.Now().Unix(),
  14702. // Mtime: time.Now().Unix(),
  14703. // ErrMsg: res.ErrMsg,
  14704. // Status: 1,
  14705. // PatientId: id,
  14706. // RecordTime: recordDateTime,
  14707. // Stage: 1,
  14708. // }
  14709. // service.CreateErrMsgLog(errlog)
  14710. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeGdybOneException)
  14711. // return
  14712. // }
  14713. // }
  14714. //
  14715. //}
  14716. //func (c *HisApiController) GetUploadDiag() {
  14717. // id, _ := c.GetInt64("id")
  14718. // record_time := c.GetString("record_time")
  14719. //
  14720. // diagnosis_id, _ := c.GetInt64("diagnosis")
  14721. // sick_type, _ := c.GetInt64("sick_type")
  14722. // reg_type, _ := c.GetInt64("reg_type")
  14723. //
  14724. // timeLayout := "2006-01-02"
  14725. // loc, _ := time.LoadLocation("Local")
  14726. // theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  14727. // if err != nil {
  14728. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  14729. // return
  14730. // }
  14731. //
  14732. // var patientPrescription models.HisPrescriptionInfo
  14733. // recordDateTime := theTime.Unix()
  14734. // adminInfo := c.GetAdminUserInfo()
  14735. // patientPrescription, _ = service.FindPatientPrescriptionInfo(adminInfo.CurrentOrgId, id, recordDateTime)
  14736. //
  14737. // if patientPrescription.ID == 0 {
  14738. // patientPrescription, _ = service.FindLastPatientPrescriptionInfo(adminInfo.CurrentOrgId, id, recordDateTime)
  14739. // }
  14740. //
  14741. // miConfig, _ := service.FindMedicalInsuranceInfo(adminInfo.CurrentOrgId)
  14742. // diagnosisConfig, _ := service.FindDiagnoseById(diagnosis_id)
  14743. // his, _ := service.GetVMHisPatientInfo(adminInfo.CurrentOrgId, id, recordDateTime)
  14744. // sickConfig, _ := service.FindSickById(sick_type)
  14745. // department, _ := service.GetDepartMentDetail(patientPrescription.Departments)
  14746. //
  14747. // api2 := "http://127.0.0.1:9532/" + "gdyb/four?psn_no=" + his.PsnNo +
  14748. // "&mdtrt_id=" + his.Number + "&doctor=" + patientPrescription.Doctor + "&department=" + department.Name +
  14749. // "&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 +
  14750. // "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&sick_code=" + sickConfig.ContentCode + "&sick_name=" + sickConfig.ClassName
  14751. // resp2, requestErr2 := http.Get(api2)
  14752. // if requestErr2 != nil {
  14753. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14754. // return
  14755. // }
  14756. // body2, ioErr2 := ioutil.ReadAll(resp2.Body)
  14757. // if ioErr2 != nil {
  14758. // utils.ErrorLog("接口返回数据读取失败: %v", ioErr2)
  14759. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14760. // return
  14761. // }
  14762. // var respJSON2 map[string]interface{}
  14763. // if err := json.Unmarshal([]byte(string(body2)), &respJSON2); err != nil {
  14764. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  14765. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14766. // return
  14767. // }
  14768. // respJSON2 = respJSON2["data"].(map[string]interface{})["pre"].(map[string]interface{})
  14769. // userJSONBytes2, _ := json.Marshal(respJSON2)
  14770. //
  14771. // var res2 ResultSix
  14772. // if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  14773. // utils.ErrorLog("解析失败:%v", err)
  14774. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14775. // return
  14776. // }
  14777. // if res2.Infcode != 0 {
  14778. // adminUser := c.GetAdminUserInfo()
  14779. // errlog := &models.HisOrderError{
  14780. // UserOrgId: adminUser.CurrentOrgId,
  14781. // Ctime: time.Now().Unix(),
  14782. // Mtime: time.Now().Unix(),
  14783. // ErrMsg: res2.ErrMsg,
  14784. // Status: 1,
  14785. // PatientId: id,
  14786. // RecordTime: recordDateTime,
  14787. // Stage: 3,
  14788. // }
  14789. // service.CreateErrMsgLog(errlog)
  14790. //
  14791. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeRegisterThreeException)
  14792. // return
  14793. // }
  14794. //
  14795. // c.ServeSuccessJSON(map[string]interface{}{
  14796. // "msg": "上传成功",
  14797. // })
  14798. //
  14799. //}
  14800. type QueryResult struct {
  14801. ID int64
  14802. Name string
  14803. Code string
  14804. List_type_code string
  14805. }
  14806. func (c *HisApiController) GetCheckCode() {
  14807. ids_str := c.GetString("ids")
  14808. record_type, _ := c.GetInt64("record_type") //1.药品 2.耗材 3.项目
  14809. ids_arr := strings.Split(ids_str, ",")
  14810. var queryResult []QueryResult
  14811. ids := make([]int64, 0)
  14812. for _, item := range ids_arr {
  14813. id, _ := strconv.ParseInt(item, 10, 64)
  14814. ids = append(ids, id)
  14815. }
  14816. if record_type == 1 {
  14817. drugs, _ := service.GetBatchDrugList(ids)
  14818. for _, item := range drugs {
  14819. result := QueryResult{
  14820. ID: item.ID,
  14821. Name: item.DrugName,
  14822. Code: item.MedicalInsuranceNumber,
  14823. List_type_code: "101",
  14824. }
  14825. queryResult = append(queryResult, result)
  14826. }
  14827. } else if record_type == 2 {
  14828. goods, _ := service.GetBatchGoodInformationList(ids)
  14829. for _, item := range goods {
  14830. result := QueryResult{
  14831. ID: item.ID,
  14832. Name: item.GoodName,
  14833. Code: item.MedicalInsuranceNumber,
  14834. List_type_code: "301",
  14835. }
  14836. queryResult = append(queryResult, result)
  14837. }
  14838. } else if record_type == 3 {
  14839. projects, _ := service.GetBathchMyPorjecgList(ids)
  14840. for _, item := range projects {
  14841. result := QueryResult{
  14842. ID: item.ID,
  14843. Name: item.ProjectName,
  14844. Code: item.MedicalCode,
  14845. List_type_code: "201",
  14846. }
  14847. queryResult = append(queryResult, result)
  14848. }
  14849. }
  14850. admin_user_id, _ := c.GetInt64("admin_user_id")
  14851. adminUser := c.GetAdminUserInfo()
  14852. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  14853. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  14854. var user_name string
  14855. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  14856. if role.ID == 0 {
  14857. user_name = "xxx"
  14858. } else {
  14859. user_name = role.UserName
  14860. }
  14861. baseParams := &models.BaseParams{
  14862. SecretKey: miConfig.SecretKey,
  14863. FixmedinsCode: miConfig.Code,
  14864. InsuplcAdmdvs: miConfig.InsuplcAdmdvs,
  14865. MdtrtareaAdmvs: miConfig.MdtrtareaAdmvs,
  14866. OrgName: miConfig.OrgName,
  14867. Doctor: user_name,
  14868. }
  14869. if config.IsOpen == 1 {
  14870. for _, item := range queryResult {
  14871. var result string
  14872. if record_type == 1 {
  14873. result = service.Gdyb3301(baseParams, item.Name, item.Code, item.List_type_code, "2021-04-26", "", item.List_type_code)
  14874. } else if record_type == 2 {
  14875. result = service.Gdyb3301(baseParams, item.Name, item.Code, item.List_type_code, "2021-04-26", "", item.List_type_code)
  14876. } else if record_type == 3 {
  14877. result = service.Gdyb3301(baseParams, item.Name, item.Code, item.List_type_code, "2021-04-26", "", item.List_type_code)
  14878. }
  14879. var dat map[string]interface{}
  14880. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  14881. fmt.Println(dat)
  14882. } else {
  14883. fmt.Println(err)
  14884. }
  14885. userJSONBytes, _ := json.Marshal(dat)
  14886. var res ResultSix
  14887. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  14888. utils.ErrorLog("解析失败:%v", err)
  14889. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14890. return
  14891. }
  14892. if res.Infcode == 0 {
  14893. if record_type == 1 {
  14894. service.UpdateBaseDrugById(item.ID)
  14895. } else if record_type == 2 {
  14896. service.UpdateGoodInformaitonByDetail(item.ID)
  14897. } else if record_type == 3 {
  14898. service.UpdateProjectById(item.ID)
  14899. }
  14900. c.ServeSuccessJSON(map[string]interface{}{
  14901. "failed_code": 0,
  14902. "msg": "目录对照成功",
  14903. })
  14904. } else {
  14905. c.ServeSuccessJSON(map[string]interface{}{
  14906. "failed_code": -10,
  14907. "msg": res.ErrMsg,
  14908. })
  14909. }
  14910. }
  14911. }
  14912. }
  14913. func (c *HisApiController) UnCheckCode() {
  14914. ids_str := c.GetString("ids")
  14915. record_type, _ := c.GetInt64("record_type") //1.药品 2.耗材 3.项目
  14916. admin_user_id, _ := c.GetInt64("admin_user_id")
  14917. ids_arr := strings.Split(ids_str, ",")
  14918. var queryResult []QueryResult
  14919. ids := make([]int64, 0)
  14920. for _, item := range ids_arr {
  14921. id, _ := strconv.ParseInt(item, 10, 64)
  14922. ids = append(ids, id)
  14923. }
  14924. if record_type == 1 {
  14925. drugs, _ := service.GetBatchDrugList(ids)
  14926. for _, item := range drugs {
  14927. result := QueryResult{
  14928. ID: item.ID,
  14929. Name: item.DrugName,
  14930. Code: item.MedicalInsuranceNumber,
  14931. List_type_code: "101",
  14932. }
  14933. queryResult = append(queryResult, result)
  14934. }
  14935. } else if record_type == 2 {
  14936. goods, _ := service.GetBatchGoodInformationList(ids)
  14937. for _, item := range goods {
  14938. result := QueryResult{
  14939. ID: item.ID,
  14940. Name: item.GoodName,
  14941. Code: item.MedicalInsuranceNumber,
  14942. List_type_code: "301",
  14943. }
  14944. queryResult = append(queryResult, result)
  14945. }
  14946. } else if record_type == 3 {
  14947. projects, _ := service.GetBathchMyPorjecgList(ids)
  14948. for _, item := range projects {
  14949. result := QueryResult{
  14950. ID: item.ID,
  14951. Name: item.ProjectName,
  14952. Code: item.MedicalCode,
  14953. List_type_code: "201",
  14954. }
  14955. queryResult = append(queryResult, result)
  14956. }
  14957. }
  14958. adminUser := c.GetAdminUserInfo()
  14959. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  14960. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  14961. var user_name string
  14962. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  14963. if role.ID == 0 {
  14964. user_name = "xxx"
  14965. } else {
  14966. user_name = role.UserName
  14967. }
  14968. baseParams := &models.BaseParams{
  14969. SecretKey: miConfig.SecretKey,
  14970. FixmedinsCode: miConfig.Code,
  14971. InsuplcAdmdvs: miConfig.InsuplcAdmdvs,
  14972. MdtrtareaAdmvs: miConfig.MdtrtareaAdmvs,
  14973. OrgName: miConfig.OrgName,
  14974. Doctor: user_name,
  14975. }
  14976. if config.IsOpen == 1 {
  14977. for _, item := range queryResult {
  14978. var result string
  14979. if record_type == 1 {
  14980. result = service.Gdyb3302(baseParams, item.Name, item.Code, item.List_type_code)
  14981. } else if record_type == 2 {
  14982. result = service.Gdyb3302(baseParams, item.Name, item.Code, item.List_type_code)
  14983. } else if record_type == 3 {
  14984. result = service.Gdyb3302(baseParams, item.Name, item.Code, item.List_type_code)
  14985. }
  14986. var dat2 map[string]interface{}
  14987. if err := json.Unmarshal([]byte(result), &dat2); err == nil {
  14988. fmt.Println(dat2)
  14989. } else {
  14990. fmt.Println(err)
  14991. }
  14992. userJSONBytes, _ := json.Marshal(dat2)
  14993. var res ResultSix
  14994. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  14995. utils.ErrorLog("解析失败:%v", err)
  14996. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14997. return
  14998. }
  14999. if res.Infcode == 0 {
  15000. if record_type == 1 {
  15001. service.UpdateDrugByIdDetail(item.ID)
  15002. } else if record_type == 2 {
  15003. service.UpdateGoodInfoById(item.ID)
  15004. } else if record_type == 3 {
  15005. service.UpdateMyProjectById(item.ID)
  15006. }
  15007. c.ServeSuccessJSON(map[string]interface{}{
  15008. "failed_code": 0,
  15009. "msg": "撤销目录对照成功",
  15010. })
  15011. } else {
  15012. c.ServeSuccessJSON(map[string]interface{}{
  15013. "failed_code": -10,
  15014. "msg": res.ErrMsg,
  15015. })
  15016. }
  15017. }
  15018. }
  15019. }
  15020. func (c *HisApiController) GetPatientInfo() {
  15021. id_card_no := c.GetString("id_card_no")
  15022. admin_user_id, _ := c.GetInt64("admin_user_id")
  15023. patient, _ := service.GetPatientByIDCard(id_card_no, c.GetAdminUserInfo().CurrentOrgId)
  15024. if patient.ID == 0 {
  15025. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodePatientNoExist)
  15026. return
  15027. }
  15028. role, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  15029. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  15030. config, _ := service.GetMedicalInsuranceConfig(c.GetAdminUserInfo().CurrentOrgId)
  15031. if config.IsOpen == 1 {
  15032. result := service.Gdyb1101A(id_card_no, miConfig.OrgName, role.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, patient.Name)
  15033. var dat map[string]interface{}
  15034. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  15035. fmt.Println(dat)
  15036. } else {
  15037. fmt.Println(err)
  15038. }
  15039. userJSONBytes, _ := json.Marshal(dat)
  15040. var res ResultTwo
  15041. var res10265 ResultTwo10265
  15042. if miConfig.Code == "H15049901371" {
  15043. if err := json.Unmarshal(userJSONBytes, &res10265); err != nil {
  15044. utils.ErrorLog("解析失败:%v", err)
  15045. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  15046. return
  15047. }
  15048. res.ErrMsg = res10265.ErrMsg
  15049. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  15050. res.Infcode = infocode
  15051. res.Output = res10265.Output
  15052. res.InfRefmsgid = res10265.InfRefmsgid
  15053. } else {
  15054. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  15055. utils.ErrorLog("解析失败:%v", err)
  15056. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  15057. return
  15058. }
  15059. }
  15060. //if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  15061. // utils.ErrorLog("解析失败:%v", err)
  15062. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  15063. // return
  15064. //}
  15065. for index, item := range res.Output.Iinfo {
  15066. if item.PsnInsuStas == "2" {
  15067. fmt.Println("--------")
  15068. res.Output.Iinfo[index].Insutype = "300"
  15069. res.Output.Iinfo[index].PsnInsuStas = "1"
  15070. }
  15071. }
  15072. fmt.Println(res.Output.Iinfo)
  15073. if res.Infcode != 0 {
  15074. c.ServeSuccessJSON(map[string]interface{}{
  15075. "failed_code": -10,
  15076. "msg": res.ErrMsg,
  15077. })
  15078. } else {
  15079. c.ServeSuccessJSON(map[string]interface{}{
  15080. "failed_code": 0,
  15081. "info": res,
  15082. })
  15083. }
  15084. }
  15085. }
  15086. func (c *HisApiController) PsnPutOnRecord() {
  15087. record_type, _ := c.GetInt64("type")
  15088. patient_id, _ := c.GetInt64("patient_id")
  15089. admin_user_id, _ := c.GetInt64("admin_user_id")
  15090. start_time := c.GetString("start_time")
  15091. end_time := c.GetString("end_time")
  15092. adminUser := c.GetAdminUserInfo()
  15093. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  15094. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  15095. var patients []*models.Patients
  15096. if record_type == 1 { //全部备案
  15097. patient, _ := service.GetAllPatient(adminUser.CurrentOrgId)
  15098. patients = append(patients, patient...)
  15099. } else { //单个备案
  15100. patient, _ := service.GetPatientByID(adminUser.CurrentOrgId, patient_id)
  15101. patients = append(patients, patient)
  15102. }
  15103. var user_name string
  15104. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  15105. if role.ID == 0 {
  15106. user_name = "xxx"
  15107. } else {
  15108. user_name = role.UserName
  15109. }
  15110. if config.IsOpen == 1 {
  15111. for _, item := range patients {
  15112. 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
  15113. resp, requestErr := http.Get(api)
  15114. if requestErr != nil {
  15115. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  15116. return
  15117. }
  15118. defer resp.Body.Close()
  15119. body, ioErr := ioutil.ReadAll(resp.Body)
  15120. if ioErr != nil {
  15121. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  15122. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  15123. return
  15124. }
  15125. var respJSON map[string]interface{}
  15126. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  15127. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  15128. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  15129. return
  15130. }
  15131. userJSON := respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  15132. userJSONBytes, _ := json.Marshal(userJSON)
  15133. var res ResultTwo
  15134. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  15135. utils.ErrorLog("解析失败:%v", err)
  15136. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  15137. return
  15138. }
  15139. if res.Infcode == 0 {
  15140. result := service.Gdyb2505(res.Output.Baseinfo.PsnNo, user_name, miConfig.OrgName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, start_time, end_time)
  15141. var dat map[string]interface{}
  15142. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  15143. fmt.Println(dat)
  15144. } else {
  15145. fmt.Println(err)
  15146. }
  15147. userJSONBytes, _ := json.Marshal(dat)
  15148. var res2 ResultThirteen
  15149. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  15150. utils.ErrorLog("解析失败:%v", err)
  15151. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  15152. return
  15153. }
  15154. if res2.Infcode == 0 {
  15155. psnResult := &models.GdybPsnRecord{
  15156. UserOrgId: adminUser.CurrentOrgId,
  15157. PatientId: item.ID,
  15158. PsnNo: res.Output.Baseinfo.PsnNo,
  15159. Ctime: time.Now().Unix(),
  15160. Mtime: time.Now().Unix(),
  15161. Status: 1,
  15162. IsCancel: 1,
  15163. TrtDclaDetlSn: res2.Output.Result.TrtDclaDetlSn,
  15164. }
  15165. service.CreatePsnRecord(psnResult)
  15166. } else {
  15167. c.ServeSuccessJSON(map[string]interface{}{
  15168. "failed_code": -10,
  15169. "msg": res2.ErrMsg,
  15170. })
  15171. return
  15172. }
  15173. }
  15174. }
  15175. }
  15176. }
  15177. func (c *HisApiController) PsnUnPutOnRecord() {
  15178. id, _ := c.GetInt64("id")
  15179. //record_type, _ := c.GetInt64("type")
  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. psn_record, _ := service.GetPsnRecordById(id)
  15192. if psn_record.ID == 0 {
  15193. c.ServeFailJSONWithSGJErrorCode(enums.ErrorPsnRecordNoExistWrong)
  15194. return
  15195. }
  15196. if config.IsOpen == 1 {
  15197. result := service.Gdyb2506(psn_record.PsnNo, user_name, miConfig.OrgName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, psn_record.TrtDclaDetlSn)
  15198. var dat map[string]interface{}
  15199. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  15200. fmt.Println(dat)
  15201. } else {
  15202. fmt.Println(err)
  15203. }
  15204. userJSONBytes, _ := json.Marshal(dat)
  15205. var res ResultFourteen
  15206. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  15207. utils.ErrorLog("解析失败:%v", err)
  15208. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  15209. return
  15210. }
  15211. if res.Infcode == 0 {
  15212. psn_record.IsCancel = 2
  15213. service.CreatePsnRecord(&psn_record)
  15214. } else {
  15215. c.ServeSuccessJSON(map[string]interface{}{
  15216. "failed_code": -10,
  15217. "msg": res.ErrMsg,
  15218. })
  15219. return
  15220. }
  15221. }
  15222. }
  15223. func (c *HisApiController) PsnPutNCDSOnRecord() {
  15224. patient_id, _ := c.GetInt64("patient_id")
  15225. insutype_two := c.GetString("insutype")
  15226. psn_no := c.GetString("psn_no")
  15227. doctor_id, _ := c.GetInt64("doctor_id")
  15228. sick_id, _ := c.GetInt64("sick_id")
  15229. department_id, _ := c.GetInt64("department_id")
  15230. start_time := c.GetString("start_time")
  15231. end_time := c.GetString("end_time")
  15232. check_time := c.GetString("check_time")
  15233. hospital_code := c.GetString("hospital_code")
  15234. hospital_name := c.GetString("hospital_name")
  15235. adminUser := c.GetAdminUserInfo()
  15236. patient, _ := service.GetPatientByID(adminUser.CurrentOrgId, patient_id)
  15237. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  15238. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  15239. sick, _ := service.FindSickById(sick_id)
  15240. doctor, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, doctor_id)
  15241. if len(hospital_code) == 0 {
  15242. hospital_code = miConfig.Code
  15243. }
  15244. if len(hospital_name) == 0 {
  15245. hospital_name = miConfig.OrgName
  15246. }
  15247. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, doctor_id)
  15248. var res ResultTwo
  15249. var res10265 ResultTwo10265
  15250. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  15251. psn_info, _ := service.GetPsnByPatientId(patient.ID)
  15252. api := "http://192.168.2.3:9532/" + "hbyb/1101?cert_no=" + "" +
  15253. "&org_name=" + miConfig.OrgName + "&doctor=" + role.UserName + "&fixmedins_code=" + miConfig.Code +
  15254. "&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
  15255. resp, requestErr := http.Get(api)
  15256. if requestErr != nil {
  15257. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  15258. return
  15259. }
  15260. body, ioErr := ioutil.ReadAll(resp.Body)
  15261. if ioErr != nil {
  15262. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  15263. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  15264. return
  15265. }
  15266. var respJSON map[string]interface{}
  15267. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  15268. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  15269. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  15270. return
  15271. }
  15272. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  15273. result, _ := json.Marshal(respJSON)
  15274. fmt.Println("log")
  15275. fmt.Println(string(result))
  15276. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  15277. utils.ErrorLog("解析失败:%v", err)
  15278. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  15279. return
  15280. }
  15281. res.ErrMsg = res10265.ErrMsg
  15282. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  15283. res.Infcode = infocode
  15284. res.Output = res10265.Output
  15285. res.InfRefmsgid = res10265.InfRefmsgid
  15286. } else {
  15287. result, _ := service.Gdyb1101(patient.IdCardNo, miConfig.OrgName, role.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, 2, "", "0", patient.Name)
  15288. if miConfig.Code == "H15049901371" {
  15289. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  15290. utils.ErrorLog("解析失败:%v", err)
  15291. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  15292. return
  15293. }
  15294. res.ErrMsg = res10265.ErrMsg
  15295. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  15296. res.Infcode = infocode
  15297. res.Output = res10265.Output
  15298. res.InfRefmsgid = res10265.InfRefmsgid
  15299. } else {
  15300. if err := json.Unmarshal([]byte(result), &res); err != nil {
  15301. utils.ErrorLog("解析失败:%v", err)
  15302. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  15303. return
  15304. }
  15305. }
  15306. }
  15307. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  15308. infoStr := string(Iinfos)
  15309. var rf []*ResultFive
  15310. json.Unmarshal([]byte(infoStr), &rf)
  15311. var insuplc_admdvs string
  15312. var insutype string
  15313. var is390 int = 0
  15314. var is310 int = 0
  15315. var insutypes []*ResultFive
  15316. for _, item := range rf {
  15317. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  15318. insutypes = append(insutypes, item)
  15319. }
  15320. }
  15321. if len(insutypes) == 1 {
  15322. insutype = insutypes[0].Insutype
  15323. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  15324. } else {
  15325. for _, i := range insutypes {
  15326. if i.Insutype == "390" {
  15327. is390 = 1
  15328. }
  15329. if i.Insutype == "310" {
  15330. is310 = 1
  15331. }
  15332. }
  15333. }
  15334. if is390 == 1 {
  15335. insutype = "390"
  15336. }
  15337. if is310 == 1 {
  15338. insutype = "310"
  15339. }
  15340. if len(insutypes) == 2 {
  15341. insutype = insutype_two
  15342. }
  15343. if len(insutypes) == 0 {
  15344. insutype = "310"
  15345. }
  15346. insutype = insutype_two
  15347. fmt.Println(insutype)
  15348. for _, item := range rf {
  15349. fmt.Println(item.Insutype)
  15350. fmt.Println(insutype)
  15351. if item.Insutype == insutype {
  15352. fmt.Println(item.Insutype)
  15353. fmt.Println(insutype)
  15354. insuplc_admdvs = item.InsuplcAdmdvs
  15355. }
  15356. }
  15357. fmt.Println(insuplc_admdvs)
  15358. var res2 ResultThirteen
  15359. var res10265_2 ResultThirteen10265
  15360. if config.IsOpen == 1 {
  15361. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  15362. } else {
  15363. 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)
  15364. var dat map[string]interface{}
  15365. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  15366. fmt.Println(dat)
  15367. } else {
  15368. fmt.Println(err)
  15369. }
  15370. userJSONBytes, _ := json.Marshal(dat)
  15371. if miConfig.Code == "H15049901371" {
  15372. if err := json.Unmarshal(userJSONBytes, &res10265_2); err != nil {
  15373. utils.ErrorLog("解析失败:%v", err)
  15374. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  15375. return
  15376. }
  15377. res2.ErrMsg = res10265_2.ErrMsg
  15378. infocode, _ := strconv.ParseInt(res10265_2.Infcode, 10, 64)
  15379. res2.Infcode = infocode
  15380. res2.Output = res10265_2.Output
  15381. res2.InfRefmsgid = res10265_2.InfRefmsgid
  15382. } else {
  15383. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  15384. utils.ErrorLog("解析失败:%v", err)
  15385. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  15386. return
  15387. }
  15388. }
  15389. }
  15390. if res2.Infcode == 0 {
  15391. psnResult := &models.GdybPsnNcdsRecord{
  15392. UserOrgId: adminUser.CurrentOrgId,
  15393. PatientId: patient.ID,
  15394. PsnNo: psn_no,
  15395. DoctorId: doctor.AdminUserId,
  15396. DepartmentId: department_id,
  15397. SickType: sick_id,
  15398. Insutype: insutype,
  15399. Ctime: time.Now().Unix(),
  15400. Mtime: time.Now().Unix(),
  15401. Status: 1,
  15402. IsCancel: 1,
  15403. TrtDclaDetlSn: res2.Output.Result.TrtDclaDetlSn,
  15404. }
  15405. service.CreatePsnNCDSRecord(psnResult)
  15406. c.ServeSuccessJSON(map[string]interface{}{
  15407. "failed_code": 0,
  15408. "msg": "备案成功",
  15409. "result": psnResult,
  15410. })
  15411. } else {
  15412. c.ServeSuccessJSON(map[string]interface{}{
  15413. "failed_code": -10,
  15414. "msg": res2.ErrMsg,
  15415. })
  15416. return
  15417. }
  15418. }
  15419. }
  15420. func (c *HisApiController) PsnPutUnNCDSOnRecord() {
  15421. id, _ := c.GetInt64("id")
  15422. admin_user_id, _ := c.GetInt64("admin_user_id")
  15423. adminUser := c.GetAdminUserInfo()
  15424. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  15425. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  15426. //config, _ := service.Ge(adminUser.CurrentOrgId)
  15427. patient, _ := service.GetPatientByID(c.GetAdminUserInfo().CurrentOrgId, id)
  15428. //role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  15429. //var user_name string
  15430. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  15431. //if role.ID == 0 {
  15432. // user_name = "xxx"
  15433. //} else {
  15434. // user_name = role.UserName
  15435. //}
  15436. psn_record, _ := service.GetPsnNCDSRecordById(id)
  15437. if psn_record.ID == 0 {
  15438. c.ServeFailJSONWithSGJErrorCode(enums.ErrorPsnRecordNoExistWrong)
  15439. return
  15440. }
  15441. result, _ := service.Gdyb1101(patient.IdCardNo, miConfig.OrgName, role.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, 2, "", "0", patient.Name)
  15442. var res ResultTwo
  15443. var res10265 ResultTwo10265
  15444. if miConfig.Code == "H15049901371" {
  15445. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  15446. utils.ErrorLog("解析失败:%v", err)
  15447. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  15448. return
  15449. }
  15450. res.ErrMsg = res10265.ErrMsg
  15451. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  15452. res.Infcode = infocode
  15453. res.Output = res10265.Output
  15454. res.InfRefmsgid = res10265.InfRefmsgid
  15455. } else {
  15456. if err := json.Unmarshal([]byte(result), &res); err != nil {
  15457. utils.ErrorLog("解析失败:%v", err)
  15458. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  15459. return
  15460. }
  15461. }
  15462. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  15463. infoStr := string(Iinfos)
  15464. var rf []*ResultFive
  15465. json.Unmarshal([]byte(infoStr), &rf)
  15466. var insuplc_admdvs string
  15467. var insutype string
  15468. var is390 int = 0
  15469. var is310 int = 0
  15470. var insutypes []*ResultFive
  15471. for _, item := range rf {
  15472. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  15473. insutypes = append(insutypes, item)
  15474. }
  15475. }
  15476. if len(insutypes) == 1 {
  15477. insutype = insutypes[0].Insutype
  15478. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  15479. } else {
  15480. for _, i := range insutypes {
  15481. if i.Insutype == "390" {
  15482. is390 = 1
  15483. }
  15484. if i.Insutype == "310" {
  15485. is310 = 1
  15486. }
  15487. }
  15488. }
  15489. if is390 == 1 {
  15490. insutype = "390"
  15491. }
  15492. if is310 == 1 {
  15493. insutype = "310"
  15494. }
  15495. if len(insutypes) == 0 {
  15496. insutype = "310"
  15497. }
  15498. insutype = psn_record.Insutype
  15499. for _, item := range rf {
  15500. if item.Insutype == insutype {
  15501. insuplc_admdvs = item.InsuplcAdmdvs
  15502. }
  15503. }
  15504. if config.IsOpen == 1 {
  15505. result := service.Gdyb2504(psn_record.PsnNo, miConfig.OrgName, role.UserName, miConfig.Code, insuplc_admdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, psn_record.TrtDclaDetlSn)
  15506. var dat map[string]interface{}
  15507. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  15508. fmt.Println(dat)
  15509. } else {
  15510. fmt.Println(err)
  15511. }
  15512. userJSONBytes, _ := json.Marshal(dat)
  15513. var res ResultFourteen
  15514. var res10265 ResultFourteen10265
  15515. if miConfig.Code == "H15049901371" {
  15516. if err := json.Unmarshal(userJSONBytes, &res10265); err != nil {
  15517. utils.ErrorLog("解析失败:%v", err)
  15518. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  15519. return
  15520. }
  15521. res.ErrMsg = res10265.ErrMsg
  15522. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  15523. res.Infcode = infocode
  15524. res.Output = res10265.Output
  15525. res.InfRefmsgid = res10265.InfRefmsgid
  15526. } else {
  15527. if err := json.Unmarshal([]byte(result), &res); err != nil {
  15528. utils.ErrorLog("解析失败:%v", err)
  15529. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  15530. return
  15531. }
  15532. }
  15533. //if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  15534. // utils.ErrorLog("解析失败:%v", err)
  15535. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  15536. // return
  15537. //}
  15538. if res.Infcode == 0 {
  15539. psn_record.IsCancel = 2
  15540. service.CreatePsnNCDSRecord(&psn_record)
  15541. c.ServeSuccessJSON(map[string]interface{}{
  15542. "failed_code": 0,
  15543. "msg": "撤销备案成功",
  15544. })
  15545. } else {
  15546. c.ServeSuccessJSON(map[string]interface{}{
  15547. "failed_code": -10,
  15548. "msg": res.ErrMsg,
  15549. })
  15550. return
  15551. }
  15552. }
  15553. }
  15554. func (c *HisApiController) TestTest() {
  15555. patient, _ := service.GetHisPatientInfo(4, 456, 1619712000)
  15556. fmt.Println(patient.Iinfo)
  15557. }
  15558. type CustomData struct {
  15559. MsgId string
  15560. PsnNo string
  15561. Info string
  15562. }
  15563. func (c *HisApiController) ReversalData() {
  15564. var customData []*CustomData
  15565. custom := &CustomData{
  15566. MsgId: "H44022900158202103301714472004",
  15567. PsnNo: "44020000001101329945",
  15568. Info: "2207",
  15569. }
  15570. customData = append(customData, custom)
  15571. custom1 := &CustomData{
  15572. MsgId: "H4402290015820210330172057803",
  15573. PsnNo: "44020000001101161813",
  15574. Info: "2207",
  15575. }
  15576. customData = append(customData, custom1)
  15577. custom2 := &CustomData{
  15578. MsgId: "H44022900158202103301705198813",
  15579. PsnNo: "44190000133097375417",
  15580. Info: "2207",
  15581. }
  15582. customData = append(customData, custom2)
  15583. custom3 := &CustomData{
  15584. MsgId: "H44022900158202103301715524756",
  15585. PsnNo: "44020000001100187221",
  15586. Info: "2207",
  15587. }
  15588. customData = append(customData, custom3)
  15589. custom4 := &CustomData{
  15590. MsgId: "H44022900158202103301730376224",
  15591. PsnNo: "44020000001101959155",
  15592. Info: "2207",
  15593. }
  15594. customData = append(customData, custom4)
  15595. custom5 := &CustomData{
  15596. MsgId: "H44022900158202103301748008725",
  15597. PsnNo: "44020000001104246641",
  15598. Info: "2207",
  15599. }
  15600. customData = append(customData, custom5)
  15601. custom6 := &CustomData{
  15602. MsgId: "H44022900158202103301718096755",
  15603. PsnNo: "44020000001102211860",
  15604. Info: "2207",
  15605. }
  15606. customData = append(customData, custom6)
  15607. custom7 := &CustomData{
  15608. MsgId: "H44022900158202103301736551640",
  15609. PsnNo: "44020000001102687718",
  15610. Info: "2207",
  15611. }
  15612. customData = append(customData, custom7)
  15613. custom8 := &CustomData{
  15614. MsgId: "H44022900158202103301743097676",
  15615. PsnNo: "44020000001102127785",
  15616. Info: "2207",
  15617. }
  15618. customData = append(customData, custom8)
  15619. custom9 := &CustomData{
  15620. MsgId: "H44022900158202103301712304203",
  15621. PsnNo: "44020000001101518097",
  15622. Info: "2207",
  15623. }
  15624. customData = append(customData, custom9)
  15625. custom10 := &CustomData{
  15626. MsgId: "H44022900158202103301738448785",
  15627. PsnNo: "44020000001100500813",
  15628. Info: "2207",
  15629. }
  15630. customData = append(customData, custom10)
  15631. custom11 := &CustomData{
  15632. MsgId: "H44022900158202103301732455843",
  15633. PsnNo: "44020000001102690557",
  15634. Info: "2207",
  15635. }
  15636. customData = append(customData, custom11)
  15637. custom12 := &CustomData{
  15638. MsgId: "H44022900158202103301745421708",
  15639. PsnNo: "44020000001102211928",
  15640. Info: "2207",
  15641. }
  15642. customData = append(customData, custom12)
  15643. custom1212 := &CustomData{
  15644. MsgId: "H440229001582021033017351627",
  15645. PsnNo: "44020000001102481733",
  15646. Info: "2207",
  15647. }
  15648. customData = append(customData, custom1212)
  15649. custom13 := &CustomData{
  15650. MsgId: "H44022900158202103301740327951",
  15651. PsnNo: "44020000001103174866",
  15652. Info: "2207",
  15653. }
  15654. customData = append(customData, custom13)
  15655. custom14 := &CustomData{
  15656. MsgId: "H4402290015820210330174922668",
  15657. PsnNo: "44020000001102927272",
  15658. Info: "2207",
  15659. }
  15660. customData = append(customData, custom14)
  15661. custom15 := &CustomData{
  15662. MsgId: "H44022900158202103301752362273",
  15663. PsnNo: "44020000001102942890",
  15664. Info: "2207",
  15665. }
  15666. customData = append(customData, custom15)
  15667. custom16 := &CustomData{
  15668. MsgId: "H44022900158202103301751082917",
  15669. PsnNo: "44020000001101662162",
  15670. Info: "2207",
  15671. }
  15672. customData = append(customData, custom16)
  15673. custom17 := &CustomData{
  15674. MsgId: "H44022900158202103301754147728",
  15675. PsnNo: "44020000000229014511",
  15676. Info: "2207",
  15677. }
  15678. customData = append(customData, custom17)
  15679. adminUser := c.GetAdminUserInfo()
  15680. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  15681. for _, item := range customData {
  15682. result := service.Gdyb2601(item.PsnNo, item.MsgId, item.Info, miConfig.OrgName, "张俊杰", miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey)
  15683. fmt.Println(result)
  15684. }
  15685. }
  15686. func (c *HisApiController) GetAllopatry() {
  15687. year := c.GetString("year")
  15688. month := c.GetString("month")
  15689. admin_user_id, _ := c.GetInt64("admin_user_id")
  15690. adminUser := c.GetAdminUserInfo()
  15691. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  15692. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  15693. result, _ := service.Gdyb9001Two(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, admin_user_id)
  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. var res models.Result9001
  15702. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  15703. utils.ErrorLog("解析失败:%v", err)
  15704. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  15705. return
  15706. }
  15707. fmt.Println(res.Output.Signinoutb)
  15708. fmt.Println(res.Output.Signinoutb.SignNo)
  15709. fmt.Println(string(userJSONBytes))
  15710. result3, _ := service.Gdyb3260(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, year, month, res.Output.Signinoutb.SignNo, 0)
  15711. var dat3 map[string]interface{}
  15712. if err := json.Unmarshal([]byte(result3), &dat3); err == nil {
  15713. fmt.Println(dat3)
  15714. } else {
  15715. fmt.Println(err)
  15716. }
  15717. userJSONBytes3, _ := json.Marshal(dat3)
  15718. var res3 models.Result3260
  15719. if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  15720. utils.ErrorLog("解析失败:%v", err)
  15721. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  15722. return
  15723. }
  15724. var curpage int
  15725. var pagesize int = 100
  15726. var start int = 1
  15727. //var stop int
  15728. //pagecount := 10
  15729. pagecount := int(math.Ceil(float64(res3.Output.Totalrow) / float64(pagesize)))
  15730. for curpage = 1; curpage <= pagecount; curpage++ {
  15731. if curpage == 1 {
  15732. start = 0
  15733. } else {
  15734. start = (curpage-1)*pagesize + 1
  15735. }
  15736. //stop = curpage * pagesize
  15737. //if stop > int(res3.Output.Totalrow) {
  15738. // stop =int(res3.Output.Totalrow)
  15739. //}
  15740. result2, _ := service.Gdyb3260(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, year, month, res.Output.Signinoutb.SignNo, start)
  15741. var dat2 map[string]interface{}
  15742. if err := json.Unmarshal([]byte(result2), &dat2); err == nil {
  15743. fmt.Println(dat)
  15744. } else {
  15745. fmt.Println(err)
  15746. }
  15747. userJSONBytes2, _ := json.Marshal(dat2)
  15748. var res2 models.Result3260
  15749. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  15750. utils.ErrorLog("解析失败:%v", err)
  15751. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  15752. return
  15753. }
  15754. //if res2.Infcode == 0 {
  15755. // service.Gdyb3261(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, year, month, res2, res.Output.Signinoutb.SignNo)
  15756. // //var dat2 map[string]interface{}
  15757. // //if err := json.Unmarshal([]byte(result3), &dat2); err == nil {
  15758. // // fmt.Println(dat)
  15759. // //} else {
  15760. // // fmt.Println(err)
  15761. // //}
  15762. // //c.ServeSuccessJSON(map[string]interface{}{
  15763. // // "list": res2.Output.Data,
  15764. // //})
  15765. // //return
  15766. //}
  15767. }
  15768. }
  15769. func (c *HisApiController) ComfirmAllopatry() {
  15770. year := c.GetString("year")
  15771. month := c.GetString("month")
  15772. admin_user_id, _ := c.GetInt64("admin_user_id")
  15773. adminUser := c.GetAdminUserInfo()
  15774. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  15775. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  15776. result, _ := service.Gdyb9001Two(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, admin_user_id)
  15777. var dat map[string]interface{}
  15778. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  15779. fmt.Println(dat)
  15780. } else {
  15781. fmt.Println(err)
  15782. }
  15783. userJSONBytes, _ := json.Marshal(dat)
  15784. var res models.Result9001
  15785. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  15786. utils.ErrorLog("解析失败:%v", err)
  15787. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  15788. return
  15789. }
  15790. result2, _ := service.Gdyb3260(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, year, month, res.Output.Signinoutb.SignNo, 0)
  15791. var dat2 map[string]interface{}
  15792. if err := json.Unmarshal([]byte(result2), &dat2); err == nil {
  15793. fmt.Println(dat)
  15794. } else {
  15795. fmt.Println(err)
  15796. }
  15797. userJSONBytes2, _ := json.Marshal(dat2)
  15798. var res2 models.Result3260
  15799. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  15800. utils.ErrorLog("解析失败:%v", err)
  15801. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  15802. return
  15803. }
  15804. //if res2.Infcode == 0 {
  15805. // result, _, msgId := service.Gdyb3261(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, year, month, res2, res.Output.Signinoutb.SignNo)
  15806. // var dat map[string]interface{}
  15807. // if err := json.Unmarshal([]byte(result), &dat); err == nil {
  15808. // fmt.Println(dat)
  15809. // } else {
  15810. // fmt.Println(err)
  15811. // }
  15812. // userJSONBytes, _ := json.Marshal(dat)
  15813. // var res3 models.Result3261
  15814. // if err := json.Unmarshal(userJSONBytes, &res3); err != nil {
  15815. // utils.ErrorLog("解析失败:%v", err)
  15816. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  15817. // return
  15818. // }
  15819. //
  15820. // if res3.Infcode == 0 {
  15821. // record := &models.HisYidiClearRecord{
  15822. // UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  15823. // Ctime: time.Now().Unix(),
  15824. // Mtime: time.Now().Unix(),
  15825. // Status: 1,
  15826. // MsgId: msgId,
  15827. // }
  15828. // service.SaveClearRecord(record)
  15829. // c.ServeSuccessJSON(map[string]interface{}{
  15830. // "msg": "提取成功",
  15831. // })
  15832. // }
  15833. //}
  15834. }
  15835. func (c *HisApiController) RefundAllopatry() {
  15836. year := c.GetString("year")
  15837. month := c.GetString("month")
  15838. //id, _ := c.GetInt64("id")
  15839. admin_user_id, _ := c.GetInt64("admin_user_id")
  15840. adminUser := c.GetAdminUserInfo()
  15841. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  15842. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  15843. //record, _ := service.GetClearRecordById(id)
  15844. result2, _ := service.Gdyb9001Two(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, admin_user_id)
  15845. var dat map[string]interface{}
  15846. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  15847. fmt.Println(dat)
  15848. } else {
  15849. fmt.Println(err)
  15850. }
  15851. userJSONBytes, _ := json.Marshal(dat)
  15852. var res models.Result9001
  15853. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  15854. utils.ErrorLog("解析失败:%v", err)
  15855. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  15856. return
  15857. }
  15858. result, _ := service.Gdyb3262(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, year, month, "", res.Output.Signinoutb.SignNo)
  15859. var dat2 map[string]interface{}
  15860. if err := json.Unmarshal([]byte(result), &dat2); err == nil {
  15861. fmt.Println(dat)
  15862. } else {
  15863. fmt.Println(err)
  15864. }
  15865. userJSONBytes2, _ := json.Marshal(dat2)
  15866. var empty ResultFourteen
  15867. if err := json.Unmarshal(userJSONBytes2, &empty); err != nil {
  15868. utils.ErrorLog("解析失败:%v", err)
  15869. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  15870. return
  15871. }
  15872. if empty.Infcode == 0 {
  15873. c.ServeSuccessJSON(map[string]interface{}{
  15874. "msg": "撤销成功",
  15875. })
  15876. return
  15877. }
  15878. }
  15879. func (c *HisApiController) ReversalOtherData() {
  15880. var customData []*CustomData
  15881. custom := &CustomData{
  15882. MsgId: "H44022900158202103301714472004",
  15883. PsnNo: "44020000001101329945",
  15884. Info: "2208",
  15885. }
  15886. customData = append(customData, custom)
  15887. custom1 := &CustomData{
  15888. MsgId: "H4402290015820210330172057803",
  15889. PsnNo: "44020000001101161813",
  15890. Info: "2208",
  15891. }
  15892. customData = append(customData, custom1)
  15893. custom2 := &CustomData{
  15894. MsgId: "H44022900158202103301705198813",
  15895. PsnNo: "44190000133097375417",
  15896. Info: "2208",
  15897. }
  15898. customData = append(customData, custom2)
  15899. custom3 := &CustomData{
  15900. MsgId: "H44022900158202103301715524756",
  15901. PsnNo: "44020000001100187221",
  15902. Info: "2208",
  15903. }
  15904. customData = append(customData, custom3)
  15905. custom4 := &CustomData{
  15906. MsgId: "H44022900158202103301730376224",
  15907. PsnNo: "44020000001101959155",
  15908. Info: "2208",
  15909. }
  15910. customData = append(customData, custom4)
  15911. custom5 := &CustomData{
  15912. MsgId: "H44022900158202103301748008725",
  15913. PsnNo: "44020000001104246641",
  15914. Info: "2208",
  15915. }
  15916. customData = append(customData, custom5)
  15917. custom6 := &CustomData{
  15918. MsgId: "H44022900158202103301718096755",
  15919. PsnNo: "44020000001102211860",
  15920. Info: "2208",
  15921. }
  15922. customData = append(customData, custom6)
  15923. custom7 := &CustomData{
  15924. MsgId: "H44022900158202103301736551640",
  15925. PsnNo: "44020000001102687718",
  15926. Info: "2208",
  15927. }
  15928. customData = append(customData, custom7)
  15929. custom8 := &CustomData{
  15930. MsgId: "H44022900158202103301743097676",
  15931. PsnNo: "44020000001102127785",
  15932. Info: "2208",
  15933. }
  15934. customData = append(customData, custom8)
  15935. custom9 := &CustomData{
  15936. MsgId: "H44022900158202103301712304203",
  15937. PsnNo: "44020000001101518097",
  15938. Info: "2208",
  15939. }
  15940. customData = append(customData, custom9)
  15941. custom10 := &CustomData{
  15942. MsgId: "H44022900158202103301738448785",
  15943. PsnNo: "44020000001100500813",
  15944. Info: "2208",
  15945. }
  15946. customData = append(customData, custom10)
  15947. custom11 := &CustomData{
  15948. MsgId: "H44022900158202103301732455843",
  15949. PsnNo: "44020000001102690557",
  15950. Info: "2208",
  15951. }
  15952. customData = append(customData, custom11)
  15953. custom12 := &CustomData{
  15954. MsgId: "H44022900158202103301745421708",
  15955. PsnNo: "44020000001102211928",
  15956. Info: "2208",
  15957. }
  15958. customData = append(customData, custom12)
  15959. custom1212 := &CustomData{
  15960. MsgId: "H440229001582021033017351627",
  15961. PsnNo: "44020000001102481733",
  15962. Info: "2208",
  15963. }
  15964. customData = append(customData, custom1212)
  15965. custom13 := &CustomData{
  15966. MsgId: "H44022900158202103301740327951",
  15967. PsnNo: "44020000001103174866",
  15968. Info: "2208",
  15969. }
  15970. customData = append(customData, custom13)
  15971. custom14 := &CustomData{
  15972. MsgId: "H4402290015820210330174922668",
  15973. PsnNo: "44020000001102927272",
  15974. Info: "2208",
  15975. }
  15976. customData = append(customData, custom14)
  15977. custom15 := &CustomData{
  15978. MsgId: "H44022900158202103301752362273",
  15979. PsnNo: "44020000001102942890",
  15980. Info: "2208",
  15981. }
  15982. customData = append(customData, custom15)
  15983. custom16 := &CustomData{
  15984. MsgId: "H44022900158202103301751082917",
  15985. PsnNo: "44020000001101662162",
  15986. Info: "2208",
  15987. }
  15988. customData = append(customData, custom16)
  15989. custom17 := &CustomData{
  15990. MsgId: "H44022900158202103301754147728",
  15991. PsnNo: "44020000000229014511",
  15992. Info: "2208",
  15993. }
  15994. customData = append(customData, custom17)
  15995. adminUser := c.GetAdminUserInfo()
  15996. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  15997. for _, item := range customData {
  15998. result := service.Gdyb2601(item.PsnNo, item.MsgId, item.Info, miConfig.OrgName, "张俊杰", miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey)
  15999. fmt.Println(result)
  16000. }
  16001. }
  16002. func PathExists(path string) (bool, error) {
  16003. _, err := os.Stat(path)
  16004. if err == nil {
  16005. return true, nil
  16006. }
  16007. if os.IsNotExist(err) {
  16008. return false, nil
  16009. }
  16010. return false, err
  16011. }
  16012. // 创建文件夹
  16013. func Mkdir(dir string) {
  16014. // 创建文件夹
  16015. exist, err := PathExists(dir)
  16016. if err != nil {
  16017. fmt.Println(err.Error())
  16018. } else {
  16019. if exist {
  16020. fmt.Println(dir + "文件夹已存在!")
  16021. } else {
  16022. // 文件夹名称,权限
  16023. err := os.Mkdir(dir, os.ModePerm)
  16024. if err != nil {
  16025. fmt.Println(dir+"文件夹创建失败:", err.Error())
  16026. } else {
  16027. fmt.Println(dir + "文件夹创建成功!")
  16028. }
  16029. }
  16030. }
  16031. }
  16032. // 压缩文件
  16033. func Zip(srcFile string, destZip string) error {
  16034. zipfile, err := os.Create(destZip)
  16035. if err != nil {
  16036. return err
  16037. }
  16038. defer zipfile.Close()
  16039. archive := zip.NewWriter(zipfile)
  16040. defer archive.Close()
  16041. filepath.Walk(srcFile, func(path string, info os.FileInfo, err error) error {
  16042. if err != nil {
  16043. return err
  16044. }
  16045. header, err := zip.FileInfoHeader(info)
  16046. if err != nil {
  16047. return err
  16048. }
  16049. header.Name = strings.TrimPrefix(path, filepath.Dir(srcFile)+"/")
  16050. // header.Name = path
  16051. if info.IsDir() {
  16052. header.Name += "/"
  16053. } else {
  16054. header.Method = zip.Deflate
  16055. }
  16056. writer, err := archive.CreateHeader(header)
  16057. if err != nil {
  16058. return err
  16059. }
  16060. if !info.IsDir() {
  16061. file, err := os.Open(path)
  16062. if err != nil {
  16063. return err
  16064. }
  16065. defer file.Close()
  16066. _, err = io.Copy(writer, file)
  16067. }
  16068. return err
  16069. })
  16070. return err
  16071. }
  16072. func ReadFile(filePath string) []byte {
  16073. f, err := os.Open(filePath)
  16074. if err != nil {
  16075. fmt.Println("read file fail", err)
  16076. return nil
  16077. }
  16078. defer f.Close()
  16079. fd, err := ioutil.ReadAll(f)
  16080. if err != nil {
  16081. fmt.Println("read to fd fail", err)
  16082. return nil
  16083. }
  16084. return fd
  16085. }
  16086. func saveLog(result string, request string, infno string, desc string) {
  16087. org_id, _ := beego.AppConfig.Int64("org_id")
  16088. miConfig, _ := service.FindMedicalInsuranceInfo(org_id)
  16089. dir := miConfig.OrgName + "日志"
  16090. utils.Mkdir(dir)
  16091. month := time.Unix(1557042972, 0).Format("1")
  16092. year := time.Now().Format("2006")
  16093. month = time.Now().Format("01")
  16094. day := time.Now().Format("02")
  16095. hour := time.Now().Format("15")
  16096. min := time.Now().Format("04")
  16097. sec := time.Now().Format("05")
  16098. result_time := year + "-" + month + "-" + day + " " + hour + ":" + min + ":" + sec
  16099. file := strconv.FormatInt(org_id, 10) + "_" + year + month + day + "_log"
  16100. file_name := file + ".txt"
  16101. file_path := miConfig.OrgName + "日志" + "/" + file_name
  16102. exist, _ := utils.PathExists(file_path)
  16103. if exist { //存在
  16104. fmt.Println("存在")
  16105. f, err := os.OpenFile(file_path, os.O_WRONLY, 0644)
  16106. if err != nil {
  16107. fmt.Println("read fail")
  16108. }
  16109. content := "\r\n" + "\r\n" + "\r\n" + result_time + " " + "【 " + desc + infno + "入参" + " 】:" + "\r\n" + request + "\r\n" + result_time + " " + "【 " + desc + infno + "出参" + " 】:" + "\r\n" + result
  16110. n, _ := f.Seek(0, 2)
  16111. _, err = f.WriteAt([]byte(content), n)
  16112. } else { //不存在
  16113. fmt.Println("文件不存在,创建文件")
  16114. f, err := os.Create(miConfig.OrgName + "日志" + "/" + file_name)
  16115. defer f.Close()
  16116. if err != nil {
  16117. } else {
  16118. _, err = f.Write([]byte("记录日志"))
  16119. }
  16120. }
  16121. }
  16122. type Charset string
  16123. const (
  16124. UTF8 = Charset("UTF-8")
  16125. GB18030 = Charset("GB18030")
  16126. )
  16127. func ConvertToString(src string, srcCode string, tagCode string) string {
  16128. srcCoder := mahonia.NewDecoder(srcCode)
  16129. srcResult := srcCoder.ConvertString(src)
  16130. tagCoder := mahonia.NewDecoder(tagCode)
  16131. _, cdata, _ := tagCoder.Translate([]byte(srcResult), true)
  16132. result := string(cdata)
  16133. return result
  16134. }
  16135. func ReadEleCard(admin_user_id int64, org_id int64, c *HisApiController) string {
  16136. roles, _ := service.GetAdminUserInfoByID(org_id, admin_user_id)
  16137. miConfig, _ := service.FindMedicalInsuranceInfo(org_id)
  16138. var token string
  16139. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  16140. var api string
  16141. if miConfig.MdtrtareaAdmvs == "320921" {
  16142. 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 +
  16143. "&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
  16144. fmt.Println(api)
  16145. } else {
  16146. 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 +
  16147. "&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
  16148. }
  16149. resp, requestErr := http.Get(api)
  16150. if requestErr != nil {
  16151. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  16152. return ""
  16153. }
  16154. body, ioErr := ioutil.ReadAll(resp.Body)
  16155. if ioErr != nil {
  16156. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  16157. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  16158. return ""
  16159. }
  16160. var respJSON map[string]interface{}
  16161. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  16162. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  16163. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  16164. return ""
  16165. }
  16166. var status string
  16167. status = respJSON["data"].(map[string]interface{})["status"].(string)
  16168. //card_type := respJSON["data"].(map[string]interface{})["type"].(string)
  16169. var res ResultTwo //1101结果
  16170. var res10265 ResultTwo10265 //1101结果
  16171. if status == "0" { //读卡成功
  16172. var card_info string //卡信息
  16173. var busi_card_info string
  16174. token = respJSON["data"].(map[string]interface{})["token"].(string)
  16175. busi_card_info = respJSON["data"].(map[string]interface{})["busi_card_info"].(string)
  16176. card_info = respJSON["data"].(map[string]interface{})["card_info"].(string)
  16177. fmt.Println(card_info)
  16178. fmt.Println(busi_card_info)
  16179. respJSON = respJSON["data"].(map[string]interface{})["result"].(map[string]interface{})
  16180. result, _ := json.Marshal(respJSON)
  16181. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  16182. utils.ErrorLog("解析失败:%v", err)
  16183. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  16184. return ""
  16185. }
  16186. res.ErrMsg = res10265.ErrMsg
  16187. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  16188. res.Infcode = infocode
  16189. res.Output = res10265.Output
  16190. res.InfRefmsgid = res10265.InfRefmsgid
  16191. if res.Infcode == 0 {
  16192. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  16193. if err == gorm.ErrRecordNotFound {
  16194. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  16195. return ""
  16196. } else if err != nil {
  16197. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  16198. return ""
  16199. } else {
  16200. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  16201. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  16202. infoStr := string(Iinfos)
  16203. idetinfoStr := string(Idetinfos)
  16204. psn := &models.HisPsn{
  16205. PsnNo: res.Output.Baseinfo.PsnNo,
  16206. Age: res.Output.Baseinfo.Age,
  16207. PatientId: patient.ID,
  16208. Certno: res.Output.Baseinfo.Certno,
  16209. Brdy: res.Output.Baseinfo.Brdy,
  16210. Gend: res.Output.Baseinfo.Gend,
  16211. Naty: res.Output.Baseinfo.Naty,
  16212. PsnCertType: res.Output.Baseinfo.PsnCertType,
  16213. PsnName: res.Output.Baseinfo.PsnName,
  16214. Idetinfo: idetinfoStr,
  16215. Insuinfo: infoStr,
  16216. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  16217. CardInfo: card_info,
  16218. VerifyNumber: token,
  16219. }
  16220. service.CreateHisPsn(psn)
  16221. return token
  16222. }
  16223. }
  16224. } else {
  16225. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  16226. return ""
  16227. }
  16228. } else { //读卡失败
  16229. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  16230. return ""
  16231. }
  16232. return token
  16233. }
  16234. func DeleteExtraSpaceTwo(s string) string {
  16235. //删除字符串中的多余空格,有多个空格时,仅保留一个空格
  16236. s1 := strings.Replace(s, " ", " ", -1) //替换tab为空格
  16237. regstr := "\\s{2,}" //两个及两个以上空格的正则表达式
  16238. reg, _ := regexp.Compile(regstr) //编译正则表达式
  16239. s2 := make([]byte, len(s1)) //定义字符数组切片
  16240. copy(s2, s1) //将字符串复制到切片
  16241. spc_index := reg.FindStringIndex(string(s2)) //在字符串中搜索
  16242. for len(spc_index) > 0 { //找到适配项
  16243. s2 = append(s2[:spc_index[0]+1], s2[spc_index[1]:]...) //删除多余空格
  16244. spc_index = reg.FindStringIndex(string(s2)) //继续在字符串中搜索
  16245. }
  16246. return string(s2)
  16247. }
  16248. func Remove0000(s string) string {
  16249. str := make([]rune, 0, len(s))
  16250. for _, v := range []rune(s) {
  16251. if v == 0 {
  16252. continue
  16253. }
  16254. str = append(str, v)
  16255. }
  16256. return string(str)
  16257. }
  16258. func (c *HisApiController) GetELeCertInfo(code string, operator_id string, operator_name string) (string, string) {
  16259. DllDef := syscall.MustLoadDLL("HeaSecReadInfo.dll")
  16260. readCard := DllDef.MustFindProc("EcQuery")
  16261. pCardInfo := make([]byte, 8192)
  16262. pBusiCardInfo := make([]byte, 8192)
  16263. data := make(map[string]interface{})
  16264. //pData := make(map[string]interface{})
  16265. inputData := make(map[string]interface{})
  16266. inputData["orgId"] = code
  16267. inputData["businessType"] = "01101"
  16268. inputData["operatorId"] = operator_id
  16269. inputData["operatorName"] = operator_name
  16270. inputData["officeId"] = "001"
  16271. inputData["officeName"] = "血透室"
  16272. //
  16273. data["data"] = inputData
  16274. data["transType"] = "ec.query"
  16275. data["orgId"] = code
  16276. bytesData, _ := json.Marshal(data)
  16277. pCardInfo = bytesData
  16278. ret2, _, _ := readCard.Call((uintptr)(unsafe.Pointer(&pCardInfo[0])), (uintptr)(unsafe.Pointer(&pBusiCardInfo[0])))
  16279. fmt.Println(ret2)
  16280. //fmt.Println(DeleteExtraSpace(string(bytesData)))
  16281. //fmt.Println(DeleteExtraSpace(string(pBusiCardInfo)))
  16282. fmt.Println(":", ConvertToString(DeleteExtraSpace(string(bytesData)), "gbk", "utf-8"))
  16283. fmt.Println(":", ConvertToString(DeleteExtraSpace(string(pBusiCardInfo)), "gbk", "utf-8"))
  16284. if ret2 != 0 {
  16285. return "", ""
  16286. }
  16287. return DeleteExtraSpace(string(bytesData)), DeleteExtraSpace(string(pBusiCardInfo))
  16288. }
  16289. func DeleteExtraSpace(s string) string {
  16290. //删除字符串中的多余空格,有多个空格时,仅保留一个空格
  16291. s1 := strings.Replace(s, " ", " ", -1) //替换tab为空格
  16292. regstr := "\\s{2,}" //两个及两个以上空格的正则表达式
  16293. reg, _ := regexp.Compile(regstr) //编译正则表达式
  16294. s2 := make([]byte, len(s1)) //定义字符数组切片
  16295. copy(s2, s1) //将字符串复制到切片
  16296. spc_index := reg.FindStringIndex(string(s2)) //在字符串中搜索
  16297. for len(spc_index) > 0 { //找到适配项
  16298. s2 = append(s2[:spc_index[0]+1], s2[spc_index[1]:]...) //删除多余空格
  16299. spc_index = reg.FindStringIndex(string(s2)) //继续在字符串中搜索
  16300. }
  16301. return string(s2)
  16302. }
  16303. // 对账
  16304. func (c *HisApiController) Post3202() {
  16305. start_time := c.GetString("start_time")
  16306. end_time := c.GetString("end_time")
  16307. //insutype := c.GetString("insutype")
  16308. clr_type := c.GetString("clr_type")
  16309. clr_org := c.GetString("clr_optins")
  16310. admin_user_id, _ := c.GetInt64("admin_user_id")
  16311. adminUser := c.GetAdminUserInfo()
  16312. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  16313. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  16314. if len(clr_org) == 0 {
  16315. clr_org = miConfig.MdtrtareaAdmvs
  16316. }
  16317. timeLayout := "2006-01-02"
  16318. loc, _ := time.LoadLocation("Local")
  16319. startime, _ := time.ParseInLocation(timeLayout+" 15:04:05", start_time+" 00:00:00", loc)
  16320. endtime, _ := time.ParseInLocation(timeLayout+" 15:04:05", end_time+" 23:59:59", loc)
  16321. orders, _ := service.GetOrderByTimeFour(startime.Unix(), endtime.Unix(), adminUser.CurrentOrgId)
  16322. //orders_two, _ := service.GetOrderByTimeFour(startime.Unix(), endtime.Unix(), adminUser.CurrentOrgId, "310", "", clr_type)
  16323. //fixmedins_setl_cnt := int64(len(orders))
  16324. var medfee_sumamt float64
  16325. var acct_pay float64
  16326. var fund_pay_sumamt float64
  16327. for _, item := range orders {
  16328. medfee_sumamt = medfee_sumamt + item.MedfeeSumamt
  16329. acct_pay = acct_pay + item.AcctPay
  16330. fund_pay_sumamt = fund_pay_sumamt + item.FundPaySumamt
  16331. }
  16332. //var medfee_sumamt_two float64
  16333. //var acct_pay_two float64
  16334. //var fund_pay_sumamt_two float64
  16335. //for _, item := range orders_two {
  16336. // medfee_sumamt_two = medfee_sumamt_two + item.MedfeeSumamt
  16337. // acct_pay_two = acct_pay_two + item.AcctPay
  16338. // fund_pay_sumamt_two = fund_pay_sumamt_two + item.FundPaySumamt
  16339. //}
  16340. //var user_name string
  16341. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  16342. //if role.ID == 0 {
  16343. // user_name = "xxx"
  16344. //} else {
  16345. // user_name = role.UserName
  16346. //}
  16347. var res ResultSix
  16348. if config.IsOpen == 1 {
  16349. var bps []*models.BusinessParamsTwo
  16350. var bp models.BusinessParamsTwo
  16351. medfee_sumamt_str := fmt.Sprintf("%.2f", medfee_sumamt)
  16352. acct_pay_str := fmt.Sprintf("%.2f", acct_pay)
  16353. fund_pay_sumamt_str := fmt.Sprintf("%.2f", fund_pay_sumamt)
  16354. bp.MedfeeSumamt = medfee_sumamt_str
  16355. bp.AcctPay = acct_pay_str
  16356. bp.FundPaySumamt = fund_pay_sumamt_str
  16357. bp.Insutype = "390"
  16358. bp.StmtBegndate = start_time
  16359. bp.ClrType = clr_type
  16360. bp.SetlOptins = clr_org
  16361. bp.StmtEnddate = end_time
  16362. bps = append(bps, &bp)
  16363. data := make(map[string]interface{})
  16364. data["bps"] = bps
  16365. data["org_name"] = miConfig.OrgName
  16366. data["doctor"] = role.UserName
  16367. data["fixmedins_code"] = miConfig.Code
  16368. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  16369. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  16370. if miConfig.MdtrtareaAdmvs == "421300" {
  16371. client := &http.Client{}
  16372. bytesData, _ := json.Marshal(data)
  16373. req, _ := http.NewRequest("POST", "http://192.168.124.4:9532/"+"hbyb/3202", bytes.NewReader(bytesData))
  16374. resp, _ := client.Do(req)
  16375. defer resp.Body.Close()
  16376. body, ioErr := ioutil.ReadAll(resp.Body)
  16377. if ioErr != nil {
  16378. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  16379. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  16380. return
  16381. }
  16382. var respJSON map[string]interface{}
  16383. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  16384. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  16385. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  16386. return
  16387. }
  16388. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  16389. userJSONBytes, _ := json.Marshal(respJSON)
  16390. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  16391. utils.ErrorLog("解析失败:%v", err)
  16392. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  16393. return
  16394. }
  16395. }
  16396. if res.Infcode == 0 {
  16397. c.ServeSuccessJSON(map[string]interface{}{
  16398. "msg": "发起成功",
  16399. })
  16400. } else {
  16401. c.ServeSuccessJSON(map[string]interface{}{
  16402. "code": -10,
  16403. "msg": res.ErrMsg,
  16404. })
  16405. }
  16406. }
  16407. }
  16408. func (c *HisApiController) Post3501() {
  16409. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  16410. data := make(map[string]interface{})
  16411. var struct3501s []models.Struct3501
  16412. var struct3501 models.Struct3501
  16413. struct3501.OrgName = miConfig.OrgName
  16414. struct3501.AccessKey = miConfig.AccessKey
  16415. struct3501.RequestUrl = miConfig.Url
  16416. struct3501.SecretKey = miConfig.SecretKey
  16417. struct3501.ManuDate = "2022-08-17"
  16418. struct3501.FixmedinsBchno = ""
  16419. struct3501.ManuLotnum = ""
  16420. struct3501.RxFlag = "0"
  16421. struct3501.ExpyEnd = "2022-08-17"
  16422. struct3501.Invdate = "2022-08-17"
  16423. struct3501.InvCnt = "20.25"
  16424. struct3501.Memo = ""
  16425. struct3501.MedListCodg = "XB01ABD056B002020200517"
  16426. struct3501.FixmedinsHilistId = miConfig.Code
  16427. struct3501.FixmedinsHilistName = miConfig.OrgName
  16428. struct3501s = append(struct3501s, struct3501)
  16429. data["struct_3501s"] = struct3501s
  16430. client := &http.Client{}
  16431. bytesData, _ := json.Marshal(data)
  16432. var req *http.Request
  16433. if miConfig.MdtrtareaAdmvs == "320921" {
  16434. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3501", bytes.NewReader(bytesData))
  16435. } else {
  16436. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3501", bytes.NewReader(bytesData))
  16437. }
  16438. resp, _ := client.Do(req)
  16439. defer resp.Body.Close()
  16440. body, ioErr := ioutil.ReadAll(resp.Body)
  16441. if ioErr != nil {
  16442. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  16443. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  16444. return
  16445. }
  16446. var respJSON map[string]interface{}
  16447. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  16448. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  16449. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  16450. return
  16451. }
  16452. var res ResultSix
  16453. var resSix10265 ResultSix10265 //1101结果
  16454. respJSON = respJSON["data"].(map[string]interface{})["request_log"].(map[string]interface{})
  16455. result, _ := json.Marshal(respJSON)
  16456. if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  16457. utils.ErrorLog("解析失败:%v", err)
  16458. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  16459. return
  16460. }
  16461. res.InfRefmsgid = resSix10265.InfRefmsgid
  16462. res.Output = resSix10265.Output
  16463. res.ErrMsg = resSix10265.ErrMsg
  16464. res.Cainfo = resSix10265.Cainfo
  16465. res.WarnMsg = resSix10265.WarnMsg
  16466. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  16467. res.Infcode = infocode
  16468. if infocode == 0 {
  16469. c.ServeSuccessJSON(map[string]interface{}{
  16470. "msg": "上传成功",
  16471. })
  16472. return
  16473. } else {
  16474. c.ServeSuccessJSON(map[string]interface{}{
  16475. "failed_code": -10,
  16476. "msg": res.ErrMsg,
  16477. })
  16478. return
  16479. }
  16480. }
  16481. func (c *HisApiController) Post3502() {
  16482. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  16483. data := make(map[string]interface{})
  16484. var struct3502s []models.Struct3502
  16485. var struct3502 models.Struct3502
  16486. struct3502.OrgName = miConfig.OrgName
  16487. struct3502.AccessKey = miConfig.AccessKey
  16488. struct3502.RequestUrl = miConfig.Url
  16489. struct3502.SecretKey = miConfig.SecretKey
  16490. struct3502.ManuDate = "2022-08-15"
  16491. struct3502.FixmedinsBchno = ""
  16492. struct3502.ManuLotnum = ""
  16493. struct3502.RxFlag = "0"
  16494. struct3502.ExpyEnd = "2022-08-15"
  16495. struct3502.Invdate = "2022-08-15"
  16496. struct3502.InvCnt = "20.25"
  16497. struct3502.Memo = ""
  16498. struct3502.MedListCodg = "XB01ABD056B002020200517"
  16499. struct3502.FixmedinsHilistId = miConfig.Code
  16500. struct3502.FixmedinsHilistName = miConfig.OrgName
  16501. struct3502s = append(struct3502s, struct3502)
  16502. data["struct_3502s"] = struct3502s
  16503. client := &http.Client{}
  16504. bytesData, _ := json.Marshal(data)
  16505. var req *http.Request
  16506. if miConfig.MdtrtareaAdmvs == "320921" {
  16507. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3501", bytes.NewReader(bytesData))
  16508. } else {
  16509. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3501", bytes.NewReader(bytesData))
  16510. }
  16511. resp, _ := client.Do(req)
  16512. defer resp.Body.Close()
  16513. body, ioErr := ioutil.ReadAll(resp.Body)
  16514. if ioErr != nil {
  16515. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  16516. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  16517. return
  16518. }
  16519. var respJSON map[string]interface{}
  16520. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  16521. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  16522. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  16523. return
  16524. }
  16525. var res ResultSix
  16526. var resSix10265 ResultSix10265 //1101结果
  16527. respJSON = respJSON["data"].(map[string]interface{})["request_log"].(map[string]interface{})
  16528. result, _ := json.Marshal(respJSON)
  16529. if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  16530. utils.ErrorLog("解析失败:%v", err)
  16531. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  16532. return
  16533. }
  16534. res.InfRefmsgid = resSix10265.InfRefmsgid
  16535. res.Output = resSix10265.Output
  16536. res.ErrMsg = resSix10265.ErrMsg
  16537. res.Cainfo = resSix10265.Cainfo
  16538. res.WarnMsg = resSix10265.WarnMsg
  16539. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  16540. res.Infcode = infocode
  16541. if infocode == 0 {
  16542. c.ServeSuccessJSON(map[string]interface{}{
  16543. "msg": "上传成功",
  16544. })
  16545. return
  16546. } else {
  16547. c.ServeSuccessJSON(map[string]interface{}{
  16548. "failed_code": -10,
  16549. "msg": res.ErrMsg,
  16550. })
  16551. return
  16552. }
  16553. }
  16554. func (c *HisApiController) Post3503() {
  16555. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  16556. data := make(map[string]interface{})
  16557. var struct3501s []models.Struct3501
  16558. var struct3501 models.Struct3501
  16559. struct3501.OrgName = miConfig.OrgName
  16560. struct3501.AccessKey = miConfig.AccessKey
  16561. struct3501.RequestUrl = miConfig.Url
  16562. struct3501.SecretKey = miConfig.SecretKey
  16563. struct3501.ManuDate = "2022-08-15"
  16564. struct3501.FixmedinsBchno = ""
  16565. struct3501.ManuLotnum = ""
  16566. struct3501.RxFlag = "0"
  16567. struct3501.ExpyEnd = "2022-08-15"
  16568. struct3501.Invdate = "2022-08-15"
  16569. struct3501.InvCnt = "20.25"
  16570. struct3501.Memo = ""
  16571. struct3501.MedListCodg = "XB01ABD056B002020200517"
  16572. struct3501.FixmedinsHilistId = miConfig.Code
  16573. struct3501.FixmedinsHilistName = miConfig.OrgName
  16574. struct3501s = append(struct3501s, struct3501)
  16575. data["struct_3501s"] = struct3501s
  16576. client := &http.Client{}
  16577. bytesData, _ := json.Marshal(data)
  16578. var req *http.Request
  16579. if miConfig.MdtrtareaAdmvs == "320921" {
  16580. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3501", bytes.NewReader(bytesData))
  16581. } else {
  16582. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3501", bytes.NewReader(bytesData))
  16583. }
  16584. resp, _ := client.Do(req)
  16585. defer resp.Body.Close()
  16586. body, ioErr := ioutil.ReadAll(resp.Body)
  16587. if ioErr != nil {
  16588. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  16589. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  16590. return
  16591. }
  16592. var respJSON map[string]interface{}
  16593. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  16594. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  16595. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  16596. return
  16597. }
  16598. var res ResultSix
  16599. var resSix10265 ResultSix10265 //1101结果
  16600. respJSON = respJSON["data"].(map[string]interface{})["request_log"].(map[string]interface{})
  16601. result, _ := json.Marshal(respJSON)
  16602. if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  16603. utils.ErrorLog("解析失败:%v", err)
  16604. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  16605. return
  16606. }
  16607. res.InfRefmsgid = resSix10265.InfRefmsgid
  16608. res.Output = resSix10265.Output
  16609. res.ErrMsg = resSix10265.ErrMsg
  16610. res.Cainfo = resSix10265.Cainfo
  16611. res.WarnMsg = resSix10265.WarnMsg
  16612. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  16613. res.Infcode = infocode
  16614. if infocode == 0 {
  16615. c.ServeSuccessJSON(map[string]interface{}{
  16616. "msg": "上传成功",
  16617. })
  16618. return
  16619. } else {
  16620. c.ServeSuccessJSON(map[string]interface{}{
  16621. "failed_code": -10,
  16622. "msg": res.ErrMsg,
  16623. })
  16624. return
  16625. }
  16626. }
  16627. func (c *HisApiController) Post3504() {
  16628. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  16629. data := make(map[string]interface{})
  16630. var struct3501s []models.Struct3501
  16631. var struct3501 models.Struct3501
  16632. struct3501.OrgName = miConfig.OrgName
  16633. struct3501.AccessKey = miConfig.AccessKey
  16634. struct3501.RequestUrl = miConfig.Url
  16635. struct3501.SecretKey = miConfig.SecretKey
  16636. struct3501.ManuDate = "2022-08-15"
  16637. struct3501.FixmedinsBchno = ""
  16638. struct3501.ManuLotnum = ""
  16639. struct3501.RxFlag = "0"
  16640. struct3501.ExpyEnd = "2022-08-15"
  16641. struct3501.Invdate = "2022-08-15"
  16642. struct3501.InvCnt = "20.25"
  16643. struct3501.Memo = ""
  16644. struct3501.MedListCodg = "XB01ABD056B002020200517"
  16645. struct3501.FixmedinsHilistId = miConfig.Code
  16646. struct3501.FixmedinsHilistName = miConfig.OrgName
  16647. struct3501s = append(struct3501s, struct3501)
  16648. data["struct_3501s"] = struct3501s
  16649. client := &http.Client{}
  16650. bytesData, _ := json.Marshal(data)
  16651. var req *http.Request
  16652. if miConfig.MdtrtareaAdmvs == "320921" {
  16653. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3501", bytes.NewReader(bytesData))
  16654. } else {
  16655. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3501", bytes.NewReader(bytesData))
  16656. }
  16657. resp, _ := client.Do(req)
  16658. defer resp.Body.Close()
  16659. body, ioErr := ioutil.ReadAll(resp.Body)
  16660. if ioErr != nil {
  16661. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  16662. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  16663. return
  16664. }
  16665. var respJSON map[string]interface{}
  16666. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  16667. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  16668. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  16669. return
  16670. }
  16671. var res ResultSix
  16672. var resSix10265 ResultSix10265 //1101结果
  16673. respJSON = respJSON["data"].(map[string]interface{})["request_log"].(map[string]interface{})
  16674. result, _ := json.Marshal(respJSON)
  16675. if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  16676. utils.ErrorLog("解析失败:%v", err)
  16677. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  16678. return
  16679. }
  16680. res.InfRefmsgid = resSix10265.InfRefmsgid
  16681. res.Output = resSix10265.Output
  16682. res.ErrMsg = resSix10265.ErrMsg
  16683. res.Cainfo = resSix10265.Cainfo
  16684. res.WarnMsg = resSix10265.WarnMsg
  16685. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  16686. res.Infcode = infocode
  16687. if infocode == 0 {
  16688. c.ServeSuccessJSON(map[string]interface{}{
  16689. "msg": "上传成功",
  16690. })
  16691. return
  16692. } else {
  16693. c.ServeSuccessJSON(map[string]interface{}{
  16694. "failed_code": -10,
  16695. "msg": res.ErrMsg,
  16696. })
  16697. return
  16698. }
  16699. }
  16700. func (c *HisApiController) Post3505() {
  16701. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  16702. data := make(map[string]interface{})
  16703. var struct3501s []models.Struct3501
  16704. var struct3501 models.Struct3501
  16705. struct3501.OrgName = miConfig.OrgName
  16706. struct3501.AccessKey = miConfig.AccessKey
  16707. struct3501.RequestUrl = miConfig.Url
  16708. struct3501.SecretKey = miConfig.SecretKey
  16709. struct3501.ManuDate = "2022-08-15"
  16710. struct3501.FixmedinsBchno = ""
  16711. struct3501.ManuLotnum = ""
  16712. struct3501.RxFlag = "0"
  16713. struct3501.ExpyEnd = "2022-08-15"
  16714. struct3501.Invdate = "2022-08-15"
  16715. struct3501.InvCnt = "20.25"
  16716. struct3501.Memo = ""
  16717. struct3501.MedListCodg = "XB01ABD056B002020200517"
  16718. struct3501.FixmedinsHilistId = miConfig.Code
  16719. struct3501.FixmedinsHilistName = miConfig.OrgName
  16720. struct3501s = append(struct3501s, struct3501)
  16721. data["struct_3501s"] = struct3501s
  16722. client := &http.Client{}
  16723. bytesData, _ := json.Marshal(data)
  16724. var req *http.Request
  16725. if miConfig.MdtrtareaAdmvs == "320921" {
  16726. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3501", bytes.NewReader(bytesData))
  16727. } else {
  16728. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3501", bytes.NewReader(bytesData))
  16729. }
  16730. resp, _ := client.Do(req)
  16731. defer resp.Body.Close()
  16732. body, ioErr := ioutil.ReadAll(resp.Body)
  16733. if ioErr != nil {
  16734. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  16735. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  16736. return
  16737. }
  16738. var respJSON map[string]interface{}
  16739. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  16740. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  16741. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  16742. return
  16743. }
  16744. var res ResultSix
  16745. var resSix10265 ResultSix10265 //1101结果
  16746. respJSON = respJSON["data"].(map[string]interface{})["request_log"].(map[string]interface{})
  16747. result, _ := json.Marshal(respJSON)
  16748. if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  16749. utils.ErrorLog("解析失败:%v", err)
  16750. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  16751. return
  16752. }
  16753. res.InfRefmsgid = resSix10265.InfRefmsgid
  16754. res.Output = resSix10265.Output
  16755. res.ErrMsg = resSix10265.ErrMsg
  16756. res.Cainfo = resSix10265.Cainfo
  16757. res.WarnMsg = resSix10265.WarnMsg
  16758. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  16759. res.Infcode = infocode
  16760. if infocode == 0 {
  16761. c.ServeSuccessJSON(map[string]interface{}{
  16762. "msg": "上传成功",
  16763. })
  16764. return
  16765. } else {
  16766. c.ServeSuccessJSON(map[string]interface{}{
  16767. "failed_code": -10,
  16768. "msg": res.ErrMsg,
  16769. })
  16770. return
  16771. }
  16772. }
  16773. func (c *HisApiController) Post3506() {
  16774. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  16775. data := make(map[string]interface{})
  16776. var struct3501s []models.Struct3501
  16777. var struct3501 models.Struct3501
  16778. struct3501.OrgName = miConfig.OrgName
  16779. struct3501.AccessKey = miConfig.AccessKey
  16780. struct3501.RequestUrl = miConfig.Url
  16781. struct3501.SecretKey = miConfig.SecretKey
  16782. struct3501.ManuDate = "2022-08-15"
  16783. struct3501.FixmedinsBchno = ""
  16784. struct3501.ManuLotnum = ""
  16785. struct3501.RxFlag = "0"
  16786. struct3501.ExpyEnd = "2022-08-15"
  16787. struct3501.Invdate = "2022-08-15"
  16788. struct3501.InvCnt = "20.25"
  16789. struct3501.Memo = ""
  16790. struct3501.MedListCodg = "XB01ABD056B002020200517"
  16791. struct3501.FixmedinsHilistId = miConfig.Code
  16792. struct3501.FixmedinsHilistName = miConfig.OrgName
  16793. struct3501s = append(struct3501s, struct3501)
  16794. data["struct_3501s"] = struct3501s
  16795. client := &http.Client{}
  16796. bytesData, _ := json.Marshal(data)
  16797. var req *http.Request
  16798. if miConfig.MdtrtareaAdmvs == "320921" {
  16799. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3501", bytes.NewReader(bytesData))
  16800. } else {
  16801. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3501", bytes.NewReader(bytesData))
  16802. }
  16803. resp, _ := client.Do(req)
  16804. defer resp.Body.Close()
  16805. body, ioErr := ioutil.ReadAll(resp.Body)
  16806. if ioErr != nil {
  16807. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  16808. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  16809. return
  16810. }
  16811. var respJSON map[string]interface{}
  16812. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  16813. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  16814. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  16815. return
  16816. }
  16817. var res ResultSix
  16818. var resSix10265 ResultSix10265 //1101结果
  16819. respJSON = respJSON["data"].(map[string]interface{})["request_log"].(map[string]interface{})
  16820. result, _ := json.Marshal(respJSON)
  16821. if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  16822. utils.ErrorLog("解析失败:%v", err)
  16823. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  16824. return
  16825. }
  16826. res.InfRefmsgid = resSix10265.InfRefmsgid
  16827. res.Output = resSix10265.Output
  16828. res.ErrMsg = resSix10265.ErrMsg
  16829. res.Cainfo = resSix10265.Cainfo
  16830. res.WarnMsg = resSix10265.WarnMsg
  16831. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  16832. res.Infcode = infocode
  16833. if infocode == 0 {
  16834. c.ServeSuccessJSON(map[string]interface{}{
  16835. "msg": "上传成功",
  16836. })
  16837. return
  16838. } else {
  16839. c.ServeSuccessJSON(map[string]interface{}{
  16840. "failed_code": -10,
  16841. "msg": res.ErrMsg,
  16842. })
  16843. return
  16844. }
  16845. }
  16846. func (c *HisApiController) Post3507() {
  16847. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  16848. data := make(map[string]interface{})
  16849. var struct3501s []models.Struct3501
  16850. var struct3501 models.Struct3501
  16851. struct3501.OrgName = miConfig.OrgName
  16852. struct3501.AccessKey = miConfig.AccessKey
  16853. struct3501.RequestUrl = miConfig.Url
  16854. struct3501.SecretKey = miConfig.SecretKey
  16855. struct3501.ManuDate = "2022-08-15"
  16856. struct3501.FixmedinsBchno = ""
  16857. struct3501.ManuLotnum = ""
  16858. struct3501.RxFlag = "0"
  16859. struct3501.ExpyEnd = "2022-08-15"
  16860. struct3501.Invdate = "2022-08-15"
  16861. struct3501.InvCnt = "20.25"
  16862. struct3501.Memo = ""
  16863. struct3501.MedListCodg = "XB01ABD056B002020200517"
  16864. struct3501.FixmedinsHilistId = miConfig.Code
  16865. struct3501.FixmedinsHilistName = miConfig.OrgName
  16866. struct3501s = append(struct3501s, struct3501)
  16867. data["struct_3501s"] = struct3501s
  16868. client := &http.Client{}
  16869. bytesData, _ := json.Marshal(data)
  16870. var req *http.Request
  16871. if miConfig.MdtrtareaAdmvs == "320921" {
  16872. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3501", bytes.NewReader(bytesData))
  16873. } else {
  16874. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3501", bytes.NewReader(bytesData))
  16875. }
  16876. resp, _ := client.Do(req)
  16877. defer resp.Body.Close()
  16878. body, ioErr := ioutil.ReadAll(resp.Body)
  16879. if ioErr != nil {
  16880. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  16881. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  16882. return
  16883. }
  16884. var respJSON map[string]interface{}
  16885. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  16886. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  16887. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  16888. return
  16889. }
  16890. var res ResultSix
  16891. var resSix10265 ResultSix10265 //1101结果
  16892. respJSON = respJSON["data"].(map[string]interface{})["request_log"].(map[string]interface{})
  16893. result, _ := json.Marshal(respJSON)
  16894. if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  16895. utils.ErrorLog("解析失败:%v", err)
  16896. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  16897. return
  16898. }
  16899. res.InfRefmsgid = resSix10265.InfRefmsgid
  16900. res.Output = resSix10265.Output
  16901. res.ErrMsg = resSix10265.ErrMsg
  16902. res.Cainfo = resSix10265.Cainfo
  16903. res.WarnMsg = resSix10265.WarnMsg
  16904. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  16905. res.Infcode = infocode
  16906. if infocode == 0 {
  16907. c.ServeSuccessJSON(map[string]interface{}{
  16908. "msg": "上传成功",
  16909. })
  16910. return
  16911. } else {
  16912. c.ServeSuccessJSON(map[string]interface{}{
  16913. "failed_code": -10,
  16914. "msg": res.ErrMsg,
  16915. })
  16916. return
  16917. }
  16918. }
  16919. func GetELeInfo(code string, operator_id string, operator_name string) (string, string) {
  16920. // WebSocket服务器地址
  16921. serverURL := "ws://127.0.0.1:8899"
  16922. // 解析WebSocket服务器地址
  16923. u, err := url.Parse(serverURL)
  16924. if err != nil {
  16925. }
  16926. // 建立WebSocket连接
  16927. conn, _, err := websocket.DefaultDialer.Dial(u.String(), nil)
  16928. if err != nil {
  16929. }
  16930. defer conn.Close()
  16931. input2 := make(map[string]interface{})
  16932. input := make(map[string]interface{})
  16933. inputData := make(map[string]interface{})
  16934. inputData["orgId"] = code
  16935. inputData["businessType"] = "01101"
  16936. inputData["operatorId"] = operator_id
  16937. inputData["operatorName"] = operator_name
  16938. inputData["officeId"] = "001"
  16939. inputData["officeName"] = "血透室"
  16940. inputData["deviceType"] = ""
  16941. input["data"] = inputData
  16942. input["orgId"] = code
  16943. input["transType"] = "ec.query"
  16944. input2["url"] = "http://igb.hsa.gdgov.cn/prd_nation_eccode/prd_eccode/localcfc/api/hsecfc/localQrCodeQuery"
  16945. input2["indata"] = input
  16946. bytesData, _ := json.Marshal(input2)
  16947. err = conn.WriteMessage(websocket.TextMessage, bytesData)
  16948. if err != nil {
  16949. fmt.Println(err)
  16950. }
  16951. // 接收消息
  16952. _, receivedMessage, err := conn.ReadMessage()
  16953. if err != nil {
  16954. fmt.Println(err)
  16955. }
  16956. return "", string(receivedMessage)
  16957. }
  16958. func GetELeInfoThree(code string, operator_id string, operator_name string) (string, string) {
  16959. // WebSocket服务器地址
  16960. serverURL := "ws://127.0.0.1:8899"
  16961. // 解析WebSocket服务器地址
  16962. u, err := url.Parse(serverURL)
  16963. if err != nil {
  16964. }
  16965. // 建立WebSocket连接
  16966. conn, _, err := websocket.DefaultDialer.Dial(u.String(), nil)
  16967. if err != nil {
  16968. }
  16969. defer conn.Close()
  16970. input2 := make(map[string]interface{})
  16971. input := make(map[string]interface{})
  16972. inputData := make(map[string]interface{})
  16973. inputData["orgId"] = code
  16974. inputData["businessType"] = "01301"
  16975. inputData["operatorId"] = operator_id
  16976. inputData["operatorName"] = operator_name
  16977. inputData["officeId"] = "001"
  16978. inputData["officeName"] = "血透室"
  16979. inputData["deviceType"] = ""
  16980. input["data"] = inputData
  16981. input["orgId"] = code
  16982. input["transType"] = "ec.query"
  16983. input2["url"] = "http://igb.hsa.gdgov.cn/prd_nation_eccode/prd_eccode/localcfc/api/hsecfc/localQrCodeQuery"
  16984. input2["indata"] = input
  16985. bytesData, _ := json.Marshal(input2)
  16986. err = conn.WriteMessage(websocket.TextMessage, bytesData)
  16987. if err != nil {
  16988. fmt.Println(err)
  16989. }
  16990. // 接收消息
  16991. _, receivedMessage, err := conn.ReadMessage()
  16992. if err != nil {
  16993. fmt.Println(err)
  16994. }
  16995. return "", string(receivedMessage)
  16996. }