his_api_controller.go 719KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473247424752476247724782479248024812482248324842485248624872488248924902491249224932494249524962497249824992500250125022503250425052506250725082509251025112512251325142515251625172518251925202521252225232524252525262527252825292530253125322533253425352536253725382539254025412542254325442545254625472548254925502551255225532554255525562557255825592560256125622563256425652566256725682569257025712572257325742575257625772578257925802581258225832584258525862587258825892590259125922593259425952596259725982599260026012602260326042605260626072608260926102611261226132614261526162617261826192620262126222623262426252626262726282629263026312632263326342635263626372638263926402641264226432644264526462647264826492650265126522653265426552656265726582659266026612662266326642665266626672668266926702671267226732674267526762677267826792680268126822683268426852686268726882689269026912692269326942695269626972698269927002701270227032704270527062707270827092710271127122713271427152716271727182719272027212722272327242725272627272728272927302731273227332734273527362737273827392740274127422743274427452746274727482749275027512752275327542755275627572758275927602761276227632764276527662767276827692770277127722773277427752776277727782779278027812782278327842785278627872788278927902791279227932794279527962797279827992800280128022803280428052806280728082809281028112812281328142815281628172818281928202821282228232824282528262827282828292830283128322833283428352836283728382839284028412842284328442845284628472848284928502851285228532854285528562857285828592860286128622863286428652866286728682869287028712872287328742875287628772878287928802881288228832884288528862887288828892890289128922893289428952896289728982899290029012902290329042905290629072908290929102911291229132914291529162917291829192920292129222923292429252926292729282929293029312932293329342935293629372938293929402941294229432944294529462947294829492950295129522953295429552956295729582959296029612962296329642965296629672968296929702971297229732974297529762977297829792980298129822983298429852986298729882989299029912992299329942995299629972998299930003001300230033004300530063007300830093010301130123013301430153016301730183019302030213022302330243025302630273028302930303031303230333034303530363037303830393040304130423043304430453046304730483049305030513052305330543055305630573058305930603061306230633064306530663067306830693070307130723073307430753076307730783079308030813082308330843085308630873088308930903091309230933094309530963097309830993100310131023103310431053106310731083109311031113112311331143115311631173118311931203121312231233124312531263127312831293130313131323133313431353136313731383139314031413142314331443145314631473148314931503151315231533154315531563157315831593160316131623163316431653166316731683169317031713172317331743175317631773178317931803181318231833184318531863187318831893190319131923193319431953196319731983199320032013202320332043205320632073208320932103211321232133214321532163217321832193220322132223223322432253226322732283229323032313232323332343235323632373238323932403241324232433244324532463247324832493250325132523253325432553256325732583259326032613262326332643265326632673268326932703271327232733274327532763277327832793280328132823283328432853286328732883289329032913292329332943295329632973298329933003301330233033304330533063307330833093310331133123313331433153316331733183319332033213322332333243325332633273328332933303331333233333334333533363337333833393340334133423343334433453346334733483349335033513352335333543355335633573358335933603361336233633364336533663367336833693370337133723373337433753376337733783379338033813382338333843385338633873388338933903391339233933394339533963397339833993400340134023403340434053406340734083409341034113412341334143415341634173418341934203421342234233424342534263427342834293430343134323433343434353436343734383439344034413442344334443445344634473448344934503451345234533454345534563457345834593460346134623463346434653466346734683469347034713472347334743475347634773478347934803481348234833484348534863487348834893490349134923493349434953496349734983499350035013502350335043505350635073508350935103511351235133514351535163517351835193520352135223523352435253526352735283529353035313532353335343535353635373538353935403541354235433544354535463547354835493550355135523553355435553556355735583559356035613562356335643565356635673568356935703571357235733574357535763577357835793580358135823583358435853586358735883589359035913592359335943595359635973598359936003601360236033604360536063607360836093610361136123613361436153616361736183619362036213622362336243625362636273628362936303631363236333634363536363637363836393640364136423643364436453646364736483649365036513652365336543655365636573658365936603661366236633664366536663667366836693670367136723673367436753676367736783679368036813682368336843685368636873688368936903691369236933694369536963697369836993700370137023703370437053706370737083709371037113712371337143715371637173718371937203721372237233724372537263727372837293730373137323733373437353736373737383739374037413742374337443745374637473748374937503751375237533754375537563757375837593760376137623763376437653766376737683769377037713772377337743775377637773778377937803781378237833784378537863787378837893790379137923793379437953796379737983799380038013802380338043805380638073808380938103811381238133814381538163817381838193820382138223823382438253826382738283829383038313832383338343835383638373838383938403841384238433844384538463847384838493850385138523853385438553856385738583859386038613862386338643865386638673868386938703871387238733874387538763877387838793880388138823883388438853886388738883889389038913892389338943895389638973898389939003901390239033904390539063907390839093910391139123913391439153916391739183919392039213922392339243925392639273928392939303931393239333934393539363937393839393940394139423943394439453946394739483949395039513952395339543955395639573958395939603961396239633964396539663967396839693970397139723973397439753976397739783979398039813982398339843985398639873988398939903991399239933994399539963997399839994000400140024003400440054006400740084009401040114012401340144015401640174018401940204021402240234024402540264027402840294030403140324033403440354036403740384039404040414042404340444045404640474048404940504051405240534054405540564057405840594060406140624063406440654066406740684069407040714072407340744075407640774078407940804081408240834084408540864087408840894090409140924093409440954096409740984099410041014102410341044105410641074108410941104111411241134114411541164117411841194120412141224123412441254126412741284129413041314132413341344135413641374138413941404141414241434144414541464147414841494150415141524153415441554156415741584159416041614162416341644165416641674168416941704171417241734174417541764177417841794180418141824183418441854186418741884189419041914192419341944195419641974198419942004201420242034204420542064207420842094210421142124213421442154216421742184219422042214222422342244225422642274228422942304231423242334234423542364237423842394240424142424243424442454246424742484249425042514252425342544255425642574258425942604261426242634264426542664267426842694270427142724273427442754276427742784279428042814282428342844285428642874288428942904291429242934294429542964297429842994300430143024303430443054306430743084309431043114312431343144315431643174318431943204321432243234324432543264327432843294330433143324333433443354336433743384339434043414342434343444345434643474348434943504351435243534354435543564357435843594360436143624363436443654366436743684369437043714372437343744375437643774378437943804381438243834384438543864387438843894390439143924393439443954396439743984399440044014402440344044405440644074408440944104411441244134414441544164417441844194420442144224423442444254426442744284429443044314432443344344435443644374438443944404441444244434444444544464447444844494450445144524453445444554456445744584459446044614462446344644465446644674468446944704471447244734474447544764477447844794480448144824483448444854486448744884489449044914492449344944495449644974498449945004501450245034504450545064507450845094510451145124513451445154516451745184519452045214522452345244525452645274528452945304531453245334534453545364537453845394540454145424543454445454546454745484549455045514552455345544555455645574558455945604561456245634564456545664567456845694570457145724573457445754576457745784579458045814582458345844585458645874588458945904591459245934594459545964597459845994600460146024603460446054606460746084609461046114612461346144615461646174618461946204621462246234624462546264627462846294630463146324633463446354636463746384639464046414642464346444645464646474648464946504651465246534654465546564657465846594660466146624663466446654666466746684669467046714672467346744675467646774678467946804681468246834684468546864687468846894690469146924693469446954696469746984699470047014702470347044705470647074708470947104711471247134714471547164717471847194720472147224723472447254726472747284729473047314732473347344735473647374738473947404741474247434744474547464747474847494750475147524753475447554756475747584759476047614762476347644765476647674768476947704771477247734774477547764777477847794780478147824783478447854786478747884789479047914792479347944795479647974798479948004801480248034804480548064807480848094810481148124813481448154816481748184819482048214822482348244825482648274828482948304831483248334834483548364837483848394840484148424843484448454846484748484849485048514852485348544855485648574858485948604861486248634864486548664867486848694870487148724873487448754876487748784879488048814882488348844885488648874888488948904891489248934894489548964897489848994900490149024903490449054906490749084909491049114912491349144915491649174918491949204921492249234924492549264927492849294930493149324933493449354936493749384939494049414942494349444945494649474948494949504951495249534954495549564957495849594960496149624963496449654966496749684969497049714972497349744975497649774978497949804981498249834984498549864987498849894990499149924993499449954996499749984999500050015002500350045005500650075008500950105011501250135014501550165017501850195020502150225023502450255026502750285029503050315032503350345035503650375038503950405041504250435044504550465047504850495050505150525053505450555056505750585059506050615062506350645065506650675068506950705071507250735074507550765077507850795080508150825083508450855086508750885089509050915092509350945095509650975098509951005101510251035104510551065107510851095110511151125113511451155116511751185119512051215122512351245125512651275128512951305131513251335134513551365137513851395140514151425143514451455146514751485149515051515152515351545155515651575158515951605161516251635164516551665167516851695170517151725173517451755176517751785179518051815182518351845185518651875188518951905191519251935194519551965197519851995200520152025203520452055206520752085209521052115212521352145215521652175218521952205221522252235224522552265227522852295230523152325233523452355236523752385239524052415242524352445245524652475248524952505251525252535254525552565257525852595260526152625263526452655266526752685269527052715272527352745275527652775278527952805281528252835284528552865287528852895290529152925293529452955296529752985299530053015302530353045305530653075308530953105311531253135314531553165317531853195320532153225323532453255326532753285329533053315332533353345335533653375338533953405341534253435344534553465347534853495350535153525353535453555356535753585359536053615362536353645365536653675368536953705371537253735374537553765377537853795380538153825383538453855386538753885389539053915392539353945395539653975398539954005401540254035404540554065407540854095410541154125413541454155416541754185419542054215422542354245425542654275428542954305431543254335434543554365437543854395440544154425443544454455446544754485449545054515452545354545455545654575458545954605461546254635464546554665467546854695470547154725473547454755476547754785479548054815482548354845485548654875488548954905491549254935494549554965497549854995500550155025503550455055506550755085509551055115512551355145515551655175518551955205521552255235524552555265527552855295530553155325533553455355536553755385539554055415542554355445545554655475548554955505551555255535554555555565557555855595560556155625563556455655566556755685569557055715572557355745575557655775578557955805581558255835584558555865587558855895590559155925593559455955596559755985599560056015602560356045605560656075608560956105611561256135614561556165617561856195620562156225623562456255626562756285629563056315632563356345635563656375638563956405641564256435644564556465647564856495650565156525653565456555656565756585659566056615662566356645665566656675668566956705671567256735674567556765677567856795680568156825683568456855686568756885689569056915692569356945695569656975698569957005701570257035704570557065707570857095710571157125713571457155716571757185719572057215722572357245725572657275728572957305731573257335734573557365737573857395740574157425743574457455746574757485749575057515752575357545755575657575758575957605761576257635764576557665767576857695770577157725773577457755776577757785779578057815782578357845785578657875788578957905791579257935794579557965797579857995800580158025803580458055806580758085809581058115812581358145815581658175818581958205821582258235824582558265827582858295830583158325833583458355836583758385839584058415842584358445845584658475848584958505851585258535854585558565857585858595860586158625863586458655866586758685869587058715872587358745875587658775878587958805881588258835884588558865887588858895890589158925893589458955896589758985899590059015902590359045905590659075908590959105911591259135914591559165917591859195920592159225923592459255926592759285929593059315932593359345935593659375938593959405941594259435944594559465947594859495950595159525953595459555956595759585959596059615962596359645965596659675968596959705971597259735974597559765977597859795980598159825983598459855986598759885989599059915992599359945995599659975998599960006001600260036004600560066007600860096010601160126013601460156016601760186019602060216022602360246025602660276028602960306031603260336034603560366037603860396040604160426043604460456046604760486049605060516052605360546055605660576058605960606061606260636064606560666067606860696070607160726073607460756076607760786079608060816082608360846085608660876088608960906091609260936094609560966097609860996100610161026103610461056106610761086109611061116112611361146115611661176118611961206121612261236124612561266127612861296130613161326133613461356136613761386139614061416142614361446145614661476148614961506151615261536154615561566157615861596160616161626163616461656166616761686169617061716172617361746175617661776178617961806181618261836184618561866187618861896190619161926193619461956196619761986199620062016202620362046205620662076208620962106211621262136214621562166217621862196220622162226223622462256226622762286229623062316232623362346235623662376238623962406241624262436244624562466247624862496250625162526253625462556256625762586259626062616262626362646265626662676268626962706271627262736274627562766277627862796280628162826283628462856286628762886289629062916292629362946295629662976298629963006301630263036304630563066307630863096310631163126313631463156316631763186319632063216322632363246325632663276328632963306331633263336334633563366337633863396340634163426343634463456346634763486349635063516352635363546355635663576358635963606361636263636364636563666367636863696370637163726373637463756376637763786379638063816382638363846385638663876388638963906391639263936394639563966397639863996400640164026403640464056406640764086409641064116412641364146415641664176418641964206421642264236424642564266427642864296430643164326433643464356436643764386439644064416442644364446445644664476448644964506451645264536454645564566457645864596460646164626463646464656466646764686469647064716472647364746475647664776478647964806481648264836484648564866487648864896490649164926493649464956496649764986499650065016502650365046505650665076508650965106511651265136514651565166517651865196520652165226523652465256526652765286529653065316532653365346535653665376538653965406541654265436544654565466547654865496550655165526553655465556556655765586559656065616562656365646565656665676568656965706571657265736574657565766577657865796580658165826583658465856586658765886589659065916592659365946595659665976598659966006601660266036604660566066607660866096610661166126613661466156616661766186619662066216622662366246625662666276628662966306631663266336634663566366637663866396640664166426643664466456646664766486649665066516652665366546655665666576658665966606661666266636664666566666667666866696670667166726673667466756676667766786679668066816682668366846685668666876688668966906691669266936694669566966697669866996700670167026703670467056706670767086709671067116712671367146715671667176718671967206721672267236724672567266727672867296730673167326733673467356736673767386739674067416742674367446745674667476748674967506751675267536754675567566757675867596760676167626763676467656766676767686769677067716772677367746775677667776778677967806781678267836784678567866787678867896790679167926793679467956796679767986799680068016802680368046805680668076808680968106811681268136814681568166817681868196820682168226823682468256826682768286829683068316832683368346835683668376838683968406841684268436844684568466847684868496850685168526853685468556856685768586859686068616862686368646865686668676868686968706871687268736874687568766877687868796880688168826883688468856886688768886889689068916892689368946895689668976898689969006901690269036904690569066907690869096910691169126913691469156916691769186919692069216922692369246925692669276928692969306931693269336934693569366937693869396940694169426943694469456946694769486949695069516952695369546955695669576958695969606961696269636964696569666967696869696970697169726973697469756976697769786979698069816982698369846985698669876988698969906991699269936994699569966997699869997000700170027003700470057006700770087009701070117012701370147015701670177018701970207021702270237024702570267027702870297030703170327033703470357036703770387039704070417042704370447045704670477048704970507051705270537054705570567057705870597060706170627063706470657066706770687069707070717072707370747075707670777078707970807081708270837084708570867087708870897090709170927093709470957096709770987099710071017102710371047105710671077108710971107111711271137114711571167117711871197120712171227123712471257126712771287129713071317132713371347135713671377138713971407141714271437144714571467147714871497150715171527153715471557156715771587159716071617162716371647165716671677168716971707171717271737174717571767177717871797180718171827183718471857186718771887189719071917192719371947195719671977198719972007201720272037204720572067207720872097210721172127213721472157216721772187219722072217222722372247225722672277228722972307231723272337234723572367237723872397240724172427243724472457246724772487249725072517252725372547255725672577258725972607261726272637264726572667267726872697270727172727273727472757276727772787279728072817282728372847285728672877288728972907291729272937294729572967297729872997300730173027303730473057306730773087309731073117312731373147315731673177318731973207321732273237324732573267327732873297330733173327333733473357336733773387339734073417342734373447345734673477348734973507351735273537354735573567357735873597360736173627363736473657366736773687369737073717372737373747375737673777378737973807381738273837384738573867387738873897390739173927393739473957396739773987399740074017402740374047405740674077408740974107411741274137414741574167417741874197420742174227423742474257426742774287429743074317432743374347435743674377438743974407441744274437444744574467447744874497450745174527453745474557456745774587459746074617462746374647465746674677468746974707471747274737474747574767477747874797480748174827483748474857486748774887489749074917492749374947495749674977498749975007501750275037504750575067507750875097510751175127513751475157516751775187519752075217522752375247525752675277528752975307531753275337534753575367537753875397540754175427543754475457546754775487549755075517552755375547555755675577558755975607561756275637564756575667567756875697570757175727573757475757576757775787579758075817582758375847585758675877588758975907591759275937594759575967597759875997600760176027603760476057606760776087609761076117612761376147615761676177618761976207621762276237624762576267627762876297630763176327633763476357636763776387639764076417642764376447645764676477648764976507651765276537654765576567657765876597660766176627663766476657666766776687669767076717672767376747675767676777678767976807681768276837684768576867687768876897690769176927693769476957696769776987699770077017702770377047705770677077708770977107711771277137714771577167717771877197720772177227723772477257726772777287729773077317732773377347735773677377738773977407741774277437744774577467747774877497750775177527753775477557756775777587759776077617762776377647765776677677768776977707771777277737774777577767777777877797780778177827783778477857786778777887789779077917792779377947795779677977798779978007801780278037804780578067807780878097810781178127813781478157816781778187819782078217822782378247825782678277828782978307831783278337834783578367837783878397840784178427843784478457846784778487849785078517852785378547855785678577858785978607861786278637864786578667867786878697870787178727873787478757876787778787879788078817882788378847885788678877888788978907891789278937894789578967897789878997900790179027903790479057906790779087909791079117912791379147915791679177918791979207921792279237924792579267927792879297930793179327933793479357936793779387939794079417942794379447945794679477948794979507951795279537954795579567957795879597960796179627963796479657966796779687969797079717972797379747975797679777978797979807981798279837984798579867987798879897990799179927993799479957996799779987999800080018002800380048005800680078008800980108011801280138014801580168017801880198020802180228023802480258026802780288029803080318032803380348035803680378038803980408041804280438044804580468047804880498050805180528053805480558056805780588059806080618062806380648065806680678068806980708071807280738074807580768077807880798080808180828083808480858086808780888089809080918092809380948095809680978098809981008101810281038104810581068107810881098110811181128113811481158116811781188119812081218122812381248125812681278128812981308131813281338134813581368137813881398140814181428143814481458146814781488149815081518152815381548155815681578158815981608161816281638164816581668167816881698170817181728173817481758176817781788179818081818182818381848185818681878188818981908191819281938194819581968197819881998200820182028203820482058206820782088209821082118212821382148215821682178218821982208221822282238224822582268227822882298230823182328233823482358236823782388239824082418242824382448245824682478248824982508251825282538254825582568257825882598260826182628263826482658266826782688269827082718272827382748275827682778278827982808281828282838284828582868287828882898290829182928293829482958296829782988299830083018302830383048305830683078308830983108311831283138314831583168317831883198320832183228323832483258326832783288329833083318332833383348335833683378338833983408341834283438344834583468347834883498350835183528353835483558356835783588359836083618362836383648365836683678368836983708371837283738374837583768377837883798380838183828383838483858386838783888389839083918392839383948395839683978398839984008401840284038404840584068407840884098410841184128413841484158416841784188419842084218422842384248425842684278428842984308431843284338434843584368437843884398440844184428443844484458446844784488449845084518452845384548455845684578458845984608461846284638464846584668467846884698470847184728473847484758476847784788479848084818482848384848485848684878488848984908491849284938494849584968497849884998500850185028503850485058506850785088509851085118512851385148515851685178518851985208521852285238524852585268527852885298530853185328533853485358536853785388539854085418542854385448545854685478548854985508551855285538554855585568557855885598560856185628563856485658566856785688569857085718572857385748575857685778578857985808581858285838584858585868587858885898590859185928593859485958596859785988599860086018602860386048605860686078608860986108611861286138614861586168617861886198620862186228623862486258626862786288629863086318632863386348635863686378638863986408641864286438644864586468647864886498650865186528653865486558656865786588659866086618662866386648665866686678668866986708671867286738674867586768677867886798680868186828683868486858686868786888689869086918692869386948695869686978698869987008701870287038704870587068707870887098710871187128713871487158716871787188719872087218722872387248725872687278728872987308731873287338734873587368737873887398740874187428743874487458746874787488749875087518752875387548755875687578758875987608761876287638764876587668767876887698770877187728773877487758776877787788779878087818782878387848785878687878788878987908791879287938794879587968797879887998800880188028803880488058806880788088809881088118812881388148815881688178818881988208821882288238824882588268827882888298830883188328833883488358836883788388839884088418842884388448845884688478848884988508851885288538854885588568857885888598860886188628863886488658866886788688869887088718872887388748875887688778878887988808881888288838884888588868887888888898890889188928893889488958896889788988899890089018902890389048905890689078908890989108911891289138914891589168917891889198920892189228923892489258926892789288929893089318932893389348935893689378938893989408941894289438944894589468947894889498950895189528953895489558956895789588959896089618962896389648965896689678968896989708971897289738974897589768977897889798980898189828983898489858986898789888989899089918992899389948995899689978998899990009001900290039004900590069007900890099010901190129013901490159016901790189019902090219022902390249025902690279028902990309031903290339034903590369037903890399040904190429043904490459046904790489049905090519052905390549055905690579058905990609061906290639064906590669067906890699070907190729073907490759076907790789079908090819082908390849085908690879088908990909091909290939094909590969097909890999100910191029103910491059106910791089109911091119112911391149115911691179118911991209121912291239124912591269127912891299130913191329133913491359136913791389139914091419142914391449145914691479148914991509151915291539154915591569157915891599160916191629163916491659166916791689169917091719172917391749175917691779178917991809181918291839184918591869187918891899190919191929193919491959196919791989199920092019202920392049205920692079208920992109211921292139214921592169217921892199220922192229223922492259226922792289229923092319232923392349235923692379238923992409241924292439244924592469247924892499250925192529253925492559256925792589259926092619262926392649265926692679268926992709271927292739274927592769277927892799280928192829283928492859286928792889289929092919292929392949295929692979298929993009301930293039304930593069307930893099310931193129313931493159316931793189319932093219322932393249325932693279328932993309331933293339334933593369337933893399340934193429343934493459346934793489349935093519352935393549355935693579358935993609361936293639364936593669367936893699370937193729373937493759376937793789379938093819382938393849385938693879388938993909391939293939394939593969397939893999400940194029403940494059406940794089409941094119412941394149415941694179418941994209421942294239424942594269427942894299430943194329433943494359436943794389439944094419442944394449445944694479448944994509451945294539454945594569457945894599460946194629463946494659466946794689469947094719472947394749475947694779478947994809481948294839484948594869487948894899490949194929493949494959496949794989499950095019502950395049505950695079508950995109511951295139514951595169517951895199520952195229523952495259526952795289529953095319532953395349535953695379538953995409541954295439544954595469547954895499550955195529553955495559556955795589559956095619562956395649565956695679568956995709571957295739574957595769577957895799580958195829583958495859586958795889589959095919592959395949595959695979598959996009601960296039604960596069607960896099610961196129613961496159616961796189619962096219622962396249625962696279628962996309631963296339634963596369637963896399640964196429643964496459646964796489649965096519652965396549655965696579658965996609661966296639664966596669667966896699670967196729673967496759676967796789679968096819682968396849685968696879688968996909691969296939694969596969697969896999700970197029703970497059706970797089709971097119712971397149715971697179718971997209721972297239724972597269727972897299730973197329733973497359736973797389739974097419742974397449745974697479748974997509751975297539754975597569757975897599760976197629763976497659766976797689769977097719772977397749775977697779778977997809781978297839784978597869787978897899790979197929793979497959796979797989799980098019802980398049805980698079808980998109811981298139814981598169817981898199820982198229823982498259826982798289829983098319832983398349835983698379838983998409841984298439844984598469847984898499850985198529853985498559856985798589859986098619862986398649865986698679868986998709871987298739874987598769877987898799880988198829883988498859886988798889889989098919892989398949895989698979898989999009901990299039904990599069907990899099910991199129913991499159916991799189919992099219922992399249925992699279928992999309931993299339934993599369937993899399940994199429943994499459946994799489949995099519952995399549955995699579958995999609961996299639964996599669967996899699970997199729973997499759976997799789979998099819982998399849985998699879988998999909991999299939994999599969997999899991000010001100021000310004100051000610007100081000910010100111001210013100141001510016100171001810019100201002110022100231002410025100261002710028100291003010031100321003310034100351003610037100381003910040100411004210043100441004510046100471004810049100501005110052100531005410055100561005710058100591006010061100621006310064100651006610067100681006910070100711007210073100741007510076100771007810079100801008110082100831008410085100861008710088100891009010091100921009310094100951009610097100981009910100101011010210103101041010510106101071010810109101101011110112101131011410115101161011710118101191012010121101221012310124101251012610127101281012910130101311013210133101341013510136101371013810139101401014110142101431014410145101461014710148101491015010151101521015310154101551015610157101581015910160101611016210163101641016510166101671016810169101701017110172101731017410175101761017710178101791018010181101821018310184101851018610187101881018910190101911019210193101941019510196101971019810199102001020110202102031020410205102061020710208102091021010211102121021310214102151021610217102181021910220102211022210223102241022510226102271022810229102301023110232102331023410235102361023710238102391024010241102421024310244102451024610247102481024910250102511025210253102541025510256102571025810259102601026110262102631026410265102661026710268102691027010271102721027310274102751027610277102781027910280102811028210283102841028510286102871028810289102901029110292102931029410295102961029710298102991030010301103021030310304103051030610307103081030910310103111031210313103141031510316103171031810319103201032110322103231032410325103261032710328103291033010331103321033310334103351033610337103381033910340103411034210343103441034510346103471034810349103501035110352103531035410355103561035710358103591036010361103621036310364103651036610367103681036910370103711037210373103741037510376103771037810379103801038110382103831038410385103861038710388103891039010391103921039310394103951039610397103981039910400104011040210403104041040510406104071040810409104101041110412104131041410415104161041710418104191042010421104221042310424104251042610427104281042910430104311043210433104341043510436104371043810439104401044110442104431044410445104461044710448104491045010451104521045310454104551045610457104581045910460104611046210463104641046510466104671046810469104701047110472104731047410475104761047710478104791048010481104821048310484104851048610487104881048910490104911049210493104941049510496104971049810499105001050110502105031050410505105061050710508105091051010511105121051310514105151051610517105181051910520105211052210523105241052510526105271052810529105301053110532105331053410535105361053710538105391054010541105421054310544105451054610547105481054910550105511055210553105541055510556105571055810559105601056110562105631056410565105661056710568105691057010571105721057310574105751057610577105781057910580105811058210583105841058510586105871058810589105901059110592105931059410595105961059710598105991060010601106021060310604106051060610607106081060910610106111061210613106141061510616106171061810619106201062110622106231062410625106261062710628106291063010631106321063310634106351063610637106381063910640106411064210643106441064510646106471064810649106501065110652106531065410655106561065710658106591066010661106621066310664106651066610667106681066910670106711067210673106741067510676106771067810679106801068110682106831068410685106861068710688106891069010691106921069310694106951069610697106981069910700107011070210703107041070510706107071070810709107101071110712107131071410715107161071710718107191072010721107221072310724107251072610727107281072910730107311073210733107341073510736107371073810739107401074110742107431074410745107461074710748107491075010751107521075310754107551075610757107581075910760107611076210763107641076510766107671076810769107701077110772107731077410775107761077710778107791078010781107821078310784107851078610787107881078910790107911079210793107941079510796107971079810799108001080110802108031080410805108061080710808108091081010811108121081310814108151081610817108181081910820108211082210823108241082510826108271082810829108301083110832108331083410835108361083710838108391084010841108421084310844108451084610847108481084910850108511085210853108541085510856108571085810859108601086110862108631086410865108661086710868108691087010871108721087310874108751087610877108781087910880108811088210883108841088510886108871088810889108901089110892108931089410895108961089710898108991090010901109021090310904109051090610907109081090910910109111091210913109141091510916109171091810919109201092110922109231092410925109261092710928109291093010931109321093310934109351093610937109381093910940109411094210943109441094510946109471094810949109501095110952109531095410955109561095710958109591096010961109621096310964109651096610967109681096910970109711097210973109741097510976109771097810979109801098110982109831098410985109861098710988109891099010991109921099310994109951099610997109981099911000110011100211003110041100511006110071100811009110101101111012110131101411015110161101711018110191102011021110221102311024110251102611027110281102911030110311103211033110341103511036110371103811039110401104111042110431104411045110461104711048110491105011051110521105311054110551105611057110581105911060110611106211063110641106511066110671106811069110701107111072110731107411075110761107711078110791108011081110821108311084110851108611087110881108911090110911109211093110941109511096110971109811099111001110111102111031110411105111061110711108111091111011111111121111311114111151111611117111181111911120111211112211123111241112511126111271112811129111301113111132111331113411135111361113711138111391114011141111421114311144111451114611147111481114911150111511115211153111541115511156111571115811159111601116111162111631116411165111661116711168111691117011171111721117311174111751117611177111781117911180111811118211183111841118511186111871118811189111901119111192111931119411195111961119711198111991120011201112021120311204112051120611207112081120911210112111121211213112141121511216112171121811219112201122111222112231122411225112261122711228112291123011231112321123311234112351123611237112381123911240112411124211243112441124511246112471124811249112501125111252112531125411255112561125711258112591126011261112621126311264112651126611267112681126911270112711127211273112741127511276112771127811279112801128111282112831128411285112861128711288112891129011291112921129311294112951129611297112981129911300113011130211303113041130511306113071130811309113101131111312113131131411315113161131711318113191132011321113221132311324113251132611327113281132911330113311133211333113341133511336113371133811339113401134111342113431134411345113461134711348113491135011351113521135311354113551135611357113581135911360113611136211363113641136511366113671136811369113701137111372113731137411375113761137711378113791138011381113821138311384113851138611387113881138911390113911139211393113941139511396113971139811399114001140111402114031140411405114061140711408114091141011411114121141311414114151141611417114181141911420114211142211423114241142511426114271142811429114301143111432114331143411435114361143711438114391144011441114421144311444114451144611447114481144911450114511145211453114541145511456114571145811459114601146111462114631146411465114661146711468114691147011471114721147311474114751147611477114781147911480114811148211483114841148511486114871148811489114901149111492114931149411495114961149711498114991150011501115021150311504115051150611507115081150911510115111151211513115141151511516115171151811519115201152111522115231152411525115261152711528115291153011531115321153311534115351153611537115381153911540115411154211543115441154511546115471154811549115501155111552115531155411555115561155711558115591156011561115621156311564115651156611567115681156911570115711157211573115741157511576115771157811579115801158111582115831158411585115861158711588115891159011591115921159311594115951159611597115981159911600116011160211603116041160511606116071160811609116101161111612116131161411615116161161711618116191162011621116221162311624116251162611627116281162911630116311163211633116341163511636116371163811639116401164111642116431164411645116461164711648116491165011651116521165311654116551165611657116581165911660116611166211663116641166511666116671166811669116701167111672116731167411675116761167711678116791168011681116821168311684116851168611687116881168911690116911169211693116941169511696116971169811699117001170111702117031170411705117061170711708117091171011711117121171311714117151171611717117181171911720117211172211723117241172511726117271172811729117301173111732117331173411735117361173711738117391174011741117421174311744117451174611747117481174911750117511175211753117541175511756117571175811759117601176111762117631176411765117661176711768117691177011771117721177311774117751177611777117781177911780117811178211783117841178511786117871178811789117901179111792117931179411795117961179711798117991180011801118021180311804118051180611807118081180911810118111181211813118141181511816118171181811819118201182111822118231182411825118261182711828118291183011831118321183311834118351183611837118381183911840118411184211843118441184511846118471184811849118501185111852118531185411855118561185711858118591186011861118621186311864118651186611867118681186911870118711187211873118741187511876118771187811879118801188111882118831188411885118861188711888118891189011891118921189311894118951189611897118981189911900119011190211903119041190511906119071190811909119101191111912119131191411915119161191711918119191192011921119221192311924119251192611927119281192911930119311193211933119341193511936119371193811939119401194111942119431194411945119461194711948119491195011951119521195311954119551195611957119581195911960119611196211963119641196511966119671196811969119701197111972119731197411975119761197711978119791198011981119821198311984119851198611987119881198911990119911199211993119941199511996119971199811999120001200112002120031200412005120061200712008120091201012011120121201312014120151201612017120181201912020120211202212023120241202512026120271202812029120301203112032120331203412035120361203712038120391204012041120421204312044120451204612047120481204912050120511205212053120541205512056120571205812059120601206112062120631206412065120661206712068120691207012071120721207312074120751207612077120781207912080120811208212083120841208512086120871208812089120901209112092120931209412095120961209712098120991210012101121021210312104121051210612107121081210912110121111211212113121141211512116121171211812119121201212112122121231212412125121261212712128121291213012131121321213312134121351213612137121381213912140121411214212143121441214512146121471214812149121501215112152121531215412155121561215712158121591216012161121621216312164121651216612167121681216912170121711217212173121741217512176121771217812179121801218112182121831218412185121861218712188121891219012191121921219312194121951219612197121981219912200122011220212203122041220512206122071220812209122101221112212122131221412215122161221712218122191222012221122221222312224122251222612227122281222912230122311223212233122341223512236122371223812239122401224112242122431224412245122461224712248122491225012251122521225312254122551225612257122581225912260122611226212263122641226512266122671226812269122701227112272122731227412275122761227712278122791228012281122821228312284122851228612287122881228912290122911229212293122941229512296122971229812299123001230112302123031230412305123061230712308123091231012311123121231312314123151231612317123181231912320123211232212323123241232512326123271232812329123301233112332123331233412335123361233712338123391234012341123421234312344123451234612347123481234912350123511235212353123541235512356123571235812359123601236112362123631236412365123661236712368123691237012371123721237312374123751237612377123781237912380123811238212383123841238512386123871238812389123901239112392123931239412395123961239712398123991240012401124021240312404124051240612407124081240912410124111241212413124141241512416124171241812419124201242112422124231242412425124261242712428124291243012431124321243312434124351243612437124381243912440124411244212443124441244512446124471244812449124501245112452124531245412455124561245712458124591246012461124621246312464124651246612467124681246912470124711247212473124741247512476124771247812479124801248112482124831248412485124861248712488124891249012491124921249312494124951249612497124981249912500125011250212503125041250512506125071250812509125101251112512125131251412515125161251712518125191252012521125221252312524125251252612527125281252912530125311253212533125341253512536125371253812539125401254112542125431254412545125461254712548125491255012551125521255312554125551255612557125581255912560125611256212563125641256512566125671256812569125701257112572125731257412575125761257712578125791258012581125821258312584125851258612587125881258912590125911259212593125941259512596125971259812599126001260112602126031260412605126061260712608126091261012611126121261312614126151261612617126181261912620126211262212623126241262512626126271262812629126301263112632126331263412635126361263712638126391264012641126421264312644126451264612647126481264912650126511265212653126541265512656126571265812659126601266112662126631266412665126661266712668126691267012671126721267312674126751267612677126781267912680126811268212683126841268512686126871268812689126901269112692126931269412695126961269712698126991270012701127021270312704127051270612707127081270912710127111271212713127141271512716127171271812719127201272112722127231272412725127261272712728127291273012731127321273312734127351273612737127381273912740127411274212743127441274512746127471274812749127501275112752127531275412755127561275712758127591276012761127621276312764127651276612767127681276912770127711277212773127741277512776127771277812779127801278112782127831278412785127861278712788127891279012791127921279312794127951279612797127981279912800128011280212803128041280512806128071280812809128101281112812128131281412815128161281712818128191282012821128221282312824128251282612827128281282912830128311283212833128341283512836128371283812839128401284112842128431284412845128461284712848128491285012851128521285312854128551285612857128581285912860128611286212863128641286512866128671286812869128701287112872128731287412875128761287712878128791288012881128821288312884128851288612887128881288912890128911289212893128941289512896128971289812899129001290112902129031290412905129061290712908129091291012911129121291312914129151291612917129181291912920129211292212923129241292512926129271292812929129301293112932129331293412935129361293712938129391294012941129421294312944129451294612947129481294912950129511295212953129541295512956129571295812959129601296112962129631296412965129661296712968129691297012971129721297312974129751297612977129781297912980129811298212983129841298512986129871298812989129901299112992129931299412995129961299712998129991300013001130021300313004130051300613007130081300913010130111301213013130141301513016130171301813019130201302113022130231302413025130261302713028130291303013031130321303313034130351303613037130381303913040130411304213043130441304513046130471304813049130501305113052130531305413055130561305713058130591306013061130621306313064130651306613067130681306913070130711307213073130741307513076130771307813079130801308113082130831308413085130861308713088130891309013091130921309313094130951309613097130981309913100131011310213103131041310513106131071310813109131101311113112131131311413115131161311713118131191312013121131221312313124131251312613127131281312913130131311313213133131341313513136131371313813139131401314113142131431314413145131461314713148131491315013151131521315313154131551315613157131581315913160131611316213163131641316513166131671316813169131701317113172131731317413175131761317713178131791318013181131821318313184131851318613187131881318913190131911319213193131941319513196131971319813199132001320113202132031320413205132061320713208132091321013211132121321313214132151321613217132181321913220132211322213223132241322513226132271322813229132301323113232132331323413235132361323713238132391324013241132421324313244132451324613247132481324913250132511325213253132541325513256132571325813259132601326113262132631326413265132661326713268132691327013271132721327313274132751327613277132781327913280132811328213283132841328513286132871328813289132901329113292132931329413295132961329713298132991330013301133021330313304133051330613307133081330913310133111331213313133141331513316133171331813319133201332113322133231332413325133261332713328133291333013331133321333313334133351333613337133381333913340133411334213343133441334513346133471334813349133501335113352133531335413355133561335713358133591336013361133621336313364133651336613367133681336913370133711337213373133741337513376133771337813379133801338113382133831338413385133861338713388133891339013391133921339313394133951339613397133981339913400134011340213403134041340513406134071340813409134101341113412134131341413415134161341713418134191342013421134221342313424134251342613427134281342913430134311343213433134341343513436134371343813439134401344113442134431344413445134461344713448134491345013451134521345313454134551345613457134581345913460134611346213463134641346513466134671346813469134701347113472134731347413475134761347713478134791348013481134821348313484134851348613487134881348913490134911349213493134941349513496134971349813499135001350113502135031350413505135061350713508135091351013511135121351313514135151351613517135181351913520135211352213523135241352513526135271352813529135301353113532135331353413535135361353713538135391354013541135421354313544135451354613547135481354913550135511355213553135541355513556135571355813559135601356113562135631356413565135661356713568135691357013571135721357313574135751357613577135781357913580135811358213583135841358513586135871358813589135901359113592135931359413595135961359713598135991360013601136021360313604136051360613607136081360913610136111361213613136141361513616136171361813619136201362113622136231362413625136261362713628136291363013631136321363313634136351363613637136381363913640136411364213643136441364513646136471364813649136501365113652136531365413655136561365713658136591366013661136621366313664136651366613667136681366913670136711367213673136741367513676136771367813679136801368113682136831368413685136861368713688136891369013691136921369313694136951369613697136981369913700137011370213703137041370513706137071370813709137101371113712137131371413715137161371713718137191372013721137221372313724137251372613727137281372913730137311373213733137341373513736137371373813739137401374113742137431374413745137461374713748137491375013751137521375313754137551375613757137581375913760137611376213763137641376513766137671376813769137701377113772137731377413775137761377713778137791378013781137821378313784137851378613787137881378913790137911379213793137941379513796137971379813799138001380113802138031380413805138061380713808138091381013811138121381313814138151381613817138181381913820138211382213823138241382513826138271382813829138301383113832138331383413835138361383713838138391384013841138421384313844138451384613847138481384913850138511385213853138541385513856138571385813859138601386113862138631386413865138661386713868138691387013871138721387313874138751387613877138781387913880138811388213883138841388513886138871388813889138901389113892138931389413895138961389713898138991390013901139021390313904139051390613907139081390913910139111391213913139141391513916139171391813919139201392113922139231392413925139261392713928139291393013931139321393313934139351393613937139381393913940139411394213943139441394513946139471394813949139501395113952139531395413955139561395713958139591396013961139621396313964139651396613967139681396913970139711397213973139741397513976139771397813979139801398113982139831398413985139861398713988139891399013991139921399313994139951399613997139981399914000140011400214003140041400514006140071400814009140101401114012140131401414015140161401714018140191402014021140221402314024140251402614027140281402914030140311403214033140341403514036140371403814039140401404114042140431404414045140461404714048140491405014051140521405314054140551405614057140581405914060140611406214063140641406514066140671406814069140701407114072140731407414075140761407714078140791408014081140821408314084140851408614087140881408914090140911409214093140941409514096140971409814099141001410114102141031410414105141061410714108141091411014111141121411314114141151411614117141181411914120141211412214123141241412514126141271412814129141301413114132141331413414135141361413714138141391414014141141421414314144141451414614147141481414914150141511415214153141541415514156141571415814159141601416114162141631416414165141661416714168141691417014171141721417314174141751417614177141781417914180141811418214183141841418514186141871418814189141901419114192141931419414195141961419714198141991420014201142021420314204142051420614207142081420914210142111421214213142141421514216142171421814219142201422114222142231422414225142261422714228142291423014231142321423314234142351423614237142381423914240142411424214243142441424514246142471424814249142501425114252142531425414255142561425714258142591426014261142621426314264142651426614267142681426914270142711427214273142741427514276142771427814279142801428114282142831428414285142861428714288142891429014291142921429314294142951429614297142981429914300143011430214303143041430514306143071430814309143101431114312143131431414315143161431714318143191432014321143221432314324143251432614327143281432914330143311433214333143341433514336143371433814339143401434114342143431434414345143461434714348143491435014351143521435314354143551435614357143581435914360143611436214363143641436514366143671436814369143701437114372143731437414375143761437714378143791438014381143821438314384143851438614387143881438914390143911439214393143941439514396143971439814399144001440114402144031440414405144061440714408144091441014411144121441314414144151441614417144181441914420144211442214423144241442514426144271442814429144301443114432144331443414435144361443714438144391444014441144421444314444144451444614447144481444914450144511445214453144541445514456144571445814459144601446114462144631446414465144661446714468144691447014471144721447314474144751447614477144781447914480144811448214483144841448514486144871448814489144901449114492144931449414495144961449714498144991450014501145021450314504145051450614507145081450914510145111451214513145141451514516145171451814519145201452114522145231452414525145261452714528145291453014531145321453314534145351453614537145381453914540145411454214543145441454514546145471454814549145501455114552145531455414555145561455714558145591456014561145621456314564145651456614567145681456914570145711457214573145741457514576145771457814579145801458114582145831458414585145861458714588145891459014591145921459314594145951459614597145981459914600146011460214603146041460514606146071460814609146101461114612146131461414615146161461714618146191462014621146221462314624146251462614627146281462914630146311463214633146341463514636146371463814639146401464114642146431464414645146461464714648146491465014651146521465314654146551465614657146581465914660146611466214663146641466514666146671466814669146701467114672146731467414675146761467714678146791468014681146821468314684146851468614687146881468914690146911469214693146941469514696146971469814699147001470114702147031470414705147061470714708147091471014711147121471314714147151471614717147181471914720147211472214723147241472514726147271472814729147301473114732147331473414735147361473714738147391474014741147421474314744147451474614747147481474914750147511475214753147541475514756147571475814759147601476114762147631476414765147661476714768147691477014771147721477314774147751477614777147781477914780147811478214783147841478514786147871478814789147901479114792147931479414795147961479714798147991480014801148021480314804148051480614807148081480914810148111481214813148141481514816148171481814819148201482114822148231482414825148261482714828148291483014831148321483314834148351483614837148381483914840148411484214843148441484514846148471484814849148501485114852148531485414855148561485714858148591486014861148621486314864148651486614867148681486914870148711487214873148741487514876148771487814879148801488114882148831488414885148861488714888148891489014891148921489314894148951489614897148981489914900149011490214903149041490514906149071490814909149101491114912149131491414915149161491714918149191492014921149221492314924149251492614927149281492914930149311493214933149341493514936149371493814939149401494114942149431494414945149461494714948149491495014951149521495314954149551495614957149581495914960149611496214963149641496514966149671496814969149701497114972149731497414975149761497714978149791498014981149821498314984149851498614987149881498914990149911499214993149941499514996149971499814999150001500115002150031500415005150061500715008150091501015011150121501315014150151501615017150181501915020150211502215023150241502515026150271502815029150301503115032150331503415035150361503715038150391504015041150421504315044150451504615047150481504915050150511505215053150541505515056150571505815059150601506115062150631506415065150661506715068150691507015071150721507315074150751507615077150781507915080150811508215083150841508515086150871508815089150901509115092150931509415095150961509715098150991510015101151021510315104151051510615107151081510915110151111511215113151141511515116151171511815119151201512115122151231512415125151261512715128151291513015131151321513315134151351513615137151381513915140151411514215143151441514515146151471514815149151501515115152151531515415155151561515715158151591516015161151621516315164151651516615167151681516915170151711517215173151741517515176151771517815179151801518115182151831518415185151861518715188151891519015191151921519315194151951519615197151981519915200152011520215203152041520515206152071520815209152101521115212152131521415215152161521715218152191522015221152221522315224152251522615227152281522915230152311523215233152341523515236152371523815239152401524115242152431524415245152461524715248152491525015251152521525315254152551525615257152581525915260152611526215263152641526515266152671526815269152701527115272152731527415275152761527715278152791528015281152821528315284152851528615287152881528915290152911529215293152941529515296152971529815299153001530115302153031530415305153061530715308153091531015311153121531315314153151531615317153181531915320153211532215323153241532515326153271532815329153301533115332153331533415335153361533715338153391534015341153421534315344153451534615347153481534915350153511535215353153541535515356153571535815359153601536115362153631536415365153661536715368153691537015371153721537315374153751537615377153781537915380153811538215383153841538515386153871538815389153901539115392153931539415395153961539715398153991540015401154021540315404154051540615407154081540915410154111541215413154141541515416154171541815419154201542115422154231542415425154261542715428154291543015431154321543315434154351543615437154381543915440154411544215443154441544515446154471544815449154501545115452154531545415455154561545715458154591546015461154621546315464154651546615467154681546915470154711547215473154741547515476154771547815479154801548115482154831548415485154861548715488154891549015491154921549315494154951549615497154981549915500155011550215503155041550515506155071550815509155101551115512155131551415515155161551715518155191552015521155221552315524155251552615527155281552915530155311553215533155341553515536155371553815539155401554115542155431554415545155461554715548155491555015551155521555315554155551555615557155581555915560155611556215563155641556515566155671556815569155701557115572155731557415575155761557715578155791558015581155821558315584155851558615587155881558915590155911559215593155941559515596155971559815599156001560115602156031560415605156061560715608156091561015611156121561315614156151561615617156181561915620156211562215623156241562515626156271562815629156301563115632156331563415635156361563715638156391564015641156421564315644156451564615647156481564915650156511565215653156541565515656156571565815659156601566115662156631566415665156661566715668156691567015671156721567315674156751567615677156781567915680156811568215683156841568515686156871568815689156901569115692156931569415695156961569715698156991570015701157021570315704157051570615707157081570915710157111571215713157141571515716157171571815719157201572115722157231572415725157261572715728157291573015731157321573315734157351573615737157381573915740157411574215743157441574515746157471574815749157501575115752157531575415755157561575715758157591576015761157621576315764157651576615767157681576915770157711577215773157741577515776157771577815779157801578115782157831578415785157861578715788157891579015791157921579315794157951579615797157981579915800158011580215803158041580515806158071580815809158101581115812158131581415815158161581715818158191582015821158221582315824158251582615827158281582915830158311583215833158341583515836158371583815839158401584115842158431584415845158461584715848158491585015851158521585315854158551585615857158581585915860158611586215863158641586515866158671586815869158701587115872158731587415875158761587715878158791588015881158821588315884158851588615887158881588915890158911589215893158941589515896158971589815899159001590115902159031590415905159061590715908159091591015911159121591315914159151591615917159181591915920159211592215923159241592515926159271592815929159301593115932159331593415935159361593715938159391594015941159421594315944159451594615947159481594915950159511595215953159541595515956159571595815959159601596115962159631596415965159661596715968159691597015971159721597315974159751597615977159781597915980159811598215983159841598515986159871598815989159901599115992159931599415995159961599715998159991600016001160021600316004160051600616007160081600916010160111601216013160141601516016160171601816019160201602116022160231602416025160261602716028160291603016031160321603316034160351603616037160381603916040160411604216043160441604516046160471604816049160501605116052160531605416055160561605716058160591606016061160621606316064160651606616067160681606916070160711607216073160741607516076160771607816079160801608116082160831608416085160861608716088160891609016091160921609316094160951609616097160981609916100161011610216103161041610516106161071610816109161101611116112161131611416115161161611716118161191612016121161221612316124161251612616127161281612916130161311613216133161341613516136161371613816139161401614116142161431614416145161461614716148161491615016151161521615316154161551615616157161581615916160161611616216163161641616516166161671616816169161701617116172161731617416175161761617716178161791618016181161821618316184161851618616187161881618916190161911619216193161941619516196161971619816199162001620116202162031620416205162061620716208162091621016211162121621316214162151621616217162181621916220162211622216223162241622516226162271622816229162301623116232162331623416235162361623716238162391624016241162421624316244162451624616247162481624916250162511625216253162541625516256162571625816259162601626116262162631626416265162661626716268162691627016271162721627316274162751627616277162781627916280162811628216283162841628516286162871628816289162901629116292162931629416295162961629716298162991630016301163021630316304163051630616307163081630916310163111631216313163141631516316163171631816319163201632116322163231632416325163261632716328163291633016331163321633316334163351633616337163381633916340163411634216343163441634516346163471634816349163501635116352163531635416355163561635716358163591636016361163621636316364163651636616367163681636916370163711637216373163741637516376163771637816379163801638116382163831638416385163861638716388163891639016391163921639316394163951639616397163981639916400164011640216403164041640516406164071640816409164101641116412164131641416415164161641716418164191642016421164221642316424164251642616427164281642916430164311643216433164341643516436164371643816439164401644116442164431644416445164461644716448164491645016451164521645316454164551645616457164581645916460164611646216463164641646516466164671646816469164701647116472164731647416475164761647716478164791648016481164821648316484164851648616487164881648916490164911649216493164941649516496164971649816499165001650116502165031650416505165061650716508165091651016511165121651316514165151651616517165181651916520165211652216523165241652516526165271652816529165301653116532165331653416535165361653716538165391654016541165421654316544165451654616547165481654916550165511655216553165541655516556165571655816559165601656116562165631656416565165661656716568165691657016571165721657316574165751657616577165781657916580165811658216583165841658516586165871658816589165901659116592165931659416595165961659716598165991660016601166021660316604166051660616607166081660916610166111661216613166141661516616166171661816619166201662116622166231662416625166261662716628166291663016631166321663316634166351663616637166381663916640166411664216643166441664516646166471664816649166501665116652166531665416655166561665716658166591666016661166621666316664166651666616667166681666916670166711667216673166741667516676166771667816679166801668116682166831668416685166861668716688166891669016691166921669316694166951669616697166981669916700167011670216703167041670516706167071670816709167101671116712167131671416715167161671716718167191672016721167221672316724167251672616727167281672916730167311673216733167341673516736167371673816739167401674116742167431674416745167461674716748167491675016751167521675316754167551675616757167581675916760167611676216763167641676516766167671676816769167701677116772167731677416775167761677716778167791678016781167821678316784167851678616787167881678916790167911679216793167941679516796167971679816799168001680116802168031680416805168061680716808168091681016811168121681316814168151681616817168181681916820168211682216823168241682516826168271682816829168301683116832168331683416835168361683716838168391684016841168421684316844168451684616847168481684916850168511685216853168541685516856168571685816859168601686116862168631686416865168661686716868168691687016871168721687316874168751687616877168781687916880168811688216883168841688516886168871688816889168901689116892168931689416895168961689716898168991690016901169021690316904169051690616907169081690916910169111691216913169141691516916169171691816919169201692116922169231692416925169261692716928169291693016931169321693316934169351693616937169381693916940169411694216943169441694516946169471694816949169501695116952169531695416955169561695716958169591696016961169621696316964169651696616967169681696916970169711697216973169741697516976169771697816979169801698116982169831698416985169861698716988169891699016991169921699316994169951699616997169981699917000170011700217003170041700517006170071700817009170101701117012170131701417015170161701717018170191702017021170221702317024170251702617027170281702917030170311703217033170341703517036170371703817039170401704117042170431704417045170461704717048170491705017051170521705317054170551705617057170581705917060170611706217063170641706517066170671706817069170701707117072170731707417075170761707717078170791708017081170821708317084170851708617087170881708917090170911709217093170941709517096170971709817099171001710117102171031710417105171061710717108171091711017111171121711317114171151711617117171181711917120171211712217123171241712517126171271712817129171301713117132171331713417135171361713717138171391714017141171421714317144171451714617147171481714917150171511715217153171541715517156171571715817159171601716117162171631716417165171661716717168171691717017171171721717317174171751717617177171781717917180171811718217183171841718517186171871718817189171901719117192171931719417195171961719717198171991720017201172021720317204172051720617207172081720917210172111721217213172141721517216172171721817219172201722117222172231722417225172261722717228172291723017231172321723317234172351723617237172381723917240172411724217243172441724517246172471724817249172501725117252172531725417255172561725717258172591726017261172621726317264172651726617267172681726917270172711727217273172741727517276172771727817279172801728117282172831728417285172861728717288172891729017291172921729317294172951729617297172981729917300173011730217303173041730517306173071730817309173101731117312173131731417315173161731717318173191732017321173221732317324173251732617327173281732917330173311733217333173341733517336173371733817339173401734117342173431734417345173461734717348173491735017351173521735317354173551735617357173581735917360173611736217363173641736517366173671736817369173701737117372173731737417375173761737717378173791738017381173821738317384173851738617387173881738917390173911739217393173941739517396173971739817399174001740117402174031740417405174061740717408174091741017411174121741317414174151741617417174181741917420174211742217423174241742517426174271742817429174301743117432174331743417435174361743717438174391744017441174421744317444174451744617447174481744917450174511745217453174541745517456174571745817459174601746117462174631746417465174661746717468174691747017471174721747317474174751747617477174781747917480174811748217483174841748517486174871748817489174901749117492174931749417495174961749717498174991750017501175021750317504175051750617507175081750917510175111751217513175141751517516175171751817519175201752117522175231752417525175261752717528175291753017531175321753317534175351753617537175381753917540175411754217543175441754517546175471754817549175501755117552175531755417555175561755717558175591756017561175621756317564175651756617567175681756917570175711757217573175741757517576175771757817579175801758117582175831758417585175861758717588175891759017591175921759317594175951759617597175981759917600176011760217603176041760517606176071760817609176101761117612176131761417615176161761717618176191762017621176221762317624176251762617627176281762917630176311763217633176341763517636176371763817639176401764117642176431764417645176461764717648176491765017651176521765317654176551765617657176581765917660176611766217663176641766517666176671766817669176701767117672176731767417675176761767717678176791768017681176821768317684176851768617687176881768917690176911769217693176941769517696176971769817699177001770117702177031770417705177061770717708177091771017711177121771317714177151771617717177181771917720177211772217723177241772517726177271772817729177301773117732177331773417735177361773717738177391774017741177421774317744177451774617747177481774917750177511775217753177541775517756177571775817759177601776117762177631776417765177661776717768177691777017771177721777317774177751777617777177781777917780177811778217783177841778517786177871778817789177901779117792177931779417795177961779717798177991780017801178021780317804178051780617807178081780917810178111781217813178141781517816178171781817819178201782117822178231782417825178261782717828178291783017831178321783317834178351783617837178381783917840178411784217843178441784517846178471784817849178501785117852178531785417855178561785717858178591786017861178621786317864178651786617867178681786917870178711787217873178741787517876178771787817879178801788117882178831788417885178861788717888178891789017891178921789317894178951789617897178981789917900179011790217903179041790517906179071790817909179101791117912179131791417915179161791717918179191792017921179221792317924179251792617927179281792917930179311793217933179341793517936179371793817939179401794117942179431794417945179461794717948179491795017951179521795317954179551795617957179581795917960179611796217963179641796517966179671796817969179701797117972179731797417975179761797717978179791798017981179821798317984179851798617987179881798917990179911799217993179941799517996179971799817999180001800118002180031800418005180061800718008180091801018011180121801318014180151801618017180181801918020180211802218023180241802518026180271802818029180301803118032180331803418035180361803718038180391804018041180421804318044180451804618047180481804918050180511805218053180541805518056180571805818059180601806118062180631806418065180661806718068180691807018071180721807318074180751807618077180781807918080180811808218083180841808518086180871808818089180901809118092180931809418095180961809718098180991810018101181021810318104181051810618107181081810918110181111811218113181141811518116181171811818119181201812118122181231812418125181261812718128181291813018131181321813318134181351813618137181381813918140181411814218143181441814518146181471814818149181501815118152181531815418155181561815718158181591816018161181621816318164181651816618167181681816918170181711817218173181741817518176181771817818179181801818118182181831818418185181861818718188181891819018191181921819318194181951819618197181981819918200182011820218203182041820518206182071820818209182101821118212182131821418215182161821718218182191822018221182221822318224182251822618227182281822918230182311823218233182341823518236182371823818239182401824118242182431824418245182461824718248182491825018251182521825318254182551825618257182581825918260182611826218263182641826518266182671826818269182701827118272182731827418275182761827718278182791828018281182821828318284182851828618287182881828918290182911829218293182941829518296182971829818299183001830118302183031830418305183061830718308183091831018311183121831318314183151831618317183181831918320183211832218323183241832518326183271832818329183301833118332183331833418335183361833718338183391834018341183421834318344183451834618347183481834918350183511835218353183541835518356183571835818359183601836118362183631836418365183661836718368183691837018371183721837318374183751837618377183781837918380183811838218383183841838518386183871838818389183901839118392183931839418395183961839718398183991840018401184021840318404184051840618407184081840918410184111841218413184141841518416184171841818419184201842118422184231842418425184261842718428184291843018431184321843318434184351843618437184381843918440184411844218443184441844518446184471844818449184501845118452184531845418455184561845718458184591846018461184621846318464184651846618467184681846918470184711847218473184741847518476184771847818479184801848118482184831848418485184861848718488184891849018491184921849318494184951849618497184981849918500185011850218503185041850518506185071850818509185101851118512185131851418515185161851718518185191852018521185221852318524185251852618527185281852918530185311853218533185341853518536185371853818539185401854118542185431854418545185461854718548185491855018551185521855318554185551855618557185581855918560185611856218563185641856518566185671856818569185701857118572185731857418575185761857718578185791858018581185821858318584185851858618587185881858918590185911859218593185941859518596185971859818599186001860118602186031860418605186061860718608186091861018611186121861318614186151861618617186181861918620186211862218623186241862518626186271862818629186301863118632186331863418635186361863718638186391864018641186421864318644186451864618647186481864918650186511865218653186541865518656186571865818659186601866118662186631866418665186661866718668186691867018671186721867318674186751867618677186781867918680186811868218683186841868518686186871868818689186901869118692186931869418695186961869718698186991870018701187021870318704187051870618707187081870918710187111871218713187141871518716187171871818719187201872118722187231872418725187261872718728187291873018731187321873318734187351873618737187381873918740187411874218743187441874518746187471874818749187501875118752187531875418755187561875718758187591876018761187621876318764187651876618767187681876918770187711877218773187741877518776187771877818779187801878118782187831878418785187861878718788187891879018791187921879318794187951879618797187981879918800188011880218803188041880518806188071880818809188101881118812188131881418815188161881718818188191882018821188221882318824188251882618827188281882918830188311883218833188341883518836188371883818839188401884118842188431884418845188461884718848188491885018851188521885318854188551885618857188581885918860188611886218863188641886518866188671886818869188701887118872188731887418875188761887718878188791888018881188821888318884188851888618887188881888918890188911889218893188941889518896188971889818899189001890118902189031890418905189061890718908189091891018911189121891318914189151891618917189181891918920189211892218923189241892518926189271892818929189301893118932189331893418935189361893718938189391894018941189421894318944189451894618947189481894918950189511895218953189541895518956189571895818959189601896118962189631896418965189661896718968189691897018971189721897318974189751897618977189781897918980189811898218983189841898518986189871898818989189901899118992189931899418995189961899718998189991900019001190021900319004190051900619007190081900919010190111901219013190141901519016190171901819019190201902119022190231902419025190261902719028190291903019031190321903319034190351903619037190381903919040190411904219043190441904519046190471904819049190501905119052190531905419055190561905719058190591906019061190621906319064190651906619067190681906919070190711907219073190741907519076190771907819079190801908119082190831908419085190861908719088190891909019091190921909319094190951909619097190981909919100191011910219103191041910519106191071910819109191101911119112191131911419115191161911719118191191912019121191221912319124191251912619127191281912919130191311913219133191341913519136191371913819139191401914119142191431914419145191461914719148191491915019151191521915319154191551915619157191581915919160191611916219163191641916519166191671916819169191701917119172191731917419175191761917719178191791918019181191821918319184191851918619187191881918919190191911919219193191941919519196191971919819199192001920119202192031920419205192061920719208192091921019211192121921319214192151921619217192181921919220192211922219223192241922519226192271922819229
  1. package sg
  2. import (
  3. "archive/zip"
  4. "bytes"
  5. "math"
  6. //"crypto/x509/pkix"
  7. "encoding/json"
  8. "fmt"
  9. //"github.com/tjfoc/gmsm/sm2"
  10. //"github.com/tjfoc/gmsm/sm3"
  11. "gdyb/controllers"
  12. "gdyb/enums"
  13. "gdyb/models"
  14. "gdyb/service"
  15. "gdyb/utils"
  16. "github.com/astaxie/beego"
  17. "github.com/axgle/mahonia"
  18. "github.com/gorilla/websocket"
  19. "github.com/jinzhu/gorm"
  20. "github.com/shopspring/decimal"
  21. "io"
  22. "io/ioutil"
  23. //"math"
  24. "math/rand"
  25. "net/http"
  26. "net/url"
  27. "os"
  28. "path/filepath"
  29. "regexp"
  30. "strconv"
  31. "strings"
  32. "syscall"
  33. "time"
  34. "unsafe"
  35. )
  36. type HisApiController struct {
  37. controllers.BaseAuthAPIController
  38. }
  39. func HisManagerApiRegistRouters() {
  40. //挂号
  41. beego.Router("/api/register/get", &HisApiController{}, "get:GetRegisterInfo")
  42. //上传就诊信息-上传明细-结算
  43. beego.Router("/api/upload/get", &HisApiController{}, "get:GetUploadInfo")
  44. //查询
  45. beego.Router("/api/settle/query", &HisApiController{}, "get:GetSettleAccounts")
  46. //对总账
  47. beego.Router("/api/checkaccount/get", &HisApiController{}, "get:GetCheckAccount")
  48. //对明细
  49. beego.Router("/api/checkdetailaccount/get", &HisApiController{}, "get:GetCheckDetailAccount")
  50. //退费,退明细
  51. beego.Router("/api/refund/post", &HisApiController{}, "get:Refund")
  52. //退号
  53. beego.Router("/api/refundnumber/post", &HisApiController{}, "get:RefundNumber")
  54. //退明细
  55. beego.Router("/api/refunddetail/post", &HisApiController{}, "get:RefundDetail")
  56. //上传就诊信息-上传明细-预结算
  57. beego.Router("/api/presettle/get", &HisApiController{}, "get:GetPreUploadInfo")
  58. beego.Router("/api/treatment/check", &HisApiController{}, "get:CheckTreatment")
  59. beego.Router("/api/org/info", &HisApiController{}, "get:GetOrgInfo")
  60. beego.Router("/api/readcard", &HisApiController{}, "get:ReadCard")
  61. beego.Router("/api/310", &HisApiController{}, "get:Check310")
  62. beego.Router("/api/390", &HisApiController{}, "get:Check390")
  63. beego.Router("/api/patient/info", &HisApiController{}, "get:GetPatientInfo")
  64. beego.Router("/api/checkcode/get", &HisApiController{}, "get:GetCheckCode")
  65. beego.Router("/api/uncheckcode/get", &HisApiController{}, "get:UnCheckCode")
  66. beego.Router("/api/psn/putonrecord", &HisApiController{}, "get:PsnPutOnRecord")
  67. beego.Router("/api/psn/unputonrecord", &HisApiController{}, "get:PsnUnPutOnRecord")
  68. beego.Router("/api/psn/ncds/putonrecord", &HisApiController{}, "get:PsnPutNCDSOnRecord")
  69. beego.Router("/api/psn/ncds/unputonrecord", &HisApiController{}, "get:PsnPutUnNCDSOnRecord")
  70. beego.Router("/api/reversal", &HisApiController{}, "get:ReversalData")
  71. beego.Router("/api/reversal/other", &HisApiController{}, "get:ReversalOtherData")
  72. beego.Router("/api/settlelist/get", &HisApiController{}, "get:GetSettleList")
  73. beego.Router("/api/settlelisthosptial/get", &HisApiController{}, "get:GetSettleListHospital")
  74. beego.Router("/api/pwd/check", &HisApiController{}, "get:CheckCardPWD")
  75. beego.Router("/api/insutype/check", &HisApiController{}, "get:CheckInsutype")
  76. //beego.Router("/api/batchsettlelist/get", &HisApiController{}, "get:GetBatchSettleList")
  77. beego.Router("/api/psn/info", &HisApiController{}, "get:GetPsnNcdsInfo")
  78. beego.Router("/api/allopatry/refund", &HisApiController{}, "post:RefundAllopatry")
  79. beego.Router("/api/check", &HisApiController{}, "get:Check")
  80. //beego.Router("/api/check3101", &HisApiController{}, "get:Check3101")
  81. //beego.Router("/api/check3102", &HisApiController{}, "get:Check3102")
  82. beego.Router("/90990", &HisApiController{}, "get:CheckCardPWDTwo")
  83. beego.Router("/9001", &HisApiController{}, "get:Get9001")
  84. //beego.Router("/api/readelecard", &HisApiController{}, "get:ReadEleCard")
  85. beego.Router("/api/3202", &HisApiController{}, "get:Post3202")
  86. beego.Router("/api/3501", &HisApiController{}, "post:Post3501")
  87. beego.Router("/api/readele", &HisApiController{}, "get:ReadEleToken")
  88. beego.Router("/api/2505", &HisApiController{}, "get:Get2505")
  89. beego.Router("/api/4201A", &HisApiController{}, "get:Get4201A")
  90. beego.Router("/api/4202", &HisApiController{}, "get:Get4202")
  91. beego.Router("/api/4203", &HisApiController{}, "get:Get4203")
  92. beego.Router("/api/4205", &HisApiController{}, "get:Get4205")
  93. beego.Router("/api/4207", &HisApiController{}, "get:Get4207")
  94. beego.Router("/api/4208", &HisApiController{}, "get:Get4208")
  95. beego.Router("/api/4209", &HisApiController{}, "get:Get4209")
  96. beego.Router("/api/allopatry/get", &HisApiController{}, "get:GetAllopatry")
  97. //beego.Router("/api/comfirmallopatry/post", &HisApiController{}, "post:ComfirmAllopatry")
  98. beego.Router("/api/allopatry/refund", &HisApiController{}, "get:RefundAllopatry")
  99. beego.Router("/api/settle/query/batch", &HisApiController{}, "get:GetBatchSettleAccounts")
  100. beego.Router("/api/bl4201A", &HisApiController{}, "get:GetBL4201A")
  101. beego.Router("/api/bl4201A", &HisApiController{}, "get:GetBL4201A")
  102. beego.Router("/api/CFYLJG001", &HisApiController{}, "get:GetCFYLJG001")
  103. beego.Router("/api/CFYLJG002", &HisApiController{}, "get:GetCFYLJG002")
  104. beego.Router("/api/CFYLJG003", &HisApiController{}, "get:GetCFYLJG003")
  105. beego.Router("/api/CFYLJG004", &HisApiController{}, "get:GetCFYLJG004")
  106. beego.Router("/api/CFYLJG005", &HisApiController{}, "get:GetCFYLJG005")
  107. beego.Router("/api/CFYLJG006", &HisApiController{}, "get:GetCFYLJG006")
  108. beego.Router("/api/CFYLJG007", &HisApiController{}, "get:GetCFYLJG007")
  109. //beego.Router("/api/CFYLJG008", &HisApiController{}, "get:GetCFYLJG008")
  110. //beego.Router("/api/CFYLJG009", &HisApiController{}, "get:GetCFYLJG009")
  111. //beego.Router("/api/2205", &HisApiController{}, "get:Get2205")
  112. //beego.Router("/jsyb/3260", &HisApiController{}, "get:Get3260")
  113. //beego.Router("/jsyb/3261", &HisApiController{}, "get:Get3261")
  114. //beego.Router("/jsyb/3262", &HisApiController{}, "get:Get3262")
  115. //beego.Router("/jsyb/3263", &HisApiController{}, "get:Get3263")
  116. //beego.Router("/jsyb/3264", &HisApiController{}, "get:Get3264")
  117. //beego.Router("/jsyb/3265", &HisApiController{}, "get:Get3265")
  118. //beego.Router("/jsyb/3266", &HisApiController{}, "get:Get3266")
  119. //beego.Router("/jsyb/3267", &HisApiController{}, "get:Get3267")
  120. //beego.Router("/jsyb/3268", &HisApiController{}, "get:Get3268")
  121. //beego.Router("/jsyb/3269", &HisApiController{}, "get:Get3269")
  122. //beego.Router("/jsyb/3270", &HisApiController{}, "get:Get3270")
  123. //beego.Router("/jsyb/3271", &HisApiController{}, "get:Get3271")
  124. //beego.Router("/jsyb/3272", &HisApiController{}, "get:Get3272")
  125. //beego.Router("/jsyb/3273", &HisApiController{}, "get:Get3273")
  126. //beego.Router("/jsyb/3274", &HisApiController{}, "get:Get3274")
  127. //beego.Router("/jsyb/3275", &HisApiController{}, "get:Get3275")
  128. //beego.Router("/jsyb/3276", &HisApiController{}, "get:Get3276")
  129. //beego.Router("/jsyb/3277", &HisApiController{}, "get:Get3277")
  130. }
  131. //func (c *HisApiController) Get3260() {
  132. // admin_user_id, _ := c.GetInt64("admin_user_id")
  133. //
  134. // curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  135. // miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  136. // var api string
  137. // if miConfig.MdtrtareaAdmvs == "320921" {
  138. // api = "http://192.168.2.3:9532/" + "jsyb/3260?" + "org_name=" + miConfig.OrgName + "&doctor=" + curRoles.UserName + "&doctor_name=" + curRoles.UserName + "&fixmedins_code=" + miConfig.Code +
  139. // "&insuplc_admdvs=" + miConfig.MdtrtareaAdmvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  140. // } else {
  141. // api = "http://192.168.5.251:9532/" + "jsyb/3260?" + "org_name=" + miConfig.OrgName + "&doctor=" + curRoles.UserName + "&doctor_name=" + curRoles.UserName + "&fixmedins_code=" + miConfig.Code +
  142. // "&insuplc_admdvs=" + miConfig.MdtrtareaAdmvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  143. // }
  144. //
  145. //}
  146. //func (c *HisApiController) Get3261() {
  147. // admin_user_id, _ := c.GetInt64("admin_user_id")
  148. //
  149. // curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  150. // miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  151. // var api string
  152. // if miConfig.MdtrtareaAdmvs == "320921" {
  153. // api = "http://192.168.2.3:9532/" + "jsyb/3260?" + "org_name=" + miConfig.OrgName + "&doctor=" + curRoles.UserName + "&doctor_name=" + curRoles.UserName + "&fixmedins_code=" + miConfig.Code +
  154. // "&insuplc_admdvs=" + miConfig.MdtrtareaAdmvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  155. // } else {
  156. // api = "http://192.168.5.251:9532/" + "jsyb/3260?" + "org_name=" + miConfig.OrgName + "&doctor=" + curRoles.UserName + "&doctor_name=" + curRoles.UserName + "&fixmedins_code=" + miConfig.Code +
  157. // "&insuplc_admdvs=" + miConfig.MdtrtareaAdmvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  158. // }
  159. //
  160. //}
  161. //func (c *HisApiController) Get3262() {
  162. // admin_user_id, _ := c.GetInt64("admin_user_id")
  163. //
  164. // curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  165. // miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  166. // var api string
  167. // if miConfig.MdtrtareaAdmvs == "320921" {
  168. // api = "http://192.168.2.3:9532/" + "jsyb/3260?" + "org_name=" + miConfig.OrgName + "&doctor=" + curRoles.UserName + "&doctor_name=" + curRoles.UserName + "&fixmedins_code=" + miConfig.Code +
  169. // "&insuplc_admdvs=" + miConfig.MdtrtareaAdmvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  170. // } else {
  171. // api = "http://192.168.5.251:9532/" + "jsyb/3260?" + "org_name=" + miConfig.OrgName + "&doctor=" + curRoles.UserName + "&doctor_name=" + curRoles.UserName + "&fixmedins_code=" + miConfig.Code +
  172. // "&insuplc_admdvs=" + miConfig.MdtrtareaAdmvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  173. // }
  174. //
  175. //}
  176. //func (c *HisApiController) Get3263() {
  177. // admin_user_id, _ := c.GetInt64("admin_user_id")
  178. //
  179. // curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  180. // miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  181. // var api string
  182. // if miConfig.MdtrtareaAdmvs == "320921" {
  183. // api = "http://192.168.2.3:9532/" + "jsyb/3260?" + "org_name=" + miConfig.OrgName + "&doctor=" + curRoles.UserName + "&doctor_name=" + curRoles.UserName + "&fixmedins_code=" + miConfig.Code +
  184. // "&insuplc_admdvs=" + miConfig.MdtrtareaAdmvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  185. // } else {
  186. // api = "http://192.168.5.251:9532/" + "jsyb/3260?" + "org_name=" + miConfig.OrgName + "&doctor=" + curRoles.UserName + "&doctor_name=" + curRoles.UserName + "&fixmedins_code=" + miConfig.Code +
  187. // "&insuplc_admdvs=" + miConfig.MdtrtareaAdmvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  188. // }
  189. //
  190. //}
  191. //func (c *HisApiController) Get3264() {
  192. // if miConfig.MdtrtareaAdmvs == "320921" {
  193. // api = "http://192.168.2.3:9532/" + "jsyb/3264?psn_no=" + PsnNo + "&insutype=" + insutype + "&cert_no=" + cert_no + "&ipt_otp_no=" + ipt_otp_no +
  194. // "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&doctor_name=" + doctor_info.UserName + "&fixmedins_code=" + miConfig.Code +
  195. // "&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
  196. //
  197. // } else {
  198. // api = "http://192.168.5.251:9532/" + "jsyb/3264?psn_no=" + PsnNo + "&insutype=" + insutype + "&cert_no=" + cert_no + "&ipt_otp_no=" + ipt_otp_no +
  199. // "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&doctor_name=" + doctor_info.UserName + "&fixmedins_code=" + miConfig.Code +
  200. // "&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
  201. //
  202. // }
  203. //
  204. //}
  205. //func (c *HisApiController) Get3265() {
  206. // if miConfig.MdtrtareaAdmvs == "320921" {
  207. // api = "http://192.168.2.3:9532/" + "jsyb/3265?psn_no=" + PsnNo + "&insutype=" + insutype + "&cert_no=" + cert_no + "&ipt_otp_no=" + ipt_otp_no +
  208. // "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&doctor_name=" + doctor_info.UserName + "&fixmedins_code=" + miConfig.Code +
  209. // "&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
  210. //
  211. // } else {
  212. // api = "http://192.168.5.251:9532/" + "jsyb/3265?psn_no=" + PsnNo + "&insutype=" + insutype + "&cert_no=" + cert_no + "&ipt_otp_no=" + ipt_otp_no +
  213. // "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&doctor_name=" + doctor_info.UserName + "&fixmedins_code=" + miConfig.Code +
  214. // "&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
  215. //
  216. // }
  217. //}
  218. //func (c *HisApiController) Get3266() {
  219. // if miConfig.MdtrtareaAdmvs == "320921" {
  220. // api = "http://192.168.2.3:9532/" + "jsyb/3266?psn_no=" + PsnNo + "&insutype=" + insutype + "&cert_no=" + cert_no + "&ipt_otp_no=" + ipt_otp_no +
  221. // "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&doctor_name=" + doctor_info.UserName + "&fixmedins_code=" + miConfig.Code +
  222. // "&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
  223. //
  224. // } else {
  225. // api = "http://192.168.5.251:9532/" + "jsyb/3266?psn_no=" + PsnNo + "&insutype=" + insutype + "&cert_no=" + cert_no + "&ipt_otp_no=" + ipt_otp_no +
  226. // "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&doctor_name=" + doctor_info.UserName + "&fixmedins_code=" + miConfig.Code +
  227. // "&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
  228. //
  229. // }
  230. //
  231. //}
  232. //func (c *HisApiController) Get3267() {
  233. // if miConfig.MdtrtareaAdmvs == "320921" {
  234. // api = "http://192.168.2.3:9532/" + "jsyb/3267?psn_no=" + PsnNo + "&insutype=" + insutype + "&cert_no=" + cert_no + "&ipt_otp_no=" + ipt_otp_no +
  235. // "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&doctor_name=" + doctor_info.UserName + "&fixmedins_code=" + miConfig.Code +
  236. // "&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
  237. //
  238. // } else {
  239. // api = "http://192.168.5.251:9532/" + "jsyb/3267?psn_no=" + PsnNo + "&insutype=" + insutype + "&cert_no=" + cert_no + "&ipt_otp_no=" + ipt_otp_no +
  240. // "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&doctor_name=" + doctor_info.UserName + "&fixmedins_code=" + miConfig.Code +
  241. // "&insuplc_admdvs=" + insuplc_admdvs_temp + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(id_card_type, 10) + "&dept_code=" + department.Number + "&dept=" + department.Name + "&doctor_id=" + doctor_info.DoctorNumber + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&verify_number=" + psn_info.VerifyNumber + "&cainfo=" + miConfig.Cainfo
  242. //
  243. // }
  244. //
  245. //}
  246. //func (c *HisApiController) Get3268() {
  247. // if miConfig.MdtrtareaAdmvs == "320921" {
  248. // api = "http://192.168.2.3:9532/" + "jsyb/3268?psn_no=" + PsnNo + "&insutype=" + insutype + "&cert_no=" + cert_no + "&ipt_otp_no=" + ipt_otp_no +
  249. // "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&doctor_name=" + doctor_info.UserName + "&fixmedins_code=" + miConfig.Code +
  250. // "&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
  251. //
  252. // } else {
  253. // api = "http://192.168.5.251:9532/" + "jsyb/3268?psn_no=" + PsnNo + "&insutype=" + insutype + "&cert_no=" + cert_no + "&ipt_otp_no=" + ipt_otp_no +
  254. // "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&doctor_name=" + doctor_info.UserName + "&fixmedins_code=" + miConfig.Code +
  255. // "&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
  256. //
  257. // }
  258. //
  259. //}
  260. //func (c *HisApiController) Get3269() {
  261. // if miConfig.MdtrtareaAdmvs == "320921" {
  262. // api = "http://192.168.2.3:9532/" + "jsyb/3269?psn_no=" + PsnNo + "&insutype=" + insutype + "&cert_no=" + cert_no + "&ipt_otp_no=" + ipt_otp_no +
  263. // "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&doctor_name=" + doctor_info.UserName + "&fixmedins_code=" + miConfig.Code +
  264. // "&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
  265. //
  266. // } else {
  267. // api = "http://192.168.5.251:9532/" + "jsyb/3269?psn_no=" + PsnNo + "&insutype=" + insutype + "&cert_no=" + cert_no + "&ipt_otp_no=" + ipt_otp_no +
  268. // "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&doctor_name=" + doctor_info.UserName + "&fixmedins_code=" + miConfig.Code +
  269. // "&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
  270. //
  271. // }
  272. //
  273. //}
  274. //func (c *HisApiController) Get3270() {
  275. // if miConfig.MdtrtareaAdmvs == "320921" {
  276. // api = "http://192.168.2.3:9532/" + "jsyb/3270?psn_no=" + PsnNo + "&insutype=" + insutype + "&cert_no=" + cert_no + "&ipt_otp_no=" + ipt_otp_no +
  277. // "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&doctor_name=" + doctor_info.UserName + "&fixmedins_code=" + miConfig.Code +
  278. // "&insuplc_admdvs=" + insuplc_admdvs_temp + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(id_card_type, 10) + "&dept_code=" + department.Number + "&dept=" + department.Name + "&doctor_id=" + doctor_info.DoctorNumber + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&verify_number=" + psn_info.VerifyNumber + "&cainfo=" + miConfig.Cainfo
  279. //
  280. // } else {
  281. // api = "http://192.168.5.251:9532/" + "jsyb/3270?psn_no=" + PsnNo + "&insutype=" + insutype + "&cert_no=" + cert_no + "&ipt_otp_no=" + ipt_otp_no +
  282. // "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&doctor_name=" + doctor_info.UserName + "&fixmedins_code=" + miConfig.Code +
  283. // "&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
  284. //
  285. // }
  286. //
  287. //}
  288. //func (c *HisApiController) Get3271() {
  289. // if miConfig.MdtrtareaAdmvs == "320921" {
  290. // api = "http://192.168.2.3:9532/" + "jsyb/3271?psn_no=" + PsnNo + "&insutype=" + insutype + "&cert_no=" + cert_no + "&ipt_otp_no=" + ipt_otp_no +
  291. // "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&doctor_name=" + doctor_info.UserName + "&fixmedins_code=" + miConfig.Code +
  292. // "&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
  293. //
  294. // } else {
  295. // api = "http://192.168.5.251:9532/" + "jsyb/3271?psn_no=" + PsnNo + "&insutype=" + insutype + "&cert_no=" + cert_no + "&ipt_otp_no=" + ipt_otp_no +
  296. // "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&doctor_name=" + doctor_info.UserName + "&fixmedins_code=" + miConfig.Code +
  297. // "&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
  298. //
  299. // }
  300. //
  301. //}
  302. //func (c *HisApiController) Get3272() {
  303. // if miConfig.MdtrtareaAdmvs == "320921" {
  304. // api = "http://192.168.2.3:9532/" + "jsyb/3272?psn_no=" + PsnNo + "&insutype=" + insutype + "&cert_no=" + cert_no + "&ipt_otp_no=" + ipt_otp_no +
  305. // "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&doctor_name=" + doctor_info.UserName + "&fixmedins_code=" + miConfig.Code +
  306. // "&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
  307. //
  308. // } else {
  309. // api = "http://192.168.5.251:9532/" + "jsyb/3272?psn_no=" + PsnNo + "&insutype=" + insutype + "&cert_no=" + cert_no + "&ipt_otp_no=" + ipt_otp_no +
  310. // "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&doctor_name=" + doctor_info.UserName + "&fixmedins_code=" + miConfig.Code +
  311. // "&insuplc_admdvs=" + insuplc_admdvs_temp + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(id_card_type, 10) + "&dept_code=" + department.Number + "&dept=" + department.Name + "&doctor_id=" + doctor_info.DoctorNumber + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&verify_number=" + psn_info.VerifyNumber + "&cainfo=" + miConfig.Cainfo
  312. //
  313. // }
  314. //
  315. //}
  316. //func (c *HisApiController) Get3273() {
  317. // if miConfig.MdtrtareaAdmvs == "320921" {
  318. // api = "http://192.168.2.3:9532/" + "jsyb/3273?psn_no=" + PsnNo + "&insutype=" + insutype + "&cert_no=" + cert_no + "&ipt_otp_no=" + ipt_otp_no +
  319. // "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&doctor_name=" + doctor_info.UserName + "&fixmedins_code=" + miConfig.Code +
  320. // "&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
  321. //
  322. // } else {
  323. // api = "http://192.168.5.251:9532/" + "jsyb/3273?psn_no=" + PsnNo + "&insutype=" + insutype + "&cert_no=" + cert_no + "&ipt_otp_no=" + ipt_otp_no +
  324. // "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&doctor_name=" + doctor_info.UserName + "&fixmedins_code=" + miConfig.Code +
  325. // "&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
  326. //
  327. // }
  328. //
  329. //}
  330. //func (c *HisApiController) Get3274() {
  331. // if miConfig.MdtrtareaAdmvs == "320921" {
  332. // api = "http://192.168.2.3:9532/" + "jsyb/3274?psn_no=" + PsnNo + "&insutype=" + insutype + "&cert_no=" + cert_no + "&ipt_otp_no=" + ipt_otp_no +
  333. // "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&doctor_name=" + doctor_info.UserName + "&fixmedins_code=" + miConfig.Code +
  334. // "&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
  335. //
  336. // } else {
  337. // api = "http://192.168.5.251:9532/" + "jsyb/3274?psn_no=" + PsnNo + "&insutype=" + insutype + "&cert_no=" + cert_no + "&ipt_otp_no=" + ipt_otp_no +
  338. // "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&doctor_name=" + doctor_info.UserName + "&fixmedins_code=" + miConfig.Code +
  339. // "&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
  340. //
  341. // }
  342. //
  343. //}
  344. //func (c *HisApiController) Get3275() {
  345. // if miConfig.MdtrtareaAdmvs == "320921" {
  346. // api = "http://192.168.2.3:9532/" + "jsyb/3275?psn_no=" + PsnNo + "&insutype=" + insutype + "&cert_no=" + cert_no + "&ipt_otp_no=" + ipt_otp_no +
  347. // "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&doctor_name=" + doctor_info.UserName + "&fixmedins_code=" + miConfig.Code +
  348. // "&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
  349. //
  350. // } else {
  351. // api = "http://192.168.5.251:9532/" + "jsyb/3275?psn_no=" + PsnNo + "&insutype=" + insutype + "&cert_no=" + cert_no + "&ipt_otp_no=" + ipt_otp_no +
  352. // "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&doctor_name=" + doctor_info.UserName + "&fixmedins_code=" + miConfig.Code +
  353. // "&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
  354. //
  355. // }
  356. //
  357. //}
  358. //func (c *HisApiController) Get3276() {
  359. // if miConfig.MdtrtareaAdmvs == "320921" {
  360. // api = "http://192.168.2.3:9532/" + "jsyb/3276?psn_no=" + PsnNo + "&insutype=" + insutype + "&cert_no=" + cert_no + "&ipt_otp_no=" + ipt_otp_no +
  361. // "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&doctor_name=" + doctor_info.UserName + "&fixmedins_code=" + miConfig.Code +
  362. // "&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
  363. //
  364. // } else {
  365. // api = "http://192.168.5.251:9532/" + "jsyb/3276?psn_no=" + PsnNo + "&insutype=" + insutype + "&cert_no=" + cert_no + "&ipt_otp_no=" + ipt_otp_no +
  366. // "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&doctor_name=" + doctor_info.UserName + "&fixmedins_code=" + miConfig.Code +
  367. // "&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
  368. //
  369. // }
  370. //
  371. //}
  372. //func (c *HisApiController) Get3277() {
  373. // if miConfig.MdtrtareaAdmvs == "320921" {
  374. // api = "http://192.168.2.3:9532/" + "jsyb/3277?psn_no=" + PsnNo + "&insutype=" + insutype + "&cert_no=" + cert_no + "&ipt_otp_no=" + ipt_otp_no +
  375. // "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&doctor_name=" + doctor_info.UserName + "&fixmedins_code=" + miConfig.Code +
  376. // "&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
  377. //
  378. // } else {
  379. // api = "http://192.168.5.251:9532/" + "jsyb/3277?psn_no=" + PsnNo + "&insutype=" + insutype + "&cert_no=" + cert_no + "&ipt_otp_no=" + ipt_otp_no +
  380. // "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&doctor_name=" + doctor_info.UserName + "&fixmedins_code=" + miConfig.Code +
  381. // "&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
  382. //
  383. // }
  384. //}
  385. func (c *HisApiController) GetCFYLJG001() {
  386. admin_user_id, _ := c.GetInt64("admin_user_id")
  387. patient_id, _ := c.GetInt64("patient_id")
  388. his_patient_id, _ := c.GetInt64("his_patient_id")
  389. record_time := c.GetString("record_time")
  390. admin_user_id = 3626
  391. patient_id = 19424
  392. his_patient_id = 238932
  393. record_time = "2023-07-03"
  394. his, _ := service.GetHisPatientRecord(c.GetAdminUserInfo().CurrentOrgId, his_patient_id)
  395. psn, _ := service.GetPsnByPatientId(patient_id)
  396. //patient, _ := service.GetPatientByID(c.GetAdminUserInfo().CurrentOrgId,patient_id)
  397. //patient, _ := service.GetPatientByID(c.GetAdminUserInfo().CurrentOrgId,patient_id)
  398. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  399. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  400. var cFYLJG001 models.CFYLJG001
  401. timeLayout := "2006-01-02"
  402. loc, _ := time.LoadLocation("Local")
  403. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  404. if err != nil {
  405. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  406. return
  407. }
  408. recordDateTime := theTime.Unix()
  409. prescriptions, _ := service.GetHisPrescriptionForMedType(c.GetAdminUserInfo().CurrentOrgId, patient_id, recordDateTime)
  410. info, _ := service.FindLastPatientPrescriptionInfoTwo(c.GetAdminUserInfo().CurrentOrgId, patient_id, recordDateTime)
  411. for _, item := range prescriptions {
  412. doctor, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, item.Creator)
  413. if his.IdCardType == 1 {
  414. bas := strings.Split(psn.CardInfo, "|")
  415. basNumber := bas[1]
  416. fmt.Println(basNumber)
  417. card_sn := bas[3]
  418. card_no := bas[2]
  419. cFYLJG001.MdtrtCertType = "03"
  420. cFYLJG001.CardSn = card_sn
  421. cFYLJG001.MdtrtCertNo = card_no
  422. cFYLJG001.EcToken = ""
  423. cFYLJG001.AuthNo = ""
  424. } else if his.IdCardType == 2 {
  425. cFYLJG001.MdtrtCertType = "02"
  426. cFYLJG001.CardSn = ""
  427. cFYLJG001.MdtrtCertNo = his.IdCardNo
  428. cFYLJG001.EcToken = ""
  429. cFYLJG001.AuthNo = ""
  430. } else if his.IdCardType == 4 {
  431. cFYLJG001.MdtrtCertType = "01"
  432. cFYLJG001.CardSn = ""
  433. cFYLJG001.MdtrtCertNo = psn.VerifyNumber
  434. cFYLJG001.EcToken = psn.VerifyNumber
  435. cFYLJG001.AuthNo = ""
  436. }
  437. cFYLJG001.BizTypeCode = "01"
  438. cFYLJG001.InsuAdmdvs = psn.InsuplcAdmdvs
  439. cFYLJG001.HospRxno = strconv.FormatInt(item.ID, 10)
  440. cFYLJG001.RxTypeCode = "1"
  441. tempTime := time.Unix(item.PreTime, 0)
  442. timeFormatOne := tempTime.Format("2006-01-02 15:04:05")
  443. cFYLJG001.PrscTime = timeFormatOne
  444. var count float64
  445. if item.Type == 1 {
  446. for _, sumItem := range item.HisDoctorAdviceInfo {
  447. count = count + sumItem.PrescribingNumber
  448. }
  449. }
  450. cFYLJG001.RxDrugCnt = count
  451. cFYLJG001.ValiDays = "5"
  452. ts := time.Unix(item.PreTime, 0)
  453. record_time2 := ts.AddDate(0, 0, int(5)).Unix()
  454. tempTime3 := time.Unix(record_time2, 0)
  455. timeFormat3 := tempTime3.Format("2006-01-02 15:04:05")
  456. cFYLJG001.ValiEndTime = timeFormat3
  457. cFYLJG001.RxCotnFlag = "0"
  458. for _, subItem := range item.HisDoctorAdviceInfo {
  459. var drug models.RxDrug
  460. drug.MedListCodg = subItem.BaseDrugLib.MedicalInsuranceNumber
  461. drug.MedinsListCodg = subItem.BaseDrugLib.MedicalInsuranceNumber
  462. drug.RxItemTypeCode = "11"
  463. drug.DrugDosform = "乳膏剂" //TODO
  464. if subItem.BaseDrugLib.MinUnit != subItem.BaseDrugLib.DoseUnit {
  465. drug.DrugSpec = subItem.BaseDrugLib.Dose + subItem.BaseDrugLib.DoseUnit + "*" + strconv.FormatInt(subItem.BaseDrugLib.MinNumber, 10) + subItem.BaseDrugLib.MinUnit + "/" + subItem.BaseDrugLib.MaxUnit
  466. }
  467. drug.MedcWayDscr = subItem.DeliveryWay
  468. tempTime2 := time.Unix(subItem.StartTime, 0)
  469. timeFormatTwo := tempTime2.Format("2006-01-02 15:04:05")
  470. drug.MedcBegntime = timeFormatTwo
  471. if subItem.Day > 0 {
  472. ts := time.Unix(subItem.StartTime, 0)
  473. record_time := ts.AddDate(0, 0, int(subItem.Day)).Unix()
  474. tempTime4 := time.Unix(record_time, 0)
  475. timeFormat5 := tempTime4.Format("2006-01-02") + " 23:59:00"
  476. drug.MedcEndtime = timeFormat5
  477. } else {
  478. tempTime2 := time.Unix(subItem.StartTime, 0)
  479. timeFormatTwo := tempTime2.Format("2006-01-02") + " 23:59:00"
  480. drug.MedcEndtime = timeFormatTwo
  481. }
  482. drug.MedcDays = strconv.FormatInt(subItem.Day, 10)
  483. drug.DrugPric = fmt.Sprintf("%.2f", subItem.Price)
  484. drug.DrugSumamt = fmt.Sprintf("%.2f", subItem.Price*subItem.PrescribingNumber)
  485. drug.DrugCnt = subItem.PrescribingNumber
  486. drug.DrugDosunt = subItem.PrescribingNumberUnit
  487. drug.DrugGenname = subItem.AdviceName
  488. drug.MedcWayCodg = subItem.DeliveryWay
  489. //drug.DrugTotlcnt = subItem.PrescribingNumber
  490. drug.SinDoscnt = subItem.SingleDose
  491. drug.SinDosunt = subItem.SingleDoseUnit
  492. drug.UsedFrquCodg = strconv.FormatInt(subItem.ID, 10)
  493. drug.UsedFrquName = subItem.ExecutionFrequency
  494. drug.DrugTotlcnt = fmt.Sprintf("%.2f", subItem.PrescribingNumber)
  495. drug.DrugTotlcntEmp = subItem.PrescribingNumberUnit
  496. drug.HospApprFlag = "1"
  497. cFYLJG001.List = append(cFYLJG001.List, drug)
  498. }
  499. cFYLJG001.Mdtrtinfo.FixmedinsCode = miConfig.Code
  500. cFYLJG001.Mdtrtinfo.FixmedinsName = miConfig.Code
  501. cFYLJG001.Mdtrtinfo.MdtrtID = his.Number
  502. cFYLJG001.Mdtrtinfo.MedType = item.MedType
  503. cFYLJG001.Mdtrtinfo.IptOtpNo = his.IptOtpNo
  504. cFYLJG001.Mdtrtinfo.OtpIptFlag = "1"
  505. cFYLJG001.Mdtrtinfo.PsnNo = his.PsnNo
  506. cFYLJG001.Mdtrtinfo.PatnName = his.PsnName
  507. cFYLJG001.Mdtrtinfo.Certno = his.IdCardNo
  508. cFYLJG001.Mdtrtinfo.PsnCertType = "01"
  509. cFYLJG001.Mdtrtinfo.PatnAge = fmt.Sprintf("%.1f", his.Age)
  510. cFYLJG001.Mdtrtinfo.PatnHgt = "160" //todo
  511. cFYLJG001.Mdtrtinfo.PatnWt = "58" //todo
  512. cFYLJG001.Mdtrtinfo.Gend = his.Gend
  513. cFYLJG001.Mdtrtinfo.PatnAge = fmt.Sprintf("%.1f", his.Age)
  514. cFYLJG001.Mdtrtinfo.PrscDeptName = "肾内科"
  515. cFYLJG001.Mdtrtinfo.PrscDeptCode = "A03.06"
  516. cFYLJG001.Mdtrtinfo.DrCode = doctor.DoctorNumber
  517. cFYLJG001.Mdtrtinfo.PrscDrName = doctor.UserName
  518. cFYLJG001.Mdtrtinfo.DrProfttlCodg = "234"
  519. cFYLJG001.Mdtrtinfo.DrProfttlName = "医师"
  520. cFYLJG001.Mdtrtinfo.DrDeptCode = "A03.06"
  521. cFYLJG001.Mdtrtinfo.DrDeptName = "肾内科"
  522. cFYLJG001.Mdtrtinfo.Caty = "A03.06"
  523. tempTime2 := time.Now().Unix()
  524. tempTime6 := time.Unix(tempTime2, 0)
  525. timeFormatTwo := tempTime6.Format("2006-01-02 15:04:05")
  526. cFYLJG001.Mdtrtinfo.MdtrtTime = timeFormatTwo
  527. cFYLJG001.Mdtrtinfo.DiseCodg = "M07803"
  528. cFYLJG001.Mdtrtinfo.SpDiseFlag = "1"
  529. cFYLJG001.Mdtrtinfo.MaindiagCode = "N18.500"
  530. cFYLJG001.Mdtrtinfo.MaindiagName = "慢性肾脏病5期"
  531. memo := make(map[string]interface{})
  532. memo["insutype"] = his.Insutype
  533. bytesData, _ := json.Marshal(memo)
  534. cFYLJG001.Mdtrtinfo.Extras = string(bytesData)
  535. diagnosis_ids := strings.Split(info.Diagnosis, ",")
  536. var config []*models.HisXtDiagnoseConfig
  537. for _, item := range diagnosis_ids {
  538. id, _ := strconv.ParseInt(item, 10, 64)
  539. diagnosisConfig, _ := service.FindDiagnoseById(id)
  540. config = append(config, &diagnosisConfig)
  541. }
  542. for index, subitem := range config {
  543. if index == 0 {
  544. var dia models.DiseInfo
  545. dia.DiagType = "1"
  546. dia.MaindiagFlag = "1"
  547. dia.DiagSrtNo = strconv.FormatInt(int64(index+1), 10)
  548. dia.DiagCode = subitem.CountryCode
  549. dia.DiagName = subitem.ClassName
  550. dia.DiagDept = "肾内科"
  551. dia.DiagDrNo = doctor.DoctorNumber
  552. dia.DiagDrName = doctor.UserName
  553. tempTime3 := time.Unix(item.PreTime, 0)
  554. timeFormatTwo := tempTime3.Format("2006-01-02 15:04:05")
  555. dia.DiagTime = timeFormatTwo
  556. cFYLJG001.Diseinfo = append(cFYLJG001.Diseinfo, dia)
  557. } else {
  558. var dia models.DiseInfo
  559. dia.DiagType = "1"
  560. dia.MaindiagFlag = "0"
  561. dia.DiagSrtNo = strconv.FormatInt(int64(index+1), 10)
  562. dia.DiagCode = subitem.CountryCode
  563. dia.DiagName = subitem.ClassName
  564. dia.DiagDept = "肾内科"
  565. dia.DiagDrNo = doctor.DoctorNumber
  566. dia.DiagDrName = doctor.UserName
  567. tempTime3 := time.Unix(item.PreTime, 0)
  568. timeFormatTwo := tempTime3.Format("2006-01-02 15:04:05")
  569. dia.DiagTime = timeFormatTwo
  570. cFYLJG001.Diseinfo = append(cFYLJG001.Diseinfo, dia)
  571. }
  572. }
  573. fmt.Println(cFYLJG001)
  574. service.GetCFYLJG001(miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, cFYLJG001)
  575. }
  576. }
  577. func (c *HisApiController) GetCFYLJG002() {
  578. admin_user_id, _ := c.GetInt64("admin_user_id")
  579. id, _ := c.GetInt64("id")
  580. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  581. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  582. flow, _ := service.Getflow(id)
  583. his, _ := service.GetHisPatientByNumber(flow.MID)
  584. inputData := make(map[string]interface{})
  585. inputData["rxtracecode"] = flow.RxTraceCode
  586. inputData["hirxno"] = flow.HiRxno
  587. inputData["mdtrtid"] = flow.MID
  588. inputData["patnname"] = his.PsnName
  589. inputData["psncerttype"] = his.PsnCertType
  590. inputData["certno"] = his.Certno
  591. inputData["fixmedinsname"] = miConfig.OrgName
  592. inputData["fixmedinscode"] = miConfig.Code
  593. inputData["drcode"] = ""
  594. inputData["prscdrname"] = ""
  595. inputData["phardeptname"] = ""
  596. inputData["phardeptcode"] = ""
  597. inputData["pharprofttlcodg"] = ""
  598. inputData["pharprofttlname"] = ""
  599. inputData["pharcode"] = ""
  600. inputData["rxfrquname"] = ""
  601. inputData["pharcerttype"] = ""
  602. inputData["pharcertno"] = ""
  603. inputData["pharname"] = ""
  604. inputData["pharpraccertno"] = ""
  605. inputData["pharchktime"] = ""
  606. bytesData, _ := json.Marshal(inputData)
  607. fmt.Println(bytesData)
  608. //// 使用 SM3 计算 JSON 数据的哈希值
  609. //hash := sm3.New()
  610. //hash.Write(bytesData)
  611. //hashValue := hash.Sum(nil)
  612. //
  613. //// 加载 SM2 私钥
  614. //privateKeyBytes, err := ioutil.ReadFile("path/to/private_key.pem")
  615. //if err != nil {
  616. // fmt.Println("Failed to read private key file:", err)
  617. // return
  618. //}
  619. //privateKey, err := sm2.ParsePKCS8PrivateKey(privateKeyBytes)
  620. //if err != nil {
  621. // fmt.Println("Failed to parse private key:", err)
  622. // return
  623. //}
  624. //
  625. //// 使用私钥对哈希值进行签名
  626. //r, s, err := sm2.Sign(rand.Reader, privateKey.(*sm2.PrivateKey), hashValue, nil)
  627. //if err != nil {
  628. // fmt.Println("Failed to sign data:", err)
  629. // return
  630. //}
  631. //signature, err := syntax.EncodeSM2Signature(r, s)
  632. //if err != nil {
  633. // fmt.Println("Failed to encode signature:", err)
  634. // return
  635. //}
  636. //
  637. //// 构建 CMS/PKCS#7 Detached 数据结构
  638. //// 这里只包含签名值和原始数据
  639. //signedData := &pkix.ContentInfo{
  640. // ContentType: pkix.SignedDataOID,
  641. // Content: &pkix.SignedData{
  642. // Version: 3,
  643. // DigestAlgorithms: []pkix.AlgorithmIdentifier{{Algorithm: sm3.OID}},
  644. // EncapContentInfo: pkix.EncapContentInfo{
  645. // EContentType: pkix.DataOID,
  646. // EContent: jsonBytes,
  647. // },
  648. // Certificates: []pkix.Certificate{},
  649. // CRLs: []pkix.CertificateList{},
  650. // SignerInfos: []pkix.SignerInfo{},
  651. // DigestEncryptionAlgorithm: pkix.AlgorithmIdentifier{
  652. // Algorithm: sm2.SignAlgorithmSM2WithSM3,
  653. // },
  654. // EncryptedDigest: signature,
  655. // },
  656. //}
  657. //
  658. //// 使用 DER 编码进行序列化
  659. //derBytes, err := syntax.Marshal(signedData)
  660. //if err != nil {
  661. // fmt.Println("Failed to marshal CMS/PKCS#7 data:", err)
  662. // return
  663. //}
  664. service.GetCFYLJG002(miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, "", "", "")
  665. }
  666. func (c *HisApiController) GetCFYLJG003() {
  667. admin_user_id, _ := c.GetInt64("admin_user_id")
  668. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  669. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  670. var cFYLJG003 models.CFYLJG003
  671. service.GetCFYLJG003(miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, cFYLJG003)
  672. }
  673. func (c *HisApiController) GetCFYLJG004() {
  674. admin_user_id, _ := c.GetInt64("admin_user_id")
  675. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  676. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  677. var cFYLJG004 models.CFYLJG004
  678. service.GetCFYLJG004(miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, cFYLJG004)
  679. }
  680. func (c *HisApiController) GetCFYLJG005() {
  681. admin_user_id, _ := c.GetInt64("admin_user_id")
  682. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  683. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  684. var cFYLJG005 models.CFYLJG005
  685. service.GetCFYLJG005(miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, cFYLJG005)
  686. }
  687. func (c *HisApiController) GetCFYLJG006() {
  688. admin_user_id, _ := c.GetInt64("admin_user_id")
  689. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  690. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  691. var cFYLJG006 models.CFYLJG006
  692. service.GetCFYLJG006(miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, cFYLJG006)
  693. }
  694. func (c *HisApiController) GetCFYLJG007() {
  695. admin_user_id, _ := c.GetInt64("admin_user_id")
  696. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  697. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  698. var cFYLJG007 models.CFYLJG007
  699. service.GetCFYLJG007(miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, cFYLJG007)
  700. }
  701. func (c *HisApiController) GetBL4201A() {
  702. order_id, _ := c.GetInt64("order_id")
  703. admin_user_id, _ := c.GetInt64("admin_user_id")
  704. order, _ := service.GetHisOrderByIDTwo(order_id)
  705. his, _ := service.GetInHospitalRecordByNumber(order.MdtrtId)
  706. order_info, _ := service.GetHisOrderInfoByNumber(order.MdtrtId)
  707. order_info_two, _ := service.GetHisOrderInfoByNumberTwo(order.MdtrtId)
  708. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  709. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  710. department, _ := service.GetDepartMentDetail(his.Departments)
  711. pre, _ := service.GetNewHisPrescriptionByNumber(order.Number)
  712. doctor, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, pre.Creator)
  713. if order.ID == 0 {
  714. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisOrderNoExistParamWrong)
  715. return
  716. }
  717. var struct4201A models.Struct4201A
  718. var fsiOPFLDs []models.FsiOwnpayPatnFeeListDDTO
  719. for _, items := range order_info {
  720. memo := make(map[string]interface{})
  721. var fsiOPFLD models.FsiOwnpayPatnFeeListDDTO
  722. fsiOPFLD.FixmedinsMdtrtID = items.OrderNumber
  723. fsiOPFLD.MedType = "14"
  724. fsiOPFLD.BkkpSn = items.FeedetlSn
  725. fsiOPFLD.FixmedinsCode = miConfig.Code
  726. fsiOPFLD.FixmedinsName = miConfig.OrgName
  727. fsiOPFLD.Cnt = fmt.Sprintf("%.2f", items.Cnt)
  728. fsiOPFLD.Pric = fmt.Sprintf("%.2f", items.Pric)
  729. fsiOPFLD.DetItemFeeSumamt = fmt.Sprintf("%.2f", items.DetItemFeeSumamt)
  730. if items.AdviceId > 0 && items.ProjectId == 0 && items.HisDoctorAdviceInfo.BaseDrugLib.IsUser != 1 && len(items.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber) > 0 {
  731. fsiOPFLD.FeeOcurTime = time.Unix(items.HisDoctorAdviceInfo.CreatedTime, 0).Format("2006-01-02 15:04:05")
  732. fsiOPFLD.MedListCodg = items.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber
  733. fsiOPFLD.MedinsListCodg = items.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber
  734. fsiOPFLD.MedinsListName = items.HisDoctorAdviceInfo.BaseDrugLib.DrugName
  735. fsiOPFLD.Prodname = items.HisDoctorAdviceInfo.BaseDrugLib.DrugName
  736. fsiOPFLD.BilgDeptName = department.Name
  737. fsiOPFLD.BilgDeptCodg = department.Number
  738. fsiOPFLD.BilgDrCode = doctor.DoctorNumber
  739. fsiOPFLD.BilgDrName = doctor.UserName
  740. fsiOPFLD.MedChrgitmType = "09"
  741. memo["hosp_appr_flag"] = "1"
  742. memo["invoice_no"] = order.MdtrtId
  743. memo["memo"] = "自费"
  744. bytesData, _ := json.Marshal(memo)
  745. fsiOPFLD.Memo = string(bytesData)
  746. fsiOPFLDs = append(fsiOPFLDs, fsiOPFLD)
  747. } else if items.AdviceId == 0 && items.ProjectId > 0 {
  748. if items.HisPrescriptionProject.Type == 2 && len(items.HisPrescriptionProject.HisProject.MedicalCode) > 0 {
  749. fsiOPFLD.FeeOcurTime = time.Unix(items.HisPrescriptionProject.Ctime, 0).Format("2006-01-02 15:04:05")
  750. fsiOPFLD.MedListCodg = items.HisPrescriptionProject.HisProject.MedicalCode
  751. fsiOPFLD.MedinsListCodg = items.HisPrescriptionProject.HisProject.MedicalCode
  752. fsiOPFLD.MedinsListName = items.HisPrescriptionProject.HisProject.ProjectName
  753. fsiOPFLD.Prodname = items.HisPrescriptionProject.HisProject.ProjectName
  754. fsiOPFLD.BilgDeptName = department.Name
  755. fsiOPFLD.BilgDeptCodg = department.Number
  756. fsiOPFLD.BilgDrCode = doctor.DoctorNumber
  757. fsiOPFLD.BilgDrName = doctor.UserName
  758. switch items.HisPrescriptionProject.HisProject.CostClassify {
  759. case 0:
  760. break
  761. case 1:
  762. fsiOPFLD.MedChrgitmType = "14"
  763. break
  764. case 2:
  765. fsiOPFLD.MedChrgitmType = "05"
  766. break
  767. case 3:
  768. fsiOPFLD.MedChrgitmType = "03"
  769. break
  770. case 4:
  771. fsiOPFLD.MedChrgitmType = "03"
  772. break
  773. case 5:
  774. fsiOPFLD.MedChrgitmType = "08"
  775. break
  776. case 6:
  777. fsiOPFLD.MedChrgitmType = "14"
  778. break
  779. case 7:
  780. fsiOPFLD.MedChrgitmType = "14"
  781. break
  782. case 8:
  783. fsiOPFLD.MedChrgitmType = "03"
  784. break
  785. case 9:
  786. fsiOPFLD.MedChrgitmType = "14"
  787. break
  788. case 10:
  789. fsiOPFLD.MedChrgitmType = "14"
  790. break
  791. case 11:
  792. fsiOPFLD.MedChrgitmType = "06"
  793. break
  794. case 12:
  795. fsiOPFLD.MedChrgitmType = "12"
  796. break
  797. case 13:
  798. fsiOPFLD.MedChrgitmType = "01"
  799. break
  800. case 14:
  801. fsiOPFLD.MedChrgitmType = "04"
  802. break
  803. case 15:
  804. fsiOPFLD.MedChrgitmType = "14"
  805. break
  806. }
  807. memo["hosp_appr_flag"] = "1"
  808. memo["invoice_no"] = order.MdtrtId
  809. memo["memo"] = "自费"
  810. bytesData, _ := json.Marshal(memo)
  811. fsiOPFLD.Memo = string(bytesData)
  812. fsiOPFLDs = append(fsiOPFLDs, fsiOPFLD)
  813. } else if items.HisPrescriptionProject.Type == 3 && items.HisPrescriptionProject.GoodInfo.IsUser != 1 && len(items.HisPrescriptionProject.GoodInfo.MedicalInsuranceNumber) > 0 {
  814. fsiOPFLD.FeeOcurTime = time.Unix(items.HisPrescriptionProject.Ctime, 0).Format("2006-01-02 15:04:05")
  815. fsiOPFLD.MedListCodg = items.HisPrescriptionProject.GoodInfo.MedicalInsuranceNumber
  816. fsiOPFLD.MedinsListCodg = items.HisPrescriptionProject.GoodInfo.MedicalInsuranceNumber
  817. fsiOPFLD.BilgDeptName = department.Name
  818. fsiOPFLD.BilgDeptCodg = department.Number
  819. fsiOPFLD.BilgDrCode = doctor.DoctorNumber
  820. fsiOPFLD.BilgDrName = doctor.UserName
  821. fsiOPFLD.MedinsListName = items.HisPrescriptionProject.GoodInfo.GoodName
  822. fsiOPFLD.Prodname = items.HisPrescriptionProject.GoodInfo.GoodName
  823. fsiOPFLD.MedChrgitmType = "08"
  824. memo["hosp_appr_flag"] = "1"
  825. memo["invoice_no"] = order.MdtrtId
  826. memo["memo"] = "自费"
  827. bytesData, _ := json.Marshal(memo)
  828. fsiOPFLD.Memo = string(bytesData)
  829. fsiOPFLDs = append(fsiOPFLDs, fsiOPFLD)
  830. }
  831. }
  832. }
  833. for _, items := range order_info_two {
  834. memo := make(map[string]interface{})
  835. var fsiOPFLD models.FsiOwnpayPatnFeeListDDTO
  836. fsiOPFLD.FixmedinsMdtrtID = items.OrderNumber
  837. fsiOPFLD.MedType = "14"
  838. fsiOPFLD.BkkpSn = items.FeedetlSn
  839. fsiOPFLD.FixmedinsCode = miConfig.Code
  840. fsiOPFLD.FixmedinsName = miConfig.OrgName
  841. fsiOPFLD.Cnt = fmt.Sprintf("%.2f", items.Cnt)
  842. fsiOPFLD.Pric = fmt.Sprintf("%.2f", items.Pric)
  843. fsiOPFLD.DetItemFeeSumamt = fmt.Sprintf("%.2f", items.DetItemFeeSumamt)
  844. if items.AdviceId > 0 && items.ProjectId == 0 && items.HisDoctorAdviceInfo.BaseDrugLib.IsUser != 1 && len(items.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber) > 0 {
  845. fsiOPFLD.FeeOcurTime = time.Unix(items.HisDoctorAdviceInfo.CreatedTime, 0).Format("2006-01-02 15:04:05")
  846. fsiOPFLD.MedListCodg = items.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber
  847. fsiOPFLD.MedinsListCodg = items.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber
  848. fsiOPFLD.MedinsListName = items.HisDoctorAdviceInfo.BaseDrugLib.DrugName
  849. fsiOPFLD.Prodname = items.HisDoctorAdviceInfo.BaseDrugLib.DrugName
  850. fsiOPFLD.BilgDeptName = department.Name
  851. fsiOPFLD.BilgDeptCodg = department.Number
  852. fsiOPFLD.BilgDrCode = doctor.DoctorNumber
  853. fsiOPFLD.BilgDrName = doctor.UserName
  854. fsiOPFLD.MedChrgitmType = "09"
  855. memo["hosp_appr_flag"] = "1"
  856. memo["invoice_no"] = order.MdtrtId
  857. memo["memo"] = "自费"
  858. bytesData, _ := json.Marshal(memo)
  859. fsiOPFLD.Memo = string(bytesData)
  860. fsiOPFLDs = append(fsiOPFLDs, fsiOPFLD)
  861. } else if items.AdviceId == 0 && items.ProjectId > 0 {
  862. if items.HisPrescriptionProject.Type == 2 && len(items.HisPrescriptionProject.HisProject.MedicalCode) > 0 {
  863. fsiOPFLD.FeeOcurTime = time.Unix(items.HisPrescriptionProject.Ctime, 0).Format("2006-01-02 15:04:05")
  864. fsiOPFLD.MedListCodg = items.HisPrescriptionProject.HisProject.MedicalCode
  865. fsiOPFLD.MedinsListName = items.HisPrescriptionProject.HisProject.ProjectName
  866. fsiOPFLD.Prodname = items.HisPrescriptionProject.HisProject.ProjectName
  867. fsiOPFLD.MedinsListCodg = items.HisPrescriptionProject.HisProject.MedicalCode
  868. fsiOPFLD.BilgDeptName = department.Name
  869. fsiOPFLD.BilgDeptCodg = department.Number
  870. fsiOPFLD.BilgDrCode = doctor.DoctorNumber
  871. fsiOPFLD.BilgDrName = doctor.UserName
  872. switch items.HisPrescriptionProject.HisProject.CostClassify {
  873. case 0:
  874. break
  875. case 1:
  876. fsiOPFLD.MedChrgitmType = "14"
  877. break
  878. case 2:
  879. fsiOPFLD.MedChrgitmType = "05"
  880. break
  881. case 3:
  882. fsiOPFLD.MedChrgitmType = "03"
  883. break
  884. case 4:
  885. fsiOPFLD.MedChrgitmType = "03"
  886. break
  887. case 5:
  888. fsiOPFLD.MedChrgitmType = "08"
  889. break
  890. case 6:
  891. fsiOPFLD.MedChrgitmType = "14"
  892. break
  893. case 7:
  894. fsiOPFLD.MedChrgitmType = "14"
  895. break
  896. case 8:
  897. fsiOPFLD.MedChrgitmType = "03"
  898. break
  899. case 9:
  900. fsiOPFLD.MedChrgitmType = "14"
  901. break
  902. case 10:
  903. fsiOPFLD.MedChrgitmType = "14"
  904. break
  905. case 11:
  906. fsiOPFLD.MedChrgitmType = "06"
  907. break
  908. case 12:
  909. fsiOPFLD.MedChrgitmType = "12"
  910. break
  911. case 13:
  912. fsiOPFLD.MedChrgitmType = "01"
  913. break
  914. case 14:
  915. fsiOPFLD.MedChrgitmType = "04"
  916. break
  917. case 15:
  918. fsiOPFLD.MedChrgitmType = "14"
  919. break
  920. }
  921. memo["hosp_appr_flag"] = "1"
  922. memo["invoice_no"] = order.MdtrtId
  923. memo["memo"] = "自费"
  924. bytesData, _ := json.Marshal(memo)
  925. fsiOPFLD.Memo = string(bytesData)
  926. fsiOPFLDs = append(fsiOPFLDs, fsiOPFLD)
  927. } else if items.HisPrescriptionProject.Type == 3 && len(items.HisPrescriptionProject.GoodInfo.MedicalInsuranceNumber) > 0 && items.HisPrescriptionProject.GoodInfo.IsUser != 1 {
  928. fsiOPFLD.FeeOcurTime = time.Unix(items.HisPrescriptionProject.Ctime, 0).Format("2006-01-02 15:04:05")
  929. fsiOPFLD.MedListCodg = items.HisPrescriptionProject.GoodInfo.MedicalInsuranceNumber
  930. fsiOPFLD.MedinsListCodg = items.HisPrescriptionProject.GoodInfo.MedicalInsuranceNumber
  931. fsiOPFLD.BilgDeptName = department.Name
  932. fsiOPFLD.BilgDeptCodg = department.Number
  933. fsiOPFLD.BilgDrCode = doctor.DoctorNumber
  934. fsiOPFLD.BilgDrName = doctor.UserName
  935. fsiOPFLD.MedinsListName = items.HisPrescriptionProject.GoodInfo.GoodName
  936. fsiOPFLD.Prodname = items.HisPrescriptionProject.GoodInfo.GoodName
  937. fsiOPFLD.MedChrgitmType = "08"
  938. memo["hosp_appr_flag"] = "1"
  939. memo["invoice_no"] = order.MdtrtId
  940. memo["memo"] = "自费"
  941. bytesData, _ := json.Marshal(memo)
  942. fsiOPFLD.Memo = string(bytesData)
  943. fsiOPFLDs = append(fsiOPFLDs, fsiOPFLD)
  944. }
  945. }
  946. }
  947. fmt.Println(fsiOPFLDs)
  948. struct4201A.Fopfd = fsiOPFLDs
  949. fmt.Println(struct4201A.Fopfd)
  950. result, requestLog := service.Gdyb4201A(miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, struct4201A)
  951. saveLog(result, requestLog, "4201A", "自费费用明细上传")
  952. var res2 ResultSix
  953. var respJSON2 map[string]interface{}
  954. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  955. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  956. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  957. return
  958. }
  959. userJSONBytes2, _ := json.Marshal(respJSON2)
  960. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  961. utils.ErrorLog("解析失败:%v", err)
  962. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  963. return
  964. }
  965. if res2.Infcode != 0 {
  966. c.ServeSuccessJSON(map[string]interface{}{
  967. "failed_code": -10,
  968. "msg": res2.ErrMsg,
  969. })
  970. return
  971. } else {
  972. order.IsUploadOrderInfo = 1
  973. service.UpdateOrder(order)
  974. c.ServeSuccessJSON(map[string]interface{}{
  975. "msg": "上传成功",
  976. })
  977. }
  978. }
  979. func (c *HisApiController) Get2505() {
  980. miConfig, _ := service.FindMedicalInsuranceInfo(10215)
  981. 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")
  982. }
  983. func (c *HisApiController) Get4201A() {
  984. order_id, _ := c.GetInt64("order_id")
  985. admin_user_id, _ := c.GetInt64("admin_user_id")
  986. order, _ := service.GetHisOrderByIDTwo(order_id)
  987. his, _ := service.GetInHospitalRecordByNumber(order.MdtrtId)
  988. order_info, _ := service.GetHisOrderInfoByNumber(order.MdtrtId)
  989. order_info_two, _ := service.GetHisOrderInfoByNumberTwo(order.MdtrtId)
  990. //order_info = append(order_info, order_info_two...)
  991. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  992. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  993. department, _ := service.GetDepartMentDetail(his.Departments)
  994. pre, _ := service.GetNewHisPrescriptionByNumber(order.Number)
  995. doctor, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, pre.Creator)
  996. if order.ID == 0 {
  997. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisOrderNoExistParamWrong)
  998. return
  999. }
  1000. var struct4201A models.Struct4201A
  1001. var fsiOPFLDs []models.FsiOwnpayPatnFeeListDDTO
  1002. for _, items := range order_info {
  1003. memo := make(map[string]interface{})
  1004. var fsiOPFLD models.FsiOwnpayPatnFeeListDDTO
  1005. fsiOPFLD.FixmedinsMdtrtID = items.OrderNumber
  1006. fsiOPFLD.MedType = "14"
  1007. fsiOPFLD.BkkpSn = items.FeedetlSn
  1008. fsiOPFLD.FixmedinsCode = miConfig.Code
  1009. fsiOPFLD.FixmedinsName = miConfig.OrgName
  1010. fsiOPFLD.Cnt = fmt.Sprintf("%.2f", items.Cnt)
  1011. fsiOPFLD.Pric = fmt.Sprintf("%.2f", items.Pric)
  1012. fsiOPFLD.DetItemFeeSumamt = fmt.Sprintf("%.2f", items.DetItemFeeSumamt)
  1013. if items.AdviceId > 0 && items.ProjectId == 0 && items.HisDoctorAdviceInfo.BaseDrugLib.IsUser != 1 && len(items.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber) > 0 {
  1014. fsiOPFLD.FeeOcurTime = time.Unix(items.HisDoctorAdviceInfo.CreatedTime, 0).Format("2006-01-02 15:04:05")
  1015. fsiOPFLD.MedListCodg = items.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber
  1016. fsiOPFLD.MedinsListCodg = items.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber
  1017. fsiOPFLD.MedinsListName = items.HisDoctorAdviceInfo.BaseDrugLib.DrugName
  1018. fsiOPFLD.Prodname = items.HisDoctorAdviceInfo.BaseDrugLib.DrugName
  1019. fsiOPFLD.BilgDeptName = department.Name
  1020. fsiOPFLD.BilgDeptCodg = department.Number
  1021. fsiOPFLD.BilgDrCode = doctor.DoctorNumber
  1022. fsiOPFLD.BilgDrName = doctor.UserName
  1023. fsiOPFLD.MedChrgitmType = "09"
  1024. memo["hosp_appr_flag"] = "1"
  1025. memo["invoice_no"] = order.MdtrtId
  1026. memo["memo"] = "自费"
  1027. bytesData, _ := json.Marshal(memo)
  1028. fsiOPFLD.Memo = string(bytesData)
  1029. fsiOPFLDs = append(fsiOPFLDs, fsiOPFLD)
  1030. } else if items.AdviceId == 0 && items.ProjectId > 0 {
  1031. if items.HisPrescriptionProject.Type == 2 && len(items.HisPrescriptionProject.HisProject.MedicalCode) > 0 {
  1032. fsiOPFLD.FeeOcurTime = time.Unix(items.HisPrescriptionProject.Ctime, 0).Format("2006-01-02 15:04:05")
  1033. fsiOPFLD.MedListCodg = items.HisPrescriptionProject.HisProject.MedicalCode
  1034. fsiOPFLD.MedinsListCodg = items.HisPrescriptionProject.HisProject.MedicalCode
  1035. fsiOPFLD.MedinsListName = items.HisPrescriptionProject.HisProject.ProjectName
  1036. fsiOPFLD.Prodname = items.HisPrescriptionProject.HisProject.ProjectName
  1037. fsiOPFLD.BilgDeptName = department.Name
  1038. fsiOPFLD.BilgDeptCodg = department.Number
  1039. fsiOPFLD.BilgDrCode = doctor.DoctorNumber
  1040. fsiOPFLD.BilgDrName = doctor.UserName
  1041. switch items.HisPrescriptionProject.HisProject.CostClassify {
  1042. case 0:
  1043. break
  1044. case 1:
  1045. fsiOPFLD.MedChrgitmType = "14"
  1046. break
  1047. case 2:
  1048. fsiOPFLD.MedChrgitmType = "05"
  1049. break
  1050. case 3:
  1051. fsiOPFLD.MedChrgitmType = "03"
  1052. break
  1053. case 4:
  1054. fsiOPFLD.MedChrgitmType = "03"
  1055. break
  1056. case 5:
  1057. fsiOPFLD.MedChrgitmType = "08"
  1058. break
  1059. case 6:
  1060. fsiOPFLD.MedChrgitmType = "14"
  1061. break
  1062. case 7:
  1063. fsiOPFLD.MedChrgitmType = "14"
  1064. break
  1065. case 8:
  1066. fsiOPFLD.MedChrgitmType = "03"
  1067. break
  1068. case 9:
  1069. fsiOPFLD.MedChrgitmType = "14"
  1070. break
  1071. case 10:
  1072. fsiOPFLD.MedChrgitmType = "14"
  1073. break
  1074. case 11:
  1075. fsiOPFLD.MedChrgitmType = "06"
  1076. break
  1077. case 12:
  1078. fsiOPFLD.MedChrgitmType = "12"
  1079. break
  1080. case 13:
  1081. fsiOPFLD.MedChrgitmType = "01"
  1082. break
  1083. case 14:
  1084. fsiOPFLD.MedChrgitmType = "04"
  1085. break
  1086. case 15:
  1087. fsiOPFLD.MedChrgitmType = "14"
  1088. break
  1089. }
  1090. memo["hosp_appr_flag"] = "1"
  1091. memo["invoice_no"] = order.MdtrtId
  1092. memo["memo"] = "自费"
  1093. bytesData, _ := json.Marshal(memo)
  1094. fsiOPFLD.Memo = string(bytesData)
  1095. fsiOPFLDs = append(fsiOPFLDs, fsiOPFLD)
  1096. } else if items.HisPrescriptionProject.Type == 3 && items.HisPrescriptionProject.GoodInfo.IsUser != 1 && len(items.HisPrescriptionProject.GoodInfo.MedicalInsuranceNumber) > 0 {
  1097. fsiOPFLD.FeeOcurTime = time.Unix(items.HisPrescriptionProject.Ctime, 0).Format("2006-01-02 15:04:05")
  1098. fsiOPFLD.MedListCodg = items.HisPrescriptionProject.GoodInfo.MedicalInsuranceNumber
  1099. fsiOPFLD.MedinsListCodg = items.HisPrescriptionProject.GoodInfo.MedicalInsuranceNumber
  1100. fsiOPFLD.BilgDeptName = department.Name
  1101. fsiOPFLD.BilgDeptCodg = department.Number
  1102. fsiOPFLD.BilgDrCode = doctor.DoctorNumber
  1103. fsiOPFLD.BilgDrName = doctor.UserName
  1104. fsiOPFLD.MedinsListName = items.HisPrescriptionProject.GoodInfo.GoodName
  1105. fsiOPFLD.Prodname = items.HisPrescriptionProject.GoodInfo.GoodName
  1106. fsiOPFLD.MedChrgitmType = "08"
  1107. memo["hosp_appr_flag"] = "1"
  1108. memo["invoice_no"] = order.MdtrtId
  1109. memo["memo"] = "自费"
  1110. bytesData, _ := json.Marshal(memo)
  1111. fsiOPFLD.Memo = string(bytesData)
  1112. fsiOPFLDs = append(fsiOPFLDs, fsiOPFLD)
  1113. }
  1114. }
  1115. }
  1116. for _, items := range order_info_two {
  1117. memo := make(map[string]interface{})
  1118. var fsiOPFLD models.FsiOwnpayPatnFeeListDDTO
  1119. fsiOPFLD.FixmedinsMdtrtID = items.OrderNumber
  1120. fsiOPFLD.MedType = "14"
  1121. fsiOPFLD.BkkpSn = items.FeedetlSn
  1122. fsiOPFLD.FixmedinsCode = miConfig.Code
  1123. fsiOPFLD.FixmedinsName = miConfig.OrgName
  1124. fsiOPFLD.Cnt = fmt.Sprintf("%.2f", items.Cnt)
  1125. fsiOPFLD.Pric = fmt.Sprintf("%.2f", items.Pric)
  1126. fsiOPFLD.DetItemFeeSumamt = fmt.Sprintf("%.2f", items.DetItemFeeSumamt)
  1127. if items.AdviceId > 0 && items.ProjectId == 0 && items.HisDoctorAdviceInfo.BaseDrugLib.IsUser != 1 && len(items.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber) > 0 {
  1128. fsiOPFLD.FeeOcurTime = time.Unix(items.HisDoctorAdviceInfo.CreatedTime, 0).Format("2006-01-02 15:04:05")
  1129. fsiOPFLD.MedListCodg = items.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber
  1130. fsiOPFLD.MedinsListCodg = items.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber
  1131. fsiOPFLD.MedinsListName = items.HisDoctorAdviceInfo.BaseDrugLib.DrugName
  1132. fsiOPFLD.Prodname = items.HisDoctorAdviceInfo.BaseDrugLib.DrugName
  1133. fsiOPFLD.BilgDeptName = department.Name
  1134. fsiOPFLD.BilgDeptCodg = department.Number
  1135. fsiOPFLD.BilgDrCode = doctor.DoctorNumber
  1136. fsiOPFLD.BilgDrName = doctor.UserName
  1137. fsiOPFLD.MedChrgitmType = "09"
  1138. memo["hosp_appr_flag"] = "1"
  1139. memo["invoice_no"] = order.MdtrtId
  1140. memo["memo"] = "自费"
  1141. bytesData, _ := json.Marshal(memo)
  1142. fsiOPFLD.Memo = string(bytesData)
  1143. fsiOPFLDs = append(fsiOPFLDs, fsiOPFLD)
  1144. } else if items.AdviceId == 0 && items.ProjectId > 0 {
  1145. if items.HisPrescriptionProject.Type == 2 && len(items.HisPrescriptionProject.HisProject.MedicalCode) > 0 {
  1146. fsiOPFLD.FeeOcurTime = time.Unix(items.HisPrescriptionProject.Ctime, 0).Format("2006-01-02 15:04:05")
  1147. fsiOPFLD.MedListCodg = items.HisPrescriptionProject.HisProject.MedicalCode
  1148. fsiOPFLD.MedinsListName = items.HisPrescriptionProject.HisProject.ProjectName
  1149. fsiOPFLD.Prodname = items.HisPrescriptionProject.HisProject.ProjectName
  1150. fsiOPFLD.MedinsListCodg = items.HisPrescriptionProject.HisProject.MedicalCode
  1151. fsiOPFLD.BilgDeptName = department.Name
  1152. fsiOPFLD.BilgDeptCodg = department.Number
  1153. fsiOPFLD.BilgDrCode = doctor.DoctorNumber
  1154. fsiOPFLD.BilgDrName = doctor.UserName
  1155. switch items.HisPrescriptionProject.HisProject.CostClassify {
  1156. case 0:
  1157. break
  1158. case 1:
  1159. fsiOPFLD.MedChrgitmType = "14"
  1160. break
  1161. case 2:
  1162. fsiOPFLD.MedChrgitmType = "05"
  1163. break
  1164. case 3:
  1165. fsiOPFLD.MedChrgitmType = "03"
  1166. break
  1167. case 4:
  1168. fsiOPFLD.MedChrgitmType = "03"
  1169. break
  1170. case 5:
  1171. fsiOPFLD.MedChrgitmType = "08"
  1172. break
  1173. case 6:
  1174. fsiOPFLD.MedChrgitmType = "14"
  1175. break
  1176. case 7:
  1177. fsiOPFLD.MedChrgitmType = "14"
  1178. break
  1179. case 8:
  1180. fsiOPFLD.MedChrgitmType = "03"
  1181. break
  1182. case 9:
  1183. fsiOPFLD.MedChrgitmType = "14"
  1184. break
  1185. case 10:
  1186. fsiOPFLD.MedChrgitmType = "14"
  1187. break
  1188. case 11:
  1189. fsiOPFLD.MedChrgitmType = "06"
  1190. break
  1191. case 12:
  1192. fsiOPFLD.MedChrgitmType = "12"
  1193. break
  1194. case 13:
  1195. fsiOPFLD.MedChrgitmType = "01"
  1196. break
  1197. case 14:
  1198. fsiOPFLD.MedChrgitmType = "04"
  1199. break
  1200. case 15:
  1201. fsiOPFLD.MedChrgitmType = "14"
  1202. break
  1203. }
  1204. memo["hosp_appr_flag"] = "1"
  1205. memo["invoice_no"] = order.MdtrtId
  1206. memo["memo"] = "自费"
  1207. bytesData, _ := json.Marshal(memo)
  1208. fsiOPFLD.Memo = string(bytesData)
  1209. fsiOPFLDs = append(fsiOPFLDs, fsiOPFLD)
  1210. } else if items.HisPrescriptionProject.Type == 3 && len(items.HisPrescriptionProject.GoodInfo.MedicalInsuranceNumber) > 0 && items.HisPrescriptionProject.GoodInfo.IsUser != 1 {
  1211. fsiOPFLD.FeeOcurTime = time.Unix(items.HisPrescriptionProject.Ctime, 0).Format("2006-01-02 15:04:05")
  1212. fsiOPFLD.MedListCodg = items.HisPrescriptionProject.GoodInfo.MedicalInsuranceNumber
  1213. fsiOPFLD.MedinsListCodg = items.HisPrescriptionProject.GoodInfo.MedicalInsuranceNumber
  1214. fsiOPFLD.BilgDeptName = department.Name
  1215. fsiOPFLD.BilgDeptCodg = department.Number
  1216. fsiOPFLD.BilgDrCode = doctor.DoctorNumber
  1217. fsiOPFLD.BilgDrName = doctor.UserName
  1218. fsiOPFLD.MedinsListName = items.HisPrescriptionProject.GoodInfo.GoodName
  1219. fsiOPFLD.Prodname = items.HisPrescriptionProject.GoodInfo.GoodName
  1220. fsiOPFLD.MedChrgitmType = "08"
  1221. memo["hosp_appr_flag"] = "1"
  1222. memo["invoice_no"] = order.MdtrtId
  1223. memo["memo"] = "自费"
  1224. bytesData, _ := json.Marshal(memo)
  1225. fsiOPFLD.Memo = string(bytesData)
  1226. fsiOPFLDs = append(fsiOPFLDs, fsiOPFLD)
  1227. }
  1228. }
  1229. }
  1230. fmt.Println(fsiOPFLDs)
  1231. struct4201A.Fopfd = fsiOPFLDs
  1232. fmt.Println(struct4201A.Fopfd)
  1233. result, requestLog := service.Gdyb4201A(miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, struct4201A)
  1234. saveLog(result, requestLog, "4201A", "自费费用明细上传")
  1235. var res2 ResultSix
  1236. var respJSON2 map[string]interface{}
  1237. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  1238. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  1239. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1240. return
  1241. }
  1242. userJSONBytes2, _ := json.Marshal(respJSON2)
  1243. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  1244. utils.ErrorLog("解析失败:%v", err)
  1245. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1246. return
  1247. }
  1248. if res2.Infcode != 0 {
  1249. c.ServeSuccessJSON(map[string]interface{}{
  1250. "failed_code": -10,
  1251. "msg": res2.ErrMsg,
  1252. })
  1253. return
  1254. } else {
  1255. order.IsUploadOrderInfo = 1
  1256. service.UpdateOrder(order)
  1257. c.ServeSuccessJSON(map[string]interface{}{
  1258. "msg": "上传成功",
  1259. })
  1260. }
  1261. }
  1262. func (c *HisApiController) Get4202() {
  1263. order_id, _ := c.GetInt64("order_id")
  1264. admin_user_id, _ := c.GetInt64("admin_user_id")
  1265. order, _ := service.GetHisOrderByIDTwo(order_id)
  1266. his, _ := service.GetInHospitalRecordByNumber(order.MdtrtId)
  1267. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  1268. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  1269. if order.ID == 0 {
  1270. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisOrderNoExistParamWrong)
  1271. return
  1272. }
  1273. var struct4202 models.Struct4202
  1274. struct4202.OwnPayPatnMdtrtD.FixmedinsMdtrtID = his.Number
  1275. struct4202.OwnPayPatnMdtrtD.FixmedinsCode = miConfig.Code
  1276. struct4202.OwnPayPatnMdtrtD.FixmedinsName = miConfig.OrgName
  1277. struct4202.OwnPayPatnMdtrtD.PsnCertType = "01"
  1278. struct4202.OwnPayPatnMdtrtD.Certno = his.IdCardNo
  1279. struct4202.OwnPayPatnMdtrtD.PsnName = his.Name
  1280. struct4202.OwnPayPatnMdtrtD.Begntime = his.InHosptialTime
  1281. struct4202.OwnPayPatnMdtrtD.MedType = "14"
  1282. struct4202.OwnPayPatnMdtrtD.ValiFlag = "1"
  1283. struct4202.OwnPayPatnMdtrtD.MedfeeSumamt = fmt.Sprintf("%.2f", order.MedfeeSumamt)
  1284. diagnosis_ids := strings.Split(his.Diagnosis, ",")
  1285. var config []*models.HisXtDiagnoseConfig
  1286. for _, item := range diagnosis_ids {
  1287. id, _ := strconv.ParseInt(item, 10, 64)
  1288. diagnosisConfig, _ := service.FindDiagnoseById(id)
  1289. config = append(config, &diagnosisConfig)
  1290. }
  1291. var tempDiaginfos []models.OwnPayPatnDiagListD
  1292. for index, item := range config {
  1293. if index == 0 {
  1294. var tempDiaginfo models.OwnPayPatnDiagListD
  1295. tempDiaginfo.InoutDiagType = "1"
  1296. tempDiaginfo.DiagCode = item.CountryCode
  1297. tempDiaginfo.DiagName = item.CountryContentName
  1298. tempDiaginfo.DiagType = "1"
  1299. tempDiaginfo.DiagSrtNo = "1"
  1300. tempDiaginfo.MaindiagFlag = "1"
  1301. tempDiaginfo.ValiFlag = "1"
  1302. tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  1303. } else {
  1304. var tempDiaginfo models.OwnPayPatnDiagListD
  1305. tempDiaginfo.DiagCode = item.CountryCode
  1306. tempDiaginfo.DiagName = item.CountryContentName
  1307. tempDiaginfo.DiagType = "2"
  1308. tempDiaginfo.DiagSrtNo = strconv.FormatInt(int64(index+1), 10)
  1309. tempDiaginfo.MaindiagFlag = "0"
  1310. tempDiaginfo.ValiFlag = "1"
  1311. tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  1312. }
  1313. }
  1314. struct4202.ODiagListD = tempDiaginfos
  1315. result, requestLog := service.Gdyb4202(miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, struct4202)
  1316. saveLog(result, requestLog, "4202", "自费就诊和诊断信息上传")
  1317. var res2 ResultSix
  1318. var respJSON2 map[string]interface{}
  1319. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  1320. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  1321. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1322. return
  1323. }
  1324. userJSONBytes2, _ := json.Marshal(respJSON2)
  1325. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  1326. utils.ErrorLog("解析失败:%v", err)
  1327. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1328. return
  1329. }
  1330. if res2.Infcode != 0 {
  1331. c.ServeSuccessJSON(map[string]interface{}{
  1332. "failed_code": -10,
  1333. "msg": res2.ErrMsg,
  1334. })
  1335. return
  1336. } else {
  1337. order.IsUploadDiagnose = 1
  1338. service.UpdateOrder(order)
  1339. c.ServeSuccessJSON(map[string]interface{}{
  1340. "msg": "上传成功",
  1341. })
  1342. }
  1343. }
  1344. func (c *HisApiController) Get4203() {
  1345. admin_user_id, _ := c.GetInt64("admin_user_id")
  1346. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  1347. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  1348. order_id, _ := c.GetInt64("order_id")
  1349. order, _ := service.GetHisOrderByIDTwo1111(order_id)
  1350. number := ""
  1351. his, _ := service.GetHisPatientByNumber(order.MdtrtId)
  1352. hospital, _ := service.GetInHospitalRecordByNumber(order.MdtrtId)
  1353. if his.ID == 0 {
  1354. number = hospital.Number
  1355. } else {
  1356. number = his.Number
  1357. }
  1358. result, requestLog := service.Gdyb4203(miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, number)
  1359. saveLog(result, requestLog, "4203", "自费就诊与结算明细上传完成")
  1360. var res2 ResultSix
  1361. var respJSON2 map[string]interface{}
  1362. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  1363. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  1364. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1365. return
  1366. }
  1367. userJSONBytes2, _ := json.Marshal(respJSON2)
  1368. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  1369. utils.ErrorLog("解析失败:%v", err)
  1370. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1371. return
  1372. }
  1373. if res2.Infcode != 0 {
  1374. c.ServeSuccessJSON(map[string]interface{}{
  1375. "failed_code": -10,
  1376. "msg": res2.ErrMsg,
  1377. })
  1378. return
  1379. } else {
  1380. order.IsUploadSuccess = 1
  1381. service.UpdateOrderTwo(order)
  1382. c.ServeSuccessJSON(map[string]interface{}{
  1383. "msg": "上传成功",
  1384. })
  1385. }
  1386. }
  1387. func (c *HisApiController) Get4205() {
  1388. order_id, _ := c.GetInt64("order_id")
  1389. admin_user_id, _ := c.GetInt64("admin_user_id")
  1390. fapiao_code := c.GetString("fapiao_code")
  1391. order, _ := service.GetHisOrderByIDTwo1111(order_id)
  1392. his, _ := service.GetHisPatientByNumber(order.MdtrtId)
  1393. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  1394. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  1395. order_info, _ := service.GetHisOrderInfoByNumber(order.Number)
  1396. order_info_two, _ := service.GetHisOrderInfoByNumberTwo(order.Number)
  1397. //order_info = append(order_info, order_info_two...)
  1398. department, _ := service.GetDepartMentDetail(his.Departments)
  1399. pre, _ := service.GetNewHisPrescriptionByNumber(order.Number)
  1400. doctor, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, pre.Creator)
  1401. if order.ID == 0 {
  1402. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisOrderNoExistParamWrong)
  1403. return
  1404. }
  1405. var struct4201A models.Struct4201A
  1406. var fsiOPFLDs []models.FsiOwnpayPatnFeeListDDTO
  1407. for _, items := range order_info {
  1408. memo := make(map[string]interface{})
  1409. var fsiOPFLD models.FsiOwnpayPatnFeeListDDTO
  1410. fsiOPFLD.FixmedinsMdtrtID = items.OrderNumber
  1411. fsiOPFLD.MedType = pre.MedType
  1412. fsiOPFLD.FixmedinsCode = miConfig.Code
  1413. fsiOPFLD.FixmedinsName = miConfig.OrgName
  1414. fsiOPFLD.Cnt = fmt.Sprintf("%.2f", items.Cnt)
  1415. fsiOPFLD.Pric = fmt.Sprintf("%.2f", items.Pric)
  1416. fsiOPFLD.DetItemFeeSumamt = fmt.Sprintf("%.2f", items.DetItemFeeSumamt)
  1417. if items.AdviceId > 0 && items.ProjectId == 0 && items.HisDoctorAdviceInfo.BaseDrugLib.IsUser != 1 && len(items.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber) > 0 {
  1418. fsiOPFLD.FeeOcurTime = time.Unix(items.HisDoctorAdviceInfo.CreatedTime, 0).Format("2006-01-02 15:04:05")
  1419. fsiOPFLD.MedListCodg = items.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber
  1420. fsiOPFLD.BkkpSn = items.HisDoctorAdviceInfo.FeedetlSn
  1421. fsiOPFLD.MedinsListCodg = items.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber
  1422. fsiOPFLD.MedinsListName = items.HisDoctorAdviceInfo.BaseDrugLib.DrugName
  1423. fsiOPFLD.Prodname = items.HisDoctorAdviceInfo.BaseDrugLib.DrugName
  1424. fsiOPFLD.BilgDeptName = department.Name
  1425. fsiOPFLD.BilgDeptCodg = department.Number
  1426. fsiOPFLD.BilgDrCode = doctor.DoctorNumber
  1427. fsiOPFLD.BilgDrName = doctor.UserName
  1428. fsiOPFLD.MedChrgitmType = "09"
  1429. memo["hosp_appr_flag"] = "1"
  1430. memo["invoice_no"] = fapiao_code
  1431. memo["memo"] = "自费"
  1432. bytesData, _ := json.Marshal(memo)
  1433. fsiOPFLD.Memo = string(bytesData)
  1434. fsiOPFLDs = append(fsiOPFLDs, fsiOPFLD)
  1435. } else if items.AdviceId == 0 && items.ProjectId > 0 {
  1436. fsiOPFLD.BkkpSn = items.HisPrescriptionProject.FeedetlSn
  1437. if items.HisPrescriptionProject.Type == 2 && len(items.HisPrescriptionProject.HisProject.MedicalCode) > 0 {
  1438. fsiOPFLD.FeeOcurTime = time.Unix(items.HisPrescriptionProject.Ctime, 0).Format("2006-01-02 15:04:05")
  1439. fsiOPFLD.MedListCodg = items.HisPrescriptionProject.HisProject.MedicalCode
  1440. fsiOPFLD.MedinsListCodg = items.HisPrescriptionProject.HisProject.MedicalCode
  1441. fsiOPFLD.MedinsListName = items.HisPrescriptionProject.HisProject.ProjectName
  1442. fsiOPFLD.Prodname = items.HisPrescriptionProject.HisProject.ProjectName
  1443. fsiOPFLD.BilgDeptName = department.Name
  1444. fsiOPFLD.BilgDeptCodg = department.Number
  1445. fsiOPFLD.BilgDrCode = doctor.DoctorNumber
  1446. fsiOPFLD.BilgDrName = doctor.UserName
  1447. switch items.HisPrescriptionProject.HisProject.CostClassify {
  1448. case 0:
  1449. break
  1450. case 1:
  1451. fsiOPFLD.MedChrgitmType = "14"
  1452. break
  1453. case 2:
  1454. fsiOPFLD.MedChrgitmType = "05"
  1455. break
  1456. case 3:
  1457. fsiOPFLD.MedChrgitmType = "03"
  1458. break
  1459. case 4:
  1460. fsiOPFLD.MedChrgitmType = "03"
  1461. break
  1462. case 5:
  1463. fsiOPFLD.MedChrgitmType = "08"
  1464. break
  1465. case 6:
  1466. fsiOPFLD.MedChrgitmType = "14"
  1467. break
  1468. case 7:
  1469. fsiOPFLD.MedChrgitmType = "14"
  1470. break
  1471. case 8:
  1472. fsiOPFLD.MedChrgitmType = "03"
  1473. break
  1474. case 9:
  1475. fsiOPFLD.MedChrgitmType = "14"
  1476. break
  1477. case 10:
  1478. fsiOPFLD.MedChrgitmType = "14"
  1479. break
  1480. case 11:
  1481. fsiOPFLD.MedChrgitmType = "06"
  1482. break
  1483. case 12:
  1484. fsiOPFLD.MedChrgitmType = "12"
  1485. break
  1486. case 13:
  1487. fsiOPFLD.MedChrgitmType = "01"
  1488. break
  1489. case 14:
  1490. fsiOPFLD.MedChrgitmType = "04"
  1491. break
  1492. case 15:
  1493. fsiOPFLD.MedChrgitmType = "14"
  1494. break
  1495. }
  1496. memo["hosp_appr_flag"] = "1"
  1497. memo["invoice_no"] = fapiao_code
  1498. memo["memo"] = "自费"
  1499. bytesData, _ := json.Marshal(memo)
  1500. fsiOPFLD.Memo = string(bytesData)
  1501. fsiOPFLDs = append(fsiOPFLDs, fsiOPFLD)
  1502. } else if items.HisPrescriptionProject.Type == 3 && items.HisPrescriptionProject.GoodInfo.IsUser != 1 && len(items.HisPrescriptionProject.GoodInfo.MedicalInsuranceNumber) > 0 {
  1503. fsiOPFLD.FeeOcurTime = time.Unix(items.HisPrescriptionProject.Ctime, 0).Format("2006-01-02 15:04:05")
  1504. fsiOPFLD.MedListCodg = items.HisPrescriptionProject.GoodInfo.MedicalInsuranceNumber
  1505. fsiOPFLD.MedinsListCodg = items.HisPrescriptionProject.GoodInfo.MedicalInsuranceNumber
  1506. fsiOPFLD.BilgDeptName = department.Name
  1507. fsiOPFLD.BilgDeptCodg = department.Number
  1508. fsiOPFLD.BilgDrCode = doctor.DoctorNumber
  1509. fsiOPFLD.BilgDrName = doctor.UserName
  1510. fsiOPFLD.MedinsListName = items.HisPrescriptionProject.GoodInfo.GoodName
  1511. fsiOPFLD.Prodname = items.HisPrescriptionProject.GoodInfo.GoodName
  1512. fsiOPFLD.MedChrgitmType = "08"
  1513. memo["hosp_appr_flag"] = "1"
  1514. memo["invoice_no"] = fapiao_code
  1515. memo["memo"] = "自费"
  1516. bytesData, _ := json.Marshal(memo)
  1517. fsiOPFLD.Memo = string(bytesData)
  1518. fsiOPFLDs = append(fsiOPFLDs, fsiOPFLD)
  1519. }
  1520. }
  1521. }
  1522. for _, items := range order_info_two {
  1523. memo := make(map[string]interface{})
  1524. var fsiOPFLD models.FsiOwnpayPatnFeeListDDTO
  1525. fsiOPFLD.FixmedinsMdtrtID = items.OrderNumber
  1526. fsiOPFLD.MedType = pre.MedType
  1527. fsiOPFLD.BkkpSn = items.FeedetlSn
  1528. fsiOPFLD.FixmedinsCode = miConfig.Code
  1529. fsiOPFLD.FixmedinsName = miConfig.OrgName
  1530. fsiOPFLD.Cnt = fmt.Sprintf("%.2f", items.Cnt)
  1531. fsiOPFLD.Pric = fmt.Sprintf("%.2f", items.Pric)
  1532. fsiOPFLD.DetItemFeeSumamt = fmt.Sprintf("%.2f", items.DetItemFeeSumamt)
  1533. if items.AdviceId > 0 && items.ProjectId == 0 && items.HisDoctorAdviceInfo.BaseDrugLib.IsUser != 1 && len(items.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber) > 0 {
  1534. fsiOPFLD.FeeOcurTime = time.Unix(items.HisDoctorAdviceInfo.CreatedTime, 0).Format("2006-01-02 15:04:05")
  1535. fsiOPFLD.MedListCodg = items.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber
  1536. fsiOPFLD.MedinsListCodg = items.HisDoctorAdviceInfo.BaseDrugLib.MedicalInsuranceNumber
  1537. fsiOPFLD.MedinsListName = items.HisDoctorAdviceInfo.BaseDrugLib.DrugName
  1538. fsiOPFLD.Prodname = items.HisDoctorAdviceInfo.BaseDrugLib.DrugName
  1539. fsiOPFLD.BilgDeptName = department.Name
  1540. fsiOPFLD.BilgDeptCodg = department.Number
  1541. fsiOPFLD.BilgDrCode = doctor.DoctorNumber
  1542. fsiOPFLD.BilgDrName = doctor.UserName
  1543. fsiOPFLD.MedChrgitmType = "09"
  1544. memo["hosp_appr_flag"] = "1"
  1545. memo["invoice_no"] = fapiao_code
  1546. memo["memo"] = "自费"
  1547. bytesData, _ := json.Marshal(memo)
  1548. fsiOPFLD.Memo = string(bytesData)
  1549. fsiOPFLDs = append(fsiOPFLDs, fsiOPFLD)
  1550. } else if items.AdviceId == 0 && items.ProjectId > 0 {
  1551. fsiOPFLD.BkkpSn = items.HisPrescriptionProject.FeedetlSn
  1552. if items.HisPrescriptionProject.Type == 2 && len(items.HisPrescriptionProject.HisProject.MedicalCode) > 0 {
  1553. fsiOPFLD.FeeOcurTime = time.Unix(items.HisPrescriptionProject.Ctime, 0).Format("2006-01-02 15:04:05")
  1554. fsiOPFLD.MedListCodg = items.HisPrescriptionProject.HisProject.MedicalCode
  1555. fsiOPFLD.MedinsListName = items.HisPrescriptionProject.HisProject.ProjectName
  1556. fsiOPFLD.Prodname = items.HisPrescriptionProject.HisProject.ProjectName
  1557. fsiOPFLD.MedinsListCodg = items.HisPrescriptionProject.HisProject.MedicalCode
  1558. fsiOPFLD.BilgDeptName = department.Name
  1559. fsiOPFLD.BilgDeptCodg = department.Number
  1560. fsiOPFLD.BilgDrCode = doctor.DoctorNumber
  1561. fsiOPFLD.BilgDrName = doctor.UserName
  1562. switch items.HisPrescriptionProject.HisProject.CostClassify {
  1563. case 0:
  1564. break
  1565. case 1:
  1566. fsiOPFLD.MedChrgitmType = "14"
  1567. break
  1568. case 2:
  1569. fsiOPFLD.MedChrgitmType = "05"
  1570. break
  1571. case 3:
  1572. fsiOPFLD.MedChrgitmType = "03"
  1573. break
  1574. case 4:
  1575. fsiOPFLD.MedChrgitmType = "03"
  1576. break
  1577. case 5:
  1578. fsiOPFLD.MedChrgitmType = "08"
  1579. break
  1580. case 6:
  1581. fsiOPFLD.MedChrgitmType = "14"
  1582. break
  1583. case 7:
  1584. fsiOPFLD.MedChrgitmType = "14"
  1585. break
  1586. case 8:
  1587. fsiOPFLD.MedChrgitmType = "03"
  1588. break
  1589. case 9:
  1590. fsiOPFLD.MedChrgitmType = "14"
  1591. break
  1592. case 10:
  1593. fsiOPFLD.MedChrgitmType = "14"
  1594. break
  1595. case 11:
  1596. fsiOPFLD.MedChrgitmType = "06"
  1597. break
  1598. case 12:
  1599. fsiOPFLD.MedChrgitmType = "12"
  1600. break
  1601. case 13:
  1602. fsiOPFLD.MedChrgitmType = "01"
  1603. break
  1604. case 14:
  1605. fsiOPFLD.MedChrgitmType = "04"
  1606. break
  1607. case 15:
  1608. fsiOPFLD.MedChrgitmType = "14"
  1609. break
  1610. }
  1611. memo["hosp_appr_flag"] = "1"
  1612. memo["invoice_no"] = fapiao_code
  1613. memo["memo"] = "自费"
  1614. bytesData, _ := json.Marshal(memo)
  1615. fsiOPFLD.Memo = string(bytesData)
  1616. fsiOPFLDs = append(fsiOPFLDs, fsiOPFLD)
  1617. } else if items.HisPrescriptionProject.Type == 3 && len(items.HisPrescriptionProject.GoodInfo.MedicalInsuranceNumber) > 0 && items.HisPrescriptionProject.GoodInfo.IsUser != 1 {
  1618. fsiOPFLD.FeeOcurTime = time.Unix(items.HisPrescriptionProject.Ctime, 0).Format("2006-01-02 15:04:05")
  1619. fsiOPFLD.MedListCodg = items.HisPrescriptionProject.GoodInfo.MedicalInsuranceNumber
  1620. fsiOPFLD.MedinsListCodg = items.HisPrescriptionProject.GoodInfo.MedicalInsuranceNumber
  1621. fsiOPFLD.BilgDeptName = department.Name
  1622. fsiOPFLD.BilgDeptCodg = department.Number
  1623. fsiOPFLD.BilgDrCode = doctor.DoctorNumber
  1624. fsiOPFLD.BilgDrName = doctor.UserName
  1625. fsiOPFLD.MedinsListName = items.HisPrescriptionProject.GoodInfo.GoodName
  1626. fsiOPFLD.Prodname = items.HisPrescriptionProject.GoodInfo.GoodName
  1627. fsiOPFLD.MedChrgitmType = "08"
  1628. memo["hosp_appr_flag"] = "1"
  1629. memo["invoice_no"] = fapiao_code
  1630. memo["memo"] = "自费"
  1631. bytesData, _ := json.Marshal(memo)
  1632. fsiOPFLD.Memo = string(bytesData)
  1633. fsiOPFLDs = append(fsiOPFLDs, fsiOPFLD)
  1634. }
  1635. }
  1636. }
  1637. fmt.Println(fsiOPFLDs)
  1638. struct4201A.Fopfd = fsiOPFLDs
  1639. fmt.Println(struct4201A.Fopfd)
  1640. var struct4202 models.Struct4202
  1641. timeLayout := "2006-01-02 15:04:05"
  1642. dataTimeStr := time.Unix(his.Ctime, 0).Format(timeLayout)
  1643. struct4202.OwnPayPatnMdtrtD.FixmedinsMdtrtID = his.Number
  1644. struct4202.OwnPayPatnMdtrtD.FixmedinsCode = miConfig.Code
  1645. struct4202.OwnPayPatnMdtrtD.FixmedinsName = miConfig.OrgName
  1646. struct4202.OwnPayPatnMdtrtD.PsnCertType = "01"
  1647. struct4202.OwnPayPatnMdtrtD.Certno = his.IdCardNo
  1648. struct4202.OwnPayPatnMdtrtD.PsnName = his.Name
  1649. struct4202.OwnPayPatnMdtrtD.Begntime = dataTimeStr
  1650. struct4202.OwnPayPatnMdtrtD.MedType = pre.MedType
  1651. struct4202.OwnPayPatnMdtrtD.ValiFlag = "1"
  1652. struct4202.OwnPayPatnMdtrtD.MedfeeSumamt = fmt.Sprintf("%.2f", order.MedfeeSumamt)
  1653. diagnosis_ids := strings.Split(his.Diagnosis, ",")
  1654. var config []*models.HisXtDiagnoseConfig
  1655. for _, item := range diagnosis_ids {
  1656. id, _ := strconv.ParseInt(item, 10, 64)
  1657. diagnosisConfig, _ := service.FindDiagnoseById(id)
  1658. config = append(config, &diagnosisConfig)
  1659. }
  1660. var tempDiaginfos []models.OwnPayPatnDiagListD
  1661. for index, item := range config {
  1662. if index == 0 {
  1663. var tempDiaginfo models.OwnPayPatnDiagListD
  1664. tempDiaginfo.InoutDiagType = "1"
  1665. tempDiaginfo.DiagCode = item.CountryCode
  1666. tempDiaginfo.DiagName = item.CountryContentName
  1667. tempDiaginfo.DiagType = "1"
  1668. tempDiaginfo.DiagSrtNo = "1"
  1669. tempDiaginfo.MaindiagFlag = "1"
  1670. tempDiaginfo.ValiFlag = "1"
  1671. tempDiaginfo.DiagDrName = doctor.UserName
  1672. tempDiaginfo.DiagDrCode = doctor.DoctorNumber
  1673. tempDiaginfo.DiagTime = time.Unix(pre.Ctime, 0).Format("2006-01-02 15:04:05")
  1674. tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  1675. } else {
  1676. var tempDiaginfo models.OwnPayPatnDiagListD
  1677. tempDiaginfo.DiagCode = item.CountryCode
  1678. tempDiaginfo.DiagName = item.CountryContentName
  1679. tempDiaginfo.DiagType = "2"
  1680. tempDiaginfo.DiagSrtNo = strconv.FormatInt(int64(index+1), 10)
  1681. tempDiaginfo.MaindiagFlag = "0"
  1682. tempDiaginfo.ValiFlag = "1"
  1683. tempDiaginfo.DiagDrName = doctor.UserName
  1684. tempDiaginfo.DiagDrCode = doctor.DoctorNumber
  1685. tempDiaginfo.DiagTime = time.Unix(pre.Ctime, 0).Format("2006-01-02 15:04:05")
  1686. tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  1687. }
  1688. }
  1689. struct4202.ODiagListD = tempDiaginfos
  1690. result, requestLog := service.Gdyb4205(miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, struct4202, struct4201A)
  1691. saveLog(result, requestLog, "4205", "自费就诊和诊断信息上传")
  1692. var res2 ResultSix
  1693. var respJSON2 map[string]interface{}
  1694. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  1695. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  1696. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1697. return
  1698. }
  1699. userJSONBytes2, _ := json.Marshal(respJSON2)
  1700. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  1701. utils.ErrorLog("解析失败:%v", err)
  1702. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1703. return
  1704. }
  1705. if res2.Infcode != 0 {
  1706. c.ServeSuccessJSON(map[string]interface{}{
  1707. "failed_code": -10,
  1708. "msg": res2.ErrMsg,
  1709. })
  1710. return
  1711. } else {
  1712. order.IsUploadDiagnose = 1
  1713. order.IsUploadOrderInfo = 1
  1714. service.UpdateOrderTwo(order)
  1715. c.ServeSuccessJSON(map[string]interface{}{
  1716. "msg": "上传成功",
  1717. })
  1718. }
  1719. }
  1720. func (c *HisApiController) Get4207() {
  1721. admin_user_id, _ := c.GetInt64("admin_user_id")
  1722. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  1723. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  1724. order_id, _ := c.GetInt64("order_id")
  1725. order, _ := service.GetHisOrderByIDTwo(order_id)
  1726. //his, _ := service.GetInHospitalRecordByNumber(order.MdtrtId)
  1727. var struct4207 models.Struct4207
  1728. struct4207.PageNum = "1"
  1729. struct4207.PageSize = "1000"
  1730. struct4207.FixmedinsCode = miConfig.Code
  1731. struct4207.FixmedinsMdtrtID = order.Number
  1732. result, requestLog := service.Gdyb4207(miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, struct4207)
  1733. saveLog(result, requestLog, "4207", "查询")
  1734. var res2 ResultSix
  1735. var respJSON2 map[string]interface{}
  1736. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  1737. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  1738. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1739. return
  1740. }
  1741. userJSONBytes2, _ := json.Marshal(respJSON2)
  1742. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  1743. utils.ErrorLog("解析失败:%v", err)
  1744. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1745. return
  1746. }
  1747. if res2.Infcode != 0 {
  1748. c.ServeSuccessJSON(map[string]interface{}{
  1749. "failed_code": -10,
  1750. "msg": res2.ErrMsg,
  1751. })
  1752. return
  1753. } else {
  1754. c.ServeSuccessJSON(map[string]interface{}{
  1755. "msg": "查询成功",
  1756. })
  1757. }
  1758. }
  1759. func (c *HisApiController) Get4208() {
  1760. admin_user_id, _ := c.GetInt64("admin_user_id")
  1761. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  1762. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  1763. order_id, _ := c.GetInt64("order_id")
  1764. order, _ := service.GetHisOrderByIDTwo(order_id)
  1765. his, _ := service.GetInHospitalRecordByNumber(order.MdtrtId)
  1766. var struct4208 models.Struct4208
  1767. struct4208.PageNum = "1"
  1768. struct4208.PageSize = "1000"
  1769. struct4208.PsnCertType = "01"
  1770. struct4208.Certno = his.Certno
  1771. struct4208.MedType = order.MedType
  1772. struct4208.PsnName = his.Name
  1773. result, requestLog := service.Gdyb4208(miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, struct4208)
  1774. saveLog(result, requestLog, "4208", "查询")
  1775. var res2 ResultSix
  1776. var respJSON2 map[string]interface{}
  1777. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  1778. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  1779. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1780. return
  1781. }
  1782. userJSONBytes2, _ := json.Marshal(respJSON2)
  1783. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  1784. utils.ErrorLog("解析失败:%v", err)
  1785. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1786. return
  1787. }
  1788. if res2.Infcode != 0 {
  1789. c.ServeSuccessJSON(map[string]interface{}{
  1790. "failed_code": -10,
  1791. "msg": res2.ErrMsg,
  1792. })
  1793. return
  1794. } else {
  1795. c.ServeSuccessJSON(map[string]interface{}{
  1796. "msg": "查询成功",
  1797. })
  1798. }
  1799. }
  1800. func (c *HisApiController) Get4209() {
  1801. admin_user_id, _ := c.GetInt64("admin_user_id")
  1802. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  1803. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  1804. order_id, _ := c.GetInt64("order_id")
  1805. order, _ := service.GetHisOrderByIDTwo(order_id)
  1806. //his, _ := service.GetInHospitalRecordByNumber(order.MdtrtId)
  1807. var struct4209 models.Struct4209
  1808. struct4209.FixmedinsMdtrtID = order.Number
  1809. struct4209.FixmedinsCode = miConfig.Code
  1810. struct4209.PageSize = "1000"
  1811. struct4209.PageNum = "1"
  1812. result, requestLog := service.Gdyb4209(miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, struct4209)
  1813. saveLog(result, requestLog, "4209", "查询")
  1814. var res2 ResultSix
  1815. var respJSON2 map[string]interface{}
  1816. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  1817. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  1818. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1819. return
  1820. }
  1821. userJSONBytes2, _ := json.Marshal(respJSON2)
  1822. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  1823. utils.ErrorLog("解析失败:%v", err)
  1824. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1825. return
  1826. }
  1827. if res2.Infcode != 0 {
  1828. c.ServeSuccessJSON(map[string]interface{}{
  1829. "failed_code": -10,
  1830. "msg": res2.ErrMsg,
  1831. })
  1832. return
  1833. } else {
  1834. c.ServeSuccessJSON(map[string]interface{}{
  1835. "msg": "查询成功",
  1836. })
  1837. }
  1838. }
  1839. type Result3101 struct {
  1840. Infcode string `json:"infcode"`
  1841. InfRefmsgid string `json:"inf_refmsgid"`
  1842. RefmsgTime string `json:"refmsg_time"`
  1843. RespondTime string `json:"respond_time"`
  1844. Enctype string `json:"enctype"`
  1845. Signtype string `json:"signtype"`
  1846. ErrMsg string `json:"err_msg"`
  1847. Output struct {
  1848. Result []struct {
  1849. JudgeResultDetailDtos []struct {
  1850. VolaItemType string `json:"vola_item_type"`
  1851. MdtrtID string `json:"mdtrt_id"`
  1852. JrdID string `json:"jrd_id"`
  1853. PatnID string `json:"patn_id"`
  1854. RxID string `json:"rx_id"`
  1855. VolaAmt interface{} `json:"vola_amt"`
  1856. } `json:"judge_result_detail_dtos"`
  1857. RuleID string `json:"rule_id"`
  1858. VolaEvid string `json:"vola_evid"`
  1859. MdtrtID string `json:"mdtrt_id"`
  1860. RuleName string `json:"rule_name"`
  1861. VolaAmtStas string `json:"vola_amt_stas"`
  1862. JrID string `json:"jr_id"`
  1863. PatnID string `json:"patn_id"`
  1864. SevDeg string `json:"sev_deg"`
  1865. VolaAmt float64 `json:"vola_amt"`
  1866. VolaBhvrType string `json:"vola_bhvr_type"`
  1867. VolaCont string `json:"vola_cont"`
  1868. } `json:"result"`
  1869. } `json:"output"`
  1870. }
  1871. func (c *HisApiController) ReadEleToken() {
  1872. admin_user_id, _ := c.GetInt64("admin_user_id")
  1873. his_patient_id, _ := c.GetInt64("his_patient_id")
  1874. adminUser := c.GetAdminUserInfo()
  1875. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  1876. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  1877. his, _ := service.GetNewHisPatientInfoFour(c.GetAdminUserInfo().CurrentOrgId, his_patient_id)
  1878. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  1879. tokens := ReadEleCard(admin_user_id, c.GetAdminUserInfo().CurrentOrgId, c)
  1880. if len(tokens) > 0 {
  1881. c.ServeSuccessJSON(map[string]interface{}{
  1882. "msg": "读取成功",
  1883. })
  1884. } else {
  1885. c.ServeSuccessJSON(map[string]interface{}{
  1886. "failed_code": -10,
  1887. "msg": "读取失败",
  1888. })
  1889. }
  1890. } else if miConfig.MdtrtareaAdmvs == "350500" {
  1891. _, outPutInfo, errMsg := service.ReadEleCardForSettle(miConfig.Code, roles.UserName, roles.AdminUserId)
  1892. if len(errMsg) == 0 {
  1893. type ELeData struct {
  1894. Data struct {
  1895. IdNo string `json:"idNo"`
  1896. IdType string `json:"idType"`
  1897. UserName string `json:"userName"`
  1898. EcToken string `json:"ecToken"`
  1899. InsuOrg string `json:"insuOrg"`
  1900. Gender string `json:"gender"`
  1901. Birthday string `json:"birthday"`
  1902. Nationality string `json:"nationality"`
  1903. Email string `json:"email"`
  1904. Extra string `json:"extra"`
  1905. } `json:"data"`
  1906. Code int `json:"code"`
  1907. Message string `json:"message"`
  1908. }
  1909. var ele ELeData
  1910. err := json.Unmarshal([]byte(outPutInfo), &ele)
  1911. if err != nil {
  1912. utils.ErrorLog("解析失败:%v", err)
  1913. }
  1914. token := ele.Data.EcToken
  1915. if len(token) > 0 {
  1916. psn := &models.HisPsn{
  1917. PsnNo: his.PsnNo,
  1918. Age: 0,
  1919. PatientId: his.PatientId,
  1920. Certno: his.Certno,
  1921. Brdy: his.Brdy,
  1922. Gend: his.Gend,
  1923. Naty: his.Naty,
  1924. PsnCertType: his.PsnCertType,
  1925. PsnName: his.PsnName,
  1926. Idetinfo: his.Idetinfo,
  1927. Insuinfo: his.Iinfo,
  1928. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  1929. CardInfo: outPutInfo,
  1930. VerifyNumber: token,
  1931. }
  1932. service.CreateHisPsn(psn)
  1933. }
  1934. if len(token) > 0 {
  1935. c.ServeSuccessJSON(map[string]interface{}{
  1936. "msg": "读取成功",
  1937. })
  1938. } else {
  1939. c.ServeSuccessJSON(map[string]interface{}{
  1940. "failed_code": -10,
  1941. "msg": "读取失败",
  1942. })
  1943. }
  1944. }
  1945. } else if miConfig.MdtrtareaAdmvs == "360399" {
  1946. if initFlag == 0 {
  1947. c.TestGetJiangXiBasBaseInit()
  1948. }
  1949. json_result := GetJxEleBaseInfo(c.GetAdminUserInfo().CurrentOrgId)
  1950. type ELeData struct {
  1951. Data struct {
  1952. IdNo string `json:"idNo"`
  1953. IdType string `json:"idType"`
  1954. UserName string `json:"userName"`
  1955. EcToken string `json:"ecToken"`
  1956. InsuOrg string `json:"insuOrg"`
  1957. Gender string `json:"gender"`
  1958. Birthday string `json:"birthday"`
  1959. Nationality string `json:"nationality"`
  1960. Email string `json:"email"`
  1961. Extra string `json:"extra"`
  1962. } `json:"data"`
  1963. Code int `json:"code"`
  1964. Message string `json:"message"`
  1965. }
  1966. var ele ELeData
  1967. err := json.Unmarshal([]byte(json_result), &ele)
  1968. if err != nil {
  1969. utils.ErrorLog("解析失败:%v", err)
  1970. }
  1971. token := ele.Data.EcToken
  1972. token = Remove0000(token)
  1973. fmt.Println(ele.Data.UserName)
  1974. 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)
  1975. saveLog(result2, requestLog2, "1101", "获取人员信息")
  1976. var res ResultTwo
  1977. if err := json.Unmarshal([]byte(result2), &res); err != nil {
  1978. utils.ErrorLog("解析失败:%v", err)
  1979. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1980. return
  1981. }
  1982. if res.Infcode == 0 {
  1983. patient, err := service.GetPatientByNumber(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  1984. if err == gorm.ErrRecordNotFound {
  1985. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  1986. return
  1987. } else if err != nil {
  1988. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  1989. return
  1990. } else {
  1991. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  1992. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  1993. infoStr := string(Iinfos)
  1994. idetinfoStr := string(Idetinfos)
  1995. psn := &models.HisPsn{
  1996. PsnNo: res.Output.Baseinfo.PsnNo,
  1997. Age: res.Output.Baseinfo.Age,
  1998. PatientId: patient.ID,
  1999. Certno: res.Output.Baseinfo.Certno,
  2000. Brdy: res.Output.Baseinfo.Brdy,
  2001. Gend: res.Output.Baseinfo.Gend,
  2002. Naty: res.Output.Baseinfo.Naty,
  2003. PsnCertType: res.Output.Baseinfo.PsnCertType,
  2004. PsnName: res.Output.Baseinfo.PsnName,
  2005. Idetinfo: idetinfoStr,
  2006. Insuinfo: infoStr,
  2007. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  2008. CardInfo: "",
  2009. VerifyNumber: token,
  2010. }
  2011. service.CreateHisPsn(psn)
  2012. c.ServeSuccessJSON(map[string]interface{}{
  2013. "patient": patient,
  2014. "number": token,
  2015. })
  2016. }
  2017. } else {
  2018. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  2019. return
  2020. }
  2021. } else if miConfig.MdtrtareaAdmvs == "430800" {
  2022. idNo := c.GetString("idNo")
  2023. userName := c.GetString("userName")
  2024. ecToken := c.GetString("ecToken")
  2025. insuOrg := c.GetString("insuOrg")
  2026. result2, requestLog2 := service.Hnyb1101ForEleCert(miConfig.OrgName, roles.UserName, miConfig.Code, insuOrg, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, miConfig.Url, miConfig.AccessKey, ecToken, "", idNo, userName)
  2027. saveLog(result2, requestLog2, "1101", "获取人员信息")
  2028. var res ResultTwo
  2029. if err := json.Unmarshal([]byte(result2), &res); err != nil {
  2030. utils.ErrorLog("解析失败:%v", err)
  2031. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2032. return
  2033. }
  2034. if res.Infcode == 0 {
  2035. patient, err := service.GetPatientByNumber(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  2036. if err == gorm.ErrRecordNotFound {
  2037. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  2038. return
  2039. } else if err != nil {
  2040. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  2041. return
  2042. } else {
  2043. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  2044. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  2045. infoStr := string(Iinfos)
  2046. idetinfoStr := string(Idetinfos)
  2047. psn := &models.HisPsn{
  2048. PsnNo: res.Output.Baseinfo.PsnNo,
  2049. Age: res.Output.Baseinfo.Age,
  2050. PatientId: patient.ID,
  2051. Certno: res.Output.Baseinfo.Certno,
  2052. Brdy: res.Output.Baseinfo.Brdy,
  2053. Gend: res.Output.Baseinfo.Gend,
  2054. Naty: res.Output.Baseinfo.Naty,
  2055. PsnCertType: res.Output.Baseinfo.PsnCertType,
  2056. PsnName: res.Output.Baseinfo.PsnName,
  2057. Idetinfo: idetinfoStr,
  2058. Insuinfo: infoStr,
  2059. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  2060. CardInfo: "",
  2061. VerifyNumber: ecToken,
  2062. InsuplcAdmdvs: insuOrg,
  2063. }
  2064. service.CreateHisPsn(psn)
  2065. c.ServeSuccessJSON(map[string]interface{}{
  2066. "patient": patient,
  2067. "number": ecToken,
  2068. })
  2069. }
  2070. } else {
  2071. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  2072. return
  2073. }
  2074. } else {
  2075. //if initFlag == 0 {
  2076. // c.TestGetBasBaseInit()
  2077. //}
  2078. //token := c.GetEleBaseInfo()
  2079. //token = Remove0000(token)
  2080. type ELeData struct {
  2081. Code string `json:"code"`
  2082. Data struct {
  2083. Aac002 string `json:"aac002"`
  2084. Aaz500 string `json:"aaz500"`
  2085. ActCardNo string `json:"actCardNo"`
  2086. Bab520 string `json:"bab520"`
  2087. Bkz543 string `json:"bkz543"`
  2088. BusinessType string `json:"businessType"`
  2089. CertfCodg string `json:"certfCodg"`
  2090. EcIndexNo string `json:"ecIndexNo"`
  2091. EcToken string `json:"ecToken"`
  2092. ID0000 string `json:"id0000"`
  2093. IDNo string `json:"idNo"`
  2094. IDType string `json:"idType"`
  2095. Idcode string `json:"idcode"`
  2096. IdentityToken string `json:"identity_token"`
  2097. InsuOrg string `json:"insuOrg"`
  2098. OfficeID string `json:"officeId"`
  2099. OfficeName string `json:"officeName"`
  2100. OperatorID string `json:"operatorId"`
  2101. OperatorName string `json:"operatorName"`
  2102. OrgID string `json:"orgId"`
  2103. UserName string `json:"userName"`
  2104. } `json:"data"`
  2105. Infno interface{} `json:"infno"`
  2106. Message string `json:"message"`
  2107. OrgID string `json:"orgId"`
  2108. TransType string `json:"transType"`
  2109. }
  2110. _, result := GetELeInfoThree(miConfig.Code, "1", roles.UserName)
  2111. fmt.Println(result)
  2112. outPutInfo := Remove0000(result)
  2113. fmt.Println(outPutInfo)
  2114. var ele ELeData
  2115. err := json.Unmarshal([]byte(outPutInfo), &ele)
  2116. if err != nil {
  2117. utils.ErrorLog("解析失败:%v", err)
  2118. }
  2119. token := ele.Data.EcToken
  2120. if len(token) > 0 {
  2121. result2, requestLog2 := service.Gdyb1101ForEleCerttwo(miConfig.OrgName, roles.UserName, miConfig.Code, ele.Data.InsuOrg, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, token, ele.Data.UserName, ele.Data.IDNo)
  2122. saveLog(result2, requestLog2, "1101", "获取人员信息")
  2123. var res ResultTwo
  2124. if err := json.Unmarshal([]byte(result2), &res); err != nil {
  2125. utils.ErrorLog("解析失败:%v", err)
  2126. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2127. return
  2128. }
  2129. if res.Infcode == 0 {
  2130. patient, err := service.GetPatientByNumber(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  2131. if err == gorm.ErrRecordNotFound {
  2132. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  2133. return
  2134. } else if err != nil {
  2135. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  2136. return
  2137. } else {
  2138. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  2139. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  2140. infoStr := string(Iinfos)
  2141. idetinfoStr := string(Idetinfos)
  2142. psn := &models.HisPsn{
  2143. PsnNo: res.Output.Baseinfo.PsnNo,
  2144. Age: res.Output.Baseinfo.Age,
  2145. PatientId: patient.ID,
  2146. Certno: res.Output.Baseinfo.Certno,
  2147. Brdy: res.Output.Baseinfo.Brdy,
  2148. Gend: res.Output.Baseinfo.Gend,
  2149. Naty: res.Output.Baseinfo.Naty,
  2150. PsnCertType: res.Output.Baseinfo.PsnCertType,
  2151. PsnName: res.Output.Baseinfo.PsnName,
  2152. Idetinfo: idetinfoStr,
  2153. Insuinfo: infoStr,
  2154. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  2155. CardInfo: "",
  2156. VerifyNumber: token,
  2157. }
  2158. service.CreateHisPsn(psn)
  2159. c.ServeSuccessJSON(map[string]interface{}{
  2160. "msg": "读取成功",
  2161. })
  2162. }
  2163. } else {
  2164. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  2165. return
  2166. }
  2167. } else {
  2168. c.ServeSuccessJSON(map[string]interface{}{
  2169. "failed_code": -10,
  2170. "msg": "读取失败",
  2171. })
  2172. }
  2173. }
  2174. }
  2175. func (c *HisApiController) Get9001() {
  2176. adminUser := c.GetAdminUserInfo()
  2177. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  2178. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, 185)
  2179. if miConfig.MdtrtareaAdmvs == "350500" {
  2180. service.GetFjAuthorizationInfo(miConfig.Code)
  2181. } else if miConfig.MdtrtareaAdmvs == "131023" {
  2182. result, _ := service.HeBeiyb9001(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, 1669)
  2183. var dat map[string]interface{}
  2184. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  2185. fmt.Println(dat)
  2186. } else {
  2187. fmt.Println(err)
  2188. }
  2189. userJSONBytes, _ := json.Marshal(dat)
  2190. var res models.Result9001
  2191. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  2192. utils.ErrorLog("解析失败:%v", err)
  2193. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2194. return
  2195. }
  2196. } else {
  2197. result, _ := service.Gdyb9001(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, 1669)
  2198. var dat map[string]interface{}
  2199. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  2200. fmt.Println(dat)
  2201. } else {
  2202. fmt.Println(err)
  2203. }
  2204. userJSONBytes, _ := json.Marshal(dat)
  2205. var res models.Result9001
  2206. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  2207. utils.ErrorLog("解析失败:%v", err)
  2208. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2209. return
  2210. }
  2211. }
  2212. }
  2213. 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) {
  2214. var res Result3101
  2215. adminUser := c.GetAdminUserInfo()
  2216. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  2217. //his, _ := service.GetNewHisPatientInfoFour(c.GetAdminUserInfo().CurrentOrgId, his_patient_id)
  2218. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  2219. //record_time := c.GetString("record_time")
  2220. //trig_scen := c.GetString("trig_scen")
  2221. timeLayout := "2006-01-02"
  2222. loc, _ := time.LoadLocation("Local")
  2223. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  2224. if err != nil {
  2225. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  2226. return res
  2227. }
  2228. recordDateTime := theTime.Unix()
  2229. var patientPrescription models.HisPrescriptionInfo
  2230. //patientPrescription, _ = service.FindHisPatientPrescriptionInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  2231. //if patientPrescription.ID == 0 {
  2232. patientPrescription, _ = service.FindLastPatientPrescriptionInfoTwo(adminUser.CurrentOrgId, patient_id, recordDateTime)
  2233. //}
  2234. department, _ := service.GetDepartMentDetail(patientPrescription.Departments)
  2235. doctor_info, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, patientPrescription.DoctorId)
  2236. //
  2237. diagnosis_ids := strings.Split(patientPrescription.Diagnosis, ",")
  2238. //prescriptions, _ := service.GetNewHisPrescriptionTen(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  2239. var pp models.PublicParams
  2240. pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  2241. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  2242. pp.FixmedinsName = miConfig.OrgName
  2243. pp.FixmedinsCode = miConfig.Code
  2244. pp.RequestUrl = miConfig.Url
  2245. pp.Cainfo = miConfig.Cainfo
  2246. pp.SecretKey = miConfig.SecretKey
  2247. pp.AccessKey = miConfig.AccessKey
  2248. pp.OpterName = roles.UserName
  2249. var config []*models.HisXtDiagnoseConfig
  2250. for _, item := range diagnosis_ids {
  2251. id, _ := strconv.ParseInt(item, 10, 64)
  2252. diagnosisConfig, _ := service.FindDiagnoseById(id)
  2253. config = append(config, &diagnosisConfig)
  2254. }
  2255. var pd models.PatientDtos
  2256. pd.PatnID = his.PsnNo
  2257. pd.PatnName = his.Name
  2258. pd.Gend = his.Gend
  2259. pd.Brdy = his.Brdy
  2260. pd.Poolarea = miConfig.MdtrtareaAdmvs
  2261. pd.CurrMdtrtID = his.Number
  2262. var fed models.FsiEncounterDtos
  2263. fed.MdtrtID = his.Number
  2264. fed.MedinsID = miConfig.Code
  2265. fed.MedinsName = miConfig.OrgName
  2266. fed.MedinsAdmdvs = miConfig.MdtrtareaAdmvs
  2267. fed.MedMdtrtType = "1"
  2268. fed.MedinsType = "1"
  2269. fed.MedinsLv = "11"
  2270. tm := time.Unix(his.RecordDate, 0)
  2271. s_tm := tm.Format("2006-01-02 15:04:05")
  2272. fed.AdmDate = s_tm
  2273. fed.DscgDate = s_tm
  2274. fed.DscgMainDiseCodg = config[0].CountryCode
  2275. fed.DscgMainDiseName = config[0].CountryContentName
  2276. //诊断信息
  2277. var fdds []*models.FsiDiagnoseDtos
  2278. for index, item := range config {
  2279. if index == 0 {
  2280. var fdd models.FsiDiagnoseDtos
  2281. fdd.DiseID = strconv.FormatInt(item.ID, 10)
  2282. fdd.InoutDiseType = "1"
  2283. fdd.MaindiseFlag = "1"
  2284. fdd.DiseDate = s_tm
  2285. fdd.DiasSrtNo = "1"
  2286. fdd.DiseName = item.CountryContentName
  2287. fdd.DiseCodg = item.CountryCode
  2288. fdds = append(fdds, &fdd)
  2289. } else {
  2290. var fdd models.FsiDiagnoseDtos
  2291. fdd.DiseID = strconv.FormatInt(item.ID, 10)
  2292. fdd.InoutDiseType = "1"
  2293. fdd.MaindiseFlag = "1"
  2294. fdd.DiseDate = s_tm
  2295. fdd.DiasSrtNo = strconv.FormatInt(int64(index), 10)
  2296. fdd.DiseName = item.CountryContentName
  2297. fdd.DiseCodg = item.CountryCode
  2298. fdds = append(fdds, &fdd)
  2299. }
  2300. }
  2301. fed.DrCodg = strconv.FormatInt(doctor_info.ID, 10)
  2302. fed.AdmDeptCodg = strconv.FormatInt(department.ID, 10)
  2303. fed.AdmDeptName = department.Name
  2304. fed.DscgDeptCodg = strconv.FormatInt(department.ID, 10)
  2305. fed.DscgDeptName = department.Name
  2306. fed.MedMdtrtType = "1"
  2307. fed.MedType = "11"
  2308. //if his.Insutype == "390" {
  2309. // fed.MedType = "1402"
  2310. //} else {
  2311. // fed.MedType = "9933"
  2312. //}
  2313. var orders []*models.FsiOrderDtos
  2314. if trig_scen == "2" {
  2315. //处方医嘱信息
  2316. for _, item := range prescriptions {
  2317. for _, subItem := range item.HisDoctorAdviceInfo {
  2318. var order models.FsiOrderDtos
  2319. order.RxID = strconv.FormatInt(item.ID, 10)
  2320. order.Rxno = strconv.FormatInt(item.ID, 10)
  2321. order.LongDrordFlag = "0"
  2322. order.HilistType = "1"
  2323. order.ChrgType = "1"
  2324. order.DrordBhvr = "-"
  2325. order.HilistCode = subItem.BaseDrugLib.MedicalInsuranceNumber
  2326. order.HosplistName = subItem.BaseDrugLib.DrugName
  2327. order.HilistLv = "1"
  2328. order.HilistPric = fmt.Sprintf("%.2f", subItem.Price)
  2329. order.HosplistCode = subItem.BaseDrugLib.MedicalInsuranceNumber
  2330. order.HosplistName = subItem.BaseDrugLib.DrugName
  2331. order.Cnt = fmt.Sprintf("%.2f", subItem.PrescribingNumber)
  2332. order.Pric = fmt.Sprintf("%.2f", subItem.Price)
  2333. order.Sumamt = fmt.Sprintf("%.2f", (subItem.PrescribingNumber * subItem.Price))
  2334. order.OwnpayAmt = ""
  2335. order.SelfpayAmt = ""
  2336. order.Spec = ""
  2337. order.SpecUnt = ""
  2338. order.DrordBegnDate = s_tm
  2339. order.DrordStopDate = ""
  2340. order.DrordDrCodg = "1"
  2341. order.DrordDeptName = department.Name
  2342. order.DrordDrCodg = "1"
  2343. order.DrordDrName = doctor_info.UserName
  2344. order.DrordDrProfttl = ""
  2345. order.CurrDrordFlag = "1"
  2346. orders = append(orders, &order)
  2347. }
  2348. for _, subItem := range item.HisPrescriptionProject {
  2349. if subItem.Type == 2 {
  2350. var order models.FsiOrderDtos
  2351. order.RxID = strconv.FormatInt(item.ID, 10)
  2352. order.Rxno = strconv.FormatInt(item.ID, 10)
  2353. order.LongDrordFlag = "0"
  2354. order.HilistType = "1"
  2355. order.ChrgType = "1"
  2356. order.DrordBhvr = "-"
  2357. order.HilistCode = subItem.HisProject.MedicalCode
  2358. order.HosplistName = subItem.HisProject.ProjectName
  2359. order.HilistLv = "1"
  2360. order.HilistPric = fmt.Sprintf("%.2f", subItem.Price)
  2361. order.HosplistCode = subItem.HisProject.MedicalCode
  2362. order.HosplistName = subItem.HisProject.ProjectName
  2363. order.Cnt = subItem.Count
  2364. cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  2365. order.Pric = fmt.Sprintf("%.2f", subItem.Price)
  2366. order.Sumamt = fmt.Sprintf("%.2f", subItem.Price*cnt)
  2367. order.OwnpayAmt = ""
  2368. order.SelfpayAmt = ""
  2369. order.Spec = ""
  2370. order.SpecUnt = ""
  2371. order.DrordBegnDate = s_tm
  2372. order.DrordStopDate = ""
  2373. order.DrordDrCodg = "1"
  2374. order.DrordDeptName = department.Name
  2375. order.DrordDrCodg = "1"
  2376. order.DrordDrName = doctor_info.UserName
  2377. order.DrordDrProfttl = ""
  2378. order.CurrDrordFlag = "1"
  2379. orders = append(orders, &order)
  2380. }
  2381. if subItem.Type == 3 {
  2382. var order models.FsiOrderDtos
  2383. order.RxID = strconv.FormatInt(item.ID, 10)
  2384. order.Rxno = strconv.FormatInt(item.ID, 10)
  2385. order.LongDrordFlag = "0"
  2386. order.HilistType = "1"
  2387. order.ChrgType = "1"
  2388. order.DrordBhvr = "-"
  2389. order.HilistCode = subItem.GoodInfo.MedicalInsuranceNumber
  2390. order.HosplistName = subItem.GoodInfo.GoodName
  2391. order.HilistLv = "1"
  2392. order.HilistPric = fmt.Sprintf("%.2f", subItem.Price)
  2393. order.HosplistCode = subItem.GoodInfo.MedicalInsuranceNumber
  2394. order.HosplistName = subItem.GoodInfo.GoodName
  2395. order.Cnt = subItem.Count
  2396. cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  2397. order.Pric = fmt.Sprintf("%.2f", subItem.Price)
  2398. order.Sumamt = fmt.Sprintf("%.2f", subItem.Price*cnt)
  2399. order.OwnpayAmt = ""
  2400. order.SelfpayAmt = ""
  2401. order.Spec = ""
  2402. order.SpecUnt = ""
  2403. order.DrordBegnDate = s_tm
  2404. order.DrordStopDate = ""
  2405. order.DrordDrCodg = "1"
  2406. order.DrordDeptName = department.Name
  2407. order.DrordDrCodg = "1"
  2408. order.DrordDrName = doctor_info.UserName
  2409. order.DrordDrProfttl = ""
  2410. order.CurrDrordFlag = "1"
  2411. orders = append(orders, &order)
  2412. }
  2413. }
  2414. }
  2415. //处方医嘱信息
  2416. }
  2417. fed.MatnStas = "0"
  2418. fed.MedfeeSumamt = "0"
  2419. fed.OwnpayAmt = "0"
  2420. fed.SelfpayAmt = "0"
  2421. fed.AcctPayamt = "0"
  2422. fed.MaAmt = "0"
  2423. fed.HifpPayamt = "0"
  2424. fed.SetlTotlnum = "1"
  2425. fed.Insutype = his.Insutype
  2426. fed.ReimFlag = "0"
  2427. fed.OutSetlFlag = "0"
  2428. var fopd []*models.FsiOperationDtosData
  2429. data := make(map[string]interface{})
  2430. data["fed"] = fed
  2431. data["fdd"] = fdds
  2432. data["fod"] = orders
  2433. data["pd"] = pd
  2434. data["pp"] = pp
  2435. data["fopd"] = fopd
  2436. data["trig_scen"] = trig_scen
  2437. fmt.Println(data)
  2438. fmt.Println(fed)
  2439. fmt.Println(fdds)
  2440. fmt.Println(orders)
  2441. fmt.Println(pd)
  2442. fmt.Println(pp)
  2443. fmt.Println(fopd)
  2444. client := &http.Client{}
  2445. bytesData, _ := json.Marshal(data)
  2446. var req *http.Request
  2447. if miConfig.MdtrtareaAdmvs == "320921" {
  2448. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3101", bytes.NewReader(bytesData))
  2449. } else {
  2450. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3101", bytes.NewReader(bytesData))
  2451. }
  2452. resp, _ := client.Do(req)
  2453. defer resp.Body.Close()
  2454. body, ioErr := ioutil.ReadAll(resp.Body)
  2455. if ioErr != nil {
  2456. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  2457. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2458. return res
  2459. }
  2460. var respJSON map[string]interface{}
  2461. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  2462. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  2463. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2464. return res
  2465. }
  2466. respJSON = respJSON["data"].(map[string]interface{})["request_log"].(map[string]interface{})
  2467. fmt.Println(respJSON)
  2468. result, _ := json.Marshal(respJSON)
  2469. fmt.Println(result)
  2470. if err := json.Unmarshal([]byte(result), &res); err != nil {
  2471. utils.ErrorLog("解析失败:%v", err)
  2472. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2473. return res
  2474. }
  2475. return res
  2476. }
  2477. 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) {
  2478. adminUser := c.GetAdminUserInfo()
  2479. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  2480. his, _ := service.GetNewHisPatientInfoFour(c.GetAdminUserInfo().CurrentOrgId, his_patient_id)
  2481. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  2482. //record_time := c.GetString("record_time")
  2483. //trig_scen := c.GetString("trig_scen")
  2484. timeLayout := "2006-01-02"
  2485. loc, _ := time.LoadLocation("Local")
  2486. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  2487. if err != nil {
  2488. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  2489. return res
  2490. }
  2491. recordDateTime := theTime.Unix()
  2492. var patientPrescription models.HisPrescriptionInfo
  2493. patientPrescription, _ = service.FindHisPatientPrescriptionInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  2494. if patientPrescription.ID == 0 {
  2495. patientPrescription, _ = service.FindLastPatientPrescriptionInfo(adminUser.CurrentOrgId, patient_id, recordDateTime)
  2496. }
  2497. department, _ := service.GetDepartMentDetail(patientPrescription.Departments)
  2498. doctor_info, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, patientPrescription.DoctorId)
  2499. //
  2500. diagnosis_ids := strings.Split(patientPrescription.Diagnosis, ",")
  2501. //prescriptions, _ := service.GetNewHisPrescriptionTen(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  2502. var pp models.PublicParams
  2503. pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  2504. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  2505. pp.FixmedinsName = miConfig.OrgName
  2506. pp.FixmedinsCode = miConfig.Code
  2507. pp.RequestUrl = miConfig.Url
  2508. pp.Cainfo = miConfig.Cainfo
  2509. pp.SecretKey = miConfig.SecretKey
  2510. pp.AccessKey = miConfig.AccessKey
  2511. pp.OpterName = roles.UserName
  2512. var config []*models.HisXtDiagnoseConfig
  2513. for _, item := range diagnosis_ids {
  2514. id, _ := strconv.ParseInt(item, 10, 64)
  2515. diagnosisConfig, _ := service.FindDiagnoseById(id)
  2516. config = append(config, &diagnosisConfig)
  2517. }
  2518. var pd models.PatientDtos
  2519. pd.PatnID = his.PsnNo
  2520. pd.PatnName = his.Name
  2521. pd.Gend = his.Gend
  2522. pd.Brdy = his.Brdy
  2523. pd.Poolarea = his.InsuplcAdmdvs
  2524. pd.CurrMdtrtID = his.Number
  2525. var fed models.FsiEncounterDtos
  2526. fed.MdtrtID = his.Number
  2527. fed.MedinsID = miConfig.Code
  2528. fed.MedinsName = miConfig.OrgName
  2529. fed.MedinsAdmdvs = miConfig.MdtrtareaAdmvs
  2530. fed.MedMdtrtType = "1"
  2531. fed.MedinsType = "1"
  2532. fed.MedinsLv = "11"
  2533. tm := time.Unix(his.RecordDate, 0)
  2534. s_tm := tm.Format("2006-01-02 15:04:05")
  2535. fed.AdmDate = s_tm
  2536. fed.DscgDate = s_tm
  2537. fed.DscgMainDiseCodg = config[0].CountryCode
  2538. fed.DscgMainDiseName = config[0].CountryContentName
  2539. //诊断信息
  2540. var fdds []*models.FsiDiagnoseDtos
  2541. for index, item := range config {
  2542. if index == 0 {
  2543. var fdd models.FsiDiagnoseDtos
  2544. fdd.DiseID = strconv.FormatInt(item.ID, 10)
  2545. fdd.InoutDiseType = "1"
  2546. fdd.MaindiseFlag = "1"
  2547. fdd.DiseDate = s_tm
  2548. fdd.DiasSrtNo = "1"
  2549. fdd.DiseName = item.CountryContentName
  2550. fdd.DiseCodg = item.CountryCode
  2551. fdds = append(fdds, &fdd)
  2552. } else {
  2553. var fdd models.FsiDiagnoseDtos
  2554. fdd.DiseID = strconv.FormatInt(item.ID, 10)
  2555. fdd.InoutDiseType = "1"
  2556. fdd.MaindiseFlag = "1"
  2557. fdd.DiseDate = s_tm
  2558. fdd.DiasSrtNo = strconv.FormatInt(int64(index), 10)
  2559. fdd.DiseName = item.CountryContentName
  2560. fdd.DiseCodg = item.CountryCode
  2561. fdds = append(fdds, &fdd)
  2562. }
  2563. }
  2564. fed.DrCodg = strconv.FormatInt(doctor_info.ID, 10)
  2565. fed.AdmDeptCodg = strconv.FormatInt(department.ID, 10)
  2566. fed.AdmDeptName = department.Name
  2567. fed.DscgDeptCodg = strconv.FormatInt(department.ID, 10)
  2568. fed.DscgDeptName = department.Name
  2569. fed.MedMdtrtType = "1"
  2570. fed.MedType = "11"
  2571. //if his.Insutype == "390" {
  2572. // fed.MedType = "1402"
  2573. //} else {
  2574. // fed.MedType = "9933"
  2575. //}
  2576. var orders []*models.FsiOrderDtos
  2577. if trig_scen == "2" {
  2578. //处方医嘱信息
  2579. for _, item := range prescriptions {
  2580. for _, subItem := range item.HisDoctorAdviceInfo {
  2581. var order models.FsiOrderDtos
  2582. order.RxID = strconv.FormatInt(item.ID, 10)
  2583. order.Rxno = strconv.FormatInt(item.ID, 10)
  2584. order.LongDrordFlag = "0"
  2585. order.HilistType = "1"
  2586. order.ChrgType = "1"
  2587. order.DrordBhvr = "-"
  2588. order.HilistCode = subItem.BaseDrugLib.MedicalInsuranceNumber
  2589. order.HosplistName = subItem.BaseDrugLib.DrugName
  2590. order.HilistLv = "1"
  2591. order.HilistPric = fmt.Sprintf("%.2f", subItem.Price)
  2592. order.HosplistCode = subItem.BaseDrugLib.MedicalInsuranceNumber
  2593. order.HosplistName = subItem.BaseDrugLib.DrugName
  2594. order.Cnt = fmt.Sprintf("%.2f", subItem.PrescribingNumber)
  2595. order.Pric = fmt.Sprintf("%.2f", subItem.Price)
  2596. order.Sumamt = fmt.Sprintf("%.2f", (subItem.PrescribingNumber * subItem.Price))
  2597. order.OwnpayAmt = ""
  2598. order.SelfpayAmt = ""
  2599. order.Spec = ""
  2600. order.SpecUnt = ""
  2601. order.DrordBegnDate = s_tm
  2602. order.DrordStopDate = ""
  2603. order.DrordDrCodg = "1"
  2604. order.DrordDeptName = department.Name
  2605. order.DrordDrCodg = "1"
  2606. order.DrordDrName = doctor_info.UserName
  2607. order.DrordDrProfttl = ""
  2608. order.CurrDrordFlag = "1"
  2609. orders = append(orders, &order)
  2610. }
  2611. for _, subItem := range item.HisPrescriptionProject {
  2612. if subItem.Type == 2 {
  2613. var order models.FsiOrderDtos
  2614. order.RxID = strconv.FormatInt(item.ID, 10)
  2615. order.Rxno = strconv.FormatInt(item.ID, 10)
  2616. order.LongDrordFlag = "0"
  2617. order.HilistType = "1"
  2618. order.ChrgType = "1"
  2619. order.DrordBhvr = "-"
  2620. order.HilistCode = subItem.HisProject.MedicalCode
  2621. order.HosplistName = subItem.HisProject.ProjectName
  2622. order.HilistLv = "1"
  2623. order.HilistPric = fmt.Sprintf("%.2f", subItem.Price)
  2624. order.HosplistCode = subItem.HisProject.MedicalCode
  2625. order.HosplistName = subItem.HisProject.ProjectName
  2626. order.Cnt = subItem.Count
  2627. cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  2628. order.Pric = fmt.Sprintf("%.2f", subItem.Price)
  2629. order.Sumamt = fmt.Sprintf("%.2f", subItem.Price*cnt)
  2630. order.OwnpayAmt = ""
  2631. order.SelfpayAmt = ""
  2632. order.Spec = ""
  2633. order.SpecUnt = ""
  2634. order.DrordBegnDate = s_tm
  2635. order.DrordStopDate = ""
  2636. order.DrordDrCodg = "1"
  2637. order.DrordDeptName = department.Name
  2638. order.DrordDrCodg = "1"
  2639. order.DrordDrName = doctor_info.UserName
  2640. order.DrordDrProfttl = ""
  2641. order.CurrDrordFlag = "1"
  2642. orders = append(orders, &order)
  2643. }
  2644. if subItem.Type == 3 {
  2645. var order models.FsiOrderDtos
  2646. order.RxID = strconv.FormatInt(item.ID, 10)
  2647. order.Rxno = strconv.FormatInt(item.ID, 10)
  2648. order.LongDrordFlag = "0"
  2649. order.HilistType = "1"
  2650. order.ChrgType = "1"
  2651. order.DrordBhvr = "-"
  2652. order.HilistCode = subItem.GoodInfo.MedicalInsuranceNumber
  2653. order.HosplistName = subItem.GoodInfo.GoodName
  2654. order.HilistLv = "1"
  2655. order.HilistPric = fmt.Sprintf("%.2f", subItem.Price)
  2656. order.HosplistCode = subItem.GoodInfo.MedicalInsuranceNumber
  2657. order.HosplistName = subItem.GoodInfo.GoodName
  2658. order.Cnt = subItem.Count
  2659. cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  2660. order.Pric = fmt.Sprintf("%.2f", subItem.Price)
  2661. order.Sumamt = fmt.Sprintf("%.2f", subItem.Price*cnt)
  2662. order.OwnpayAmt = ""
  2663. order.SelfpayAmt = ""
  2664. order.Spec = ""
  2665. order.SpecUnt = ""
  2666. order.DrordBegnDate = s_tm
  2667. order.DrordStopDate = ""
  2668. order.DrordDrCodg = "1"
  2669. order.DrordDeptName = department.Name
  2670. order.DrordDrCodg = "1"
  2671. order.DrordDrName = doctor_info.UserName
  2672. order.DrordDrProfttl = ""
  2673. order.CurrDrordFlag = "1"
  2674. orders = append(orders, &order)
  2675. }
  2676. }
  2677. }
  2678. //处方医嘱信息
  2679. }
  2680. fed.MatnStas = "0"
  2681. fed.MedfeeSumamt = "0"
  2682. fed.OwnpayAmt = "0"
  2683. fed.SelfpayAmt = "0"
  2684. fed.AcctPayamt = "0"
  2685. fed.MaAmt = "0"
  2686. fed.HifpPayamt = "0"
  2687. fed.SetlTotlnum = "1"
  2688. fed.Insutype = his.Insutype
  2689. fed.ReimFlag = "0"
  2690. fed.OutSetlFlag = "0"
  2691. var fopd []*models.FsiOperationDtosData
  2692. data := make(map[string]interface{})
  2693. data["fed"] = fed
  2694. data["fdd"] = fdds
  2695. data["fod"] = orders
  2696. data["pd"] = pd
  2697. data["pp"] = pp
  2698. data["fopd"] = fopd
  2699. data["trig_scen"] = trig_scen
  2700. fmt.Println(data)
  2701. fmt.Println(fed)
  2702. fmt.Println(fdds)
  2703. fmt.Println(orders)
  2704. fmt.Println(pd)
  2705. fmt.Println(pp)
  2706. fmt.Println(fopd)
  2707. client := &http.Client{}
  2708. bytesData, _ := json.Marshal(data)
  2709. var req *http.Request
  2710. if miConfig.MdtrtareaAdmvs == "320921" {
  2711. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3101", bytes.NewReader(bytesData))
  2712. } else {
  2713. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3101", bytes.NewReader(bytesData))
  2714. }
  2715. resp, _ := client.Do(req)
  2716. defer resp.Body.Close()
  2717. body, ioErr := ioutil.ReadAll(resp.Body)
  2718. if ioErr != nil {
  2719. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  2720. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2721. return res
  2722. }
  2723. var respJSON map[string]interface{}
  2724. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  2725. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  2726. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2727. return res
  2728. }
  2729. respJSON = respJSON["data"].(map[string]interface{})["request_log"].(map[string]interface{})
  2730. result, _ := json.Marshal(respJSON)
  2731. if err := json.Unmarshal([]byte(result), &res); err != nil {
  2732. utils.ErrorLog("解析失败:%v", err)
  2733. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2734. return res
  2735. }
  2736. return res
  2737. }
  2738. func Check3102(c *HisApiController, patient_id int64, his_patient_id int64, admin_user_id int64, trig_scen string, order_id int64) (res Result3101) {
  2739. ////patient_id, _ := c.GetInt64("patient_id")
  2740. //order_id, _ := c.GetInt64("order_id")
  2741. ////his_patient_id, _ := c.GetInt64("his_patient_id")
  2742. ////admin_user_id, _ := c.GetInt64("admin_user_id")
  2743. //trig_scen := c.GetString("trig_scen")
  2744. adminUser := c.GetAdminUserInfo()
  2745. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  2746. his, _ := service.GetNewHisPatientInfoFour(c.GetAdminUserInfo().CurrentOrgId, his_patient_id)
  2747. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  2748. record_time := c.GetString("record_time")
  2749. order, _ := service.GetHisOrderByID(order_id)
  2750. timeLayout := "2006-01-02"
  2751. loc, _ := time.LoadLocation("Local")
  2752. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  2753. if err != nil {
  2754. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  2755. return
  2756. }
  2757. recordDateTime := theTime.Unix()
  2758. var patientPrescription models.HisPrescriptionInfo
  2759. patientPrescription, _ = service.FindHisPatientPrescriptionInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  2760. if patientPrescription.ID == 0 {
  2761. patientPrescription, _ = service.FindLastPatientPrescriptionInfo(adminUser.CurrentOrgId, patient_id, recordDateTime)
  2762. }
  2763. department, _ := service.GetDepartMentDetail(patientPrescription.Departments)
  2764. doctor_info, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, patientPrescription.DoctorId)
  2765. //
  2766. diagnosis_ids := strings.Split(his.Diagnosis, ",")
  2767. prescriptions, _ := service.GetNewHisPrescriptionTen(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  2768. var pp models.PublicParams
  2769. pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  2770. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  2771. pp.FixmedinsName = miConfig.OrgName
  2772. pp.FixmedinsCode = miConfig.Code
  2773. pp.RequestUrl = miConfig.Url
  2774. pp.Cainfo = miConfig.Cainfo
  2775. pp.SecretKey = miConfig.SecretKey
  2776. pp.AccessKey = miConfig.AccessKey
  2777. pp.OpterName = roles.UserName
  2778. var config []*models.HisXtDiagnoseConfig
  2779. for _, item := range diagnosis_ids {
  2780. id, _ := strconv.ParseInt(item, 10, 64)
  2781. diagnosisConfig, _ := service.FindDiagnoseById(id)
  2782. config = append(config, &diagnosisConfig)
  2783. }
  2784. var pd models.PatientDtos
  2785. pd.PatnID = his.PsnNo
  2786. pd.PatnName = his.Name
  2787. pd.Gend = his.Gend
  2788. pd.Brdy = his.Brdy
  2789. pd.Poolarea = his.InsuplcAdmdvs
  2790. pd.CurrMdtrtID = his.Number
  2791. var fed models.FsiEncounterDtos
  2792. fed.MdtrtID = his.Number
  2793. fed.MedinsID = miConfig.Code
  2794. fed.MedinsName = miConfig.OrgName
  2795. fed.MedinsAdmdvs = miConfig.MdtrtareaAdmvs
  2796. fed.MedMdtrtType = "1"
  2797. fed.MedinsType = "1"
  2798. fed.MedinsLv = "11"
  2799. tm := time.Unix(his.RecordDate, 0)
  2800. s_tm := tm.Format("2006-01-02 15:04:05")
  2801. fed.AdmDate = s_tm
  2802. fed.DscgDate = s_tm
  2803. fed.DscgMainDiseCodg = config[0].CountryCode
  2804. fed.DscgMainDiseName = config[0].CountryContentName
  2805. //诊断信息
  2806. var fdds []*models.FsiDiagnoseDtos
  2807. for index, item := range config {
  2808. if index == 0 {
  2809. var fdd models.FsiDiagnoseDtos
  2810. fdd.DiseID = strconv.FormatInt(item.ID, 10)
  2811. fdd.InoutDiseType = "1"
  2812. fdd.MaindiseFlag = "1"
  2813. fdd.DiseDate = s_tm
  2814. fdd.DiasSrtNo = "1"
  2815. fdd.DiseName = item.CountryContentName
  2816. fdd.DiseCodg = item.CountryCode
  2817. fdds = append(fdds, &fdd)
  2818. } else {
  2819. var fdd models.FsiDiagnoseDtos
  2820. fdd.DiseID = strconv.FormatInt(item.ID, 10)
  2821. fdd.InoutDiseType = "1"
  2822. fdd.MaindiseFlag = "1"
  2823. fdd.DiseDate = s_tm
  2824. fdd.DiasSrtNo = strconv.FormatInt(int64(index), 10)
  2825. fdd.DiseName = item.CountryContentName
  2826. fdd.DiseCodg = item.CountryCode
  2827. fdds = append(fdds, &fdd)
  2828. }
  2829. }
  2830. fed.DrCodg = strconv.FormatInt(doctor_info.ID, 10)
  2831. fed.AdmDeptCodg = strconv.FormatInt(department.ID, 10)
  2832. fed.AdmDeptName = department.Name
  2833. fed.DscgDeptCodg = strconv.FormatInt(department.ID, 10)
  2834. fed.DscgDeptName = department.Name
  2835. fed.MedType = order.MedType
  2836. //处方医嘱信息
  2837. var orders []*models.FsiOrderDtos
  2838. //for _, item := range prescriptions {
  2839. // for _, subItem := range item.HisDoctorAdviceInfo {
  2840. // var order models.FsiOrderDtos
  2841. // order.RxID = strconv.FormatInt(item.ID, 10)
  2842. // order.Rxno = strconv.FormatInt(item.ID, 10)
  2843. // order.LongDrordFlag = "0"
  2844. // order.HilistType = "1"
  2845. // order.ChrgType = "1"
  2846. // order.DrordBhvr = "-"
  2847. // order.HilistCode = subItem.BaseDrugLib.MedicalInsuranceNumber
  2848. // order.HosplistName = subItem.BaseDrugLib.DrugName
  2849. // order.HilistLv = "1"
  2850. // order.HilistPric = strconv.FormatFloat(subItem.Price, 'E', -1, 64)
  2851. // order.HosplistCode = subItem.BaseDrugLib.MedicalInsuranceNumber
  2852. // order.HosplistName = subItem.BaseDrugLib.DrugName
  2853. // order.Cnt = strconv.FormatFloat(subItem.PrescribingNumber, 'E', -1, 64)
  2854. // order.Pric = strconv.FormatFloat(subItem.Price, 'E', -1, 64)
  2855. // order.Sumamt = strconv.FormatFloat((subItem.Price * subItem.PrescribingNumber), 'E', -1, 64)
  2856. // order.OwnpayAmt = ""
  2857. // order.SelfpayAmt = ""
  2858. // order.Spec = ""
  2859. // order.SpecUnt = ""
  2860. // order.DrordBegnDate = s_tm
  2861. // order.DrordStopDate = ""
  2862. // order.DrordDrCodg = "1"
  2863. // order.DrordDeptName = department.Name
  2864. // order.DrordDrCodg = "1"
  2865. // order.DrordDrName = doctor_info.UserName
  2866. // order.DrordDrProfttl = ""
  2867. // order.CurrDrordFlag = "1"
  2868. // orders = append(orders, &order)
  2869. // }
  2870. // for _, subItem := range item.HisPrescriptionProject {
  2871. // if subItem.Type == 2 {
  2872. // var order models.FsiOrderDtos
  2873. // order.RxID = strconv.FormatInt(item.ID, 10)
  2874. // order.Rxno = strconv.FormatInt(item.ID, 10)
  2875. // order.LongDrordFlag = "0"
  2876. // order.HilistType = "1"
  2877. // order.ChrgType = "1"
  2878. // order.DrordBhvr = "-"
  2879. // order.HilistCode = subItem.HisProject.MedicalCode
  2880. // order.HosplistName = subItem.HisProject.ProjectName
  2881. // order.HilistLv = "1"
  2882. // order.HilistPric = strconv.FormatFloat(subItem.Price, 'E', -1, 64)
  2883. // order.HosplistCode = subItem.HisProject.MedicalCode
  2884. // order.HosplistName = subItem.HisProject.ProjectName
  2885. // order.Cnt = subItem.Count
  2886. // cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  2887. //
  2888. // order.Pric = strconv.FormatFloat(subItem.Price, 'E', -1, 64)
  2889. // order.Sumamt = strconv.FormatFloat((subItem.Price * cnt), 'E', -1, 64)
  2890. // order.OwnpayAmt = ""
  2891. // order.SelfpayAmt = ""
  2892. // order.Spec = ""
  2893. // order.SpecUnt = ""
  2894. // order.DrordBegnDate = s_tm
  2895. // order.DrordStopDate = ""
  2896. // order.DrordDrCodg = "1"
  2897. // order.DrordDeptName = department.Name
  2898. // order.DrordDrCodg = "1"
  2899. // order.DrordDrName = doctor_info.UserName
  2900. // order.DrordDrProfttl = ""
  2901. // order.CurrDrordFlag = "1"
  2902. // orders = append(orders, &order)
  2903. //
  2904. // }
  2905. // if subItem.Type == 3 {
  2906. //
  2907. // var order models.FsiOrderDtos
  2908. // order.RxID = strconv.FormatInt(item.ID, 10)
  2909. // order.Rxno = strconv.FormatInt(item.ID, 10)
  2910. // order.LongDrordFlag = "0"
  2911. // order.HilistType = "1"
  2912. // order.ChrgType = "1"
  2913. // order.DrordBhvr = "-"
  2914. // order.HilistCode = subItem.GoodInfo.MedicalInsuranceNumber
  2915. // order.HosplistName = subItem.GoodInfo.GoodName
  2916. // order.HilistLv = "1"
  2917. // order.HilistPric = strconv.FormatFloat(subItem.Price, 'E', -1, 64)
  2918. // order.HosplistCode = subItem.GoodInfo.MedicalInsuranceNumber
  2919. // order.HosplistName = subItem.GoodInfo.GoodName
  2920. // order.Cnt = subItem.Count
  2921. // cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  2922. // order.Pric = strconv.FormatFloat(subItem.Price, 'E', -1, 64)
  2923. // order.Sumamt = strconv.FormatFloat((subItem.Price * cnt), 'E', -1, 64)
  2924. // order.OwnpayAmt = ""
  2925. // order.SelfpayAmt = ""
  2926. // order.Spec = ""
  2927. // order.SpecUnt = ""
  2928. // order.DrordBegnDate = s_tm
  2929. // order.DrordStopDate = ""
  2930. // order.DrordDrCodg = "1"
  2931. // order.DrordDeptName = department.Name
  2932. // order.DrordDrCodg = "1"
  2933. // order.DrordDrName = doctor_info.UserName
  2934. // order.DrordDrProfttl = ""
  2935. // order.CurrDrordFlag = "1"
  2936. // orders = append(orders, &order)
  2937. //
  2938. // }
  2939. // }
  2940. //}
  2941. for _, item := range prescriptions {
  2942. for _, subItem := range item.HisDoctorAdviceInfo {
  2943. var order models.FsiOrderDtos
  2944. order.RxID = strconv.FormatInt(item.ID, 10)
  2945. order.Rxno = strconv.FormatInt(item.ID, 10)
  2946. order.LongDrordFlag = "0"
  2947. order.HilistType = "1"
  2948. order.ChrgType = "1"
  2949. order.DrordBhvr = "-"
  2950. order.HilistCode = subItem.BaseDrugLib.MedicalInsuranceNumber
  2951. order.HosplistName = subItem.BaseDrugLib.DrugName
  2952. order.HilistLv = "1"
  2953. order.HilistPric = fmt.Sprintf("%.2f", subItem.Price)
  2954. order.HosplistCode = subItem.BaseDrugLib.MedicalInsuranceNumber
  2955. order.HosplistName = subItem.BaseDrugLib.DrugName
  2956. order.Cnt = fmt.Sprintf("%.2f", subItem.PrescribingNumber)
  2957. order.Pric = fmt.Sprintf("%.2f", subItem.Price)
  2958. order.Sumamt = fmt.Sprintf("%.2f", (subItem.PrescribingNumber * subItem.Price))
  2959. order.OwnpayAmt = ""
  2960. order.SelfpayAmt = ""
  2961. order.Spec = ""
  2962. order.SpecUnt = ""
  2963. order.DrordBegnDate = s_tm
  2964. order.DrordStopDate = ""
  2965. order.DrordDrCodg = "1"
  2966. order.DrordDeptName = department.Name
  2967. order.DrordDrCodg = "1"
  2968. order.DrordDrName = doctor_info.UserName
  2969. order.DrordDrProfttl = ""
  2970. order.CurrDrordFlag = "1"
  2971. orders = append(orders, &order)
  2972. }
  2973. for _, subItem := range item.HisPrescriptionProject {
  2974. if subItem.Type == 2 {
  2975. var order models.FsiOrderDtos
  2976. order.RxID = strconv.FormatInt(item.ID, 10)
  2977. order.Rxno = strconv.FormatInt(item.ID, 10)
  2978. order.LongDrordFlag = "0"
  2979. order.HilistType = "1"
  2980. order.ChrgType = "1"
  2981. order.DrordBhvr = "-"
  2982. order.HilistCode = subItem.HisProject.MedicalCode
  2983. order.HosplistName = subItem.HisProject.ProjectName
  2984. order.HilistLv = "1"
  2985. order.HilistPric = fmt.Sprintf("%.2f", subItem.Price)
  2986. order.HosplistCode = subItem.HisProject.MedicalCode
  2987. order.HosplistName = subItem.HisProject.ProjectName
  2988. order.Cnt = subItem.Count
  2989. cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  2990. order.Pric = fmt.Sprintf("%.2f", subItem.Price)
  2991. order.Sumamt = fmt.Sprintf("%.2f", subItem.Price*cnt)
  2992. order.OwnpayAmt = ""
  2993. order.SelfpayAmt = ""
  2994. order.Spec = ""
  2995. order.SpecUnt = ""
  2996. order.DrordBegnDate = s_tm
  2997. order.DrordStopDate = ""
  2998. order.DrordDrCodg = "1"
  2999. order.DrordDeptName = department.Name
  3000. order.DrordDrCodg = "1"
  3001. order.DrordDrName = doctor_info.UserName
  3002. order.DrordDrProfttl = ""
  3003. order.CurrDrordFlag = "1"
  3004. orders = append(orders, &order)
  3005. }
  3006. if subItem.Type == 3 {
  3007. var order models.FsiOrderDtos
  3008. order.RxID = strconv.FormatInt(item.ID, 10)
  3009. order.Rxno = strconv.FormatInt(item.ID, 10)
  3010. order.LongDrordFlag = "0"
  3011. order.HilistType = "1"
  3012. order.ChrgType = "1"
  3013. order.DrordBhvr = "-"
  3014. order.HilistCode = subItem.GoodInfo.MedicalInsuranceNumber
  3015. order.HosplistName = subItem.GoodInfo.GoodName
  3016. order.HilistLv = "1"
  3017. order.HilistPric = fmt.Sprintf("%.2f", subItem.Price)
  3018. order.HosplistCode = subItem.GoodInfo.MedicalInsuranceNumber
  3019. order.HosplistName = subItem.GoodInfo.GoodName
  3020. order.Cnt = subItem.Count
  3021. cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  3022. order.Pric = fmt.Sprintf("%.2f", subItem.Price)
  3023. order.Sumamt = fmt.Sprintf("%.2f", subItem.Price*cnt)
  3024. order.OwnpayAmt = ""
  3025. order.SelfpayAmt = ""
  3026. order.Spec = ""
  3027. order.SpecUnt = ""
  3028. order.DrordBegnDate = s_tm
  3029. order.DrordStopDate = ""
  3030. order.DrordDrCodg = "1"
  3031. order.DrordDeptName = department.Name
  3032. order.DrordDrCodg = "1"
  3033. order.DrordDrName = doctor_info.UserName
  3034. order.DrordDrProfttl = ""
  3035. order.CurrDrordFlag = "1"
  3036. orders = append(orders, &order)
  3037. }
  3038. }
  3039. }
  3040. //处方医嘱信息
  3041. fed.MatnStas = "0"
  3042. fed.MedfeeSumamt = fmt.Sprintf("%.2f", order.MedfeeSumamt)
  3043. fed.OwnpayAmt = fmt.Sprintf("%.2f", order.FulamtOwnpayAmt)
  3044. fed.SelfpayAmt = fmt.Sprintf("%.2f", order.PreselfpayAmt)
  3045. fed.AcctPayamt = fmt.Sprintf("%.2f", order.AcctPay)
  3046. fed.MaAmt = fmt.Sprintf("%.2f", order.MafPay)
  3047. fed.HifpPayamt = fmt.Sprintf("%.2f", order.HifpPay)
  3048. fed.SetlTotlnum = "1"
  3049. fed.Insutype = his.Insutype
  3050. fed.ReimFlag = "0"
  3051. fed.OutSetlFlag = "0"
  3052. var fopd []*models.FsiOperationDtosData
  3053. data := make(map[string]interface{})
  3054. data["fed"] = fed
  3055. data["fdd"] = fdds
  3056. data["fod"] = orders
  3057. data["pd"] = pd
  3058. data["pp"] = pp
  3059. data["fopd"] = fopd
  3060. data["trig_scen"] = trig_scen
  3061. client := &http.Client{}
  3062. bytesData, _ := json.Marshal(data)
  3063. var req *http.Request
  3064. if miConfig.MdtrtareaAdmvs == "320921" {
  3065. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3102", bytes.NewReader(bytesData))
  3066. } else {
  3067. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3102", bytes.NewReader(bytesData))
  3068. }
  3069. resp, _ := client.Do(req)
  3070. defer resp.Body.Close()
  3071. body, ioErr := ioutil.ReadAll(resp.Body)
  3072. if ioErr != nil {
  3073. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  3074. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3075. return res
  3076. }
  3077. var respJSON map[string]interface{}
  3078. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  3079. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  3080. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3081. return res
  3082. }
  3083. respJSON = respJSON["data"].(map[string]interface{})["request_log"].(map[string]interface{})
  3084. result, _ := json.Marshal(respJSON)
  3085. if err := json.Unmarshal([]byte(result), &res); err != nil {
  3086. utils.ErrorLog("解析失败:%v", err)
  3087. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3088. return res
  3089. }
  3090. return res
  3091. //手术操作集合
  3092. //手术操作集合
  3093. }
  3094. func (c *HisApiController) Check() {
  3095. psn_no := c.GetString("psn_no")
  3096. in := c.GetString("in")
  3097. mt := c.GetString("mt")
  3098. baseParams := models.BaseParams{
  3099. SecretKey: "MSDBYGxXm1Mtyi3PtOUB7n1ktcxwyW57",
  3100. FixmedinsCode: "H15049901371",
  3101. InsuplcAdmdvs: "150499",
  3102. MdtrtareaAdmvs: "150499",
  3103. OrgName: "赤峰费森血液透析中心",
  3104. Doctor: "1111",
  3105. }
  3106. service.Gdyb2001(baseParams, psn_no, in, mt)
  3107. }
  3108. func (c *HisApiController) GetPsnNcdsInfo() {
  3109. admin_user_id, _ := c.GetInt64("admin_user_id")
  3110. patient_id, _ := c.GetInt64("patient_id")
  3111. id, _ := c.GetInt64("id")
  3112. adminUser := c.GetAdminUserInfo()
  3113. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  3114. //config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  3115. //patient, _ := service.GetPatientByID(c.GetAdminUserInfo().CurrentOrgId, id)
  3116. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  3117. psn_record, _ := service.GetPsnNCDSRecordById(id)
  3118. //
  3119. //if psn_record.ID == 0 {
  3120. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorPsnRecordNoExistWrong)
  3121. // return
  3122. //}
  3123. var res Result5301
  3124. var res10265 Result5301For10265
  3125. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  3126. psn_info, _ := service.GetPsnByPatientId(patient_id)
  3127. var api string
  3128. if miConfig.MdtrtareaAdmvs == "320921" {
  3129. 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 +
  3130. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&psn_no=" + psn_info.PsnNo + "&cainfo=" + miConfig.Cainfo
  3131. } else {
  3132. 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 +
  3133. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&psn_no=" + psn_info.PsnNo + "&cainfo=" + miConfig.Cainfo
  3134. }
  3135. resp, requestErr := http.Get(api)
  3136. if requestErr != nil {
  3137. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3138. return
  3139. }
  3140. body, ioErr := ioutil.ReadAll(resp.Body)
  3141. if ioErr != nil {
  3142. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  3143. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3144. return
  3145. }
  3146. var respJSON map[string]interface{}
  3147. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  3148. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  3149. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3150. return
  3151. }
  3152. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  3153. result, _ := json.Marshal(respJSON)
  3154. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  3155. utils.ErrorLog("解析失败:%v", err)
  3156. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3157. return
  3158. }
  3159. res.ErrMsg = res10265.ErrMsg
  3160. res.Output = res10265.Output
  3161. res.InfRefmsgid = res10265.InfRefmsgid
  3162. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  3163. res.Infcode = infocode
  3164. } else if miConfig.MdtrtareaAdmvs == "360399" {
  3165. p, _ := service.GetHisPatientById(patient_id)
  3166. result, _ := service.Jxyb5301(p.PsnNo, miConfig.OrgName, role.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, miConfig.Url, miConfig.AccessKey, "")
  3167. var dat map[string]interface{}
  3168. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  3169. fmt.Println(dat)
  3170. } else {
  3171. fmt.Println(err)
  3172. }
  3173. userJSONBytes, _ := json.Marshal(dat)
  3174. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  3175. utils.ErrorLog("解析失败:%v", err)
  3176. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3177. return
  3178. }
  3179. } else if miConfig.MdtrtareaAdmvs == "430800" {
  3180. p, _ := service.GetHisPatientById(patient_id)
  3181. result, _ := service.Hnyb5301(p.PsnNo, miConfig.OrgName, role.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, miConfig.Url, miConfig.AccessKey, "")
  3182. var dat map[string]interface{}
  3183. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  3184. fmt.Println(dat)
  3185. } else {
  3186. fmt.Println(err)
  3187. }
  3188. userJSONBytes, _ := json.Marshal(dat)
  3189. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  3190. utils.ErrorLog("解析失败:%v", err)
  3191. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3192. return
  3193. }
  3194. } else {
  3195. result := service.Gdyb5301(psn_record.PsnNo, miConfig.OrgName, role.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey)
  3196. var dat map[string]interface{}
  3197. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  3198. fmt.Println(dat)
  3199. } else {
  3200. fmt.Println(err)
  3201. }
  3202. userJSONBytes, _ := json.Marshal(dat)
  3203. if miConfig.Code == "H15049901371" {
  3204. if err := json.Unmarshal(userJSONBytes, &res10265); err != nil {
  3205. utils.ErrorLog("解析失败:%v", err)
  3206. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3207. return
  3208. }
  3209. res.InfRefmsgid = res10265.InfRefmsgid
  3210. res.Output = res10265.Output
  3211. res.ErrMsg = res10265.ErrMsg
  3212. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  3213. res.Infcode = infocode
  3214. } else {
  3215. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  3216. utils.ErrorLog("解析失败:%v", err)
  3217. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3218. return
  3219. }
  3220. }
  3221. }
  3222. if res.Infcode == 0 {
  3223. c.ServeSuccessJSON(map[string]interface{}{
  3224. "result": res.Output.Result,
  3225. })
  3226. }
  3227. }
  3228. func (c *HisApiController) CheckInsutype() {
  3229. his_patient_id, _ := c.GetInt64("his_patient_id")
  3230. admin_user_id, _ := c.GetInt64("admin_user_id")
  3231. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  3232. his, _ := service.GetNewHisPatientInfoFour(c.GetAdminUserInfo().CurrentOrgId, his_patient_id)
  3233. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  3234. result := service.Gdyb90100(his.PsnNo, miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey)
  3235. var dat map[string]interface{}
  3236. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  3237. fmt.Println(dat)
  3238. } else {
  3239. fmt.Println(err)
  3240. }
  3241. userJSONBytes, _ := json.Marshal(dat)
  3242. var res Result90100
  3243. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  3244. utils.ErrorLog("解析失败:%v", err)
  3245. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3246. return
  3247. }
  3248. if res.Infcode != 0 {
  3249. c.ServeSuccessJSON(map[string]interface{}{
  3250. "failed_code": -10,
  3251. "msg": res.ErrMsg,
  3252. })
  3253. return
  3254. } else {
  3255. fmt.Println(res)
  3256. }
  3257. }
  3258. func (c *HisApiController) CheckCardPWD() {
  3259. card_pwd := c.GetString("card_pwd")
  3260. his_patient_id, _ := c.GetInt64("his_patient_id")
  3261. admin_user_id, _ := c.GetInt64("admin_user_id")
  3262. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  3263. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  3264. his, _ := service.GetNewHisPatientInfoFour(c.GetAdminUserInfo().CurrentOrgId, his_patient_id)
  3265. psn, _ := service.GetPsnByPatientId(his.PatientId)
  3266. bas := strings.Split(psn.CardInfo, "|")
  3267. basNumber := bas[2]
  3268. if psn.InsuplcAdmdvs[:4] == "4403" {
  3269. result := service.Gdyb90991(his.PsnNo, miConfig.OrgName, roles.UserName, miConfig.Code, his.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, card_pwd, basNumber)
  3270. var dat map[string]interface{}
  3271. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  3272. fmt.Println(dat)
  3273. } else {
  3274. fmt.Println(err)
  3275. }
  3276. userJSONBytes, _ := json.Marshal(dat)
  3277. var res Result90991
  3278. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  3279. utils.ErrorLog("解析失败:%v", err)
  3280. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3281. return
  3282. }
  3283. if res.Infcode != 0 {
  3284. c.ServeSuccessJSON(map[string]interface{}{
  3285. "failed_code": -10,
  3286. "msg": res.ErrMsg,
  3287. })
  3288. return
  3289. } else {
  3290. if res.Output.Result.SscnoCheckStat == "0" && res.Output.Result.CardStat != "10" {
  3291. var msg string
  3292. switch res.Output.Result.CardStat {
  3293. case "00":
  3294. msg = "未激活"
  3295. break
  3296. case "10":
  3297. msg = "激活"
  3298. break
  3299. case "20":
  3300. msg = "窗口挂失"
  3301. break
  3302. case "21":
  3303. msg = "电话挂失"
  3304. break
  3305. case "22":
  3306. msg = "单位网上申报挂失"
  3307. break
  3308. case "23":
  3309. msg = "保健办挂失"
  3310. break
  3311. case "24":
  3312. msg = "个人网上挂失"
  3313. break
  3314. case "25":
  3315. msg = "网上服务大厅挂失"
  3316. break
  3317. case "30":
  3318. msg = "注销"
  3319. break
  3320. case "40":
  3321. msg = "回收"
  3322. break
  3323. case "99":
  3324. msg = "制卡中(无效卡)"
  3325. break
  3326. }
  3327. c.ServeSuccessJSON(map[string]interface{}{
  3328. "failed_code": -10,
  3329. "msg": msg,
  3330. })
  3331. return
  3332. } else {
  3333. c.ServeSuccessJSON(map[string]interface{}{
  3334. "msg": "校验成功",
  3335. })
  3336. return
  3337. }
  3338. }
  3339. } else {
  3340. c.ServeSuccessJSON(map[string]interface{}{
  3341. "msg": "校验成功",
  3342. })
  3343. return
  3344. }
  3345. }
  3346. func (c *HisApiController) CheckCardPWDTwo() {
  3347. //card_pwd := c.GetString("card_pwd")
  3348. //his_patient_id, _ := c.GetInt64("his_patient_id")
  3349. admin_user_id, _ := c.GetInt64("admin_user_id")
  3350. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  3351. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  3352. result := service.Gdyb90991("44030000000629690364", miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, "000000", "BDM421363")
  3353. var dat map[string]interface{}
  3354. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  3355. fmt.Println(dat)
  3356. } else {
  3357. fmt.Println(err)
  3358. }
  3359. userJSONBytes, _ := json.Marshal(dat)
  3360. var res Result90991
  3361. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  3362. utils.ErrorLog("解析失败:%v", err)
  3363. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3364. return
  3365. }
  3366. if res.Infcode != 0 {
  3367. c.ServeSuccessJSON(map[string]interface{}{
  3368. "failed_code": -10,
  3369. "msg": res.ErrMsg,
  3370. })
  3371. return
  3372. } else {
  3373. if res.Output.Result.SscnoCheckStat == "0" {
  3374. var msg string
  3375. switch res.Output.Result.CardStat {
  3376. case "00":
  3377. msg = "未激活"
  3378. break
  3379. case "10":
  3380. msg = "激活"
  3381. break
  3382. case "20":
  3383. msg = "窗口挂失"
  3384. break
  3385. case "21":
  3386. msg = "电话挂失"
  3387. break
  3388. case "22":
  3389. msg = "单位网上申报挂失"
  3390. break
  3391. case "23":
  3392. msg = "保健办挂失"
  3393. break
  3394. case "24":
  3395. msg = "个人网上挂失"
  3396. break
  3397. case "25":
  3398. msg = "网上服务大厅挂失"
  3399. break
  3400. case "30":
  3401. msg = "注销"
  3402. break
  3403. case "40":
  3404. msg = "回收"
  3405. break
  3406. case "99":
  3407. msg = "制卡中(无效卡)"
  3408. break
  3409. }
  3410. c.ServeSuccessJSON(map[string]interface{}{
  3411. "failed_code": -10,
  3412. "msg": msg,
  3413. })
  3414. return
  3415. } else {
  3416. c.ServeSuccessJSON(map[string]interface{}{
  3417. "msg": "校验成功",
  3418. })
  3419. return
  3420. }
  3421. }
  3422. }
  3423. type ELeCertData struct {
  3424. Data struct {
  3425. Extra string `json:"extra"`
  3426. IDNo string `json:"idNo"`
  3427. IDType string `json:"idType"`
  3428. EcToken string `json:"ecToken"`
  3429. InsuOrg string `json:"insuOrg"`
  3430. UserName string `json:"userName"`
  3431. EcIndexNo string `json:"ecIndexNo"`
  3432. Gender string `json:"gender"`
  3433. Birthday string `json:"birthday"`
  3434. Nationality string `json:"nationality"`
  3435. Email string `json:"email"`
  3436. } `json:"OutData"`
  3437. }
  3438. func (c *HisApiController) ReadCard() {
  3439. id_card_type, _ := c.GetInt64("id_card_type")
  3440. admin_user_id, _ := c.GetInt64("admin_user_id")
  3441. certificates, _ := c.GetInt64("certificates")
  3442. //insuplc_admdvs_str := c.GetString("insuplc_admdvs")
  3443. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  3444. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  3445. switch id_card_type {
  3446. case 1:
  3447. if miConfig.MdtrtareaAdmvs == "421300" {
  3448. var res ResultTwo
  3449. api := "http://192.168.124.4:9532/" + "hbyb/1101?cert_no=" + "" +
  3450. "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  3451. "&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)
  3452. resp, requestErr := http.Get(api)
  3453. if requestErr != nil {
  3454. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3455. return
  3456. }
  3457. body, ioErr := ioutil.ReadAll(resp.Body)
  3458. if ioErr != nil {
  3459. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  3460. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3461. return
  3462. }
  3463. var respJSON map[string]interface{}
  3464. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  3465. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  3466. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3467. return
  3468. }
  3469. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  3470. result, _ := json.Marshal(respJSON)
  3471. fmt.Println("log")
  3472. fmt.Println(string(result))
  3473. if err := json.Unmarshal([]byte(result), &res); err != nil {
  3474. utils.ErrorLog("解析失败:%v", err)
  3475. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3476. return
  3477. }
  3478. if res.Infcode == 0 {
  3479. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  3480. if err == gorm.ErrRecordNotFound {
  3481. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  3482. return
  3483. } else if err != nil {
  3484. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  3485. return
  3486. } else {
  3487. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  3488. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  3489. infoStr := string(Iinfos)
  3490. idetinfoStr := string(Idetinfos)
  3491. psn := &models.HisPsn{
  3492. PsnNo: res.Output.Baseinfo.PsnNo,
  3493. Age: res.Output.Baseinfo.Age,
  3494. PatientId: patient.ID,
  3495. Certno: res.Output.Baseinfo.Certno,
  3496. Brdy: res.Output.Baseinfo.Brdy,
  3497. Gend: res.Output.Baseinfo.Gend,
  3498. Naty: res.Output.Baseinfo.Naty,
  3499. PsnCertType: res.Output.Baseinfo.PsnCertType,
  3500. PsnName: res.Output.Baseinfo.PsnName,
  3501. Idetinfo: idetinfoStr,
  3502. Insuinfo: infoStr,
  3503. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  3504. }
  3505. service.CreateHisPsn(psn)
  3506. c.ServeSuccessJSON(map[string]interface{}{
  3507. "patient": patient,
  3508. "number": res.Output.Baseinfo.Certno,
  3509. })
  3510. }
  3511. } else {
  3512. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  3513. return
  3514. }
  3515. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  3516. var api string
  3517. if miConfig.MdtrtareaAdmvs == "320921" {
  3518. 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 +
  3519. "&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
  3520. fmt.Println(api)
  3521. } else {
  3522. 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 +
  3523. "&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)
  3524. }
  3525. resp, requestErr := http.Get(api)
  3526. if requestErr != nil {
  3527. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3528. return
  3529. }
  3530. body, ioErr := ioutil.ReadAll(resp.Body)
  3531. if ioErr != nil {
  3532. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  3533. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3534. return
  3535. }
  3536. var respJSON map[string]interface{}
  3537. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  3538. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  3539. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3540. return
  3541. }
  3542. var status string
  3543. status = respJSON["data"].(map[string]interface{})["status"].(string)
  3544. card_type := respJSON["data"].(map[string]interface{})["type"].(string)
  3545. //console.log()
  3546. fmt.Println("type===")
  3547. fmt.Println(card_type)
  3548. var token string
  3549. var res ResultTwo //1101结果
  3550. var res10265 ResultTwo10265 //1101结果
  3551. var card_info string //卡信息
  3552. var busi_card_info string
  3553. card_info = respJSON["data"].(map[string]interface{})["card_info"].(string)
  3554. busi_card_info = respJSON["data"].(map[string]interface{})["busi_card_info"].(string)
  3555. if status == "0" { //读卡成功
  3556. if card_type == "1" {
  3557. respJSON = respJSON["data"].(map[string]interface{})["result"].(map[string]interface{})
  3558. result, _ := json.Marshal(respJSON)
  3559. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  3560. utils.ErrorLog("解析失败:%v", err)
  3561. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3562. return
  3563. }
  3564. res.ErrMsg = res10265.ErrMsg
  3565. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  3566. res.Infcode = infocode
  3567. res.Output = res10265.Output
  3568. res.InfRefmsgid = res10265.InfRefmsgid
  3569. } else {
  3570. //var card_info string //卡信息
  3571. //var busi_card_info string
  3572. token = respJSON["data"].(map[string]interface{})["token"].(string)
  3573. //busi_card_info = respJSON["data"].(map[string]interface{})["busi_card_info"].(string)
  3574. //fmt.Println(card_info)
  3575. //fmt.Println(busi_card_info)
  3576. respJSON = respJSON["data"].(map[string]interface{})["result"].(map[string]interface{})
  3577. result, _ := json.Marshal(respJSON)
  3578. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  3579. utils.ErrorLog("解析失败:%v", err)
  3580. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3581. return
  3582. }
  3583. res.ErrMsg = res10265.ErrMsg
  3584. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  3585. res.Infcode = infocode
  3586. res.Output = res10265.Output
  3587. res.InfRefmsgid = res10265.InfRefmsgid
  3588. }
  3589. if res.Infcode == 0 {
  3590. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  3591. if err == gorm.ErrRecordNotFound {
  3592. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  3593. return
  3594. } else if err != nil {
  3595. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  3596. return
  3597. } else {
  3598. if card_type == "1" {
  3599. bas := strings.Split(card_info, "|")
  3600. basNumber := bas[2]
  3601. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  3602. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  3603. infoStr := string(Iinfos)
  3604. idetinfoStr := string(Idetinfos)
  3605. psn := &models.HisPsn{
  3606. PsnNo: res.Output.Baseinfo.PsnNo,
  3607. Age: res.Output.Baseinfo.Age,
  3608. PatientId: patient.ID,
  3609. Certno: res.Output.Baseinfo.Certno,
  3610. Brdy: res.Output.Baseinfo.Brdy,
  3611. Gend: res.Output.Baseinfo.Gend,
  3612. Naty: res.Output.Baseinfo.Naty,
  3613. PsnCertType: res.Output.Baseinfo.PsnCertType,
  3614. PsnName: res.Output.Baseinfo.PsnName,
  3615. Idetinfo: idetinfoStr,
  3616. Insuinfo: infoStr,
  3617. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  3618. CardInfo: card_info,
  3619. VerifyNumber: busi_card_info,
  3620. }
  3621. service.CreateHisPsn(psn)
  3622. var rf []*ResultFive
  3623. json.Unmarshal([]byte(infoStr), &rf)
  3624. var insutypes []*ResultFive
  3625. var insutype string
  3626. var is390 int = 0
  3627. var is310 int = 0
  3628. for _, item := range rf {
  3629. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  3630. insutypes = append(insutypes, item)
  3631. }
  3632. }
  3633. if len(insutypes) == 1 {
  3634. insutype = insutypes[0].Insutype
  3635. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  3636. } else {
  3637. for _, i := range insutypes {
  3638. if i.Insutype == "390" {
  3639. is390 = 1
  3640. }
  3641. if i.Insutype == "310" {
  3642. is310 = 1
  3643. }
  3644. }
  3645. }
  3646. if is390 == 1 {
  3647. insutype = "390"
  3648. }
  3649. if is310 == 1 {
  3650. insutype = "310"
  3651. }
  3652. if len(insutypes) == 0 {
  3653. insutype = "310"
  3654. }
  3655. c.ServeSuccessJSON(map[string]interface{}{
  3656. "patient": patient,
  3657. "number": basNumber,
  3658. "insutype": insutype,
  3659. })
  3660. } else {
  3661. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  3662. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  3663. infoStr := string(Iinfos)
  3664. idetinfoStr := string(Idetinfos)
  3665. psn := &models.HisPsn{
  3666. PsnNo: res.Output.Baseinfo.PsnNo,
  3667. Age: res.Output.Baseinfo.Age,
  3668. PatientId: patient.ID,
  3669. Certno: res.Output.Baseinfo.Certno,
  3670. Brdy: res.Output.Baseinfo.Brdy,
  3671. Gend: res.Output.Baseinfo.Gend,
  3672. Naty: res.Output.Baseinfo.Naty,
  3673. PsnCertType: res.Output.Baseinfo.PsnCertType,
  3674. PsnName: res.Output.Baseinfo.PsnName,
  3675. Idetinfo: idetinfoStr,
  3676. Insuinfo: infoStr,
  3677. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  3678. CardInfo: card_info,
  3679. VerifyNumber: token,
  3680. }
  3681. service.CreateHisPsn(psn)
  3682. c.ServeSuccessJSON(map[string]interface{}{
  3683. "patient": patient,
  3684. "number": token,
  3685. })
  3686. }
  3687. }
  3688. } else {
  3689. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  3690. return
  3691. }
  3692. } else { //读卡失败
  3693. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  3694. return
  3695. }
  3696. } else if miConfig.MdtrtareaAdmvs == "350500" {
  3697. cardnum, cardCode, id_card_no, name, errmsg := c.GetFjBasBaseInfo()
  3698. cardnum = DeleteExtraSpaceTwo(cardnum)
  3699. cardCode = DeleteExtraSpaceTwo(cardCode)
  3700. id_card_no = DeleteExtraSpaceTwo(id_card_no)
  3701. name = DeleteExtraSpaceTwo(name)
  3702. errmsg = DeleteExtraSpaceTwo(errmsg)
  3703. cardnum = Remove0000(cardnum)
  3704. cardCode = Remove0000(cardCode)
  3705. id_card_no = Remove0000(id_card_no)
  3706. name = Remove0000(name)
  3707. errmsg = Remove0000(errmsg)
  3708. patient, _ := service.GetPatientByIDCard(id_card_no, miConfig.UserOrgId)
  3709. basStr := cardnum + "|" + cardCode + "|" + id_card_no + "|" + name
  3710. //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)
  3711. //fmt.Println(result2)
  3712. //fmt.Println(requestLog2)
  3713. //fmt.Println(errMsgLog2)
  3714. 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)
  3715. saveLog(result, requestLog, "1101", "获取人员信息")
  3716. fmt.Println(errMsgLog)
  3717. if len(errMsgLog) > 0 {
  3718. } else {
  3719. var dat map[string]interface{}
  3720. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  3721. fmt.Println(dat)
  3722. } else {
  3723. fmt.Println(err)
  3724. }
  3725. userJSONBytes, _ := json.Marshal(dat)
  3726. var res ResultTwo
  3727. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  3728. utils.ErrorLog("解析失败:%v", err)
  3729. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3730. return
  3731. }
  3732. res.ErrMsg = errMsgLog
  3733. if res.Infcode == 0 {
  3734. patient, err := service.GetPatientByNumber(id_card_no, c.GetAdminUserInfo().CurrentOrgId)
  3735. if err == gorm.ErrRecordNotFound {
  3736. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  3737. return
  3738. } else if err != nil {
  3739. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  3740. return
  3741. } else {
  3742. fmt.Println(res)
  3743. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  3744. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  3745. infoStr := string(Iinfos)
  3746. idetinfoStr := string(Idetinfos)
  3747. var rf []*ResultFive
  3748. json.Unmarshal([]byte(infoStr), &rf)
  3749. var insutypes []*ResultFive
  3750. var insutype string
  3751. var is390 int = 0
  3752. var is310 int = 0
  3753. for _, item := range rf {
  3754. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  3755. insutypes = append(insutypes, item)
  3756. }
  3757. }
  3758. if len(insutypes) == 1 {
  3759. insutype = insutypes[0].Insutype
  3760. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  3761. } else {
  3762. for _, i := range insutypes {
  3763. if i.Insutype == "390" {
  3764. is390 = 1
  3765. }
  3766. if i.Insutype == "310" {
  3767. is310 = 1
  3768. }
  3769. }
  3770. }
  3771. if is390 == 1 {
  3772. insutype = "390"
  3773. }
  3774. if is310 == 1 {
  3775. insutype = "310"
  3776. }
  3777. if len(insutypes) == 0 {
  3778. insutype = "390"
  3779. }
  3780. var insuplc_admdvs string
  3781. for _, item := range rf {
  3782. if item.Insutype == insutype {
  3783. insuplc_admdvs = item.InsuplcAdmdvs
  3784. }
  3785. }
  3786. psn := &models.HisPsn{
  3787. PsnNo: res.Output.Baseinfo.PsnNo,
  3788. Age: res.Output.Baseinfo.Age,
  3789. PatientId: patient.ID,
  3790. Certno: res.Output.Baseinfo.Certno,
  3791. Brdy: res.Output.Baseinfo.Brdy,
  3792. Gend: res.Output.Baseinfo.Gend,
  3793. Naty: res.Output.Baseinfo.Naty,
  3794. PsnCertType: res.Output.Baseinfo.PsnCertType,
  3795. PsnName: res.Output.Baseinfo.PsnName,
  3796. Idetinfo: idetinfoStr,
  3797. Insuinfo: infoStr,
  3798. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  3799. CardInfo: basStr,
  3800. VerifyNumber: "",
  3801. InsuplcAdmdvs: insuplc_admdvs,
  3802. }
  3803. service.CreateHisPsn(psn)
  3804. c.ServeSuccessJSON(map[string]interface{}{
  3805. "patient": patient,
  3806. "number": cardnum,
  3807. "insutype": insutype,
  3808. })
  3809. }
  3810. } else {
  3811. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  3812. return
  3813. }
  3814. }
  3815. } else if miConfig.MdtrtareaAdmvs == "360399" {
  3816. fmt.Println(initFlag)
  3817. fmt.Println("initFlag")
  3818. if initFlag == 0 {
  3819. c.TestGetJiangXiBasBaseInit()
  3820. }
  3821. basStr := c.GetBasBaseInfo()
  3822. if len(basStr) == 0 {
  3823. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeReadCardException)
  3824. return
  3825. }
  3826. fmt.Println(basStr)
  3827. bas := strings.Split(basStr, "|")
  3828. basNumber := bas[1]
  3829. fmt.Println(basNumber)
  3830. card_sn := bas[3]
  3831. fmt.Println(card_sn)
  3832. 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, "")
  3833. //result := service.Jxyb1101(basNumber, miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, id_card_type, card_sn, certificates)
  3834. var dat map[string]interface{}
  3835. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  3836. fmt.Println(dat)
  3837. } else {
  3838. fmt.Println(err)
  3839. }
  3840. userJSONBytes, _ := json.Marshal(dat)
  3841. var res ResultTwo
  3842. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  3843. utils.ErrorLog("解析失败:%v", err)
  3844. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3845. return
  3846. }
  3847. if res.Infcode == 0 {
  3848. patient, err := service.GetPatientByNumber(basNumber, c.GetAdminUserInfo().CurrentOrgId)
  3849. if err == gorm.ErrRecordNotFound {
  3850. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  3851. return
  3852. } else if err != nil {
  3853. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  3854. return
  3855. } else {
  3856. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  3857. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  3858. infoStr := string(Iinfos)
  3859. idetinfoStr := string(Idetinfos)
  3860. psn := &models.HisPsn{
  3861. PsnNo: res.Output.Baseinfo.PsnNo,
  3862. Age: res.Output.Baseinfo.Age,
  3863. PatientId: patient.ID,
  3864. Certno: res.Output.Baseinfo.Certno,
  3865. Brdy: res.Output.Baseinfo.Brdy,
  3866. Gend: res.Output.Baseinfo.Gend,
  3867. Naty: res.Output.Baseinfo.Naty,
  3868. PsnCertType: res.Output.Baseinfo.PsnCertType,
  3869. PsnName: res.Output.Baseinfo.PsnName,
  3870. Idetinfo: idetinfoStr,
  3871. Insuinfo: infoStr,
  3872. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  3873. CardInfo: basStr,
  3874. VerifyNumber: "",
  3875. }
  3876. service.CreateHisPsn(psn)
  3877. var rf []*ResultFive
  3878. json.Unmarshal([]byte(infoStr), &rf)
  3879. var insutypes []*ResultFive
  3880. var insutype string
  3881. var is390 int = 0
  3882. var is310 int = 0
  3883. for _, item := range rf {
  3884. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  3885. insutypes = append(insutypes, item)
  3886. }
  3887. }
  3888. if len(insutypes) == 1 {
  3889. insutype = insutypes[0].Insutype
  3890. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  3891. } else {
  3892. for _, i := range insutypes {
  3893. if i.Insutype == "390" {
  3894. is390 = 1
  3895. }
  3896. if i.Insutype == "310" {
  3897. is310 = 1
  3898. }
  3899. }
  3900. }
  3901. if is390 == 1 {
  3902. insutype = "390"
  3903. }
  3904. if is310 == 1 {
  3905. insutype = "310"
  3906. }
  3907. if len(insutypes) == 0 {
  3908. insutype = "310"
  3909. }
  3910. c.ServeSuccessJSON(map[string]interface{}{
  3911. "patient": patient,
  3912. "number": basNumber,
  3913. "insutype": insutype,
  3914. })
  3915. }
  3916. } else {
  3917. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  3918. return
  3919. }
  3920. } else if miConfig.MdtrtareaAdmvs == "430800" {
  3921. fmt.Println(initFlag)
  3922. fmt.Println("initFlag")
  3923. if initFlag == 0 {
  3924. c.TestGetHnBasBaseInit()
  3925. }
  3926. basStr := c.GetBasBaseInfo()
  3927. if len(basStr) == 0 {
  3928. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeReadCardException)
  3929. return
  3930. }
  3931. fmt.Println(basStr)
  3932. bas := strings.Split(basStr, "|")
  3933. basNumber := bas[1]
  3934. fmt.Println(basNumber)
  3935. card_sn := bas[3]
  3936. card_no := bas[2]
  3937. fmt.Println(card_sn)
  3938. name := bas[4]
  3939. name = ConvertToString(name, "gbk", "utf-8")
  3940. 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)
  3941. //result := service.Jxyb1101(basNumber, miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, id_card_type, card_sn, certificates)
  3942. var dat map[string]interface{}
  3943. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  3944. fmt.Println(dat)
  3945. } else {
  3946. fmt.Println(err)
  3947. }
  3948. userJSONBytes, _ := json.Marshal(dat)
  3949. var res ResultTwo
  3950. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  3951. utils.ErrorLog("解析失败:%v", err)
  3952. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3953. return
  3954. }
  3955. if res.Infcode == 0 {
  3956. patient, err := service.GetPatientByNumber(basNumber, c.GetAdminUserInfo().CurrentOrgId)
  3957. if err == gorm.ErrRecordNotFound {
  3958. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  3959. return
  3960. } else if err != nil {
  3961. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  3962. return
  3963. } else {
  3964. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  3965. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  3966. infoStr := string(Iinfos)
  3967. idetinfoStr := string(Idetinfos)
  3968. psn := &models.HisPsn{
  3969. PsnNo: res.Output.Baseinfo.PsnNo,
  3970. Age: res.Output.Baseinfo.Age,
  3971. PatientId: patient.ID,
  3972. Certno: res.Output.Baseinfo.Certno,
  3973. Brdy: res.Output.Baseinfo.Brdy,
  3974. Gend: res.Output.Baseinfo.Gend,
  3975. Naty: res.Output.Baseinfo.Naty,
  3976. PsnCertType: res.Output.Baseinfo.PsnCertType,
  3977. PsnName: res.Output.Baseinfo.PsnName,
  3978. Idetinfo: idetinfoStr,
  3979. Insuinfo: infoStr,
  3980. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  3981. CardInfo: basStr,
  3982. VerifyNumber: "",
  3983. }
  3984. service.CreateHisPsn(psn)
  3985. var rf []*ResultFive
  3986. json.Unmarshal([]byte(infoStr), &rf)
  3987. var insutypes []*ResultFive
  3988. var insutype string
  3989. var is390 int = 0
  3990. var is310 int = 0
  3991. for _, item := range rf {
  3992. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  3993. insutypes = append(insutypes, item)
  3994. }
  3995. }
  3996. if len(insutypes) == 1 {
  3997. insutype = insutypes[0].Insutype
  3998. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  3999. } else {
  4000. for _, i := range insutypes {
  4001. if i.Insutype == "390" {
  4002. is390 = 1
  4003. }
  4004. if i.Insutype == "310" {
  4005. is310 = 1
  4006. }
  4007. }
  4008. }
  4009. if is390 == 1 {
  4010. insutype = "390"
  4011. }
  4012. if is310 == 1 {
  4013. insutype = "310"
  4014. }
  4015. if len(insutypes) == 0 {
  4016. insutype = "310"
  4017. }
  4018. c.ServeSuccessJSON(map[string]interface{}{
  4019. "patient": patient,
  4020. "number": basNumber,
  4021. "insutype": insutype,
  4022. })
  4023. }
  4024. } else {
  4025. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  4026. return
  4027. }
  4028. } else {
  4029. if initFlag == 0 {
  4030. c.TestGetBasBaseInit()
  4031. }
  4032. basStr := c.GetBasBaseInfo()
  4033. if len(basStr) == 0 {
  4034. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeReadCardException)
  4035. return
  4036. }
  4037. fmt.Println(basStr)
  4038. bas := strings.Split(basStr, "|")
  4039. basNumber := bas[1]
  4040. fmt.Println(basNumber)
  4041. card_sn := bas[3]
  4042. fmt.Println(card_sn)
  4043. cardNumber := bas[2]
  4044. fmt.Println(cardNumber)
  4045. patient, _ := service.GetPatientByIDCard(basNumber, miConfig.UserOrgId)
  4046. var result string
  4047. if bas[0][:2] == "44" {
  4048. 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)
  4049. } else {
  4050. 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)
  4051. }
  4052. var dat map[string]interface{}
  4053. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  4054. fmt.Println(dat)
  4055. } else {
  4056. fmt.Println(err)
  4057. }
  4058. userJSONBytes, _ := json.Marshal(dat)
  4059. var res ResultTwo
  4060. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  4061. utils.ErrorLog("解析失败:%v", err)
  4062. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4063. return
  4064. }
  4065. if res.Infcode == 0 {
  4066. patient, err := service.GetPatientByNumber(basNumber, c.GetAdminUserInfo().CurrentOrgId)
  4067. if err == gorm.ErrRecordNotFound {
  4068. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  4069. return
  4070. } else if err != nil {
  4071. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  4072. return
  4073. } else {
  4074. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  4075. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  4076. infoStr := string(Iinfos)
  4077. idetinfoStr := string(Idetinfos)
  4078. var rf []*ResultFive
  4079. json.Unmarshal([]byte(infoStr), &rf)
  4080. var insutypes []*ResultFive
  4081. var insutype string
  4082. var is390 int = 0
  4083. var is310 int = 0
  4084. var insuplc_admdvs string
  4085. for _, item := range rf {
  4086. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  4087. insutypes = append(insutypes, item)
  4088. }
  4089. }
  4090. if len(insutypes) == 1 {
  4091. insutype = insutypes[0].Insutype
  4092. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  4093. } else {
  4094. for _, i := range insutypes {
  4095. if i.Insutype == "390" {
  4096. is390 = 1
  4097. }
  4098. if i.Insutype == "310" {
  4099. is310 = 1
  4100. }
  4101. }
  4102. }
  4103. if is390 == 1 {
  4104. insutype = "390"
  4105. }
  4106. if is310 == 1 {
  4107. insutype = "310"
  4108. }
  4109. if len(insutypes) == 0 {
  4110. insutype = "310"
  4111. }
  4112. for _, item := range rf {
  4113. if item.Insutype == insutype {
  4114. insuplc_admdvs = item.InsuplcAdmdvs
  4115. }
  4116. }
  4117. psn := &models.HisPsn{
  4118. PsnNo: res.Output.Baseinfo.PsnNo,
  4119. Age: res.Output.Baseinfo.Age,
  4120. PatientId: patient.ID,
  4121. Certno: res.Output.Baseinfo.Certno,
  4122. Brdy: res.Output.Baseinfo.Brdy,
  4123. Gend: res.Output.Baseinfo.Gend,
  4124. Naty: res.Output.Baseinfo.Naty,
  4125. PsnCertType: res.Output.Baseinfo.PsnCertType,
  4126. PsnName: res.Output.Baseinfo.PsnName,
  4127. Idetinfo: idetinfoStr,
  4128. Insuinfo: infoStr,
  4129. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  4130. CardInfo: basStr,
  4131. VerifyNumber: "",
  4132. InsuplcAdmdvs: insuplc_admdvs,
  4133. }
  4134. service.CreateHisPsn(psn)
  4135. c.ServeSuccessJSON(map[string]interface{}{
  4136. "patient": patient,
  4137. "number": basNumber,
  4138. })
  4139. }
  4140. } else {
  4141. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  4142. return
  4143. }
  4144. break
  4145. }
  4146. case 2:
  4147. if miConfig.MdtrtareaAdmvs == "430800" {
  4148. if initFlag == 0 {
  4149. c.TestGetHnBasBaseInit()
  4150. }
  4151. SFZStr := c.GetSFZBaseInfo()
  4152. if len(SFZStr) == 0 {
  4153. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeReadCardException)
  4154. return
  4155. }
  4156. fmt.Println(SFZStr)
  4157. id_card_str := strings.Split(SFZStr, "^")
  4158. card_no := id_card_str[0]
  4159. patient, _ := service.GetPatientByNumber(card_no, c.GetAdminUserInfo().CurrentOrgId)
  4160. //name := id_card_str[1]
  4161. //name = ConvertToString(name, "gbk", "utf-8")
  4162. 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)
  4163. var dat map[string]interface{}
  4164. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  4165. fmt.Println(dat)
  4166. } else {
  4167. fmt.Println(err)
  4168. }
  4169. userJSONBytes, _ := json.Marshal(dat)
  4170. var res ResultTwo
  4171. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  4172. utils.ErrorLog("解析失败:%v", err)
  4173. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4174. return
  4175. }
  4176. if res.Infcode == 0 {
  4177. patient, err := service.GetPatientByNumber(card_no, c.GetAdminUserInfo().CurrentOrgId)
  4178. if err == gorm.ErrRecordNotFound {
  4179. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  4180. return
  4181. } else if err != nil {
  4182. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  4183. return
  4184. } else {
  4185. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  4186. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  4187. infoStr := string(Iinfos)
  4188. idetinfoStr := string(Idetinfos)
  4189. psn := &models.HisPsn{
  4190. PsnNo: res.Output.Baseinfo.PsnNo,
  4191. Age: res.Output.Baseinfo.Age,
  4192. PatientId: patient.ID,
  4193. Certno: res.Output.Baseinfo.Certno,
  4194. Brdy: res.Output.Baseinfo.Brdy,
  4195. Gend: res.Output.Baseinfo.Gend,
  4196. Naty: res.Output.Baseinfo.Naty,
  4197. PsnCertType: res.Output.Baseinfo.PsnCertType,
  4198. PsnName: res.Output.Baseinfo.PsnName,
  4199. Idetinfo: idetinfoStr,
  4200. Insuinfo: infoStr,
  4201. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  4202. CardInfo: SFZStr,
  4203. VerifyNumber: "",
  4204. }
  4205. service.CreateHisPsn(psn)
  4206. var rf []*ResultFive
  4207. json.Unmarshal([]byte(infoStr), &rf)
  4208. var insutypes []*ResultFive
  4209. var insutype string
  4210. var is390 int = 0
  4211. var is310 int = 0
  4212. for _, item := range rf {
  4213. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  4214. insutypes = append(insutypes, item)
  4215. }
  4216. }
  4217. if len(insutypes) == 1 {
  4218. insutype = insutypes[0].Insutype
  4219. } else {
  4220. for _, i := range insutypes {
  4221. if i.Insutype == "390" {
  4222. is390 = 1
  4223. }
  4224. if i.Insutype == "310" {
  4225. is310 = 1
  4226. }
  4227. }
  4228. }
  4229. if is390 == 1 {
  4230. insutype = "390"
  4231. }
  4232. if is310 == 1 {
  4233. insutype = "310"
  4234. }
  4235. if len(insutypes) == 0 {
  4236. insutype = "310"
  4237. }
  4238. c.ServeSuccessJSON(map[string]interface{}{
  4239. "patient": patient,
  4240. "number": card_no,
  4241. "insutype": insutype,
  4242. })
  4243. }
  4244. } else {
  4245. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  4246. return
  4247. }
  4248. } else {
  4249. SFZStr := c.GetSFZBaseInfo()
  4250. id_card_str := strings.Split(SFZStr, "^")
  4251. id_card_number := id_card_str[0]
  4252. card_sn := ""
  4253. result := service.Gdyb1101B(id_card_number, miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, id_card_type, card_sn, certificates, "", "")
  4254. var dat map[string]interface{}
  4255. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  4256. fmt.Println(dat)
  4257. } else {
  4258. fmt.Println(err)
  4259. }
  4260. userJSONBytes, _ := json.Marshal(dat)
  4261. var res ResultTwo
  4262. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  4263. utils.ErrorLog("解析失败:%v", err)
  4264. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4265. return
  4266. }
  4267. if res.Infcode == 0 {
  4268. patient, err := service.GetPatientByNumber(id_card_number, c.GetAdminUserInfo().CurrentOrgId)
  4269. if err == gorm.ErrRecordNotFound {
  4270. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  4271. return
  4272. } else if err != nil {
  4273. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  4274. return
  4275. } else {
  4276. c.ServeSuccessJSON(map[string]interface{}{
  4277. "patient": patient,
  4278. "number": id_card_number,
  4279. })
  4280. }
  4281. } else {
  4282. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  4283. return
  4284. }
  4285. }
  4286. break
  4287. case 3:
  4288. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  4289. var api string
  4290. if miConfig.MdtrtareaAdmvs == "320921" {
  4291. 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 +
  4292. "&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
  4293. fmt.Println(api)
  4294. } else {
  4295. 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 +
  4296. "&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)
  4297. }
  4298. resp, requestErr := http.Get(api)
  4299. if requestErr != nil {
  4300. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4301. return
  4302. }
  4303. body, ioErr := ioutil.ReadAll(resp.Body)
  4304. if ioErr != nil {
  4305. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  4306. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4307. return
  4308. }
  4309. var respJSON map[string]interface{}
  4310. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  4311. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  4312. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4313. return
  4314. }
  4315. var status string
  4316. status = respJSON["data"].(map[string]interface{})["status"].(string)
  4317. card_type := respJSON["data"].(map[string]interface{})["type"].(string)
  4318. var token string
  4319. var res ResultTwo //1101结果
  4320. var res10265 ResultTwo10265 //1101结果
  4321. var card_info string //卡信息
  4322. var busi_card_info string
  4323. //card_info = respJSON["data"].(map[string]interface{})["card_info"].(string)
  4324. busi_card_info = respJSON["data"].(map[string]interface{})["busi_card_info"].(string)
  4325. if status == "0" { //读卡成功
  4326. if card_type == "1" {
  4327. respJSON = respJSON["data"].(map[string]interface{})["result"].(map[string]interface{})
  4328. result, _ := json.Marshal(respJSON)
  4329. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  4330. utils.ErrorLog("解析失败:%v", err)
  4331. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4332. return
  4333. }
  4334. res.ErrMsg = res10265.ErrMsg
  4335. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  4336. res.Infcode = infocode
  4337. res.Output = res10265.Output
  4338. res.InfRefmsgid = res10265.InfRefmsgid
  4339. } else {
  4340. //var card_info string //卡信息
  4341. //var busi_card_info string
  4342. token = respJSON["data"].(map[string]interface{})["token"].(string)
  4343. //busi_card_info = respJSON["data"].(map[string]interface{})["busi_card_info"].(string)
  4344. //fmt.Println(card_info)
  4345. //fmt.Println(busi_card_info)
  4346. respJSON = respJSON["data"].(map[string]interface{})["result"].(map[string]interface{})
  4347. result, _ := json.Marshal(respJSON)
  4348. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  4349. utils.ErrorLog("解析失败:%v", err)
  4350. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4351. return
  4352. }
  4353. res.ErrMsg = res10265.ErrMsg
  4354. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  4355. res.Infcode = infocode
  4356. res.Output = res10265.Output
  4357. res.InfRefmsgid = res10265.InfRefmsgid
  4358. }
  4359. if res.Infcode == 0 {
  4360. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  4361. if err == gorm.ErrRecordNotFound {
  4362. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  4363. return
  4364. } else if err != nil {
  4365. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  4366. return
  4367. } else {
  4368. if card_type == "1" {
  4369. bas := strings.Split(card_info, "|")
  4370. basNumber := bas[2]
  4371. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  4372. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  4373. infoStr := string(Iinfos)
  4374. idetinfoStr := string(Idetinfos)
  4375. psn := &models.HisPsn{
  4376. PsnNo: res.Output.Baseinfo.PsnNo,
  4377. Age: res.Output.Baseinfo.Age,
  4378. PatientId: patient.ID,
  4379. Certno: res.Output.Baseinfo.Certno,
  4380. Brdy: res.Output.Baseinfo.Brdy,
  4381. Gend: res.Output.Baseinfo.Gend,
  4382. Naty: res.Output.Baseinfo.Naty,
  4383. PsnCertType: res.Output.Baseinfo.PsnCertType,
  4384. PsnName: res.Output.Baseinfo.PsnName,
  4385. Idetinfo: idetinfoStr,
  4386. Insuinfo: infoStr,
  4387. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  4388. CardInfo: card_info,
  4389. VerifyNumber: busi_card_info,
  4390. }
  4391. service.CreateHisPsn(psn)
  4392. c.ServeSuccessJSON(map[string]interface{}{
  4393. "patient": patient,
  4394. "number": basNumber,
  4395. })
  4396. } else {
  4397. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  4398. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  4399. infoStr := string(Iinfos)
  4400. idetinfoStr := string(Idetinfos)
  4401. psn := &models.HisPsn{
  4402. PsnNo: res.Output.Baseinfo.PsnNo,
  4403. Age: res.Output.Baseinfo.Age,
  4404. PatientId: patient.ID,
  4405. Certno: res.Output.Baseinfo.Certno,
  4406. Brdy: res.Output.Baseinfo.Brdy,
  4407. Gend: res.Output.Baseinfo.Gend,
  4408. Naty: res.Output.Baseinfo.Naty,
  4409. PsnCertType: res.Output.Baseinfo.PsnCertType,
  4410. PsnName: res.Output.Baseinfo.PsnName,
  4411. Idetinfo: idetinfoStr,
  4412. Insuinfo: infoStr,
  4413. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  4414. CardInfo: card_info,
  4415. VerifyNumber: token,
  4416. }
  4417. service.CreateHisPsn(psn)
  4418. var rf []*ResultFive
  4419. json.Unmarshal([]byte(infoStr), &rf)
  4420. var insutypes []*ResultFive
  4421. var insutype string
  4422. var is390 int = 0
  4423. var is310 int = 0
  4424. for _, item := range rf {
  4425. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  4426. insutypes = append(insutypes, item)
  4427. }
  4428. }
  4429. if len(insutypes) == 1 {
  4430. insutype = insutypes[0].Insutype
  4431. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  4432. } else {
  4433. for _, i := range insutypes {
  4434. if i.Insutype == "390" {
  4435. is390 = 1
  4436. }
  4437. if i.Insutype == "310" {
  4438. is310 = 1
  4439. }
  4440. }
  4441. }
  4442. if is390 == 1 {
  4443. insutype = "390"
  4444. }
  4445. if is310 == 1 {
  4446. insutype = "310"
  4447. }
  4448. if len(insutypes) == 0 {
  4449. insutype = "310"
  4450. }
  4451. c.ServeSuccessJSON(map[string]interface{}{
  4452. "patient": patient,
  4453. "number": token,
  4454. "insutype": insutype,
  4455. })
  4456. }
  4457. }
  4458. } else {
  4459. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  4460. return
  4461. }
  4462. } else { //读卡失败
  4463. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  4464. return
  4465. }
  4466. }
  4467. break
  4468. case 4:
  4469. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  4470. var api string
  4471. if miConfig.MdtrtareaAdmvs == "320921" {
  4472. 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 +
  4473. "&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
  4474. fmt.Println(api)
  4475. } else {
  4476. 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 +
  4477. "&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)
  4478. }
  4479. resp, requestErr := http.Get(api)
  4480. if requestErr != nil {
  4481. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4482. return
  4483. }
  4484. body, ioErr := ioutil.ReadAll(resp.Body)
  4485. if ioErr != nil {
  4486. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  4487. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4488. return
  4489. }
  4490. var respJSON map[string]interface{}
  4491. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  4492. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  4493. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4494. return
  4495. }
  4496. var status string
  4497. status = respJSON["data"].(map[string]interface{})["status"].(string)
  4498. //card_type := respJSON["data"].(map[string]interface{})["type"].(string)
  4499. var token string
  4500. var res ResultTwo //1101结果
  4501. var res10265 ResultTwo10265 //1101结果
  4502. if status == "0" { //读卡成功
  4503. var card_info string //卡信息
  4504. var busi_card_info string
  4505. token = respJSON["data"].(map[string]interface{})["token"].(string)
  4506. busi_card_info = respJSON["data"].(map[string]interface{})["busi_card_info"].(string)
  4507. card_info = respJSON["data"].(map[string]interface{})["card_info"].(string)
  4508. fmt.Println(card_info)
  4509. fmt.Println(busi_card_info)
  4510. respJSON = respJSON["data"].(map[string]interface{})["result"].(map[string]interface{})
  4511. result, _ := json.Marshal(respJSON)
  4512. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  4513. utils.ErrorLog("解析失败:%v", err)
  4514. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4515. return
  4516. }
  4517. res.ErrMsg = res10265.ErrMsg
  4518. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  4519. res.Infcode = infocode
  4520. res.Output = res10265.Output
  4521. res.InfRefmsgid = res10265.InfRefmsgid
  4522. if res.Infcode == 0 {
  4523. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  4524. if err == gorm.ErrRecordNotFound {
  4525. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  4526. return
  4527. } else if err != nil {
  4528. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  4529. return
  4530. } else {
  4531. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  4532. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  4533. infoStr := string(Iinfos)
  4534. idetinfoStr := string(Idetinfos)
  4535. psn := &models.HisPsn{
  4536. PsnNo: res.Output.Baseinfo.PsnNo,
  4537. Age: res.Output.Baseinfo.Age,
  4538. PatientId: patient.ID,
  4539. Certno: res.Output.Baseinfo.Certno,
  4540. Brdy: res.Output.Baseinfo.Brdy,
  4541. Gend: res.Output.Baseinfo.Gend,
  4542. Naty: res.Output.Baseinfo.Naty,
  4543. PsnCertType: res.Output.Baseinfo.PsnCertType,
  4544. PsnName: res.Output.Baseinfo.PsnName,
  4545. Idetinfo: idetinfoStr,
  4546. Insuinfo: infoStr,
  4547. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  4548. CardInfo: card_info,
  4549. VerifyNumber: token,
  4550. }
  4551. var rf []*ResultFive
  4552. json.Unmarshal([]byte(infoStr), &rf)
  4553. var insutypes []*ResultFive
  4554. var insutype string
  4555. var is390 int = 0
  4556. var is310 int = 0
  4557. for _, item := range rf {
  4558. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  4559. insutypes = append(insutypes, item)
  4560. }
  4561. }
  4562. if len(insutypes) == 1 {
  4563. insutype = insutypes[0].Insutype
  4564. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  4565. } else {
  4566. for _, i := range insutypes {
  4567. if i.Insutype == "390" {
  4568. is390 = 1
  4569. }
  4570. if i.Insutype == "310" {
  4571. is310 = 1
  4572. }
  4573. }
  4574. }
  4575. if is390 == 1 {
  4576. insutype = "390"
  4577. }
  4578. if is310 == 1 {
  4579. insutype = "310"
  4580. }
  4581. if len(insutypes) == 0 {
  4582. insutype = "310"
  4583. }
  4584. service.CreateHisPsn(psn)
  4585. c.ServeSuccessJSON(map[string]interface{}{
  4586. "patient": patient,
  4587. "number": token,
  4588. "insutype": insutype,
  4589. })
  4590. }
  4591. } else {
  4592. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  4593. return
  4594. }
  4595. } else { //读卡失败
  4596. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  4597. return
  4598. }
  4599. } else if miConfig.MdtrtareaAdmvs == "430800" {
  4600. idNo := c.GetString("idNo")
  4601. userName := c.GetString("userName")
  4602. ecToken := c.GetString("ecToken")
  4603. insuOrg := c.GetString("insuOrg")
  4604. result2, requestLog2 := service.Hnyb1101ForEleCert(miConfig.OrgName, roles.UserName, miConfig.Code, insuOrg, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, miConfig.Url, miConfig.AccessKey, ecToken, "", idNo, userName)
  4605. saveLog(result2, requestLog2, "1101", "获取人员信息")
  4606. var res ResultTwo
  4607. if err := json.Unmarshal([]byte(result2), &res); err != nil {
  4608. utils.ErrorLog("解析失败:%v", err)
  4609. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4610. return
  4611. }
  4612. if res.Infcode == 0 {
  4613. patient, err := service.GetPatientByNumber(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  4614. if err == gorm.ErrRecordNotFound {
  4615. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  4616. return
  4617. } else if err != nil {
  4618. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  4619. return
  4620. } else {
  4621. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  4622. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  4623. infoStr := string(Iinfos)
  4624. idetinfoStr := string(Idetinfos)
  4625. psn := &models.HisPsn{
  4626. PsnNo: res.Output.Baseinfo.PsnNo,
  4627. Age: res.Output.Baseinfo.Age,
  4628. PatientId: patient.ID,
  4629. Certno: res.Output.Baseinfo.Certno,
  4630. Brdy: res.Output.Baseinfo.Brdy,
  4631. Gend: res.Output.Baseinfo.Gend,
  4632. Naty: res.Output.Baseinfo.Naty,
  4633. PsnCertType: res.Output.Baseinfo.PsnCertType,
  4634. PsnName: res.Output.Baseinfo.PsnName,
  4635. Idetinfo: idetinfoStr,
  4636. Insuinfo: infoStr,
  4637. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  4638. CardInfo: "",
  4639. Stage: "1",
  4640. VerifyNumber: ecToken,
  4641. InsuplcAdmdvs: insuOrg,
  4642. }
  4643. service.CreateHisPsn(psn)
  4644. var rf []*ResultFive
  4645. json.Unmarshal([]byte(infoStr), &rf)
  4646. var insutypes []*ResultFive
  4647. var insutype string
  4648. var is390 int = 0
  4649. var is310 int = 0
  4650. for _, item := range rf {
  4651. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  4652. insutypes = append(insutypes, item)
  4653. }
  4654. }
  4655. if len(insutypes) == 1 {
  4656. insutype = insutypes[0].Insutype
  4657. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  4658. } else {
  4659. for _, i := range insutypes {
  4660. if i.Insutype == "390" {
  4661. is390 = 1
  4662. }
  4663. if i.Insutype == "310" {
  4664. is310 = 1
  4665. }
  4666. }
  4667. }
  4668. if is390 == 1 {
  4669. insutype = "390"
  4670. }
  4671. if is310 == 1 {
  4672. insutype = "310"
  4673. }
  4674. if len(insutypes) == 0 {
  4675. insutype = "310"
  4676. }
  4677. c.ServeSuccessJSON(map[string]interface{}{
  4678. "patient": patient,
  4679. "number": ecToken,
  4680. "insutype": insutype,
  4681. })
  4682. }
  4683. } else {
  4684. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  4685. return
  4686. }
  4687. } else if miConfig.MdtrtareaAdmvs == "360399" {
  4688. //if initFlag == 0 {
  4689. c.TestGetJiangXiBasBaseInit()
  4690. //}
  4691. //if initEleFlag == 0 {
  4692. // GetJxEleBaseInitInfo(c.GetAdminUserInfo().CurrentOrgId)
  4693. //}
  4694. json_result := GetJxEleBaseInfo(c.GetAdminUserInfo().CurrentOrgId)
  4695. type ELeData struct {
  4696. Data struct {
  4697. IdNo string `json:"idNo"`
  4698. IdType string `json:"idType"`
  4699. UserName string `json:"userName"`
  4700. EcToken string `json:"ecToken"`
  4701. InsuOrg string `json:"insuOrg"`
  4702. Gender string `json:"gender"`
  4703. Birthday string `json:"birthday"`
  4704. Nationality string `json:"nationality"`
  4705. Email string `json:"email"`
  4706. Extra string `json:"extra"`
  4707. } `json:"data"`
  4708. Code int `json:"code"`
  4709. Message string `json:"message"`
  4710. }
  4711. var ele ELeData
  4712. err := json.Unmarshal([]byte(json_result), &ele)
  4713. if err != nil {
  4714. utils.ErrorLog("解析失败:%v", err)
  4715. }
  4716. token := ele.Data.EcToken
  4717. token = Remove0000(token)
  4718. 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)
  4719. saveLog(result2, requestLog2, "1101", "获取人员信息")
  4720. var res ResultTwo
  4721. if err := json.Unmarshal([]byte(result2), &res); err != nil {
  4722. utils.ErrorLog("解析失败:%v", err)
  4723. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4724. return
  4725. }
  4726. if res.Infcode == 0 {
  4727. patient, err := service.GetPatientByNumber(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  4728. if err == gorm.ErrRecordNotFound {
  4729. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  4730. return
  4731. } else if err != nil {
  4732. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  4733. return
  4734. } else {
  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: "",
  4753. //RecordDate:
  4754. VerifyNumber: token,
  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. } else if miConfig.MdtrtareaAdmvs == "430800" {
  4801. //if initFlag == 0 {
  4802. c.TestGetJiangXiBasBaseInit()
  4803. //}
  4804. //if initEleFlag == 0 {
  4805. // GetJxEleBaseInitInfo(c.GetAdminUserInfo().CurrentOrgId)
  4806. //}
  4807. json_result := GetJxEleBaseInfo(c.GetAdminUserInfo().CurrentOrgId)
  4808. type ELeData struct {
  4809. Data struct {
  4810. IdNo string `json:"idNo"`
  4811. IdType string `json:"idType"`
  4812. UserName string `json:"userName"`
  4813. EcToken string `json:"ecToken"`
  4814. InsuOrg string `json:"insuOrg"`
  4815. Gender string `json:"gender"`
  4816. Birthday string `json:"birthday"`
  4817. Nationality string `json:"nationality"`
  4818. Email string `json:"email"`
  4819. Extra string `json:"extra"`
  4820. } `json:"data"`
  4821. Code int `json:"code"`
  4822. Message string `json:"message"`
  4823. }
  4824. var ele ELeData
  4825. err := json.Unmarshal([]byte(json_result), &ele)
  4826. if err != nil {
  4827. utils.ErrorLog("解析失败:%v", err)
  4828. }
  4829. token := ele.Data.EcToken
  4830. token = Remove0000(token)
  4831. 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)
  4832. saveLog(result2, requestLog2, "1101", "获取人员信息")
  4833. var res ResultTwo
  4834. if err := json.Unmarshal([]byte(result2), &res); err != nil {
  4835. utils.ErrorLog("解析失败:%v", err)
  4836. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4837. return
  4838. }
  4839. if res.Infcode == 0 {
  4840. patient, err := service.GetPatientByNumber(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  4841. if err == gorm.ErrRecordNotFound {
  4842. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  4843. return
  4844. } else if err != nil {
  4845. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  4846. return
  4847. } else {
  4848. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  4849. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  4850. infoStr := string(Iinfos)
  4851. idetinfoStr := string(Idetinfos)
  4852. psn := &models.HisPsn{
  4853. PsnNo: res.Output.Baseinfo.PsnNo,
  4854. Age: res.Output.Baseinfo.Age,
  4855. PatientId: patient.ID,
  4856. Certno: res.Output.Baseinfo.Certno,
  4857. Brdy: res.Output.Baseinfo.Brdy,
  4858. Gend: res.Output.Baseinfo.Gend,
  4859. Naty: res.Output.Baseinfo.Naty,
  4860. PsnCertType: res.Output.Baseinfo.PsnCertType,
  4861. PsnName: res.Output.Baseinfo.PsnName,
  4862. Idetinfo: idetinfoStr,
  4863. Insuinfo: infoStr,
  4864. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  4865. CardInfo: "",
  4866. VerifyNumber: token,
  4867. }
  4868. service.CreateHisPsn(psn)
  4869. var rf []*ResultFive
  4870. json.Unmarshal([]byte(infoStr), &rf)
  4871. var insutypes []*ResultFive
  4872. var insutype string
  4873. var is390 int = 0
  4874. var is310 int = 0
  4875. for _, item := range rf {
  4876. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  4877. insutypes = append(insutypes, item)
  4878. }
  4879. }
  4880. if len(insutypes) == 1 {
  4881. insutype = insutypes[0].Insutype
  4882. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  4883. } else {
  4884. for _, i := range insutypes {
  4885. if i.Insutype == "390" {
  4886. is390 = 1
  4887. }
  4888. if i.Insutype == "310" {
  4889. is310 = 1
  4890. }
  4891. }
  4892. }
  4893. if is390 == 1 {
  4894. insutype = "390"
  4895. }
  4896. if is310 == 1 {
  4897. insutype = "310"
  4898. }
  4899. if len(insutypes) == 0 {
  4900. insutype = "310"
  4901. }
  4902. c.ServeSuccessJSON(map[string]interface{}{
  4903. "patient": patient,
  4904. "number": token,
  4905. "insutype": insutype,
  4906. })
  4907. }
  4908. } else {
  4909. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  4910. return
  4911. }
  4912. } else if miConfig.MdtrtareaAdmvs == "350500" {
  4913. type ELeData struct {
  4914. Code string `json:"code"`
  4915. Data struct {
  4916. Aac002 string `json:"aac002"`
  4917. Aaz500 string `json:"aaz500"`
  4918. ActCardNo string `json:"actCardNo"`
  4919. Bab520 string `json:"bab520"`
  4920. Bkz543 string `json:"bkz543"`
  4921. BusinessType string `json:"businessType"`
  4922. CertfCodg string `json:"certfCodg"`
  4923. EcIndexNo string `json:"ecIndexNo"`
  4924. EcToken string `json:"ecToken"`
  4925. ID0000 string `json:"id0000"`
  4926. IDNo string `json:"idNo"`
  4927. IDType string `json:"idType"`
  4928. Idcode string `json:"idcode"`
  4929. IdentityToken string `json:"identity_token"`
  4930. InsuOrg string `json:"insuOrg"`
  4931. OfficeID string `json:"officeId"`
  4932. OfficeName string `json:"officeName"`
  4933. OperatorID string `json:"operatorId"`
  4934. OperatorName string `json:"operatorName"`
  4935. OrgID string `json:"orgId"`
  4936. UserName string `json:"userName"`
  4937. } `json:"data"`
  4938. Infno interface{} `json:"infno"`
  4939. Message string `json:"message"`
  4940. OrgID string `json:"orgId"`
  4941. TransType string `json:"transType"`
  4942. }
  4943. inputInfo, outPutInfo, _ := service.ReadEleCard(miConfig.Code)
  4944. outPutInfo = Remove0000(outPutInfo)
  4945. if len(outPutInfo) > 0 {
  4946. var ele ELeData
  4947. err := json.Unmarshal([]byte(outPutInfo), &ele)
  4948. if err != nil {
  4949. utils.ErrorLog("解析失败:%v", err)
  4950. }
  4951. token := ele.Data.EcToken
  4952. fmt.Println(inputInfo)
  4953. fmt.Println(outPutInfo)
  4954. 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)
  4955. saveLog(result, requestLog, "1101", "获取人员信息")
  4956. var dat map[string]interface{}
  4957. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  4958. fmt.Println(dat)
  4959. } else {
  4960. fmt.Println(err)
  4961. }
  4962. userJSONBytes, _ := json.Marshal(dat)
  4963. var res ResultTwo
  4964. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  4965. utils.ErrorLog("解析失败:%v", err)
  4966. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4967. return
  4968. }
  4969. res.ErrMsg = errMsgLog
  4970. if res.Infcode == 0 {
  4971. patient, err := service.GetPatientByNumber(ele.Data.IDNo, c.GetAdminUserInfo().CurrentOrgId)
  4972. if err == gorm.ErrRecordNotFound {
  4973. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  4974. return
  4975. } else if err != nil {
  4976. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  4977. return
  4978. } else {
  4979. fmt.Println(res)
  4980. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  4981. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  4982. infoStr := string(Iinfos)
  4983. idetinfoStr := string(Idetinfos)
  4984. psn := &models.HisPsn{
  4985. PsnNo: res.Output.Baseinfo.PsnNo,
  4986. Age: res.Output.Baseinfo.Age,
  4987. PatientId: patient.ID,
  4988. Certno: res.Output.Baseinfo.Certno,
  4989. Brdy: res.Output.Baseinfo.Brdy,
  4990. Gend: res.Output.Baseinfo.Gend,
  4991. Naty: res.Output.Baseinfo.Naty,
  4992. PsnCertType: res.Output.Baseinfo.PsnCertType,
  4993. PsnName: res.Output.Baseinfo.PsnName,
  4994. Idetinfo: idetinfoStr,
  4995. Insuinfo: infoStr,
  4996. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  4997. CardInfo: outPutInfo,
  4998. VerifyNumber: token,
  4999. InsuplcAdmdvs: ele.Data.InsuOrg,
  5000. }
  5001. service.CreateHisPsn(psn)
  5002. var rf []*ResultFive
  5003. json.Unmarshal([]byte(infoStr), &rf)
  5004. var insutypes []*ResultFive
  5005. var insutype string
  5006. var is390 int = 0
  5007. var is310 int = 0
  5008. for _, item := range rf {
  5009. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  5010. insutypes = append(insutypes, item)
  5011. }
  5012. }
  5013. if len(insutypes) == 1 {
  5014. insutype = insutypes[0].Insutype
  5015. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  5016. } else {
  5017. for _, i := range insutypes {
  5018. if i.Insutype == "390" {
  5019. is390 = 1
  5020. }
  5021. if i.Insutype == "310" {
  5022. is310 = 1
  5023. }
  5024. }
  5025. }
  5026. if is390 == 1 {
  5027. insutype = "390"
  5028. }
  5029. if is310 == 1 {
  5030. insutype = "310"
  5031. }
  5032. if len(insutypes) == 0 {
  5033. insutype = "310"
  5034. }
  5035. c.ServeSuccessJSON(map[string]interface{}{
  5036. "patient": patient,
  5037. "number": token,
  5038. "insutype": insutype,
  5039. })
  5040. }
  5041. } else {
  5042. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  5043. return
  5044. }
  5045. }
  5046. } else {
  5047. type ELeData struct {
  5048. Code string `json:"code"`
  5049. Data struct {
  5050. Aac002 string `json:"aac002"`
  5051. Aaz500 string `json:"aaz500"`
  5052. ActCardNo string `json:"actCardNo"`
  5053. Bab520 string `json:"bab520"`
  5054. Bkz543 string `json:"bkz543"`
  5055. BusinessType string `json:"businessType"`
  5056. CertfCodg string `json:"certfCodg"`
  5057. EcIndexNo string `json:"ecIndexNo"`
  5058. EcToken string `json:"ecToken"`
  5059. ID0000 string `json:"id0000"`
  5060. IDNo string `json:"idNo"`
  5061. IDType string `json:"idType"`
  5062. Idcode string `json:"idcode"`
  5063. IdentityToken string `json:"identity_token"`
  5064. InsuOrg string `json:"insuOrg"`
  5065. OfficeID string `json:"officeId"`
  5066. OfficeName string `json:"officeName"`
  5067. OperatorID string `json:"operatorId"`
  5068. OperatorName string `json:"operatorName"`
  5069. OrgID string `json:"orgId"`
  5070. UserName string `json:"userName"`
  5071. } `json:"data"`
  5072. Infno interface{} `json:"infno"`
  5073. Message string `json:"message"`
  5074. OrgID string `json:"orgId"`
  5075. TransType string `json:"transType"`
  5076. }
  5077. _, result := GetELeInfo(miConfig.Code, "1", roles.UserName)
  5078. fmt.Println(result)
  5079. outPutInfo := Remove0000(result)
  5080. fmt.Println(outPutInfo)
  5081. if len(outPutInfo) > 0 {
  5082. var ele ELeData
  5083. err := json.Unmarshal([]byte(outPutInfo), &ele)
  5084. if err != nil {
  5085. utils.ErrorLog("解析失败:%v", err)
  5086. }
  5087. token := ele.Data.EcToken
  5088. fmt.Println(outPutInfo)
  5089. result, requestLog := service.Gdyb1101ForEleCert(miConfig.OrgName, roles.UserName, miConfig.Code, ele.Data.InsuOrg, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, token, ele.Data.UserName, ele.Data.IDNo)
  5090. saveLog(result, requestLog, "1101", "获取人员信息")
  5091. var dat map[string]interface{}
  5092. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  5093. fmt.Println(dat)
  5094. } else {
  5095. fmt.Println(err)
  5096. }
  5097. userJSONBytes, _ := json.Marshal(dat)
  5098. var res ResultTwo
  5099. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  5100. utils.ErrorLog("解析失败:%v", err)
  5101. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5102. return
  5103. }
  5104. if res.Infcode == 0 {
  5105. patient, err := service.GetPatientByNumber(ele.Data.IDNo, c.GetAdminUserInfo().CurrentOrgId)
  5106. if err == gorm.ErrRecordNotFound {
  5107. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  5108. return
  5109. } else if err != nil {
  5110. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  5111. return
  5112. } else {
  5113. fmt.Println(res)
  5114. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  5115. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  5116. infoStr := string(Iinfos)
  5117. idetinfoStr := string(Idetinfos)
  5118. psn := &models.HisPsn{
  5119. PsnNo: res.Output.Baseinfo.PsnNo,
  5120. Age: res.Output.Baseinfo.Age,
  5121. PatientId: patient.ID,
  5122. Certno: res.Output.Baseinfo.Certno,
  5123. Brdy: res.Output.Baseinfo.Brdy,
  5124. Gend: res.Output.Baseinfo.Gend,
  5125. Naty: res.Output.Baseinfo.Naty,
  5126. PsnCertType: res.Output.Baseinfo.PsnCertType,
  5127. PsnName: res.Output.Baseinfo.PsnName,
  5128. Idetinfo: idetinfoStr,
  5129. Insuinfo: infoStr,
  5130. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  5131. CardInfo: outPutInfo,
  5132. VerifyNumber: token,
  5133. InsuplcAdmdvs: ele.Data.InsuOrg,
  5134. }
  5135. service.CreateHisPsn(psn)
  5136. var rf []*ResultFive
  5137. json.Unmarshal([]byte(infoStr), &rf)
  5138. var insutypes []*ResultFive
  5139. var insutype string
  5140. var is390 int = 0
  5141. var is310 int = 0
  5142. for _, item := range rf {
  5143. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  5144. insutypes = append(insutypes, item)
  5145. }
  5146. }
  5147. if len(insutypes) == 1 {
  5148. insutype = insutypes[0].Insutype
  5149. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  5150. } else {
  5151. for _, i := range insutypes {
  5152. if i.Insutype == "390" {
  5153. is390 = 1
  5154. }
  5155. if i.Insutype == "310" {
  5156. is310 = 1
  5157. }
  5158. }
  5159. }
  5160. if is390 == 1 {
  5161. insutype = "390"
  5162. }
  5163. if is310 == 1 {
  5164. insutype = "310"
  5165. }
  5166. if len(insutypes) == 0 {
  5167. insutype = "310"
  5168. }
  5169. c.ServeSuccessJSON(map[string]interface{}{
  5170. "patient": patient,
  5171. "number": token,
  5172. "insutype": insutype,
  5173. })
  5174. }
  5175. } else {
  5176. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  5177. return
  5178. }
  5179. }
  5180. //fmt.Println(result)
  5181. //
  5182. //if initFlag == 0 {
  5183. // c.TestGetBasBaseInit()
  5184. //}
  5185. //token := c.GetEleBaseInfo()
  5186. //
  5187. //token = Remove0000(token)
  5188. //
  5189. //result2, requestLog2 := service.Gdyb1101ForEleCert(miConfig.OrgName, roles.UserName, miConfig.Code, insuplc_admdvs_str, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, token, "", "")
  5190. //saveLog(result2, requestLog2, "1101", "获取人员信息")
  5191. ////
  5192. //var res ResultTwo
  5193. //if err := json.Unmarshal([]byte(result2), &res); err != nil {
  5194. // utils.ErrorLog("解析失败:%v", err)
  5195. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5196. // return
  5197. //}
  5198. //
  5199. //if res.Infcode == 0 {
  5200. // patient, err := service.GetPatientByNumber(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  5201. // if err == gorm.ErrRecordNotFound {
  5202. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  5203. // return
  5204. // } else if err != nil {
  5205. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  5206. // return
  5207. //
  5208. // } else {
  5209. // Iinfos, _ := json.Marshal(res.Output.Iinfo)
  5210. // Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  5211. // infoStr := string(Iinfos)
  5212. // idetinfoStr := string(Idetinfos)
  5213. //
  5214. //
  5215. //
  5216. //
  5217. // var rf []*ResultFive
  5218. // json.Unmarshal([]byte(infoStr), &rf)
  5219. //
  5220. // var insutypes []*ResultFive
  5221. // var insutype string
  5222. // var is390 int = 0
  5223. // var is310 int = 0
  5224. // var insuplc_admdvs string
  5225. //
  5226. // for _, item := range rf {
  5227. // if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  5228. // insutypes = append(insutypes, item)
  5229. // }
  5230. // }
  5231. //
  5232. // if len(insutypes) == 1 {
  5233. // insutype = insutypes[0].Insutype
  5234. // //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  5235. // } else {
  5236. // for _, i := range insutypes {
  5237. // if i.Insutype == "390" {
  5238. // is390 = 1
  5239. // }
  5240. //
  5241. // if i.Insutype == "310" {
  5242. // is310 = 1
  5243. // }
  5244. // }
  5245. // }
  5246. // if is390 == 1 {
  5247. // insutype = "390"
  5248. // }
  5249. //
  5250. // if is310 == 1 {
  5251. // insutype = "310"
  5252. // }
  5253. // if len(insutypes) == 0 {
  5254. // insutype = "310"
  5255. // }
  5256. // for _, item := range rf {
  5257. // if item.Insutype == insutype {
  5258. // insuplc_admdvs = item.InsuplcAdmdvs
  5259. // }
  5260. // }
  5261. // psn := &models.HisPsn{
  5262. // PsnNo: res.Output.Baseinfo.PsnNo,
  5263. // Age: res.Output.Baseinfo.Age,
  5264. // PatientId: patient.ID,
  5265. // Certno: res.Output.Baseinfo.Certno,
  5266. // Brdy: res.Output.Baseinfo.Brdy,
  5267. // Gend: res.Output.Baseinfo.Gend,
  5268. // Naty: res.Output.Baseinfo.Naty,
  5269. // PsnCertType: res.Output.Baseinfo.PsnCertType,
  5270. // PsnName: res.Output.Baseinfo.PsnName,
  5271. // Idetinfo: idetinfoStr,
  5272. // Insuinfo: infoStr,
  5273. // UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  5274. // CardInfo: "",
  5275. // VerifyNumber: token,
  5276. // InsuplcAdmdvs: insuplc_admdvs,
  5277. // }
  5278. // service.CreateHisPsn(psn)
  5279. //
  5280. // c.ServeSuccessJSON(map[string]interface{}{
  5281. // "patient": patient,
  5282. // "number": token,
  5283. // })
  5284. // }
  5285. //} else {
  5286. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  5287. // return
  5288. //}
  5289. }
  5290. break
  5291. }
  5292. }
  5293. var initFlag int64 = 0
  5294. var initEleFlag int64 = 0
  5295. func (c *HisApiController) TestGetBasBaseInit() {
  5296. DllDef := syscall.MustLoadDLL("SSCard.dll")
  5297. Iinit := DllDef.MustFindProc("Init")
  5298. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  5299. ret, _, err := Iinit.Call(StrPtr("http://igb.hsa.gdgov.cn/gdyb_api/prd/api/card/initDll"), StrPtr(miConfig.InsuplcAdmdvs))
  5300. if ret != 0 {
  5301. fmt.Println("SSCard的报错原因:", err)
  5302. fmt.Println("SSCard的运算结果为:", ret)
  5303. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeReadCardException)
  5304. return
  5305. }
  5306. result := int(ret)
  5307. fmt.Println("SSCard的运算结果为1:", result)
  5308. initFlag = 1
  5309. return
  5310. }
  5311. func (c *HisApiController) HandleJiangXiReadCard() {
  5312. fmt.Println("~~~~~~")
  5313. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  5314. admin_user_id, _ := c.GetInt64("admin_user_id")
  5315. id_card_type, _ := c.GetInt64("id_card_type")
  5316. //certificates, _ := c.GetInt64("certificates")
  5317. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  5318. if initFlag == 0 {
  5319. c.TestGetJiangXiBasBaseInit()
  5320. }
  5321. basStr := c.GetBasBaseInfo()
  5322. if len(basStr) == 0 {
  5323. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeReadCardException)
  5324. return
  5325. }
  5326. fmt.Println(basStr)
  5327. bas := strings.Split(basStr, "|")
  5328. basNumber := bas[1]
  5329. fmt.Println(basNumber)
  5330. card_sn := bas[3]
  5331. fmt.Println(card_sn)
  5332. 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, "")
  5333. //result := service.Jxyb1101(basNumber, miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, id_card_type, card_sn, certificates)
  5334. var dat map[string]interface{}
  5335. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  5336. fmt.Println(dat)
  5337. } else {
  5338. fmt.Println(err)
  5339. }
  5340. userJSONBytes, _ := json.Marshal(dat)
  5341. var res ResultTwo
  5342. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  5343. utils.ErrorLog("解析失败:%v", err)
  5344. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5345. return
  5346. }
  5347. if res.Infcode == 0 {
  5348. patient, err := service.GetPatientByNumber(basNumber, c.GetAdminUserInfo().CurrentOrgId)
  5349. if err == gorm.ErrRecordNotFound {
  5350. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  5351. return
  5352. } else if err != nil {
  5353. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  5354. return
  5355. } else {
  5356. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  5357. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  5358. infoStr := string(Iinfos)
  5359. idetinfoStr := string(Idetinfos)
  5360. psn := &models.HisPsn{
  5361. PsnNo: res.Output.Baseinfo.PsnNo,
  5362. Age: res.Output.Baseinfo.Age,
  5363. PatientId: patient.ID,
  5364. Certno: res.Output.Baseinfo.Certno,
  5365. Brdy: res.Output.Baseinfo.Brdy,
  5366. Gend: res.Output.Baseinfo.Gend,
  5367. Naty: res.Output.Baseinfo.Naty,
  5368. PsnCertType: res.Output.Baseinfo.PsnCertType,
  5369. PsnName: res.Output.Baseinfo.PsnName,
  5370. Idetinfo: idetinfoStr,
  5371. Insuinfo: infoStr,
  5372. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  5373. CardInfo: basStr,
  5374. VerifyNumber: "",
  5375. }
  5376. service.CreateHisPsn(psn)
  5377. c.ServeSuccessJSON(map[string]interface{}{
  5378. "patient": patient,
  5379. "number": basNumber,
  5380. })
  5381. }
  5382. } else {
  5383. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  5384. return
  5385. }
  5386. }
  5387. func (c *HisApiController) TestGetHnBasBaseInit() {
  5388. DllDef := syscall.MustLoadDLL("SSCard.dll")
  5389. Iinit := DllDef.MustFindProc("Init")
  5390. //miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  5391. //http://10.77.211.236/CSB/hsa-fsi-1303
  5392. ret, _, err := Iinit.Call(StrPtr("http://10.93.32.89:20001/hsa-hgs-adapt/api/card/initDll"), StrPtr("430100|10.93.32.89:20001"))
  5393. if ret != 0 {
  5394. fmt.Println("SSCard的报错原因:", err)
  5395. fmt.Println("SSCard的运算结果为:", ret)
  5396. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeReadCardException)
  5397. return
  5398. }
  5399. result := int(ret)
  5400. fmt.Println("SSCard的运算结果为1:", result)
  5401. initFlag = 1
  5402. return
  5403. }
  5404. func (c *HisApiController) TestGetJiangXiBasBaseInit() {
  5405. DllDef := syscall.MustLoadDLL("SSCard.dll")
  5406. Iinit := DllDef.MustFindProc("Init")
  5407. //miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  5408. //http://10.77.211.236/CSB/hsa-fsi-1303
  5409. ret, _, err := Iinit.Call(StrPtr("http://10.77.224.18:9001/1.0.0/agent-card-init"), StrPtr("360399"))
  5410. if ret != 0 {
  5411. fmt.Println("SSCard的报错原因:", err)
  5412. fmt.Println("SSCard的运算结果为:", ret)
  5413. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeReadCardException)
  5414. return
  5415. }
  5416. result := int(ret)
  5417. fmt.Println("SSCard的运算结果为1:", result)
  5418. initFlag = 1
  5419. return
  5420. }
  5421. func (c *HisApiController) GetSFZBaseInfo() string {
  5422. DllDef := syscall.MustLoadDLL("SSCard.dll")
  5423. readCard := DllDef.MustFindProc("ReadSFZ")
  5424. if readCard == nil {
  5425. fmt.Println("readcard is nil")
  5426. readCard = DllDef.MustFindProc("ReadSFZ")
  5427. }
  5428. str := make([]byte, 8096)
  5429. str1 := make([]byte, 8096)
  5430. r, _, _ := readCard.Call((uintptr)(unsafe.Pointer(&str[0])), IntPtr(8096), (uintptr)(unsafe.Pointer(&str1[0])), IntPtr(8096))
  5431. fmt.Println(r)
  5432. return Remove0000(string(str))
  5433. }
  5434. func (c *HisApiController) GetEleBaseInfo() string {
  5435. DllDef := syscall.MustLoadDLL("SSCard.dll")
  5436. readCard := DllDef.MustFindProc("GetQRBase")
  5437. fmt.Println(readCard)
  5438. if readCard == nil {
  5439. fmt.Println("readcard is nil")
  5440. readCard = DllDef.MustFindProc("GetQRBase")
  5441. }
  5442. str := make([]byte, 1024)
  5443. str1 := make([]byte, 1024)
  5444. ret2, _, _ := readCard.Call(uintptr(180), (uintptr)(unsafe.Pointer(&str[0])), uintptr(1024), (uintptr)(unsafe.Pointer(&str1[0])), uintptr(1024))
  5445. fmt.Println(ret2)
  5446. fmt.Println(string(str1))
  5447. fmt.Println(string(str))
  5448. fmt.Println(":", ConvertToString(string(str1), "gbk", "utf-8"))
  5449. fmt.Println(":", ConvertToString(string(str), "gbk", "utf-8"))
  5450. if ret2 != 0 {
  5451. return ""
  5452. }
  5453. return string(str)
  5454. }
  5455. func GetHnEleBaseInfo(code string, operator_id int64, operator_name string) (string, string) {
  5456. DllDef := syscall.MustLoadDLL("NationECCode.dll")
  5457. readCard := DllDef.MustFindProc("NationEcTrans")
  5458. fmt.Println(readCard)
  5459. fmt.Println("!!!!!")
  5460. pBusiCardInfo := make([]byte, 2048)
  5461. input := make(map[string]interface{})
  5462. inputData := make(map[string]interface{})
  5463. inputData["orgId"] = code
  5464. inputData["businessType"] = "01101"
  5465. inputData["operatorId"] = "1"
  5466. inputData["operatorName"] = "admin"
  5467. inputData["officeId"] = "001"
  5468. inputData["officeName"] = "血透室"
  5469. inputData["deviceType"] = ""
  5470. input["data"] = inputData
  5471. input["orgId"] = code
  5472. input["transType"] = "ec.query"
  5473. bytesData, _ := json.Marshal(input)
  5474. ret2, _, _ := readCard.Call(StrPtr("https://10.93.32.89:20001/localcfc/api/hsecfc/localQrCodeQuery"), StrPtr(string(bytesData)), (uintptr)(unsafe.Pointer(&pBusiCardInfo[0])))
  5475. fmt.Println(ret2)
  5476. fmt.Println(DeleteExtraSpace(string(pBusiCardInfo)))
  5477. fmt.Println(":", ConvertToString(DeleteExtraSpace(string(pBusiCardInfo)), "gbk", "utf-8"))
  5478. return DeleteExtraSpace(""), DeleteExtraSpace(string(pBusiCardInfo))
  5479. }
  5480. func GetgdEleBaseInfo(code string, operator_id int64, operator_name string) (string, string) {
  5481. DllDef := syscall.MustLoadDLL("NationECCode.dll")
  5482. readCard := DllDef.MustFindProc("NationEcTrans")
  5483. fmt.Println(readCard)
  5484. fmt.Println("!!!!!")
  5485. pBusiCardInfo := make([]byte, 2048)
  5486. input := make(map[string]interface{})
  5487. inputData := make(map[string]interface{})
  5488. inputData["orgId"] = code
  5489. inputData["businessType"] = "01101"
  5490. inputData["operatorId"] = "9"
  5491. inputData["operatorName"] = "admin"
  5492. inputData["officeId"] = "001"
  5493. inputData["officeName"] = "血透室"
  5494. inputData["deviceType"] = ""
  5495. input["data"] = inputData
  5496. input["orgId"] = code
  5497. input["transType"] = "ec.query"
  5498. bytesData, _ := json.Marshal(input)
  5499. 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])))
  5500. fmt.Println(ret2)
  5501. fmt.Println(DeleteExtraSpace(string(pBusiCardInfo)))
  5502. fmt.Println(":", ConvertToString(DeleteExtraSpace(string(pBusiCardInfo)), "gbk", "utf-8"))
  5503. return DeleteExtraSpace(""), ConvertToString(DeleteExtraSpace(string(pBusiCardInfo)), "gbk", "utf-8")
  5504. }
  5505. func GetgdEleBaseInfoTwo(code string, operator_id int64, operator_name string) (string, string) {
  5506. DllDef := syscall.MustLoadDLL("NationECCode.dll")
  5507. readCard := DllDef.MustFindProc("NationEcTrans")
  5508. fmt.Println(readCard)
  5509. fmt.Println("!!!!!")
  5510. pBusiCardInfo := make([]byte, 2048)
  5511. input := make(map[string]interface{})
  5512. inputData := make(map[string]interface{})
  5513. inputData["orgId"] = code
  5514. inputData["businessType"] = "01301"
  5515. inputData["operatorId"] = "9"
  5516. inputData["operatorName"] = "admin"
  5517. inputData["officeId"] = "001"
  5518. inputData["officeName"] = "血透室"
  5519. inputData["deviceType"] = ""
  5520. input["data"] = inputData
  5521. input["orgId"] = code
  5522. input["transType"] = "ec.query"
  5523. bytesData, _ := json.Marshal(input)
  5524. 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])))
  5525. fmt.Println(ret2)
  5526. fmt.Println(DeleteExtraSpace(string(pBusiCardInfo)))
  5527. fmt.Println(":", ConvertToString(DeleteExtraSpace(string(pBusiCardInfo)), "gbk", "utf-8"))
  5528. return DeleteExtraSpace(""), ConvertToString(DeleteExtraSpace(string(pBusiCardInfo)), "gbk", "utf-8")
  5529. }
  5530. func GetJxEleBaseInfo(org_id int64) string {
  5531. DllDef := syscall.MustLoadDLL("SSCard.dll")
  5532. readCard := DllDef.MustFindProc("NationEcTrans")
  5533. miConfig, _ := service.FindMedicalInsuranceInfo(org_id)
  5534. if readCard == nil {
  5535. fmt.Println("readcard is nil")
  5536. readCard = DllDef.MustFindProc("NationEcTrans")
  5537. }
  5538. str1 := make([]byte, 1024)
  5539. data := make(map[string]interface{})
  5540. inputData := make(map[string]interface{})
  5541. inputData["orgId"] = miConfig.Code
  5542. inputData["businessType"] = "01101"
  5543. inputData["operatorId"] = "test001"
  5544. inputData["operatorName"] = "cn"
  5545. inputData["officeId"] = "32760"
  5546. inputData["officeName"] = "waike"
  5547. inputData["deviceType"] = ""
  5548. data["data"] = inputData
  5549. data["transType"] = "ec.query"
  5550. data["extra "] = ""
  5551. data["orgId"] = miConfig.Code
  5552. bytesData, _ := json.Marshal(data)
  5553. //bytesData, _ := json.Marshal(data)
  5554. //bytesData = []byte(ConvertToString(string(bytesData), "utf-8", "gbk"))
  5555. ret2, _, _ := readCard.Call(StrPtr("http://10.77.224.18:9001/1.0.0/localQrCodeQuery"), (uintptr)(unsafe.Pointer(&bytesData[0])), (uintptr)(unsafe.Pointer(&str1[0])))
  5556. fmt.Println(ret2)
  5557. fmt.Println(string(str1))
  5558. fmt.Println(":", ConvertToString(string(str1), "gbk", "utf-8"))
  5559. if ret2 != 0 {
  5560. return ""
  5561. }
  5562. return Remove0000(ConvertToString(string(str1), "gbk", "utf-8"))
  5563. }
  5564. func GetJxEleBaseInitInfo(org_id int64) string {
  5565. DllDef := syscall.MustLoadDLL("SSCard.dll")
  5566. readCard := DllDef.MustFindProc("NationEcTrans")
  5567. miConfig, _ := service.FindMedicalInsuranceInfo(org_id)
  5568. if readCard == nil {
  5569. fmt.Println("readcard is nil")
  5570. readCard = DllDef.MustFindProc("NationEcTrans")
  5571. }
  5572. str1 := make([]byte, 2048)
  5573. data := make(map[string]interface{})
  5574. inputData := make(map[string]interface{})
  5575. inputData["orgId"] = miConfig.Code
  5576. inputData["businessType"] = "01101"
  5577. inputData["operatorId"] = "1"
  5578. inputData["operatorName"] = "huangchuang"
  5579. inputData["officeId"] = "101"
  5580. inputData["officeName"] = "xuetou"
  5581. inputData["deviceType"] = ""
  5582. data["data"] = inputData
  5583. data["transType"] = "ec.query"
  5584. data["orgId"] = miConfig.Code
  5585. bytesData, _ := json.Marshal(data)
  5586. bytesData = []byte(ConvertToString(string(bytesData), "utf-8", "gbk"))
  5587. ret2, _, _ := readCard.Call(StrPtr("http://10.77.224.18:9001/1.0.0/getEncDynamicKey"), (uintptr)(unsafe.Pointer(&bytesData[0])), (uintptr)(unsafe.Pointer(&str1[0])))
  5588. fmt.Println("http://10.77.224.18:9001/1.0.0/getEncDynamicKey")
  5589. fmt.Println(ret2)
  5590. fmt.Println(string(str1))
  5591. fmt.Println(":", ConvertToString(string(str1), "gbk", "utf-8"))
  5592. if ret2 != 0 {
  5593. return ""
  5594. }
  5595. if len(Remove0000(ConvertToString(string(str1), "gbk", "utf-8"))) > 0 {
  5596. initEleFlag = 1
  5597. }
  5598. return Remove0000(ConvertToString(string(str1), "gbk", "utf-8"))
  5599. }
  5600. func (c *HisApiController) GetBasBaseInfo() string {
  5601. DllDef := syscall.MustLoadDLL("SSCard.dll")
  5602. readCard := DllDef.MustFindProc("ReadCardBas")
  5603. if readCard == nil {
  5604. fmt.Println("readcard is nil")
  5605. readCard = DllDef.MustFindProc("ReadCardBas")
  5606. }
  5607. str := make([]byte, 1024)
  5608. str1 := make([]byte, 1024)
  5609. ret2, _, _ := readCard.Call((uintptr)(unsafe.Pointer(&str[0])), uintptr(1024), (uintptr)(unsafe.Pointer(&str1[0])), uintptr(1024))
  5610. fmt.Println(string(str1))
  5611. fmt.Println(string(str))
  5612. fmt.Println(":", ConvertToString(string(str1), "gbk", "utf-8"))
  5613. fmt.Println(":", ConvertToString(string(str), "gbk", "utf-8"))
  5614. if ret2 != 0 {
  5615. return ""
  5616. }
  5617. return string(str)
  5618. }
  5619. func (c *HisApiController) GetFjBasBaseInfo() (string, string, string, string, string) {
  5620. DllDef := syscall.MustLoadDLL("chs_fjs_standard.dll")
  5621. readCard := DllDef.MustFindProc("read_cardinfo")
  5622. if readCard == nil {
  5623. fmt.Println("readcard is nil")
  5624. readCard = DllDef.MustFindProc("read_cardinfo")
  5625. }
  5626. str := make([]byte, 1024) //卡号
  5627. str1 := make([]byte, 1024) //卡识别码
  5628. str2 := make([]byte, 1024) //身份证号
  5629. str3 := make([]byte, 1024) //姓名
  5630. str4 := make([]byte, 1024) //错误信息
  5631. 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])))
  5632. fmt.Println(string(str1))
  5633. fmt.Println(string(str))
  5634. fmt.Println(string(str2))
  5635. fmt.Println(string(str3))
  5636. fmt.Println(string(str4))
  5637. fmt.Println(":", ConvertToString(string(str1), "gbk", "utf-8"))
  5638. fmt.Println(":", ConvertToString(string(str), "gbk", "utf-8"))
  5639. fmt.Println(":", ConvertToString(string(str2), "gbk", "utf-8"))
  5640. fmt.Println(":", ConvertToString(string(str3), "gbk", "utf-8"))
  5641. fmt.Println(":", ConvertToString(string(str4), "gbk", "utf-8"))
  5642. if ret2 != 0 {
  5643. return "", "", "", "", ""
  5644. }
  5645. return string(str), string(str1), string(str2), string(str3), string(str4)
  5646. }
  5647. type CustomFundPay struct {
  5648. FundPayType string `json:"fund_pay_type"`
  5649. FundPayamt float64 `json:"fund_payamt"`
  5650. }
  5651. func (c *HisApiController) GetSettleList() {
  5652. order_id, _ := c.GetInt64("order_id")
  5653. admin_user_id, _ := c.GetInt64("admin_user_id")
  5654. order, _ := service.GetHisOrderByIDTwo(order_id)
  5655. roles, _ := service.GetDoctorListTwo(c.GetAdminUserInfo().CurrentOrgId)
  5656. his, _ := service.GetHisPatientByNumber(order.MdtrtId)
  5657. admin, _ := service.GetAdminUserByUserID(roles[0].AdminUserId)
  5658. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  5659. depart, _ := service.GetDepartMentDetail(curRoles.DepartmentId)
  5660. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  5661. pre, _ := service.GetNewHisPrescriptionByNumber(order.Number)
  5662. doctor, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, pre.Creator)
  5663. if order.ID == 0 {
  5664. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisOrderNoExistParamWrong)
  5665. return
  5666. }
  5667. //last_order, _ := service.GetLastHisOrder(c.GetAdminUserInfo().CurrentOrgId)
  5668. //max_order, _ := service.GetLastHisOrderTwo(c.GetAdminUserInfo().CurrentOrgId)
  5669. //count, _ := strconv.ParseInt(max_order.FaPiaoNumber, 10, 64)
  5670. //fmt.Println(count)
  5671. //var zero string
  5672. //number := count + 1
  5673. //if number >= 1000 {
  5674. // zero = "0000" + strconv.FormatInt(number, 10)
  5675. //} else if number >= 10000 {
  5676. // zero = "000" + strconv.FormatInt(number, 10)
  5677. //} else if number >= 100000 {
  5678. // zero = "00" + strconv.FormatInt(number, 10)
  5679. //} else if number >= 1000000 {
  5680. // zero = "0" + strconv.FormatInt(number, 10)
  5681. //} else {
  5682. // zero = strconv.FormatInt(number, 10)
  5683. //}
  5684. //fmt.Println(zero)
  5685. struct4101 := service.Struct4101{
  5686. PsnNo: order.PsnNo,
  5687. MdtrtId: order.MdtrtId,
  5688. SetlId: order.SetlId,
  5689. PsnName: order.PsnName,
  5690. Gend: order.Gend,
  5691. Brdy: his.Brdy,
  5692. Age: his.Age,
  5693. Naty: order.Naty,
  5694. PatnCertType: "01",
  5695. Certno: order.Certno,
  5696. Prfs: "90",
  5697. ConerName: roles[0].UserName,
  5698. PatnRlts: "99",
  5699. ConerAddr: miConfig.OrgName,
  5700. ConerTel: admin.Mobile,
  5701. HiType: order.Insutype,
  5702. Insuplc: miConfig.InsuplcAdmdvs,
  5703. MaindiagFlag: "1",
  5704. BillCode: order.SetlId,
  5705. BillNo: order.SetlId,
  5706. BizSn: order.Number,
  5707. PsnSelfPay: order.PsnPartAmt,
  5708. PsnOwnPay: order.PsnPartAmt,
  5709. AcctPay: order.AcctPay,
  5710. PsnCashpay: order.PsnCashPay,
  5711. HiPaymtd: "1",
  5712. Hsorg: miConfig.InsuplcAdmdvs,
  5713. HsorgOpter: miConfig.InsuplcAdmdvs,
  5714. MedinsFillPsn: curRoles.UserName,
  5715. MedinsFillDept: depart.Name,
  5716. IptMedType: "2",
  5717. }
  5718. struct4101.SetlBegnDate = order.SetlTime
  5719. struct4101.SetlEndDate = order.SetlTime
  5720. time_arr := strings.Split(order.SetlTime, " ")
  5721. struct4101.AdmTime = time_arr[0]
  5722. struct4101.AdmEndTime = time_arr[0]
  5723. var rf []CustomFundPay
  5724. json.Unmarshal([]byte(order.SetlDetail), &rf)
  5725. var tempFunPays []service.CustomStruct
  5726. for _, item := range rf {
  5727. var tempFunPay service.CustomStruct
  5728. tempFunPay.FundPayamt = item.FundPayamt
  5729. tempFunPay.FundPayType = item.FundPayType
  5730. tempFunPays = append(tempFunPays, tempFunPay)
  5731. }
  5732. struct4101.CustomStruct = tempFunPays
  5733. var tempDiaginfos []service.DiaginfoStructTwo
  5734. var tempOpspdiseinfo2 service.OpspdiseinfoStruct
  5735. var tempOpspdiseinfos []service.OpspdiseinfoStruct
  5736. diagnosis_ids := strings.Split(his.Diagnosis, ",")
  5737. var config []*models.HisXtDiagnoseConfig
  5738. for _, item := range diagnosis_ids {
  5739. id, _ := strconv.ParseInt(item, 10, 64)
  5740. diagnosisConfig, _ := service.FindDiagnoseById(id)
  5741. config = append(config, &diagnosisConfig)
  5742. }
  5743. for index, item := range config {
  5744. if index == 0 {
  5745. var tempDiaginfo service.DiaginfoStructTwo
  5746. tempDiaginfo.DiagCode = item.CountryCode
  5747. tempDiaginfo.DiagName = item.CountryContentName
  5748. tempDiaginfo.DiagType = "1"
  5749. tempDiaginfo.MaindiagFlag = "1"
  5750. tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  5751. } else {
  5752. var tempDiaginfo service.DiaginfoStructTwo
  5753. tempDiaginfo.DiagCode = item.CountryCode
  5754. tempDiaginfo.DiagName = item.CountryContentName
  5755. tempDiaginfo.DiagType = "2"
  5756. tempDiaginfo.MaindiagFlag = "0"
  5757. tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  5758. }
  5759. }
  5760. struct4101.Diseinfo = tempDiaginfos
  5761. sickConfigTwo, _ := service.FindSickById(his.SickType)
  5762. tempOpspdiseinfo2.DiagCode = sickConfigTwo.ContentCode
  5763. tempOpspdiseinfo2.DiagName = sickConfigTwo.CountryContentName
  5764. tempOpspdiseinfo2.OprnOprtCode = sickConfigTwo.ContentCode
  5765. tempOpspdiseinfo2.OprnOprtName = sickConfigTwo.CountryContentName
  5766. tempOpspdiseinfos = append(tempOpspdiseinfos, tempOpspdiseinfo2)
  5767. struct4101.OpspdiseinfoStruct = tempOpspdiseinfos
  5768. var iteminfo service.IteminfoStruct
  5769. var bedCostTotal float64 = 0 //床位总费
  5770. var bedCostSelfTotal float64 = 0 //床位自费
  5771. var bedCostPartSelfTotal float64 = 0 //床位部分项目自费
  5772. var operationCostTotal float64 = 0 //手术费
  5773. var operationCostSelfTotal float64 = 0 //手术费
  5774. var operationCostPartSelfTotal float64 = 0 //手术费
  5775. var otherCostTotal float64 = 0 //其他费用
  5776. var otherCostSelfTotal float64 = 0 //其他费用
  5777. var otherCostPartSelfTotal float64 = 0 //其他费用
  5778. var materialCostTotal float64 = 0 //材料费
  5779. var materialCostSelfTotal float64 = 0 //材料费
  5780. var materialCostPartSelfTotal float64 = 0 //材料费
  5781. var westernMedicineCostTotal float64 = 0 //西药费
  5782. var westernMedicineCostSelfTotal float64 = 0 //西药费
  5783. var westernMedicineCostPartSelfTotal float64 = 0 //西药费
  5784. var chineseTraditionalMedicineCostTotal float64 = 0 //中成药
  5785. var chineseTraditionalMedicineCostSelfTotal float64 = 0 //中成药
  5786. var chineseTraditionalMedicineCostPartSelfTotal float64 = 0 //中成药
  5787. var checkCostTotal float64 = 0 //检查费
  5788. var checkCostSelfTotal float64 = 0 //检查费
  5789. var checkCostPartSelfTotal float64 = 0 //检查费
  5790. var laboratoryCostTotal float64 = 0 //化验费
  5791. var laboratoryCostSelfTotal float64 = 0 //化验费
  5792. var laboratoryCostPartSelfTotal float64 = 0 //化验费
  5793. var treatCostTotal float64 = 0 //治疗费用
  5794. var treatCostSelfTotal float64 = 0 //治疗费用
  5795. var treatCostPartSelfTotal float64 = 0 //治疗费用
  5796. decimal.DivisionPrecision = 2
  5797. var bed_fulamt_ownpay_amt float64 = 0
  5798. var operation_fulamt_ownpay_amt float64 = 0
  5799. var other_fulamt_ownpay_amt float64 = 0
  5800. var westernMedicine_fulamt_ownpay_amt float64 = 0
  5801. var chineseTraditional_fulamt_ownpay_amt float64 = 0
  5802. var check_fulamt_ownpay_amt float64 = 0
  5803. var material_fulamt_ownpay_amt float64 = 0
  5804. var laboratory_fulamt_ownpay_amt float64 = 0
  5805. var treat_fulamt_ownpay_amt float64 = 0
  5806. var bed_claa_sunmfee float64 = 0
  5807. var bed_clab_amt float64 = 0
  5808. var bed_other_amt float64 = 0
  5809. var operation_claa_sunmfee float64 = 0
  5810. var operation_clab_amt float64 = 0
  5811. var operation_other_amt float64 = 0
  5812. var other_claa_sunmfee float64 = 0
  5813. var other_clab_amt float64 = 0
  5814. var other_other_amt float64 = 0
  5815. var westernMedicine_claa_sunmfee float64 = 0
  5816. var westernMedicine_clab_amt float64 = 0
  5817. var westernMedicine_other_amt float64 = 0
  5818. var chineseTraditional_claa_sunmfee float64 = 0
  5819. var chineseTraditional_clab_amt float64 = 0
  5820. var chineseTraditional_other_amt float64 = 0
  5821. var check_claa_sunmfee float64 = 0
  5822. var check_clab_amt float64 = 0
  5823. var check_other_amt float64 = 0
  5824. var material_claa_sunmfee float64 = 0
  5825. var material_clab_amt float64 = 0
  5826. var material_other_amt float64 = 0
  5827. var laboratory_claa_sunmfee float64 = 0
  5828. var laboratory_clab_amt float64 = 0
  5829. var laboratory_other_amt float64 = 0
  5830. var treat_claa_sunmfee float64 = 0
  5831. var treat_clab_amt float64 = 0
  5832. var treat_other_amt float64 = 0
  5833. for _, item := range order.HisOrderInfo {
  5834. if item.MedChrgitmType == "01" { //床位费
  5835. bedCostTotal, _ = decimal.NewFromFloat(bedCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  5836. bedCostSelfTotal, _ = decimal.NewFromFloat(bedCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  5837. bedCostPartSelfTotal, _ = decimal.NewFromFloat(bedCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  5838. bed_fulamt_ownpay_amt, _ = decimal.NewFromFloat(bed_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  5839. if item.ChrgitmLv == "1" {
  5840. bed_claa_sunmfee, _ = decimal.NewFromFloat(bed_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  5841. }
  5842. if item.ChrgitmLv == "2" {
  5843. bed_clab_amt, _ = decimal.NewFromFloat(bed_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  5844. }
  5845. if item.ChrgitmLv == "3" {
  5846. bed_other_amt, _ = decimal.NewFromFloat(bed_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  5847. }
  5848. }
  5849. if item.MedChrgitmType == "03" { //检查费
  5850. checkCostTotal, _ = decimal.NewFromFloat(checkCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  5851. checkCostSelfTotal, _ = decimal.NewFromFloat(checkCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  5852. checkCostPartSelfTotal, _ = decimal.NewFromFloat(checkCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  5853. check_fulamt_ownpay_amt, _ = decimal.NewFromFloat(check_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  5854. if item.ChrgitmLv == "1" {
  5855. check_claa_sunmfee, _ = decimal.NewFromFloat(check_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  5856. }
  5857. if item.ChrgitmLv == "2" {
  5858. check_clab_amt, _ = decimal.NewFromFloat(check_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  5859. }
  5860. if item.ChrgitmLv == "3" {
  5861. check_other_amt, _ = decimal.NewFromFloat(check_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  5862. }
  5863. }
  5864. if item.MedChrgitmType == "04" { //化验费
  5865. laboratoryCostTotal, _ = decimal.NewFromFloat(laboratoryCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  5866. laboratoryCostSelfTotal, _ = decimal.NewFromFloat(laboratoryCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  5867. laboratoryCostPartSelfTotal, _ = decimal.NewFromFloat(laboratoryCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  5868. laboratory_fulamt_ownpay_amt, _ = decimal.NewFromFloat(laboratory_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  5869. if item.ChrgitmLv == "1" {
  5870. laboratory_claa_sunmfee, _ = decimal.NewFromFloat(laboratory_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  5871. }
  5872. if item.ChrgitmLv == "2" {
  5873. laboratory_clab_amt, _ = decimal.NewFromFloat(laboratory_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  5874. }
  5875. if item.ChrgitmLv == "3" {
  5876. laboratory_other_amt, _ = decimal.NewFromFloat(laboratory_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  5877. }
  5878. }
  5879. if item.MedChrgitmType == "05" { //治疗费
  5880. treatCostTotal, _ = decimal.NewFromFloat(treatCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  5881. treatCostSelfTotal, _ = decimal.NewFromFloat(treatCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  5882. treatCostPartSelfTotal, _ = decimal.NewFromFloat(treatCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  5883. treat_fulamt_ownpay_amt, _ = decimal.NewFromFloat(treat_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  5884. if item.ChrgitmLv == "1" {
  5885. treat_claa_sunmfee, _ = decimal.NewFromFloat(treat_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  5886. }
  5887. if item.ChrgitmLv == "2" {
  5888. treat_clab_amt, _ = decimal.NewFromFloat(treat_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  5889. }
  5890. if item.ChrgitmLv == "3" {
  5891. treat_other_amt, _ = decimal.NewFromFloat(treat_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  5892. }
  5893. }
  5894. if item.MedChrgitmType == "06" { //手术费
  5895. operationCostTotal, _ = decimal.NewFromFloat(operationCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  5896. operationCostSelfTotal, _ = decimal.NewFromFloat(operationCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  5897. operationCostPartSelfTotal, _ = decimal.NewFromFloat(operationCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  5898. operation_fulamt_ownpay_amt, _ = decimal.NewFromFloat(operation_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  5899. if item.ChrgitmLv == "1" {
  5900. operation_claa_sunmfee, _ = decimal.NewFromFloat(operation_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  5901. }
  5902. if item.ChrgitmLv == "2" {
  5903. operation_clab_amt, _ = decimal.NewFromFloat(operation_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  5904. }
  5905. if item.ChrgitmLv == "3" {
  5906. operation_other_amt, _ = decimal.NewFromFloat(operation_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  5907. }
  5908. }
  5909. if item.MedChrgitmType == "08" { //材料费
  5910. materialCostTotal, _ = decimal.NewFromFloat(materialCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  5911. materialCostSelfTotal, _ = decimal.NewFromFloat(materialCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  5912. materialCostPartSelfTotal, _ = decimal.NewFromFloat(materialCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  5913. material_fulamt_ownpay_amt, _ = decimal.NewFromFloat(material_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  5914. if item.ChrgitmLv == "1" {
  5915. material_claa_sunmfee, _ = decimal.NewFromFloat(material_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  5916. }
  5917. if item.ChrgitmLv == "2" {
  5918. material_clab_amt, _ = decimal.NewFromFloat(material_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  5919. }
  5920. if item.ChrgitmLv == "3" {
  5921. material_other_amt, _ = decimal.NewFromFloat(material_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  5922. }
  5923. }
  5924. if item.MedChrgitmType == "09" { //西药费
  5925. westernMedicineCostTotal, _ = decimal.NewFromFloat(westernMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  5926. westernMedicineCostSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  5927. westernMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  5928. westernMedicine_fulamt_ownpay_amt, _ = decimal.NewFromFloat(westernMedicine_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  5929. if item.ChrgitmLv == "1" {
  5930. westernMedicine_claa_sunmfee, _ = decimal.NewFromFloat(westernMedicine_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  5931. }
  5932. if item.ChrgitmLv == "2" {
  5933. westernMedicine_clab_amt, _ = decimal.NewFromFloat(westernMedicine_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  5934. }
  5935. if item.ChrgitmLv == "3" {
  5936. westernMedicine_other_amt, _ = decimal.NewFromFloat(westernMedicine_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  5937. }
  5938. }
  5939. if item.MedChrgitmType == "11" { //中成费
  5940. chineseTraditionalMedicineCostTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  5941. chineseTraditionalMedicineCostSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  5942. chineseTraditionalMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  5943. chineseTraditional_fulamt_ownpay_amt, _ = decimal.NewFromFloat(chineseTraditional_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  5944. if item.ChrgitmLv == "1" {
  5945. chineseTraditional_claa_sunmfee, _ = decimal.NewFromFloat(chineseTraditional_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  5946. }
  5947. if item.ChrgitmLv == "2" {
  5948. chineseTraditional_clab_amt, _ = decimal.NewFromFloat(chineseTraditional_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  5949. }
  5950. if item.ChrgitmLv == "3" {
  5951. chineseTraditional_other_amt, _ = decimal.NewFromFloat(chineseTraditional_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  5952. }
  5953. }
  5954. if item.MedChrgitmType == "14" { //其他费
  5955. otherCostTotal, _ = decimal.NewFromFloat(otherCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  5956. otherCostSelfTotal, _ = decimal.NewFromFloat(otherCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  5957. otherCostPartSelfTotal, _ = decimal.NewFromFloat(otherCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  5958. other_fulamt_ownpay_amt, _ = decimal.NewFromFloat(other_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  5959. if item.ChrgitmLv == "1" {
  5960. other_claa_sunmfee, _ = decimal.NewFromFloat(other_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  5961. }
  5962. if item.ChrgitmLv == "2" {
  5963. other_clab_amt, _ = decimal.NewFromFloat(other_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  5964. }
  5965. if item.ChrgitmLv == "3" {
  5966. other_other_amt, _ = decimal.NewFromFloat(other_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  5967. }
  5968. }
  5969. }
  5970. var iteminfoStructs []service.IteminfoStruct
  5971. if bedCostTotal != 0 {
  5972. iteminfo.MedChrgitm = "01"
  5973. iteminfo.FulamtOwnpayAmt = bed_fulamt_ownpay_amt
  5974. iteminfo.Amt = bedCostTotal
  5975. iteminfo.ClaaSumfee = bed_claa_sunmfee
  5976. iteminfo.ClabAmt = bed_clab_amt
  5977. iteminfo.OthAmt = bed_other_amt
  5978. iteminfoStructs = append(iteminfoStructs, iteminfo)
  5979. }
  5980. if checkCostTotal != 0 {
  5981. iteminfo.MedChrgitm = "03"
  5982. iteminfo.FulamtOwnpayAmt = check_fulamt_ownpay_amt
  5983. iteminfo.Amt = checkCostTotal
  5984. iteminfo.ClaaSumfee = check_claa_sunmfee
  5985. iteminfo.ClabAmt = check_clab_amt
  5986. iteminfo.OthAmt = check_other_amt
  5987. iteminfoStructs = append(iteminfoStructs, iteminfo)
  5988. }
  5989. if laboratoryCostTotal != 0 {
  5990. iteminfo.MedChrgitm = "04"
  5991. iteminfo.FulamtOwnpayAmt = laboratory_fulamt_ownpay_amt
  5992. iteminfo.Amt = laboratoryCostTotal
  5993. iteminfo.ClaaSumfee = laboratory_claa_sunmfee
  5994. iteminfo.ClabAmt = laboratory_clab_amt
  5995. iteminfo.OthAmt = laboratory_other_amt
  5996. iteminfoStructs = append(iteminfoStructs, iteminfo)
  5997. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  5998. }
  5999. if treatCostTotal != 0 {
  6000. iteminfo.MedChrgitm = "05"
  6001. iteminfo.FulamtOwnpayAmt = treat_fulamt_ownpay_amt
  6002. iteminfo.Amt = treatCostTotal
  6003. iteminfo.ClaaSumfee = treat_claa_sunmfee
  6004. iteminfo.ClabAmt = treat_clab_amt
  6005. iteminfo.OthAmt = treat_other_amt
  6006. iteminfoStructs = append(iteminfoStructs, iteminfo)
  6007. //(struct4101.IteminfoStruct, iteminfo)
  6008. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  6009. }
  6010. if operationCostTotal != 0 {
  6011. iteminfo.MedChrgitm = "06"
  6012. iteminfo.FulamtOwnpayAmt = bed_fulamt_ownpay_amt
  6013. iteminfo.Amt = operationCostTotal
  6014. iteminfo.ClaaSumfee = operation_claa_sunmfee
  6015. iteminfo.ClabAmt = operation_clab_amt
  6016. iteminfo.OthAmt = operation_other_amt
  6017. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  6018. iteminfoStructs = append(iteminfoStructs, iteminfo)
  6019. }
  6020. if materialCostTotal != 0 {
  6021. iteminfo.MedChrgitm = "08"
  6022. iteminfo.FulamtOwnpayAmt = material_fulamt_ownpay_amt
  6023. iteminfo.Amt = materialCostTotal
  6024. iteminfo.ClaaSumfee = material_claa_sunmfee
  6025. iteminfo.ClabAmt = material_clab_amt
  6026. iteminfo.OthAmt = material_other_amt
  6027. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  6028. iteminfoStructs = append(iteminfoStructs, iteminfo)
  6029. }
  6030. if westernMedicineCostTotal != 0 {
  6031. iteminfo.MedChrgitm = "09"
  6032. iteminfo.FulamtOwnpayAmt = westernMedicine_fulamt_ownpay_amt
  6033. iteminfo.Amt = westernMedicineCostTotal
  6034. iteminfo.ClaaSumfee = westernMedicine_claa_sunmfee
  6035. iteminfo.ClabAmt = westernMedicine_clab_amt
  6036. iteminfo.OthAmt = westernMedicine_other_amt
  6037. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  6038. iteminfoStructs = append(iteminfoStructs, iteminfo)
  6039. }
  6040. if chineseTraditionalMedicineCostTotal != 0 {
  6041. iteminfo.MedChrgitm = "11"
  6042. iteminfo.FulamtOwnpayAmt = westernMedicine_fulamt_ownpay_amt
  6043. iteminfo.Amt = westernMedicineCostTotal
  6044. iteminfo.ClaaSumfee = westernMedicine_claa_sunmfee
  6045. iteminfo.ClabAmt = westernMedicine_clab_amt
  6046. iteminfo.OthAmt = westernMedicine_other_amt
  6047. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  6048. iteminfoStructs = append(iteminfoStructs, iteminfo)
  6049. }
  6050. if otherCostTotal != 0 {
  6051. iteminfo.MedChrgitm = "14"
  6052. iteminfo.FulamtOwnpayAmt = other_fulamt_ownpay_amt
  6053. iteminfo.Amt = otherCostTotal
  6054. iteminfo.ClaaSumfee = other_claa_sunmfee
  6055. iteminfo.ClabAmt = other_clab_amt
  6056. iteminfo.OthAmt = other_other_amt
  6057. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  6058. iteminfoStructs = append(iteminfoStructs, iteminfo)
  6059. }
  6060. struct4101.IteminfoStruct = iteminfoStructs
  6061. struct4101.Ntly = "中国"
  6062. struct4101.AdmCaty = "A03.06"
  6063. struct4101.DoctorName = doctor.UserName
  6064. struct4101.DoctorCode = doctor.DoctorNumber
  6065. var res ResultSeventeen
  6066. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  6067. struct4101.BillCode = order.Number
  6068. struct4101.BillNo = order.SetlId
  6069. var resOther ResultSeventeenOther
  6070. var pp models.PublicParams
  6071. pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  6072. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  6073. pp.FixmedinsName = miConfig.OrgName
  6074. pp.FixmedinsCode = miConfig.Code
  6075. pp.RequestUrl = miConfig.Url
  6076. pp.Cainfo = miConfig.Cainfo
  6077. pp.SecretKey = miConfig.SecretKey
  6078. pp.AccessKey = miConfig.AccessKey
  6079. pp.OpterName = curRoles.UserName
  6080. client := &http.Client{}
  6081. var req *http.Request
  6082. data := make(map[string]interface{})
  6083. data["struct4101"] = struct4101
  6084. data["pp"] = pp
  6085. bytesData, _ := json.Marshal(data)
  6086. if miConfig.MdtrtareaAdmvs == "320921" {
  6087. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/4101", bytes.NewReader(bytesData))
  6088. } else {
  6089. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/4101", bytes.NewReader(bytesData))
  6090. }
  6091. resp, _ := client.Do(req)
  6092. defer resp.Body.Close()
  6093. body, ioErr := ioutil.ReadAll(resp.Body)
  6094. if ioErr != nil {
  6095. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  6096. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6097. return
  6098. }
  6099. var respJSON map[string]interface{}
  6100. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  6101. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  6102. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6103. return
  6104. }
  6105. respJSON = respJSON["data"].(map[string]interface{})["request_log"].(map[string]interface{})
  6106. userJSONBytes, _ := json.Marshal(respJSON)
  6107. fmt.Println("log")
  6108. fmt.Println(string(userJSONBytes))
  6109. if err := json.Unmarshal(userJSONBytes, &resOther); err != nil {
  6110. utils.ErrorLog("解析失败:%v", err)
  6111. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6112. return
  6113. }
  6114. res.InfRefmsgid = resOther.InfRefmsgid
  6115. res.Output = resOther.Output
  6116. res.ErrMsg = resOther.ErrMsg
  6117. infocode, _ := strconv.ParseInt(resOther.Infcode, 10, 64)
  6118. res.Infcode = infocode
  6119. } else if miConfig.MdtrtareaAdmvs == "360399" {
  6120. var pp models.PublicParams
  6121. pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  6122. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  6123. pp.FixmedinsName = miConfig.OrgName
  6124. pp.FixmedinsCode = miConfig.Code
  6125. pp.RequestUrl = miConfig.Url
  6126. pp.Cainfo = miConfig.Cainfo
  6127. pp.SecretKey = miConfig.SecretKey
  6128. pp.AccessKey = miConfig.AccessKey
  6129. pp.OpterName = curRoles.UserName
  6130. result, _ := service.Jxyb4101(struct4101, pp)
  6131. var dat map[string]interface{}
  6132. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  6133. fmt.Println(dat)
  6134. } else {
  6135. fmt.Println(err)
  6136. }
  6137. userJSONBytes, _ := json.Marshal(dat)
  6138. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  6139. utils.ErrorLog("解析失败:%v", err)
  6140. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6141. return
  6142. }
  6143. } else if miConfig.MdtrtareaAdmvs == "430800" {
  6144. var pp models.PublicParams
  6145. pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  6146. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  6147. pp.FixmedinsName = miConfig.OrgName
  6148. pp.FixmedinsCode = miConfig.Code
  6149. pp.RequestUrl = miConfig.Url
  6150. pp.Cainfo = miConfig.Cainfo
  6151. pp.SecretKey = miConfig.SecretKey
  6152. pp.AccessKey = miConfig.AccessKey
  6153. pp.OpterName = curRoles.UserName
  6154. result, _ := service.Hnyb4101(struct4101, pp)
  6155. var dat map[string]interface{}
  6156. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  6157. fmt.Println(dat)
  6158. } else {
  6159. fmt.Println(err)
  6160. }
  6161. userJSONBytes, _ := json.Marshal(dat)
  6162. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  6163. utils.ErrorLog("解析失败:%v", err)
  6164. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6165. return
  6166. }
  6167. } else {
  6168. result, _ := service.Gdyb4101(struct4101, miConfig.SecretKey, miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.UserOrgId)
  6169. var dat map[string]interface{}
  6170. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  6171. fmt.Println(dat)
  6172. } else {
  6173. fmt.Println(err)
  6174. }
  6175. userJSONBytes, _ := json.Marshal(dat)
  6176. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  6177. utils.ErrorLog("解析失败:%v", err)
  6178. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6179. return
  6180. }
  6181. }
  6182. if res.Infcode != 0 {
  6183. c.ServeSuccessJSON(map[string]interface{}{
  6184. "failed_code": -10,
  6185. "msg": res.ErrMsg,
  6186. })
  6187. return
  6188. } else {
  6189. //order.FaPiaoNumber = zero
  6190. //order.FaPiaoCode = last_order.FaPiaoCode
  6191. //service.UpdateOrder(order)
  6192. hisFundSettleListResult := &models.HisFundSettleListResult{
  6193. Number: res.Output.SetlListId,
  6194. Status: 1,
  6195. Ctime: time.Now().Unix(),
  6196. Mtime: time.Now().Unix(),
  6197. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  6198. IsUpload: 1,
  6199. OrderId: order_id,
  6200. }
  6201. service.CreateUploadRecord(hisFundSettleListResult)
  6202. c.ServeSuccessJSON(map[string]interface{}{
  6203. "msg": "上传成功",
  6204. "result": hisFundSettleListResult,
  6205. })
  6206. return
  6207. }
  6208. }
  6209. func (c *HisApiController) GetSettleListHospital() {
  6210. order_id, _ := c.GetInt64("order_id")
  6211. admin_user_id, _ := c.GetInt64("admin_user_id")
  6212. order, _ := service.GetHisOrderByIDTwo(order_id)
  6213. roles, _ := service.GetDoctorListTwo(c.GetAdminUserInfo().CurrentOrgId)
  6214. his, _ := service.GetInHospitalRecordByNumber(order.MdtrtId)
  6215. admin, _ := service.GetAdminUserByUserID(roles[0].AdminUserId)
  6216. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  6217. depart, _ := service.GetDepartMentDetail(curRoles.DepartmentId)
  6218. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  6219. if order.ID == 0 {
  6220. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisOrderNoExistParamWrong)
  6221. return
  6222. }
  6223. last_order, _ := service.GetLastHisOrder(c.GetAdminUserInfo().CurrentOrgId)
  6224. max_order, _ := service.GetLastHisOrderTwo(c.GetAdminUserInfo().CurrentOrgId)
  6225. count, _ := strconv.ParseInt(max_order.FaPiaoNumber, 10, 64)
  6226. fmt.Println(count)
  6227. var zero string
  6228. number := count + 1
  6229. if number >= 1000 {
  6230. zero = "0000" + strconv.FormatInt(number, 10)
  6231. } else if number >= 10000 {
  6232. zero = "000" + strconv.FormatInt(number, 10)
  6233. } else if number >= 100000 {
  6234. zero = "00" + strconv.FormatInt(number, 10)
  6235. } else if number >= 1000000 {
  6236. zero = "0" + strconv.FormatInt(number, 10)
  6237. } else {
  6238. zero = strconv.FormatInt(number, 10)
  6239. }
  6240. fmt.Println(zero)
  6241. struct4101 := service.Struct4101{
  6242. PsnNo: order.PsnNo,
  6243. MdtrtId: order.MdtrtId,
  6244. SetlId: order.SetlId,
  6245. PsnName: order.PsnName,
  6246. Gend: order.Gend,
  6247. Brdy: his.Brdy,
  6248. Age: int64(order.Age),
  6249. Naty: order.Naty,
  6250. PatnCertType: "01",
  6251. Certno: order.Certno,
  6252. Prfs: "90",
  6253. ConerName: roles[0].UserName,
  6254. PatnRlts: "99",
  6255. ConerAddr: miConfig.OrgName,
  6256. ConerTel: admin.Mobile,
  6257. HiType: order.Insutype,
  6258. Insuplc: miConfig.InsuplcAdmdvs,
  6259. MaindiagFlag: "1",
  6260. BillCode: order.SetlId,
  6261. BillNo: order.SetlId,
  6262. BizSn: order.Number,
  6263. PsnSelfPay: order.PsnPartAmt,
  6264. PsnOwnPay: order.PsnPartAmt,
  6265. AcctPay: order.AcctPay,
  6266. PsnCashpay: order.PsnCashPay,
  6267. HiPaymtd: "1",
  6268. Hsorg: miConfig.InsuplcAdmdvs,
  6269. HsorgOpter: miConfig.InsuplcAdmdvs,
  6270. MedinsFillPsn: curRoles.UserName,
  6271. MedinsFillDept: depart.Name,
  6272. IptMedType: "2",
  6273. AdmTime: his.InHosptialTime,
  6274. AdmEndTime: his.OutHosptialTime,
  6275. }
  6276. struct4101.SetlBegnDate = order.SetlTime
  6277. struct4101.SetlEndDate = order.SetlTime
  6278. var rf []CustomFundPay
  6279. json.Unmarshal([]byte(order.SetlDetail), &rf)
  6280. var tempFunPays []service.CustomStruct
  6281. for _, item := range rf {
  6282. var tempFunPay service.CustomStruct
  6283. tempFunPay.FundPayamt = item.FundPayamt
  6284. tempFunPay.FundPayType = item.FundPayType
  6285. tempFunPays = append(tempFunPays, tempFunPay)
  6286. }
  6287. struct4101.CustomStruct = tempFunPays
  6288. var tempDiaginfos []service.DiaginfoStructTwo
  6289. var tempOpspdiseinfo2 service.OpspdiseinfoStruct
  6290. var tempOpspdiseinfos []service.OpspdiseinfoStruct
  6291. diagnosis_ids := strings.Split(his.Diagnosis, ",")
  6292. var config []*models.HisXtDiagnoseConfig
  6293. for _, item := range diagnosis_ids {
  6294. id, _ := strconv.ParseInt(item, 10, 64)
  6295. diagnosisConfig, _ := service.FindDiagnoseById(id)
  6296. config = append(config, &diagnosisConfig)
  6297. }
  6298. for index, item := range config {
  6299. if index == 0 {
  6300. var tempDiaginfo service.DiaginfoStructTwo
  6301. tempDiaginfo.DiagCode = item.CountryCode
  6302. tempDiaginfo.DiagName = item.CountryContentName
  6303. tempDiaginfo.DiagType = "1"
  6304. tempDiaginfo.MaindiagFlag = "1"
  6305. tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  6306. } else {
  6307. var tempDiaginfo service.DiaginfoStructTwo
  6308. tempDiaginfo.DiagCode = item.CountryCode
  6309. tempDiaginfo.DiagName = item.CountryContentName
  6310. tempDiaginfo.DiagType = "2"
  6311. tempDiaginfo.MaindiagFlag = "0"
  6312. tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  6313. }
  6314. }
  6315. struct4101.Diseinfo = tempDiaginfos
  6316. sickConfigTwo, _ := service.FindSickById(his.SickType)
  6317. tempOpspdiseinfo2.DiagCode = sickConfigTwo.ContentCode
  6318. tempOpspdiseinfo2.DiagName = sickConfigTwo.CountryContentName
  6319. tempOpspdiseinfo2.OprnOprtCode = ""
  6320. tempOpspdiseinfo2.OprnOprtName = ""
  6321. tempOpspdiseinfos = append(tempOpspdiseinfos, tempOpspdiseinfo2)
  6322. struct4101.OpspdiseinfoStruct = tempOpspdiseinfos
  6323. var iteminfo service.IteminfoStruct
  6324. var bedCostTotal float64 = 0 //床位总费
  6325. var bedCostSelfTotal float64 = 0 //床位自费
  6326. var bedCostPartSelfTotal float64 = 0 //床位部分项目自费
  6327. var operationCostTotal float64 = 0 //手术费
  6328. var operationCostSelfTotal float64 = 0 //手术费
  6329. var operationCostPartSelfTotal float64 = 0 //手术费
  6330. var otherCostTotal float64 = 0 //其他费用
  6331. var otherCostSelfTotal float64 = 0 //其他费用
  6332. var otherCostPartSelfTotal float64 = 0 //其他费用
  6333. var materialCostTotal float64 = 0 //材料费
  6334. var materialCostSelfTotal float64 = 0 //材料费
  6335. var materialCostPartSelfTotal float64 = 0 //材料费
  6336. var westernMedicineCostTotal float64 = 0 //西药费
  6337. var westernMedicineCostSelfTotal float64 = 0 //西药费
  6338. var westernMedicineCostPartSelfTotal float64 = 0 //西药费
  6339. var chineseTraditionalMedicineCostTotal float64 = 0 //中成药
  6340. var chineseTraditionalMedicineCostSelfTotal float64 = 0 //中成药
  6341. var chineseTraditionalMedicineCostPartSelfTotal float64 = 0 //中成药
  6342. var checkCostTotal float64 = 0 //检查费
  6343. var checkCostSelfTotal float64 = 0 //检查费
  6344. var checkCostPartSelfTotal float64 = 0 //检查费
  6345. var laboratoryCostTotal float64 = 0 //化验费
  6346. var laboratoryCostSelfTotal float64 = 0 //化验费
  6347. var laboratoryCostPartSelfTotal float64 = 0 //化验费
  6348. var treatCostTotal float64 = 0 //治疗费用
  6349. var treatCostSelfTotal float64 = 0 //治疗费用
  6350. var treatCostPartSelfTotal float64 = 0 //治疗费用
  6351. decimal.DivisionPrecision = 2
  6352. var bed_fulamt_ownpay_amt float64 = 0
  6353. var operation_fulamt_ownpay_amt float64 = 0
  6354. var other_fulamt_ownpay_amt float64 = 0
  6355. var westernMedicine_fulamt_ownpay_amt float64 = 0
  6356. var chineseTraditional_fulamt_ownpay_amt float64 = 0
  6357. var check_fulamt_ownpay_amt float64 = 0
  6358. var material_fulamt_ownpay_amt float64 = 0
  6359. var laboratory_fulamt_ownpay_amt float64 = 0
  6360. var treat_fulamt_ownpay_amt float64 = 0
  6361. var bed_claa_sunmfee float64 = 0
  6362. var bed_clab_amt float64 = 0
  6363. var bed_other_amt float64 = 0
  6364. var operation_claa_sunmfee float64 = 0
  6365. var operation_clab_amt float64 = 0
  6366. var operation_other_amt float64 = 0
  6367. var other_claa_sunmfee float64 = 0
  6368. var other_clab_amt float64 = 0
  6369. var other_other_amt float64 = 0
  6370. var westernMedicine_claa_sunmfee float64 = 0
  6371. var westernMedicine_clab_amt float64 = 0
  6372. var westernMedicine_other_amt float64 = 0
  6373. var chineseTraditional_claa_sunmfee float64 = 0
  6374. var chineseTraditional_clab_amt float64 = 0
  6375. var chineseTraditional_other_amt float64 = 0
  6376. var check_claa_sunmfee float64 = 0
  6377. var check_clab_amt float64 = 0
  6378. var check_other_amt float64 = 0
  6379. var material_claa_sunmfee float64 = 0
  6380. var material_clab_amt float64 = 0
  6381. var material_other_amt float64 = 0
  6382. var laboratory_claa_sunmfee float64 = 0
  6383. var laboratory_clab_amt float64 = 0
  6384. var laboratory_other_amt float64 = 0
  6385. var treat_claa_sunmfee float64 = 0
  6386. var treat_clab_amt float64 = 0
  6387. var treat_other_amt float64 = 0
  6388. for _, item := range order.HisOrderInfo {
  6389. if item.MedChrgitmType == "01" { //床位费
  6390. bedCostTotal, _ = decimal.NewFromFloat(bedCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  6391. bedCostSelfTotal, _ = decimal.NewFromFloat(bedCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  6392. bedCostPartSelfTotal, _ = decimal.NewFromFloat(bedCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  6393. bed_fulamt_ownpay_amt, _ = decimal.NewFromFloat(bed_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  6394. if item.ChrgitmLv == "1" {
  6395. bed_claa_sunmfee, _ = decimal.NewFromFloat(bed_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  6396. }
  6397. if item.ChrgitmLv == "2" {
  6398. bed_clab_amt, _ = decimal.NewFromFloat(bed_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  6399. }
  6400. if item.ChrgitmLv == "3" {
  6401. bed_other_amt, _ = decimal.NewFromFloat(bed_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  6402. }
  6403. }
  6404. if item.MedChrgitmType == "03" { //检查费
  6405. checkCostTotal, _ = decimal.NewFromFloat(checkCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  6406. checkCostSelfTotal, _ = decimal.NewFromFloat(checkCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  6407. checkCostPartSelfTotal, _ = decimal.NewFromFloat(checkCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  6408. check_fulamt_ownpay_amt, _ = decimal.NewFromFloat(check_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  6409. if item.ChrgitmLv == "1" {
  6410. check_claa_sunmfee, _ = decimal.NewFromFloat(check_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  6411. }
  6412. if item.ChrgitmLv == "2" {
  6413. check_clab_amt, _ = decimal.NewFromFloat(check_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  6414. }
  6415. if item.ChrgitmLv == "3" {
  6416. check_other_amt, _ = decimal.NewFromFloat(check_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  6417. }
  6418. }
  6419. if item.MedChrgitmType == "04" { //化验费
  6420. laboratoryCostTotal, _ = decimal.NewFromFloat(laboratoryCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  6421. laboratoryCostSelfTotal, _ = decimal.NewFromFloat(laboratoryCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  6422. laboratoryCostPartSelfTotal, _ = decimal.NewFromFloat(laboratoryCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  6423. laboratory_fulamt_ownpay_amt, _ = decimal.NewFromFloat(laboratory_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  6424. if item.ChrgitmLv == "1" {
  6425. laboratory_claa_sunmfee, _ = decimal.NewFromFloat(laboratory_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  6426. }
  6427. if item.ChrgitmLv == "2" {
  6428. laboratory_clab_amt, _ = decimal.NewFromFloat(laboratory_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  6429. }
  6430. if item.ChrgitmLv == "3" {
  6431. laboratory_other_amt, _ = decimal.NewFromFloat(laboratory_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  6432. }
  6433. }
  6434. if item.MedChrgitmType == "05" { //治疗费
  6435. treatCostTotal, _ = decimal.NewFromFloat(treatCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  6436. treatCostSelfTotal, _ = decimal.NewFromFloat(treatCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  6437. treatCostPartSelfTotal, _ = decimal.NewFromFloat(treatCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  6438. treat_fulamt_ownpay_amt, _ = decimal.NewFromFloat(treat_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  6439. if item.ChrgitmLv == "1" {
  6440. treat_claa_sunmfee, _ = decimal.NewFromFloat(treat_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  6441. }
  6442. if item.ChrgitmLv == "2" {
  6443. treat_clab_amt, _ = decimal.NewFromFloat(treat_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  6444. }
  6445. if item.ChrgitmLv == "3" {
  6446. treat_other_amt, _ = decimal.NewFromFloat(treat_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  6447. }
  6448. }
  6449. if item.MedChrgitmType == "06" { //手术费
  6450. operationCostTotal, _ = decimal.NewFromFloat(operationCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  6451. operationCostSelfTotal, _ = decimal.NewFromFloat(operationCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  6452. operationCostPartSelfTotal, _ = decimal.NewFromFloat(operationCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  6453. operation_fulamt_ownpay_amt, _ = decimal.NewFromFloat(operation_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  6454. if item.ChrgitmLv == "1" {
  6455. operation_claa_sunmfee, _ = decimal.NewFromFloat(operation_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  6456. }
  6457. if item.ChrgitmLv == "2" {
  6458. operation_clab_amt, _ = decimal.NewFromFloat(operation_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  6459. }
  6460. if item.ChrgitmLv == "3" {
  6461. operation_other_amt, _ = decimal.NewFromFloat(operation_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  6462. }
  6463. }
  6464. if item.MedChrgitmType == "08" { //材料费
  6465. materialCostTotal, _ = decimal.NewFromFloat(materialCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  6466. materialCostSelfTotal, _ = decimal.NewFromFloat(materialCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  6467. materialCostPartSelfTotal, _ = decimal.NewFromFloat(materialCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  6468. material_fulamt_ownpay_amt, _ = decimal.NewFromFloat(material_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  6469. if item.ChrgitmLv == "1" {
  6470. material_claa_sunmfee, _ = decimal.NewFromFloat(material_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  6471. }
  6472. if item.ChrgitmLv == "2" {
  6473. material_clab_amt, _ = decimal.NewFromFloat(material_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  6474. }
  6475. if item.ChrgitmLv == "3" {
  6476. material_other_amt, _ = decimal.NewFromFloat(material_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  6477. }
  6478. }
  6479. if item.MedChrgitmType == "09" { //西药费
  6480. westernMedicineCostTotal, _ = decimal.NewFromFloat(westernMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  6481. westernMedicineCostSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  6482. westernMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  6483. westernMedicine_fulamt_ownpay_amt, _ = decimal.NewFromFloat(westernMedicine_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  6484. if item.ChrgitmLv == "1" {
  6485. westernMedicine_claa_sunmfee, _ = decimal.NewFromFloat(westernMedicine_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  6486. }
  6487. if item.ChrgitmLv == "2" {
  6488. westernMedicine_clab_amt, _ = decimal.NewFromFloat(westernMedicine_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  6489. }
  6490. if item.ChrgitmLv == "3" {
  6491. westernMedicine_other_amt, _ = decimal.NewFromFloat(westernMedicine_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  6492. }
  6493. }
  6494. if item.MedChrgitmType == "11" { //中成费
  6495. chineseTraditionalMedicineCostTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  6496. chineseTraditionalMedicineCostSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  6497. chineseTraditionalMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  6498. chineseTraditional_fulamt_ownpay_amt, _ = decimal.NewFromFloat(chineseTraditional_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  6499. if item.ChrgitmLv == "1" {
  6500. chineseTraditional_claa_sunmfee, _ = decimal.NewFromFloat(chineseTraditional_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  6501. }
  6502. if item.ChrgitmLv == "2" {
  6503. chineseTraditional_clab_amt, _ = decimal.NewFromFloat(chineseTraditional_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  6504. }
  6505. if item.ChrgitmLv == "3" {
  6506. chineseTraditional_other_amt, _ = decimal.NewFromFloat(chineseTraditional_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  6507. }
  6508. }
  6509. if item.MedChrgitmType == "14" { //其他费
  6510. otherCostTotal, _ = decimal.NewFromFloat(otherCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  6511. otherCostSelfTotal, _ = decimal.NewFromFloat(otherCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  6512. otherCostPartSelfTotal, _ = decimal.NewFromFloat(otherCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  6513. other_fulamt_ownpay_amt, _ = decimal.NewFromFloat(other_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  6514. if item.ChrgitmLv == "1" {
  6515. other_claa_sunmfee, _ = decimal.NewFromFloat(other_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  6516. }
  6517. if item.ChrgitmLv == "2" {
  6518. other_clab_amt, _ = decimal.NewFromFloat(other_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  6519. }
  6520. if item.ChrgitmLv == "3" {
  6521. other_other_amt, _ = decimal.NewFromFloat(other_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  6522. }
  6523. }
  6524. }
  6525. var iteminfoStructs []service.IteminfoStruct
  6526. if bedCostTotal != 0 {
  6527. iteminfo.MedChrgitm = "01"
  6528. iteminfo.FulamtOwnpayAmt = bed_fulamt_ownpay_amt
  6529. iteminfo.Amt = bedCostTotal
  6530. iteminfo.ClaaSumfee = bed_claa_sunmfee
  6531. iteminfo.ClabAmt = bed_clab_amt
  6532. iteminfo.OthAmt = bed_other_amt
  6533. iteminfoStructs = append(iteminfoStructs, iteminfo)
  6534. }
  6535. if checkCostTotal != 0 {
  6536. iteminfo.MedChrgitm = "03"
  6537. iteminfo.FulamtOwnpayAmt = check_fulamt_ownpay_amt
  6538. iteminfo.Amt = checkCostTotal
  6539. iteminfo.ClaaSumfee = check_claa_sunmfee
  6540. iteminfo.ClabAmt = check_clab_amt
  6541. iteminfo.OthAmt = check_other_amt
  6542. iteminfoStructs = append(iteminfoStructs, iteminfo)
  6543. }
  6544. if laboratoryCostTotal != 0 {
  6545. iteminfo.MedChrgitm = "04"
  6546. iteminfo.FulamtOwnpayAmt = laboratory_fulamt_ownpay_amt
  6547. iteminfo.Amt = laboratoryCostTotal
  6548. iteminfo.ClaaSumfee = laboratory_claa_sunmfee
  6549. iteminfo.ClabAmt = laboratory_clab_amt
  6550. iteminfo.OthAmt = laboratory_other_amt
  6551. iteminfoStructs = append(iteminfoStructs, iteminfo)
  6552. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  6553. }
  6554. if treatCostTotal != 0 {
  6555. iteminfo.MedChrgitm = "05"
  6556. iteminfo.FulamtOwnpayAmt = treat_fulamt_ownpay_amt
  6557. iteminfo.Amt = treatCostTotal
  6558. iteminfo.ClaaSumfee = treat_claa_sunmfee
  6559. iteminfo.ClabAmt = treat_clab_amt
  6560. iteminfo.OthAmt = treat_other_amt
  6561. iteminfoStructs = append(iteminfoStructs, iteminfo)
  6562. //(struct4101.IteminfoStruct, iteminfo)
  6563. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  6564. }
  6565. if operationCostTotal != 0 {
  6566. iteminfo.MedChrgitm = "06"
  6567. iteminfo.FulamtOwnpayAmt = bed_fulamt_ownpay_amt
  6568. iteminfo.Amt = operationCostTotal
  6569. iteminfo.ClaaSumfee = operation_claa_sunmfee
  6570. iteminfo.ClabAmt = operation_clab_amt
  6571. iteminfo.OthAmt = operation_other_amt
  6572. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  6573. iteminfoStructs = append(iteminfoStructs, iteminfo)
  6574. }
  6575. if materialCostTotal != 0 {
  6576. iteminfo.MedChrgitm = "08"
  6577. iteminfo.FulamtOwnpayAmt = material_fulamt_ownpay_amt
  6578. iteminfo.Amt = materialCostTotal
  6579. iteminfo.ClaaSumfee = material_claa_sunmfee
  6580. iteminfo.ClabAmt = material_clab_amt
  6581. iteminfo.OthAmt = material_other_amt
  6582. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  6583. iteminfoStructs = append(iteminfoStructs, iteminfo)
  6584. }
  6585. if westernMedicineCostTotal != 0 {
  6586. iteminfo.MedChrgitm = "09"
  6587. iteminfo.FulamtOwnpayAmt = westernMedicine_fulamt_ownpay_amt
  6588. iteminfo.Amt = westernMedicineCostTotal
  6589. iteminfo.ClaaSumfee = westernMedicine_claa_sunmfee
  6590. iteminfo.ClabAmt = westernMedicine_clab_amt
  6591. iteminfo.OthAmt = westernMedicine_other_amt
  6592. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  6593. iteminfoStructs = append(iteminfoStructs, iteminfo)
  6594. }
  6595. if chineseTraditionalMedicineCostTotal != 0 {
  6596. iteminfo.MedChrgitm = "11"
  6597. iteminfo.FulamtOwnpayAmt = westernMedicine_fulamt_ownpay_amt
  6598. iteminfo.Amt = westernMedicineCostTotal
  6599. iteminfo.ClaaSumfee = westernMedicine_claa_sunmfee
  6600. iteminfo.ClabAmt = westernMedicine_clab_amt
  6601. iteminfo.OthAmt = westernMedicine_other_amt
  6602. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  6603. iteminfoStructs = append(iteminfoStructs, iteminfo)
  6604. }
  6605. if otherCostTotal != 0 {
  6606. iteminfo.MedChrgitm = "14"
  6607. iteminfo.FulamtOwnpayAmt = other_fulamt_ownpay_amt
  6608. iteminfo.Amt = otherCostTotal
  6609. iteminfo.ClaaSumfee = other_claa_sunmfee
  6610. iteminfo.ClabAmt = other_clab_amt
  6611. iteminfo.OthAmt = other_other_amt
  6612. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  6613. iteminfoStructs = append(iteminfoStructs, iteminfo)
  6614. }
  6615. struct4101.IteminfoStruct = iteminfoStructs
  6616. struct4101.Ntly = "中国"
  6617. struct4101.AdmCaty = "A03.06"
  6618. var resOther ResultSeventeenOther
  6619. var res ResultSeventeen
  6620. if miConfig.MdtrtareaAdmvs == "150499" {
  6621. var pp models.PublicParams
  6622. pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  6623. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  6624. pp.FixmedinsName = miConfig.OrgName
  6625. pp.FixmedinsCode = miConfig.Code
  6626. pp.RequestUrl = miConfig.Url
  6627. pp.Cainfo = miConfig.Cainfo
  6628. pp.SecretKey = miConfig.SecretKey
  6629. pp.AccessKey = miConfig.AccessKey
  6630. pp.OpterName = curRoles.UserName
  6631. client := &http.Client{}
  6632. var req *http.Request
  6633. data := make(map[string]interface{})
  6634. data["struct4101"] = struct4101
  6635. data["pp"] = pp
  6636. bytesData, _ := json.Marshal(data)
  6637. req, _ = http.NewRequest("POST", "http://172.16.13.254:9532/"+"nmyb/4101", bytes.NewReader(bytesData))
  6638. resp, _ := client.Do(req)
  6639. defer resp.Body.Close()
  6640. body, ioErr := ioutil.ReadAll(resp.Body)
  6641. if ioErr != nil {
  6642. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  6643. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6644. return
  6645. }
  6646. var respJSON map[string]interface{}
  6647. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  6648. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  6649. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6650. return
  6651. }
  6652. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  6653. userJSONBytes, _ := json.Marshal(respJSON)
  6654. if err := json.Unmarshal(userJSONBytes, &resOther); err != nil {
  6655. utils.ErrorLog("解析失败:%v", err)
  6656. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6657. return
  6658. }
  6659. res.InfRefmsgid = resOther.InfRefmsgid
  6660. res.Output = resOther.Output
  6661. res.ErrMsg = resOther.ErrMsg
  6662. infocode, _ := strconv.ParseInt(resOther.Infcode, 10, 64)
  6663. res.Infcode = infocode
  6664. } else {
  6665. result, _ := service.Gdyb4101(struct4101, miConfig.SecretKey, miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.UserOrgId)
  6666. var dat map[string]interface{}
  6667. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  6668. fmt.Println(dat)
  6669. } else {
  6670. fmt.Println(err)
  6671. }
  6672. userJSONBytes, _ := json.Marshal(dat)
  6673. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  6674. utils.ErrorLog("解析失败:%v", err)
  6675. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6676. return
  6677. }
  6678. }
  6679. if res.Infcode != 0 {
  6680. c.ServeSuccessJSON(map[string]interface{}{
  6681. "failed_code": -10,
  6682. "msg": res.ErrMsg,
  6683. })
  6684. return
  6685. } else {
  6686. if miConfig.MdtrtareaAdmvs != "150499" {
  6687. order.FaPiaoNumber = zero
  6688. order.FaPiaoCode = last_order.FaPiaoCode
  6689. service.UpdateOrder(order)
  6690. }
  6691. hisFundSettleListResult := &models.HisFundSettleListResult{
  6692. Number: res.Output.SetlListId,
  6693. Status: 1,
  6694. Ctime: time.Now().Unix(),
  6695. Mtime: time.Now().Unix(),
  6696. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  6697. IsUpload: 1,
  6698. OrderId: order_id,
  6699. }
  6700. service.CreateUploadRecord(hisFundSettleListResult)
  6701. c.ServeSuccessJSON(map[string]interface{}{
  6702. "msg": "上传成功",
  6703. "result": hisFundSettleListResult,
  6704. })
  6705. return
  6706. }
  6707. }
  6708. //func (c *HisApiController) GetBatchSettleList() {
  6709. // orders, _ := service.GetAllHisOrder(10106)
  6710. // for _, item := range orders {
  6711. // order_id := item.ID
  6712. // order, _ := service.GetHisOrderByIDTwo(order_id)
  6713. // roles, _ := service.GetDoctorListTwo(c.GetAdminUserInfo().CurrentOrgId)
  6714. // his, _ := service.GetHisPatientByNumber(order.MdtrtId)
  6715. // admin, _ := service.GetAdminUserByUserID(roles[0].AdminUserId)
  6716. // curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, 2495)
  6717. // depart, _ := service.GetDepartMentDetail(curRoles.DepartmentId)
  6718. // miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  6719. //
  6720. // pre, _ := service.GetNewHisPrescriptionByNumber(order.Number)
  6721. //
  6722. // doctor, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, pre.Creator)
  6723. //
  6724. // if order.ID == 0 {
  6725. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisOrderNoExistParamWrong)
  6726. // return
  6727. // }
  6728. // if his.BalanceAccountsType == 2 {
  6729. // continue
  6730. // }
  6731. // struct4101 := service.Struct4101{
  6732. // PsnNo: order.PsnNo,
  6733. // MdtrtId: order.MdtrtId,
  6734. // SetlId: order.SetlId,
  6735. // PsnName: order.PsnName,
  6736. // Gend: order.Gend,
  6737. // Brdy: his.Brdy,
  6738. // Age: his.Age,
  6739. // Naty: order.Naty,
  6740. // PatnCertType: "01",
  6741. // Certno: order.Certno,
  6742. // Prfs: "90",
  6743. // ConerName: roles[0].UserName,
  6744. // PatnRlts: "99",
  6745. // ConerAddr: miConfig.OrgName,
  6746. // ConerTel: admin.Mobile,
  6747. // HiType: order.Insutype,
  6748. // Insuplc: his.InsuplcAdmdvs,
  6749. // MaindiagFlag: "1",
  6750. // BillCode: order.SetlId,
  6751. // BillNo: order.SetlId,
  6752. // BizSn: order.Number,
  6753. // PsnSelfPay: order.PsnPartAmt,
  6754. // PsnOwnPay: order.PsnPartAmt,
  6755. // AcctPay: order.AcctPay,
  6756. // PsnCashpay: order.PsnCashPay,
  6757. // HiPaymtd: "1",
  6758. // Hsorg: his.InsuplcAdmdvs,
  6759. // HsorgOpter: his.InsuplcAdmdvs,
  6760. // MedinsFillPsn: curRoles.UserName,
  6761. // MedinsFillDept: depart.Name,
  6762. // IptMedType: "2",
  6763. // }
  6764. // struct4101.SetlBegnDate = order.SetlTime
  6765. // struct4101.SetlEndDate = order.SetlTime
  6766. // //if order.SettleType == 1 {
  6767. // // t := time.Unix(int64(order.SettleAccountsDate), 0)
  6768. // // dateStr := t.Format("2006-01-02")
  6769. // // struct4101.SetlBegnDate = dateStr
  6770. // // struct4101.SetlEndDate = dateStr
  6771. // //} else {
  6772. // // t := time.Unix(int64(order.SettleStartTime), 0)
  6773. // // t2 := time.Unix(int64(order.SettleEndTime), 0)
  6774. // // dateStartStr := t.Format("2006-01-02")
  6775. // // dateEndStr := t2.Format("2006-01-02")
  6776. // // struct4101.SetlBegnDate = dateStartStr
  6777. // // struct4101.SetlEndDate = dateEndStr
  6778. // //}
  6779. //
  6780. // var rf []CustomFundPay
  6781. // json.Unmarshal([]byte(order.SetlDetail), &rf)
  6782. //
  6783. // var tempFunPays []service.CustomStruct
  6784. // var tempFunPay610100 service.CustomStruct
  6785. //
  6786. // for _, item := range rf {
  6787. // if item.FundPayType == "610100" {
  6788. // tempFunPay610100.FundPayamt, _ = decimal.NewFromFloat(tempFunPay610100.FundPayamt).Add(decimal.NewFromFloat(item.FundPayamt)).Float64()
  6789. // tempFunPay610100.FundPayType = item.FundPayType
  6790. // } else {
  6791. // var tempFunPay service.CustomStruct
  6792. // tempFunPay.FundPayamt = item.FundPayamt
  6793. // tempFunPay.FundPayType = item.FundPayType
  6794. // tempFunPays = append(tempFunPays, tempFunPay)
  6795. // }
  6796. // }
  6797. // tempFunPays = append(tempFunPays, tempFunPay610100)
  6798. // struct4101.CustomStruct = tempFunPays
  6799. //
  6800. // var tempDiaginfos []service.DiaginfoStructTwo
  6801. // var tempOpspdiseinfo2 service.OpspdiseinfoStruct
  6802. // var tempOpspdiseinfos []service.OpspdiseinfoStruct
  6803. //
  6804. // diagnosis_ids := strings.Split(his.Diagnosis, ",")
  6805. // var config []*models.HisXtDiagnoseConfig
  6806. // for _, item := range diagnosis_ids {
  6807. // id, _ := strconv.ParseInt(item, 10, 64)
  6808. // diagnosisConfig, _ := service.FindDiagnoseById(id)
  6809. // config = append(config, &diagnosisConfig)
  6810. // }
  6811. //
  6812. // for index, item := range config {
  6813. // if index == 0 {
  6814. // var tempDiaginfo service.DiaginfoStructTwo
  6815. // tempDiaginfo.DiagCode = item.CountryCode
  6816. // tempDiaginfo.DiagName = item.CountryContentName
  6817. // tempDiaginfo.DiagType = "1"
  6818. // tempDiaginfo.MaindiagFlag = "1"
  6819. // tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  6820. // } else {
  6821. //
  6822. // var tempDiaginfo service.DiaginfoStructTwo
  6823. // tempDiaginfo.DiagCode = item.CountryCode
  6824. // tempDiaginfo.DiagName = item.CountryContentName
  6825. // tempDiaginfo.DiagType = "2"
  6826. // tempDiaginfo.MaindiagFlag = "0"
  6827. // tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  6828. // }
  6829. // }
  6830. // struct4101.Diseinfo = tempDiaginfos
  6831. //
  6832. // sickConfigTwo, _ := service.FindSickById(his.SickType)
  6833. // tempOpspdiseinfo2.DiagCode = sickConfigTwo.ContentCode
  6834. // tempOpspdiseinfo2.DiagName = sickConfigTwo.CountryContentName
  6835. // tempOpspdiseinfo2.OprnOprtCode = ""
  6836. // tempOpspdiseinfo2.OprnOprtName = ""
  6837. // tempOpspdiseinfos = append(tempOpspdiseinfos, tempOpspdiseinfo2)
  6838. // struct4101.OpspdiseinfoStruct = tempOpspdiseinfos
  6839. //
  6840. // var iteminfo service.IteminfoStruct
  6841. //
  6842. // var bedCostTotal float64 = 0 //床位总费
  6843. // var bedCostSelfTotal float64 = 0 //床位自费
  6844. // var bedCostPartSelfTotal float64 = 0 //床位部分项目自费
  6845. //
  6846. // var examineCostTotal float64 = 0 //诊查总费
  6847. // var examineCostSelfTotal float64 = 0 //诊查自费
  6848. // var examineCostPartSelfTotal float64 = 0 //诊查部分项目自费
  6849. //
  6850. // var nursingCostTotal float64 = 0 //护理总费
  6851. // var nursingCostSelfTotal float64 = 0 //护理自费
  6852. // var nursingCostPartSelfTotal float64 = 0 //护理部分项目自费
  6853. //
  6854. // var chineseMedicineCostTotal float64 = 0 //中成药
  6855. // var chineseMedicineCostSelfTotal float64 = 0 //中成药
  6856. // var chineseMedicineCostPartSelfTotal float64 = 0 //中成药
  6857. //
  6858. // var commonlyTreatmentCostTotal float64 = 0 //一般诊疗费
  6859. // var commonlyTreatmentCostSelfTotal float64 = 0 //一般诊疗费
  6860. // var commonlyTreatmentCostPartSelfTotal float64 = 0 //一般诊疗费
  6861. //
  6862. // var registerCostTotal float64 = 0 //一般诊疗费
  6863. // var registerCostSelfTotal float64 = 0 //一般诊疗费
  6864. // var registerPartSelfTotal float64 = 0 //一般诊疗费
  6865. //
  6866. // var operationCostTotal float64 = 0 //手术费
  6867. // var operationCostSelfTotal float64 = 0 //手术费
  6868. // var operationCostPartSelfTotal float64 = 0 //手术费
  6869. //
  6870. // var otherCostTotal float64 = 0 //其他费用
  6871. // var otherCostSelfTotal float64 = 0 //其他费用
  6872. // var otherCostPartSelfTotal float64 = 0 //其他费用
  6873. //
  6874. // var materialCostTotal float64 = 0 //材料费
  6875. // var materialCostSelfTotal float64 = 0 //材料费
  6876. // var materialCostPartSelfTotal float64 = 0 //材料费
  6877. //
  6878. // var westernMedicineCostTotal float64 = 0 //西药费
  6879. // var westernMedicineCostSelfTotal float64 = 0 //西药费
  6880. // var westernMedicineCostPartSelfTotal float64 = 0 //西药费
  6881. //
  6882. // var chineseTraditionalMedicineCostTotal float64 = 0 //中成药
  6883. // var chineseTraditionalMedicineCostSelfTotal float64 = 0 //中成药
  6884. // var chineseTraditionalMedicineCostPartSelfTotal float64 = 0 //中成药
  6885. //
  6886. // var checkCostTotal float64 = 0 //检查费
  6887. // var checkCostSelfTotal float64 = 0 //检查费
  6888. // var checkCostPartSelfTotal float64 = 0 //检查费
  6889. //
  6890. // var laboratoryCostTotal float64 = 0 //化验费
  6891. // var laboratoryCostSelfTotal float64 = 0 //化验费
  6892. // var laboratoryCostPartSelfTotal float64 = 0 //化验费
  6893. //
  6894. // var treatCostTotal float64 = 0 //治疗费用
  6895. // var treatCostSelfTotal float64 = 0 //治疗费用
  6896. // var treatCostPartSelfTotal float64 = 0 //治疗费用
  6897. //
  6898. // decimal.DivisionPrecision = 2
  6899. //
  6900. // var bed_fulamt_ownpay_amt float64 = 0
  6901. //
  6902. // var examine_fulamt_ownpay_amt float64 = 0
  6903. //
  6904. // var nursing_fulamt_ownpay_amt float64 = 0
  6905. //
  6906. // var chinese_medicine_fulamt_ownpay_amt float64 = 0
  6907. //
  6908. // var commonly_treatment_fulamt_ownpay_amt float64 = 0
  6909. //
  6910. // var register_fulamt_ownpay_amt float64 = 0
  6911. //
  6912. // var operation_fulamt_ownpay_amt float64 = 0
  6913. // var other_fulamt_ownpay_amt float64 = 0
  6914. // var westernMedicine_fulamt_ownpay_amt float64 = 0
  6915. // var chineseTraditional_fulamt_ownpay_amt float64 = 0
  6916. // var check_fulamt_ownpay_amt float64 = 0
  6917. // var material_fulamt_ownpay_amt float64 = 0
  6918. // var laboratory_fulamt_ownpay_amt float64 = 0
  6919. // var treat_fulamt_ownpay_amt float64 = 0
  6920. //
  6921. // var bed_claa_sunmfee float64 = 0
  6922. // var bed_clab_amt float64 = 0
  6923. // var bed_other_amt float64 = 0
  6924. //
  6925. // var examine_claa_sunmfee float64 = 0
  6926. // var examine_clab_amt float64 = 0
  6927. // var examine_other_amt float64 = 0
  6928. //
  6929. // var nursing_claa_sunmfee float64 = 0
  6930. // var nursing_clab_amt float64 = 0
  6931. // var nursing_other_amt float64 = 0
  6932. //
  6933. // var chinese_medicine_claa_sunmfee float64 = 0
  6934. // var chinese_medicine_clab_amt float64 = 0
  6935. // var chinese_medicine_other_amt float64 = 0
  6936. //
  6937. // var commonly_treatment_claa_sunmfee float64 = 0
  6938. // var commonly_treatment_clab_amt float64 = 0
  6939. // var commonly_treatment_other_amt float64 = 0
  6940. //
  6941. // var operation_claa_sunmfee float64 = 0
  6942. // var operation_clab_amt float64 = 0
  6943. // var operation_other_amt float64 = 0
  6944. //
  6945. // var other_claa_sunmfee float64 = 0
  6946. // var other_clab_amt float64 = 0
  6947. // var other_other_amt float64 = 0
  6948. //
  6949. // var westernMedicine_claa_sunmfee float64 = 0
  6950. // var westernMedicine_clab_amt float64 = 0
  6951. // var westernMedicine_other_amt float64 = 0
  6952. //
  6953. // var chineseTraditional_claa_sunmfee float64 = 0
  6954. // var chineseTraditional_clab_amt float64 = 0
  6955. // var chineseTraditional_other_amt float64 = 0
  6956. //
  6957. // var check_claa_sunmfee float64 = 0
  6958. // var check_clab_amt float64 = 0
  6959. // var check_other_amt float64 = 0
  6960. //
  6961. // var material_claa_sunmfee float64 = 0
  6962. // var material_clab_amt float64 = 0
  6963. // var material_other_amt float64 = 0
  6964. //
  6965. // var laboratory_claa_sunmfee float64 = 0
  6966. // var laboratory_clab_amt float64 = 0
  6967. // var laboratory_other_amt float64 = 0
  6968. //
  6969. // var treat_claa_sunmfee float64 = 0
  6970. // var treat_clab_amt float64 = 0
  6971. // var treat_other_amt float64 = 0
  6972. //
  6973. // var register_claa_sunmfee float64 = 0
  6974. // var register_clab_amt float64 = 0
  6975. // var register_other_amt float64 = 0
  6976. //
  6977. // for _, item := range order.HisOrderInfo {
  6978. // if item.MedChrgitmType == "01" { //床位费
  6979. // bedCostTotal, _ = decimal.NewFromFloat(bedCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  6980. // bedCostSelfTotal, _ = decimal.NewFromFloat(bedCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  6981. // bedCostPartSelfTotal, _ = decimal.NewFromFloat(bedCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  6982. // bed_fulamt_ownpay_amt, _ = decimal.NewFromFloat(bed_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  6983. // if item.ChrgitmLv == "1" {
  6984. // bed_claa_sunmfee, _ = decimal.NewFromFloat(bed_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  6985. // }
  6986. // if item.ChrgitmLv == "2" {
  6987. // bed_clab_amt, _ = decimal.NewFromFloat(bed_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  6988. //
  6989. // }
  6990. // if item.ChrgitmLv == "3" {
  6991. // bed_other_amt, _ = decimal.NewFromFloat(bed_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  6992. // }
  6993. //
  6994. // }
  6995. //
  6996. // if item.MedChrgitmType == "02" { //诊查
  6997. // examineCostTotal, _ = decimal.NewFromFloat(examineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  6998. // examineCostSelfTotal, _ = decimal.NewFromFloat(examineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  6999. // examineCostPartSelfTotal, _ = decimal.NewFromFloat(examineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  7000. // examine_fulamt_ownpay_amt, _ = decimal.NewFromFloat(examine_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  7001. // if item.ChrgitmLv == "1" {
  7002. // examine_claa_sunmfee, _ = decimal.NewFromFloat(examine_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  7003. // }
  7004. // if item.ChrgitmLv == "2" {
  7005. // examine_clab_amt, _ = decimal.NewFromFloat(examine_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  7006. //
  7007. // }
  7008. // if item.ChrgitmLv == "3" {
  7009. // examine_other_amt, _ = decimal.NewFromFloat(examine_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  7010. // }
  7011. //
  7012. // }
  7013. //
  7014. // if item.MedChrgitmType == "03" { //检查费
  7015. // checkCostTotal, _ = decimal.NewFromFloat(checkCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  7016. // checkCostSelfTotal, _ = decimal.NewFromFloat(checkCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  7017. // checkCostPartSelfTotal, _ = decimal.NewFromFloat(checkCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  7018. // check_fulamt_ownpay_amt, _ = decimal.NewFromFloat(check_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  7019. // if item.ChrgitmLv == "1" {
  7020. //
  7021. // check_claa_sunmfee, _ = decimal.NewFromFloat(check_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  7022. //
  7023. // }
  7024. // if item.ChrgitmLv == "2" {
  7025. // check_clab_amt, _ = decimal.NewFromFloat(check_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  7026. //
  7027. // }
  7028. // if item.ChrgitmLv == "3" {
  7029. // check_other_amt, _ = decimal.NewFromFloat(check_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  7030. // }
  7031. // }
  7032. //
  7033. // if item.MedChrgitmType == "04" { //化验费
  7034. // laboratoryCostTotal, _ = decimal.NewFromFloat(laboratoryCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  7035. // laboratoryCostSelfTotal, _ = decimal.NewFromFloat(laboratoryCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  7036. // laboratoryCostPartSelfTotal, _ = decimal.NewFromFloat(laboratoryCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  7037. // laboratory_fulamt_ownpay_amt, _ = decimal.NewFromFloat(laboratory_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  7038. // if item.ChrgitmLv == "1" {
  7039. //
  7040. // laboratory_claa_sunmfee, _ = decimal.NewFromFloat(laboratory_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  7041. //
  7042. // }
  7043. // if item.ChrgitmLv == "2" {
  7044. // laboratory_clab_amt, _ = decimal.NewFromFloat(laboratory_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  7045. //
  7046. // }
  7047. // if item.ChrgitmLv == "3" {
  7048. // laboratory_other_amt, _ = decimal.NewFromFloat(laboratory_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  7049. // }
  7050. // }
  7051. //
  7052. // if item.MedChrgitmType == "05" { //治疗费
  7053. // treatCostTotal, _ = decimal.NewFromFloat(treatCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  7054. // treatCostSelfTotal, _ = decimal.NewFromFloat(treatCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  7055. // treatCostPartSelfTotal, _ = decimal.NewFromFloat(treatCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  7056. // treat_fulamt_ownpay_amt, _ = decimal.NewFromFloat(treat_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  7057. // if item.ChrgitmLv == "1" {
  7058. //
  7059. // treat_claa_sunmfee, _ = decimal.NewFromFloat(treat_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  7060. //
  7061. // }
  7062. // if item.ChrgitmLv == "2" {
  7063. // treat_clab_amt, _ = decimal.NewFromFloat(treat_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  7064. //
  7065. // }
  7066. // if item.ChrgitmLv == "3" {
  7067. // treat_other_amt, _ = decimal.NewFromFloat(treat_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  7068. // }
  7069. // }
  7070. //
  7071. // if item.MedChrgitmType == "06" { //手术费
  7072. // operationCostTotal, _ = decimal.NewFromFloat(operationCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  7073. // operationCostSelfTotal, _ = decimal.NewFromFloat(operationCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  7074. // operationCostPartSelfTotal, _ = decimal.NewFromFloat(operationCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  7075. // operation_fulamt_ownpay_amt, _ = decimal.NewFromFloat(operation_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  7076. //
  7077. // if item.ChrgitmLv == "1" {
  7078. //
  7079. // operation_claa_sunmfee, _ = decimal.NewFromFloat(operation_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  7080. //
  7081. // }
  7082. // if item.ChrgitmLv == "2" {
  7083. // operation_clab_amt, _ = decimal.NewFromFloat(operation_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  7084. //
  7085. // }
  7086. // if item.ChrgitmLv == "3" {
  7087. // operation_other_amt, _ = decimal.NewFromFloat(operation_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  7088. // }
  7089. // }
  7090. //
  7091. // if item.MedChrgitmType == "07" { //手术费
  7092. // nursingCostTotal, _ = decimal.NewFromFloat(nursingCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  7093. // nursingCostSelfTotal, _ = decimal.NewFromFloat(nursingCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  7094. // nursingCostPartSelfTotal, _ = decimal.NewFromFloat(nursingCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  7095. // nursing_fulamt_ownpay_amt, _ = decimal.NewFromFloat(nursing_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  7096. //
  7097. // if item.ChrgitmLv == "1" {
  7098. //
  7099. // nursing_claa_sunmfee, _ = decimal.NewFromFloat(nursing_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  7100. //
  7101. // }
  7102. // if item.ChrgitmLv == "2" {
  7103. // nursing_clab_amt, _ = decimal.NewFromFloat(nursing_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  7104. //
  7105. // }
  7106. // if item.ChrgitmLv == "3" {
  7107. // nursing_other_amt, _ = decimal.NewFromFloat(nursing_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  7108. // }
  7109. // }
  7110. //
  7111. // if item.MedChrgitmType == "08" { //材料费
  7112. // materialCostTotal, _ = decimal.NewFromFloat(materialCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  7113. // materialCostSelfTotal, _ = decimal.NewFromFloat(materialCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  7114. // materialCostPartSelfTotal, _ = decimal.NewFromFloat(materialCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  7115. // material_fulamt_ownpay_amt, _ = decimal.NewFromFloat(material_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  7116. // if item.ChrgitmLv == "1" {
  7117. //
  7118. // material_claa_sunmfee, _ = decimal.NewFromFloat(material_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  7119. //
  7120. // }
  7121. // if item.ChrgitmLv == "2" {
  7122. // material_clab_amt, _ = decimal.NewFromFloat(material_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  7123. //
  7124. // }
  7125. // if item.ChrgitmLv == "3" {
  7126. // material_other_amt, _ = decimal.NewFromFloat(material_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  7127. // }
  7128. // }
  7129. // if item.MedChrgitmType == "09" { //西药费
  7130. // westernMedicineCostTotal, _ = decimal.NewFromFloat(westernMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  7131. // westernMedicineCostSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  7132. // westernMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  7133. // westernMedicine_fulamt_ownpay_amt, _ = decimal.NewFromFloat(westernMedicine_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  7134. // if item.ChrgitmLv == "1" {
  7135. // westernMedicine_claa_sunmfee, _ = decimal.NewFromFloat(westernMedicine_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  7136. // }
  7137. // if item.ChrgitmLv == "2" {
  7138. // westernMedicine_clab_amt, _ = decimal.NewFromFloat(westernMedicine_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  7139. // }
  7140. // if item.ChrgitmLv == "3" {
  7141. // westernMedicine_other_amt, _ = decimal.NewFromFloat(westernMedicine_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  7142. // }
  7143. // }
  7144. // if item.MedChrgitmType == "10" { //中药饮片
  7145. // chineseMedicineCostTotal, _ = decimal.NewFromFloat(chineseMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  7146. // chineseMedicineCostSelfTotal, _ = decimal.NewFromFloat(chineseMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  7147. // chineseMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(chineseMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  7148. // chinese_medicine_fulamt_ownpay_amt, _ = decimal.NewFromFloat(chinese_medicine_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  7149. // if item.ChrgitmLv == "1" {
  7150. // chinese_medicine_claa_sunmfee, _ = decimal.NewFromFloat(chinese_medicine_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  7151. // }
  7152. // if item.ChrgitmLv == "2" {
  7153. // chinese_medicine_clab_amt, _ = decimal.NewFromFloat(chinese_medicine_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  7154. // }
  7155. // if item.ChrgitmLv == "3" {
  7156. // chinese_medicine_other_amt, _ = decimal.NewFromFloat(chinese_medicine_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  7157. // }
  7158. // }
  7159. //
  7160. // if item.MedChrgitmType == "11" { //中成费
  7161. // chineseTraditionalMedicineCostTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  7162. // chineseTraditionalMedicineCostSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  7163. // chineseTraditionalMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  7164. // chineseTraditional_fulamt_ownpay_amt, _ = decimal.NewFromFloat(chineseTraditional_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  7165. // if item.ChrgitmLv == "1" {
  7166. //
  7167. // chineseTraditional_claa_sunmfee, _ = decimal.NewFromFloat(chineseTraditional_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  7168. //
  7169. // }
  7170. // if item.ChrgitmLv == "2" {
  7171. // chineseTraditional_clab_amt, _ = decimal.NewFromFloat(chineseTraditional_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  7172. //
  7173. // }
  7174. // if item.ChrgitmLv == "3" {
  7175. // chineseTraditional_other_amt, _ = decimal.NewFromFloat(chineseTraditional_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  7176. // }
  7177. // }
  7178. //
  7179. // if item.MedChrgitmType == "12" { //中成费
  7180. // commonlyTreatmentCostTotal, _ = decimal.NewFromFloat(commonlyTreatmentCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  7181. // commonlyTreatmentCostSelfTotal, _ = decimal.NewFromFloat(commonlyTreatmentCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  7182. // commonlyTreatmentCostPartSelfTotal, _ = decimal.NewFromFloat(commonlyTreatmentCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  7183. // commonly_treatment_fulamt_ownpay_amt, _ = decimal.NewFromFloat(commonly_treatment_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  7184. // if item.ChrgitmLv == "1" {
  7185. //
  7186. // commonly_treatment_claa_sunmfee, _ = decimal.NewFromFloat(commonly_treatment_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  7187. //
  7188. // }
  7189. // if item.ChrgitmLv == "2" {
  7190. // commonly_treatment_clab_amt, _ = decimal.NewFromFloat(commonly_treatment_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  7191. //
  7192. // }
  7193. // if item.ChrgitmLv == "3" {
  7194. // commonly_treatment_other_amt, _ = decimal.NewFromFloat(commonly_treatment_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  7195. // }
  7196. // }
  7197. //
  7198. // if item.MedChrgitmType == "13" { //中成费
  7199. // registerCostTotal, _ = decimal.NewFromFloat(registerCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  7200. // registerCostSelfTotal, _ = decimal.NewFromFloat(registerCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  7201. // registerPartSelfTotal, _ = decimal.NewFromFloat(registerPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  7202. // register_fulamt_ownpay_amt, _ = decimal.NewFromFloat(register_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  7203. // if item.ChrgitmLv == "1" {
  7204. //
  7205. // register_claa_sunmfee, _ = decimal.NewFromFloat(register_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  7206. //
  7207. // }
  7208. // if item.ChrgitmLv == "2" {
  7209. // register_clab_amt, _ = decimal.NewFromFloat(register_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  7210. //
  7211. // }
  7212. // if item.ChrgitmLv == "3" {
  7213. // register_other_amt, _ = decimal.NewFromFloat(register_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  7214. // }
  7215. // }
  7216. //
  7217. // if item.MedChrgitmType == "14" { //其他费
  7218. // otherCostTotal, _ = decimal.NewFromFloat(otherCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  7219. // otherCostSelfTotal, _ = decimal.NewFromFloat(otherCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  7220. // otherCostPartSelfTotal, _ = decimal.NewFromFloat(otherCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  7221. // other_fulamt_ownpay_amt, _ = decimal.NewFromFloat(other_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  7222. // if item.ChrgitmLv == "1" {
  7223. // other_claa_sunmfee, _ = decimal.NewFromFloat(other_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  7224. //
  7225. // }
  7226. // if item.ChrgitmLv == "2" {
  7227. // other_clab_amt, _ = decimal.NewFromFloat(other_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  7228. //
  7229. // }
  7230. // if item.ChrgitmLv == "3" {
  7231. // other_other_amt, _ = decimal.NewFromFloat(other_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  7232. // }
  7233. // }
  7234. //
  7235. // }
  7236. //
  7237. // var iteminfoStructs []service.IteminfoStruct
  7238. //
  7239. // if bedCostTotal != 0 {
  7240. // iteminfo.MedChrgitm = "01"
  7241. // iteminfo.FulamtOwnpayAmt = bed_fulamt_ownpay_amt
  7242. // iteminfo.Amt = bedCostTotal
  7243. // iteminfo.ClaaSumfee = bed_claa_sunmfee
  7244. // iteminfo.ClabAmt = bed_clab_amt
  7245. // iteminfo.OthAmt = bed_other_amt
  7246. // iteminfoStructs = append(iteminfoStructs, iteminfo)
  7247. // }
  7248. //
  7249. // if examineCostTotal != 0 {
  7250. // iteminfo.MedChrgitm = "02"
  7251. // iteminfo.FulamtOwnpayAmt = examine_fulamt_ownpay_amt
  7252. // iteminfo.Amt = examineCostTotal
  7253. // iteminfo.ClaaSumfee = examine_claa_sunmfee
  7254. // iteminfo.ClabAmt = examine_clab_amt
  7255. // iteminfo.OthAmt = examine_other_amt
  7256. // //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  7257. // iteminfoStructs = append(iteminfoStructs, iteminfo)
  7258. // }
  7259. //
  7260. // if checkCostTotal != 0 {
  7261. // iteminfo.MedChrgitm = "03"
  7262. // iteminfo.FulamtOwnpayAmt = check_fulamt_ownpay_amt
  7263. // iteminfo.Amt = checkCostTotal
  7264. // iteminfo.ClaaSumfee = check_claa_sunmfee
  7265. // iteminfo.ClabAmt = check_clab_amt
  7266. // iteminfo.OthAmt = check_other_amt
  7267. // iteminfoStructs = append(iteminfoStructs, iteminfo)
  7268. //
  7269. // }
  7270. //
  7271. // if laboratoryCostTotal != 0 {
  7272. // iteminfo.MedChrgitm = "04"
  7273. // iteminfo.FulamtOwnpayAmt = laboratory_fulamt_ownpay_amt
  7274. // iteminfo.Amt = laboratoryCostTotal
  7275. // iteminfo.ClaaSumfee = laboratory_claa_sunmfee
  7276. // iteminfo.ClabAmt = laboratory_clab_amt
  7277. // iteminfo.OthAmt = laboratory_other_amt
  7278. // iteminfoStructs = append(iteminfoStructs, iteminfo)
  7279. //
  7280. // //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  7281. //
  7282. // }
  7283. //
  7284. // if treatCostTotal != 0 {
  7285. // iteminfo.MedChrgitm = "05"
  7286. // iteminfo.FulamtOwnpayAmt = treat_fulamt_ownpay_amt
  7287. // iteminfo.Amt = treatCostTotal
  7288. // iteminfo.ClaaSumfee = treat_claa_sunmfee
  7289. // iteminfo.ClabAmt = treat_clab_amt
  7290. // iteminfo.OthAmt = treat_other_amt
  7291. // iteminfoStructs = append(iteminfoStructs, iteminfo)
  7292. // //(struct4101.IteminfoStruct, iteminfo)
  7293. // //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  7294. // }
  7295. //
  7296. // if operationCostTotal != 0 {
  7297. // iteminfo.MedChrgitm = "06"
  7298. // iteminfo.FulamtOwnpayAmt = bed_fulamt_ownpay_amt
  7299. // iteminfo.Amt = operationCostTotal
  7300. // iteminfo.ClaaSumfee = operation_claa_sunmfee
  7301. // iteminfo.ClabAmt = operation_clab_amt
  7302. // iteminfo.OthAmt = operation_other_amt
  7303. // //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  7304. // iteminfoStructs = append(iteminfoStructs, iteminfo)
  7305. // }
  7306. //
  7307. // if nursingCostTotal != 0 {
  7308. // iteminfo.MedChrgitm = "07"
  7309. // iteminfo.FulamtOwnpayAmt = nursing_fulamt_ownpay_amt
  7310. // iteminfo.Amt = nursingCostTotal
  7311. // iteminfo.ClaaSumfee = nursing_claa_sunmfee
  7312. // iteminfo.ClabAmt = nursing_clab_amt
  7313. // iteminfo.OthAmt = nursing_other_amt
  7314. // iteminfoStructs = append(iteminfoStructs, iteminfo)
  7315. // }
  7316. //
  7317. // if materialCostTotal != 0 {
  7318. // iteminfo.MedChrgitm = "08"
  7319. // iteminfo.FulamtOwnpayAmt = material_fulamt_ownpay_amt
  7320. // iteminfo.Amt = materialCostTotal
  7321. // iteminfo.ClaaSumfee = material_claa_sunmfee
  7322. // iteminfo.ClabAmt = material_clab_amt
  7323. // iteminfo.OthAmt = material_other_amt
  7324. // //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  7325. // iteminfoStructs = append(iteminfoStructs, iteminfo)
  7326. // }
  7327. //
  7328. // if westernMedicineCostTotal != 0 {
  7329. // iteminfo.MedChrgitm = "09"
  7330. // iteminfo.FulamtOwnpayAmt = westernMedicine_fulamt_ownpay_amt
  7331. // iteminfo.Amt = westernMedicineCostTotal
  7332. // iteminfo.ClaaSumfee = westernMedicine_claa_sunmfee
  7333. // iteminfo.ClabAmt = westernMedicine_clab_amt
  7334. // iteminfo.OthAmt = westernMedicine_other_amt
  7335. // //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  7336. // iteminfoStructs = append(iteminfoStructs, iteminfo)
  7337. //
  7338. // }
  7339. //
  7340. // if chineseMedicineCostTotal != 0 {
  7341. // iteminfo.MedChrgitm = "10"
  7342. // iteminfo.FulamtOwnpayAmt = chinese_medicine_fulamt_ownpay_amt
  7343. // iteminfo.Amt = chineseMedicineCostTotal
  7344. // iteminfo.ClaaSumfee = chinese_medicine_claa_sunmfee
  7345. // iteminfo.ClabAmt = chinese_medicine_clab_amt
  7346. // iteminfo.OthAmt = chinese_medicine_other_amt
  7347. // //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  7348. // iteminfoStructs = append(iteminfoStructs, iteminfo)
  7349. //
  7350. // }
  7351. //
  7352. // if chineseTraditionalMedicineCostTotal != 0 {
  7353. // iteminfo.MedChrgitm = "11"
  7354. // iteminfo.FulamtOwnpayAmt = westernMedicine_fulamt_ownpay_amt
  7355. // iteminfo.Amt = westernMedicineCostTotal
  7356. // iteminfo.ClaaSumfee = westernMedicine_claa_sunmfee
  7357. // iteminfo.ClabAmt = westernMedicine_clab_amt
  7358. // iteminfo.OthAmt = westernMedicine_other_amt
  7359. // //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  7360. // iteminfoStructs = append(iteminfoStructs, iteminfo)
  7361. //
  7362. // }
  7363. //
  7364. // if commonlyTreatmentCostTotal != 0 {
  7365. // iteminfo.MedChrgitm = "12"
  7366. // iteminfo.FulamtOwnpayAmt = commonly_treatment_fulamt_ownpay_amt
  7367. // iteminfo.Amt = commonlyTreatmentCostTotal
  7368. // iteminfo.ClaaSumfee = commonly_treatment_claa_sunmfee
  7369. // iteminfo.ClabAmt = commonly_treatment_clab_amt
  7370. // iteminfo.OthAmt = commonly_treatment_other_amt
  7371. // //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  7372. // iteminfoStructs = append(iteminfoStructs, iteminfo)
  7373. //
  7374. // }
  7375. //
  7376. // if registerCostTotal != 0 {
  7377. // iteminfo.MedChrgitm = "13"
  7378. // iteminfo.FulamtOwnpayAmt = register_fulamt_ownpay_amt
  7379. // iteminfo.Amt = registerCostTotal
  7380. // iteminfo.ClaaSumfee = register_claa_sunmfee
  7381. // iteminfo.ClabAmt = register_clab_amt
  7382. // iteminfo.OthAmt = register_other_amt
  7383. // //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  7384. // iteminfoStructs = append(iteminfoStructs, iteminfo)
  7385. //
  7386. // }
  7387. //
  7388. // if otherCostTotal != 0 {
  7389. // iteminfo.MedChrgitm = "14"
  7390. // iteminfo.FulamtOwnpayAmt = other_fulamt_ownpay_amt
  7391. // iteminfo.Amt = otherCostTotal
  7392. // iteminfo.ClaaSumfee = other_claa_sunmfee
  7393. // iteminfo.ClabAmt = other_clab_amt
  7394. // iteminfo.OthAmt = other_other_amt
  7395. // //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  7396. // iteminfoStructs = append(iteminfoStructs, iteminfo)
  7397. //
  7398. // }
  7399. // struct4101.IteminfoStruct = iteminfoStructs
  7400. // time_arr := strings.Split(order.SetlTime, " ")
  7401. // struct4101.AdmTime = time_arr[0]
  7402. // struct4101.AdmEndTime = time_arr[0]
  7403. //
  7404. // struct4101.DoctorName = doctor.UserName
  7405. // struct4101.DoctorCode = doctor.DoctorNumber
  7406. //
  7407. // struct4101.Ntly = "中国"
  7408. // struct4101.AdmCaty = "A03.06"
  7409. // var res ResultSeventeen
  7410. // if miConfig.MdtrtareaAdmvs == "421300" {
  7411. // data := make(map[string]interface{})
  7412. // data["struct4101"] = struct4101
  7413. // data["secret_key"] = miConfig.SecretKey
  7414. // data["org_name"] = miConfig.OrgName
  7415. // data["opera"] = curRoles.UserName
  7416. // data["code"] = miConfig.Code
  7417. // data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  7418. // data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  7419. //
  7420. // client := &http.Client{}
  7421. // bytesData, _ := json.Marshal(data)
  7422. // req, _ := http.NewRequest("POST", "http://192.168.124.4:9532/"+"hbyb/4101", bytes.NewReader(bytesData))
  7423. // resp, _ := client.Do(req)
  7424. // defer resp.Body.Close()
  7425. // body, ioErr := ioutil.ReadAll(resp.Body)
  7426. // if ioErr != nil {
  7427. // utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  7428. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7429. // return
  7430. // }
  7431. // var respJSON map[string]interface{}
  7432. // if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  7433. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  7434. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7435. // return
  7436. // }
  7437. //
  7438. // respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  7439. // userJSONBytes, _ := json.Marshal(respJSON)
  7440. // if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  7441. // utils.ErrorLog("解析失败:%v", err)
  7442. // //c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7443. // adminUser := c.GetAdminUserInfo()
  7444. // errlog := &models.HisOrderError{
  7445. // UserOrgId: adminUser.CurrentOrgId,
  7446. // Ctime: time.Now().Unix(),
  7447. // Mtime: time.Now().Unix(),
  7448. // ErrMsg: res.ErrMsg + "解析失败",
  7449. // Status: 1,
  7450. // PatientId: order_id,
  7451. // Stage: 10088,
  7452. // }
  7453. // service.CreateErrMsgLog(errlog)
  7454. // continue
  7455. // }
  7456. //
  7457. // } else {
  7458. // result := service.Gdyb4101(struct4101, miConfig.SecretKey, miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, c.GetAdminUserInfo().CurrentOrgId)
  7459. // fmt.Println(result)
  7460. //
  7461. // var dat map[string]interface{}
  7462. // if err := json.Unmarshal([]byte(result), &dat); err == nil {
  7463. // fmt.Println(dat)
  7464. // } else {
  7465. // fmt.Println(err)
  7466. // }
  7467. // userJSONBytes, _ := json.Marshal(dat)
  7468. // if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  7469. // utils.ErrorLog("解析失败:%v", err)
  7470. // //c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7471. // adminUser := c.GetAdminUserInfo()
  7472. // errlog := &models.HisOrderError{
  7473. // UserOrgId: adminUser.CurrentOrgId,
  7474. // Ctime: time.Now().Unix(),
  7475. // Mtime: time.Now().Unix(),
  7476. // ErrMsg: res.ErrMsg + "解析失败",
  7477. // Status: 1,
  7478. // PatientId: order_id,
  7479. // Stage: 10106,
  7480. // }
  7481. // service.CreateErrMsgLog(errlog)
  7482. // continue
  7483. // }
  7484. // }
  7485. //
  7486. // if res.Infcode != 0 {
  7487. // adminUser := c.GetAdminUserInfo()
  7488. // errlog := &models.HisOrderError{
  7489. // UserOrgId: adminUser.CurrentOrgId,
  7490. // Ctime: time.Now().Unix(),
  7491. // Mtime: time.Now().Unix(),
  7492. // ErrMsg: res.ErrMsg,
  7493. // Status: 1,
  7494. // PatientId: order_id,
  7495. // Stage: 10106,
  7496. // }
  7497. // service.CreateErrMsgLog(errlog)
  7498. // continue
  7499. // } else {
  7500. // hisFundSettleListResult := &models.HisFundSettleListResult{
  7501. // Number: res.Output.SetlListId,
  7502. // Status: 1,
  7503. // Ctime: time.Now().Unix(),
  7504. // Mtime: time.Now().Unix(),
  7505. // UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  7506. // IsUpload: 1,
  7507. // OrderId: order_id,
  7508. // }
  7509. // service.CreateUploadRecord(hisFundSettleListResult)
  7510. // continue
  7511. // }
  7512. // }
  7513. //}
  7514. func (c *HisApiController) GetOrgInfo() {
  7515. miConfig, _ := service.FindMedicalInsuranceInfo(4)
  7516. service.Gdyb1201("", miConfig.OrgName, "1122", miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, 1, "")
  7517. }
  7518. func (c *HisApiController) GetHisPatientInfo() {
  7519. medical_insurance_card := c.GetString("medical_insurance_card")
  7520. id_card_type, _ := c.GetInt64("id_card_type")
  7521. id_card := c.GetString("id_card")
  7522. adminInfo := c.GetAdminUserInfo()
  7523. config, _ := service.GetMedicalInsuranceConfig(adminInfo.CurrentOrgId)
  7524. miConfig, _ := service.FindMedicalInsuranceInfo(adminInfo.CurrentOrgId)
  7525. appRole, _ := service.GetAppRole(adminInfo.CurrentOrgId)
  7526. IdCardNo := ""
  7527. if id_card_type == 1 {
  7528. IdCardNo = medical_insurance_card
  7529. } else if id_card_type == 2 {
  7530. IdCardNo = id_card
  7531. }
  7532. if config.IsOpen == 1 {
  7533. 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
  7534. resp, requestErr := http.Get(api)
  7535. if requestErr != nil {
  7536. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7537. return
  7538. }
  7539. defer resp.Body.Close()
  7540. body, ioErr := ioutil.ReadAll(resp.Body)
  7541. if ioErr != nil {
  7542. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  7543. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7544. return
  7545. }
  7546. var respJSON map[string]interface{}
  7547. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  7548. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  7549. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7550. return
  7551. }
  7552. userJSON := respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  7553. userJSONBytes, _ := json.Marshal(userJSON)
  7554. var res ResultTwo
  7555. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  7556. utils.ErrorLog("解析失败:%v", err)
  7557. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7558. return
  7559. }
  7560. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  7561. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  7562. infoStr := string(Iinfos)
  7563. idetinfoStr := string(Idetinfos)
  7564. if res.Infcode == 0 {
  7565. his := models.VMHisPatient{
  7566. Status: 1,
  7567. Ctime: time.Now().Unix(),
  7568. Mtime: time.Now().Unix(),
  7569. PsnNo: res.Output.Baseinfo.PsnNo,
  7570. PsnCertType: res.Output.Baseinfo.PsnCertType,
  7571. Certno: res.Output.Baseinfo.Certno,
  7572. PsnName: res.Output.Baseinfo.PsnName,
  7573. Gend: res.Output.Baseinfo.Gend,
  7574. Naty: res.Output.Baseinfo.Naty,
  7575. Brdy: res.Output.Baseinfo.Brdy,
  7576. Age: res.Output.Baseinfo.Age,
  7577. Iinfo: infoStr,
  7578. Idetinfo: idetinfoStr,
  7579. UserOrgId: adminInfo.CurrentOrgId,
  7580. IsReturn: 1,
  7581. IdCardType: id_card_type,
  7582. }
  7583. c.ServeSuccessJSON(map[string]interface{}{
  7584. "info": his,
  7585. })
  7586. } else {
  7587. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  7588. return
  7589. }
  7590. }
  7591. }
  7592. //func GetBasBaseInfo() (jsonStr string, err error) {
  7593. //
  7594. // handle := syscall.NewLazyDLL("SSCard.dll")
  7595. // add := handle.NewProc("ReadCardBas")
  7596. // str := make([]byte, 1024)
  7597. // str1 := make([]byte, 1024)
  7598. // ret, _, _ := add.Call((uintptr)(unsafe.Pointer(&str[0])), IntPtr(1024), (uintptr)(unsafe.Pointer(&str1[0])), IntPtr(1024))
  7599. // fmt.Println(ConvertToString(string(str), "gbk", "utf-8"))
  7600. //
  7601. // fmt.Println(ConvertToString(string(str1), "gbk", "utf-8"))
  7602. //
  7603. // fmt.Println("> Add(4,5)的结果为:", ret)
  7604. // handle.Release()
  7605. //
  7606. // return "", nil
  7607. //
  7608. //}
  7609. //func GetQRBaseInfo() (jsonStr string, err error) {
  7610. // handle := syscall.LoadDLL("SSCard.dll")
  7611. // ReadCardBas := handle.FindProc("GetQRBase")
  7612. //
  7613. // str := make([]byte, 256)
  7614. // str1 := make([]byte, 256)
  7615. // r, _, _ := ReadCardBas.Call((uintptr)(unsafe.Pointer(&str[0])), IntPtr(1024), (uintptr)(unsafe.Pointer(&str1[0])), IntPtr(1024))
  7616. //
  7617. // fmt.Println(string(str))
  7618. // fmt.Println(r)
  7619. // return string(str), nil
  7620. //}
  7621. //func CardInit() int {
  7622. // DllTestDef := syscall.MustLoadDLL("SSCard.dll")
  7623. // add := DllTestDef.MustFindProc("Init")
  7624. // ret, _, err := add.Call(StrPtr("http://igb.hsa.gdgov.cn/gdyb_inf/poc/api/card/initDll"), StrPtr("440200"))
  7625. // if err != nil {
  7626. // fmt.Println("SSCard的运算结果为:", ret)
  7627. // }
  7628. // result := int(ret)
  7629. // return result
  7630. //}
  7631. //func CardInit() int {
  7632. // ret, _, err := add.Call(StrPtr("http://igb.hsa.gdgov.cn/gdyb_inf/poc/api/card/initDll"), StrPtr("440200"))
  7633. // if err != nil {
  7634. // fmt.Println("SSCard的运算结果为:", ret)
  7635. // }
  7636. // fmt.Println(err)
  7637. // result := int(ret)
  7638. // return result
  7639. //}
  7640. func IntPtr(n int) uintptr {
  7641. return uintptr(n)
  7642. }
  7643. func StrPtr(s string) uintptr {
  7644. return uintptr(unsafe.Pointer(syscall.StringBytePtr(s)))
  7645. }
  7646. type Result2001 struct {
  7647. Cainfo interface{} `json:"cainfo"`
  7648. ErrMsg string `json:"err_msg"`
  7649. InfRefmsgid string `json:"inf_refmsgid"`
  7650. Infcode int64 `json:"infcode"`
  7651. Output struct {
  7652. Trtinfo struct {
  7653. PsnNo string `json:"psn_no"`
  7654. TrtChkType string `json:"trt_chk_type"`
  7655. FundPayType string `json:"fund_pay_type"`
  7656. TrtEnjymntFlag string `json:"trt_enjymnt_flag"`
  7657. Begndate string `json:"begndate"`
  7658. Enddate string `json:"enddate"`
  7659. TrtChkRslt string `json:"trt_chk_rslt"`
  7660. } `json:"trtinfo"`
  7661. } `json:"output"`
  7662. RefmsgTime string `json:"refmsg_time"`
  7663. RespondTime string `json:"respond_time"`
  7664. Signtype interface{} `json:"signtype"`
  7665. WarnMsg interface{} `json:"warn_msg"`
  7666. }
  7667. type Result2001Org10265 struct {
  7668. Cainfo interface{} `json:"cainfo"`
  7669. ErrMsg string `json:"err_msg"`
  7670. InfRefmsgid string `json:"inf_refmsgid"`
  7671. Infcode string `json:"infcode"`
  7672. Output struct {
  7673. Trtinfo struct {
  7674. PsnNo string `json:"psn_no"`
  7675. TrtChkType string `json:"trt_chk_type"`
  7676. FundPayType string `json:"fund_pay_type"`
  7677. TrtEnjymntFlag string `json:"trt_enjymnt_flag"`
  7678. Begndate string `json:"begndate"`
  7679. Enddate string `json:"enddate"`
  7680. TrtChkRslt string `json:"trt_chk_rslt"`
  7681. } `json:"trtinfo"`
  7682. } `json:"output"`
  7683. RefmsgTime string `json:"refmsg_time"`
  7684. RespondTime string `json:"respond_time"`
  7685. Signtype interface{} `json:"signtype"`
  7686. WarnMsg interface{} `json:"warn_msg"`
  7687. }
  7688. type ResultTwo struct {
  7689. ErrMsg string `json:"err_msg"`
  7690. InfRefmsgid string `json:"inf_refmsgid"`
  7691. Infcode int64 `json:"infcode"`
  7692. Output struct {
  7693. Baseinfo struct {
  7694. Age float64 `json:"age"`
  7695. Brdy string `json:"brdy"`
  7696. Certno string `json:"certno"`
  7697. Gend string `json:"gend"`
  7698. Naty string `json:"naty"`
  7699. PsnCertType string `json:"psn_cert_type"`
  7700. PsnName string `json:"psn_name"`
  7701. PsnNo string `json:"psn_no"`
  7702. } `json:"baseinfo"`
  7703. Idetinfo []interface{} `json:"idetinfo"`
  7704. Iinfo []struct {
  7705. Balc float64 `json:"balc"`
  7706. CvlservFlag string `json:"cvlserv_flag"`
  7707. EmpName string `json:"emp_name"`
  7708. InsuplcAdmdvs string `json:"insuplc_admdvs"`
  7709. Insutype string `json:"insutype"`
  7710. PausInsuDansuplcAdmdvs string `json:"paus_insu_dansuplc_admdvs"`
  7711. PausInsuDate string `json:"paus_insu_date"`
  7712. PsnInsuDate string `json:"psn_insu_date"`
  7713. PsnInsuStas string `json:"psn_insu_stas"`
  7714. PsnType string `json:"psn_type"`
  7715. } `json:"insuinfo"`
  7716. } `json:"output"`
  7717. RefmsgTime string `json:"refmsg_time"`
  7718. RespondTime string `json:"respond_time"`
  7719. Signtype interface{} `json:"signtype"`
  7720. WarnInfo interface{} `json:"warn_info"`
  7721. }
  7722. type ResultTwo10265 struct {
  7723. ErrMsg string `json:"err_msg"`
  7724. InfRefmsgid string `json:"inf_refmsgid"`
  7725. Infcode string `json:"infcode"`
  7726. Output struct {
  7727. Baseinfo struct {
  7728. Age float64 `json:"age"`
  7729. Brdy string `json:"brdy"`
  7730. Certno string `json:"certno"`
  7731. Gend string `json:"gend"`
  7732. Naty string `json:"naty"`
  7733. PsnCertType string `json:"psn_cert_type"`
  7734. PsnName string `json:"psn_name"`
  7735. PsnNo string `json:"psn_no"`
  7736. } `json:"baseinfo"`
  7737. Idetinfo []interface{} `json:"idetinfo"`
  7738. Iinfo []struct {
  7739. Balc float64 `json:"balc"`
  7740. CvlservFlag string `json:"cvlserv_flag"`
  7741. EmpName string `json:"emp_name"`
  7742. InsuplcAdmdvs string `json:"insuplc_admdvs"`
  7743. Insutype string `json:"insutype"`
  7744. PausInsuDansuplcAdmdvs string `json:"paus_insu_dansuplc_admdvs"`
  7745. PausInsuDate string `json:"paus_insu_date"`
  7746. PsnInsuDate string `json:"psn_insu_date"`
  7747. PsnInsuStas string `json:"psn_insu_stas"`
  7748. PsnType string `json:"psn_type"`
  7749. } `json:"insuinfo"`
  7750. } `json:"output"`
  7751. RefmsgTime string `json:"refmsg_time"`
  7752. RespondTime string `json:"respond_time"`
  7753. Signtype interface{} `json:"signtype"`
  7754. WarnInfo interface{} `json:"warn_info"`
  7755. }
  7756. type ResultThree struct {
  7757. Cainfo interface{} `json:"cainfo"`
  7758. ErrMsg string `json:"err_msg"`
  7759. InfRefmsgid string `json:"inf_refmsgid"`
  7760. Infcode int64 `json:"infcode"`
  7761. Output struct {
  7762. Data struct {
  7763. IptOtpNo string `json:"ipt_otp_no"`
  7764. MdtrtID string `json:"mdtrt_id"`
  7765. PsnNo string `json:"psn_no"`
  7766. } `json:"data"`
  7767. } `json:"output"`
  7768. RefmsgTime string `json:"refmsg_time"`
  7769. RespondTime string `json:"respond_time"`
  7770. Signtype interface{} `json:"signtype"`
  7771. WarnMsg interface{} `json:"warn_msg"`
  7772. }
  7773. type ResultThree10265 struct {
  7774. Cainfo interface{} `json:"cainfo"`
  7775. ErrMsg string `json:"err_msg"`
  7776. InfRefmsgid string `json:"inf_refmsgid"`
  7777. Infcode string `json:"infcode"`
  7778. Output struct {
  7779. Data struct {
  7780. IptOtpNo string `json:"ipt_otp_no"`
  7781. MdtrtID string `json:"mdtrt_id"`
  7782. PsnNo string `json:"psn_no"`
  7783. } `json:"data"`
  7784. } `json:"output"`
  7785. RefmsgTime string `json:"refmsg_time"`
  7786. RespondTime string `json:"respond_time"`
  7787. Signtype interface{} `json:"signtype"`
  7788. WarnMsg interface{} `json:"warn_msg"`
  7789. }
  7790. type ResultFour struct {
  7791. Cainfo string `json:"cainfo"`
  7792. ErrMsg string `json:"err_msg"`
  7793. InfRefmsgid string `json:"inf_refmsgid"`
  7794. Infcode int64 `json:"infcode"`
  7795. Output struct {
  7796. Result []struct {
  7797. BasMednFlag string `json:"bas_medn_flag"`
  7798. ChldMedcFlag string `json:"chld_medc_flag"`
  7799. ChrgitmLv string `json:"chrgitm_lv"`
  7800. Cnt float64 `json:"cnt"`
  7801. DetItemFeeSumamt float64 `json:"det_item_fee_sumamt"`
  7802. DrtReimFlag string `json:"drt_reim_flag"`
  7803. FeedetlSn string `json:"feedetl_sn"`
  7804. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  7805. HiNegoDrugFlag string `json:"hi_nego_drug_flag"`
  7806. InscpScpAmt float64 `json:"inscp_scp_amt"`
  7807. ListSpItemFlag string `json:"list_sp_item_flag"`
  7808. LmtUsedFlag string `json:"lmt_used_flag"`
  7809. MedChrgitmType string `json:"med_chrgitm_type"`
  7810. Memo string `json:"memo"`
  7811. OverlmtAmt float64 `json:"overlmt_amt"`
  7812. PreselfpayAmt float64 `json:"preselfpay_amt"`
  7813. Pric float64 `json:"pric"`
  7814. PricUplmtAmt float64 `json:"pric_uplmt_amt"`
  7815. SelfpayProp float64 `json:"selfpay_prop"`
  7816. } `json:"result"`
  7817. } `json:"output"`
  7818. RefmsgTime string `json:"refmsg_time"`
  7819. RespondTime string `json:"respond_time"`
  7820. Signtype string `json:"signtype"`
  7821. WarnMsg string `json:"warn_msg"`
  7822. }
  7823. type ResultFour10265 struct {
  7824. Cainfo string `json:"cainfo"`
  7825. ErrMsg string `json:"err_msg"`
  7826. InfRefmsgid string `json:"inf_refmsgid"`
  7827. Infcode string `json:"infcode"`
  7828. Output struct {
  7829. Result []struct {
  7830. BasMednFlag string `json:"bas_medn_flag"`
  7831. ChldMedcFlag string `json:"chld_medc_flag"`
  7832. ChrgitmLv string `json:"chrgitm_lv"`
  7833. Cnt float64 `json:"cnt"`
  7834. DetItemFeeSumamt float64 `json:"det_item_fee_sumamt"`
  7835. DrtReimFlag string `json:"drt_reim_flag"`
  7836. FeedetlSn string `json:"feedetl_sn"`
  7837. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  7838. HiNegoDrugFlag string `json:"hi_nego_drug_flag"`
  7839. InscpScpAmt float64 `json:"inscp_scp_amt"`
  7840. ListSpItemFlag string `json:"list_sp_item_flag"`
  7841. LmtUsedFlag string `json:"lmt_used_flag"`
  7842. MedChrgitmType string `json:"med_chrgitm_type"`
  7843. Memo string `json:"memo"`
  7844. OverlmtAmt float64 `json:"overlmt_amt"`
  7845. PreselfpayAmt float64 `json:"preselfpay_amt"`
  7846. Pric float64 `json:"pric"`
  7847. PricUplmtAmt float64 `json:"pric_uplmt_amt"`
  7848. SelfpayProp float64 `json:"selfpay_prop"`
  7849. } `json:"result"`
  7850. } `json:"output"`
  7851. RefmsgTime string `json:"refmsg_time"`
  7852. RespondTime string `json:"respond_time"`
  7853. Signtype string `json:"signtype"`
  7854. WarnMsg string `json:"warn_msg"`
  7855. }
  7856. type ResultMemo struct {
  7857. InsuAdmdvs string `json:"insuAdmdvs"`
  7858. }
  7859. // [{"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}]
  7860. type ResultIDInfo struct {
  7861. Begntime string `json:"begntime"`
  7862. Endtime string `json:"endtime"`
  7863. Memo string `json:"memo"`
  7864. }
  7865. type ResultFive struct {
  7866. Balc float64 `json:"balc"`
  7867. CvlservFlag string `json:"cvlserv_flag"`
  7868. EmpName string `json:"emp_name"`
  7869. InsuplcAdmdvs string `json:"insuplc_admdvs"`
  7870. Insutype string `json:"insutype"`
  7871. PausInsuDansuplcAdmdvs string `json:"paus_insu_dansuplc_admdvs"`
  7872. PausInsuDate string `json:"paus_insu_date"`
  7873. PsnInsuDate string `json:"psn_insu_date"`
  7874. PsnInsuStas string `json:"psn_insu_stas"`
  7875. PsnType string `json:"psn_type"`
  7876. }
  7877. type ResultSix struct {
  7878. Cainfo interface{} `json:"cainfo"`
  7879. ErrMsg string `json:"err_msg"`
  7880. InfRefmsgid string `json:"inf_refmsgid"`
  7881. Infcode int64 `json:"infcode"`
  7882. Output struct {
  7883. } `json:"output"`
  7884. RefmsgTime string `json:"refmsg_time"`
  7885. RespondTime string `json:"respond_time"`
  7886. Signtype interface{} `json:"signtype"`
  7887. WarnMsg interface{} `json:"warn_msg"`
  7888. }
  7889. type ResultSix10265 struct {
  7890. Cainfo interface{} `json:"cainfo"`
  7891. ErrMsg string `json:"err_msg"`
  7892. InfRefmsgid string `json:"inf_refmsgid"`
  7893. Infcode string `json:"infcode"`
  7894. Output struct {
  7895. } `json:"output"`
  7896. RefmsgTime string `json:"refmsg_time"`
  7897. RespondTime string `json:"respond_time"`
  7898. Signtype interface{} `json:"signtype"`
  7899. WarnMsg interface{} `json:"warn_msg"`
  7900. }
  7901. type ResultSeven struct {
  7902. Cainfo string `json:"cainfo"`
  7903. ErrMsg string `json:"err_msg"`
  7904. InfRefmsgid string `json:"inf_refmsgid"`
  7905. Infcode int64 `json:"infcode"`
  7906. Output struct {
  7907. Setldetail []interface{} `json:"setldetail"`
  7908. Setlinfo struct {
  7909. AcctMulaidPay float64 `json:"acct_mulaid_pay"`
  7910. AcctPay float64 `json:"acct_pay"`
  7911. ActPayDedc float64 `json:"act_pay_dedc"`
  7912. Age float64 `json:"age"`
  7913. Balc float64 `json:"balc"`
  7914. Brdy string `json:"brdy"`
  7915. Certno string `json:"certno"`
  7916. ClrOptins string `json:"clr_optins"`
  7917. ClrType string `json:"clr_type"`
  7918. ClrWay string `json:"clr_way"`
  7919. CvlservFlag string `json:"cvlserv_flag"`
  7920. CvlservPay float64 `json:"cvlserv_pay"`
  7921. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  7922. FundPaySumamt float64 `json:"fund_pay_sumamt"`
  7923. Gend string `json:"gend"`
  7924. HifesPay float64 `json:"hifes_pay"`
  7925. HifmiPay float64 `json:"hifmi_pay"`
  7926. HifpPay float64 `json:"hifp_pay"`
  7927. HospPartAmt float64 `json:"hosp_part_amt"`
  7928. InscpScpAmt float64 `json:"inscp_scp_amt"`
  7929. Insutype string `json:"insutype"`
  7930. MafPay float64 `json:"maf_pay"`
  7931. MdtrtCertType string `json:"mdtrt_cert_type"`
  7932. HifobPay float64 `json:"hifob_pay"`
  7933. MdtrtID string `json:"mdtrt_id"`
  7934. MedType string `json:"med_type"`
  7935. MedfeeSumamt float64 `json:"medfee_sumamt"`
  7936. MedinsSetlID string `json:"medins_setl_id"`
  7937. Naty string `json:"naty"`
  7938. OthPay float64 `json:"oth_pay"`
  7939. OverlmtSelfpay float64 `json:"overlmt_selfpay"`
  7940. PoolPropSelfpay float64 `json:"pool_prop_selfpay"`
  7941. PreselfpayAmt float64 `json:"preselfpay_amt"`
  7942. PsnCashPay float64 `json:"psn_cash_pay"`
  7943. PsnCertType string `json:"psn_cert_type"`
  7944. PsnName string `json:"psn_name"`
  7945. PsnNo string `json:"psn_no"`
  7946. PsnPartAmt float64 `json:"psn_part_amt"`
  7947. PsnType string `json:"psn_type"`
  7948. SetlID string `json:"setl_id"`
  7949. SetlTime string `json:"setl_time"`
  7950. } `json:"setlinfo"`
  7951. } `json:"output"`
  7952. RefmsgTime string `json:"refmsg_time"`
  7953. RespondTime string `json:"respond_time"`
  7954. Signtype interface{} `json:"signtype"`
  7955. WarnMsg interface{} `json:"warn_msg"`
  7956. }
  7957. type ResultSeven10265 struct {
  7958. Cainfo string `json:"cainfo"`
  7959. ErrMsg string `json:"err_msg"`
  7960. InfRefmsgid string `json:"inf_refmsgid"`
  7961. Infcode string `json:"infcode"`
  7962. Output struct {
  7963. Setldetail []interface{} `json:"setldetail"`
  7964. Setlinfo struct {
  7965. AcctMulaidPay float64 `json:"acct_mulaid_pay"`
  7966. AcctPay float64 `json:"acct_pay"`
  7967. ActPayDedc float64 `json:"act_pay_dedc"`
  7968. Age float64 `json:"age"`
  7969. Balc float64 `json:"balc"`
  7970. Brdy string `json:"brdy"`
  7971. Certno string `json:"certno"`
  7972. ClrOptins string `json:"clr_optins"`
  7973. ClrType string `json:"clr_type"`
  7974. ClrWay string `json:"clr_way"`
  7975. CvlservFlag string `json:"cvlserv_flag"`
  7976. CvlservPay float64 `json:"cvlserv_pay"`
  7977. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  7978. FundPaySumamt float64 `json:"fund_pay_sumamt"`
  7979. Gend string `json:"gend"`
  7980. HifesPay float64 `json:"hifes_pay"`
  7981. HifmiPay float64 `json:"hifmi_pay"`
  7982. HifpPay float64 `json:"hifp_pay"`
  7983. HospPartAmt float64 `json:"hosp_part_amt"`
  7984. InscpScpAmt float64 `json:"inscp_scp_amt"`
  7985. Insutype string `json:"insutype"`
  7986. MafPay float64 `json:"maf_pay"`
  7987. MdtrtCertType string `json:"mdtrt_cert_type"`
  7988. HifobPay float64 `json:"hifob_pay"`
  7989. MdtrtID string `json:"mdtrt_id"`
  7990. MedType string `json:"med_type"`
  7991. MedfeeSumamt float64 `json:"medfee_sumamt"`
  7992. MedinsSetlID string `json:"medins_setl_id"`
  7993. Naty string `json:"naty"`
  7994. OthPay float64 `json:"oth_pay"`
  7995. OverlmtSelfpay float64 `json:"overlmt_selfpay"`
  7996. PoolPropSelfpay float64 `json:"pool_prop_selfpay"`
  7997. PreselfpayAmt float64 `json:"preselfpay_amt"`
  7998. PsnCashPay float64 `json:"psn_cash_pay"`
  7999. PsnCertType string `json:"psn_cert_type"`
  8000. PsnName string `json:"psn_name"`
  8001. PsnNo string `json:"psn_no"`
  8002. PsnPartAmt float64 `json:"psn_part_amt"`
  8003. PsnType string `json:"psn_type"`
  8004. SetlID string `json:"setl_id"`
  8005. SetlTime string `json:"setl_time"`
  8006. } `json:"setlinfo"`
  8007. } `json:"output"`
  8008. RefmsgTime string `json:"refmsg_time"`
  8009. RespondTime string `json:"respond_time"`
  8010. Signtype interface{} `json:"signtype"`
  8011. WarnMsg interface{} `json:"warn_msg"`
  8012. }
  8013. type ResultEight struct {
  8014. Cainfo string `json:"cainfo"`
  8015. ErrMsg string `json:"err_msg"`
  8016. InfRefmsgid string `json:"inf_refmsgid"`
  8017. Infcode int64 `json:"infcode"`
  8018. Output struct {
  8019. Stmtinfo struct {
  8020. SetlOptins string `json:"setl_optins"`
  8021. StmtRslt string `json:"stmt_rslt"`
  8022. StmtRsltDscr string `json:"stmt_rslt_dscr"`
  8023. } `json:"stmtinfo"`
  8024. } `json:"output"`
  8025. RefmsgTime string `json:"refmsg_time"`
  8026. RespondTime string `json:"respond_time"`
  8027. Signtype interface{} `json:"signtype"`
  8028. WarnMsg interface{} `json:"warn_msg"`
  8029. }
  8030. type ResultEightFor10188 struct {
  8031. Cainfo string `json:"cainfo"`
  8032. ErrMsg string `json:"err_msg"`
  8033. InfRefmsgid string `json:"inf_refmsgid"`
  8034. Infcode string `json:"infcode"`
  8035. Output struct {
  8036. Stmtinfo struct {
  8037. SetlOptins string `json:"setl_optins"`
  8038. StmtRslt string `json:"stmt_rslt"`
  8039. StmtRsltDscr string `json:"stmt_rslt_dscr"`
  8040. } `json:"stmtinfo"`
  8041. } `json:"output"`
  8042. RefmsgTime string `json:"refmsg_time"`
  8043. RespondTime string `json:"respond_time"`
  8044. Signtype interface{} `json:"signtype"`
  8045. WarnMsg interface{} `json:"warn_msg"`
  8046. }
  8047. type ResultNine struct {
  8048. Cainfo string `json:"cainfo"`
  8049. ErrMsg string `json:"err_msg"`
  8050. InfRefmsgid string `json:"inf_refmsgid"`
  8051. Infcode int64 `json:"infcode"`
  8052. Output struct {
  8053. FileQuryNo string `json:"file_qury_no"`
  8054. } `json:"output"`
  8055. RefmsgTime string `json:"refmsg_time"`
  8056. RespondTime string `json:"respond_time"`
  8057. Signtype interface{} `json:"signtype"`
  8058. WarnMsg interface{} `json:"warn_msg"`
  8059. }
  8060. type ResultTen struct {
  8061. Cainfo string `json:"cainfo"`
  8062. ErrMsg string `json:"err_msg"`
  8063. InfRefmsgid string `json:"inf_refmsgid"`
  8064. Infcode int64 `json:"infcode"`
  8065. Output struct {
  8066. DldEndtime string `json:"dld_endtime"`
  8067. FileQuryNo string `json:"file_qury_no"`
  8068. Filename string `json:"filename"`
  8069. } `json:"output"`
  8070. RefmsgTime string `json:"refmsg_time"`
  8071. RespondTime string `json:"respond_time"`
  8072. Signtype interface{} `json:"signtype"`
  8073. WarnMsg interface{} `json:"warn_msg"`
  8074. }
  8075. //type Autogenerated struct {
  8076. // Output struct {
  8077. // Setlinfo struct {
  8078. // SetlTime string `json:"setl_time"`
  8079. // CvlservPay float64 `json:"cvlserv_pay"`
  8080. // Year string `json:"year"`
  8081. // MedType string `json:"med_type"`
  8082. // PsnPay float64 `json:"psn_pay"`
  8083. // OpterID string `json:"opter_id"`
  8084. // Begndate string `json:"begndate"`
  8085. // FlxempeFlag string `json:"flxempe_flag"`
  8086. // HifmiPay float64 `json:"hifmi_pay"`
  8087. // PsnNo string `json:"psn_no"`
  8088. // ActPayDedc float64 `json:"act_pay_dedc"`
  8089. // MedinsSetlID interface{} `json:"medins_setl_id"`
  8090. // AcctMulaidPay interface{} `json:"acct_mulaid_pay"`
  8091. // ClrWay string `json:"clr_way"`
  8092. // OthPay float64 `json:"oth_pay"`
  8093. // Gend string `json:"gend"`
  8094. // MdtrtID string `json:"mdtrt_id"`
  8095. // AcctPay float64 `json:"acct_pay"`
  8096. // InscpScpAmt float64 `json:"inscp_scp_amt"`
  8097. // Insutype string `json:"insutype"`
  8098. // Invono interface{} `json:"invono"`
  8099. // Enddate string `json:"enddate"`
  8100. // CashPayamt float64 `json:"cash_payamt"`
  8101. // PsnType string `json:"psn_type"`
  8102. // FixmedinsName string `json:"fixmedins_name"`
  8103. // HifpPay float64 `json:"hifp_pay"`
  8104. // NewFlag interface{} `json:"new_flag"`
  8105. // OverlmtSelfpay float64 `json:"overlmt_selfpay"`
  8106. // PreselfpayAmt float64 `json:"preselfpay_amt"`
  8107. // PayLoc string `json:"pay_loc"`
  8108. // ClrType string `json:"clr_type"`
  8109. // RefdSetlFlag string `json:"refd_setl_flag"`
  8110. // CvlservFlag string `json:"cvlserv_flag"`
  8111. // EmpName string `json:"emp_name"`
  8112. // Brdy string `json:"brdy"`
  8113. // Naty string `json:"naty"`
  8114. // Certno string `json:"certno"`
  8115. // DiseCode string `json:"dise_code"`
  8116. // FixmedinsCode string `json:"fixmedins_code"`
  8117. // DedcHospLv string `json:"dedc_hosp_lv"`
  8118. // OpterName string `json:"opter_name"`
  8119. // Balc float64 `json:"balc"`
  8120. // FixmedinsPoolarea string `json:"fixmedins_poolarea"`
  8121. // PsnCertType string `json:"psn_cert_type"`
  8122. // HifobPay float64 `json:"hifob_pay"`
  8123. // MedfeeSumamt float64 `json:"medfee_sumamt"`
  8124. // HifesPay float64 `json:"hifes_pay"`
  8125. // FundPaySumamt float64 `json:"fund_pay_sumamt"`
  8126. // OptTime string `json:"opt_time"`
  8127. // FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  8128. // SetlID string `json:"setl_id"`
  8129. // MafPay float64 `json:"maf_pay"`
  8130. // PsnName string `json:"psn_name"`
  8131. // InsuOptins interface{} `json:"insu_optins"`
  8132. // PrefFundPay interface{} `json:"pref_fund_pay"`
  8133. // ClrOptins string `json:"clr_optins"`
  8134. // PoolPropSelfpay float64 `json:"pool_prop_selfpay"`
  8135. // DiseName string `json:"dise_name"`
  8136. // LmtpricHospLv string `json:"lmtpric_hosp_lv"`
  8137. // Age float64 `json:"age"`
  8138. // DtrtCertType string `json:"dtrt_cert_type"`
  8139. // HospLv string `json:"hosp_lv"`
  8140. // } `json:"setlinfo"`
  8141. // Setldetail []struct {
  8142. // FundPayType string `json:"fund_pay_type"`
  8143. // FundPayamt float64 `json:"fund_payamt"`
  8144. // SetlProcInfo interface{} `json:"setl_proc_info"`
  8145. // CrtPaybLmtAmt interface{} `json:"crt_payb_lmt_amt"`
  8146. // InscpScpAmt interface{} `json:"inscp_scp_amt"`
  8147. // FundPayTypeName interface{} `json:"fund_pay_type_name"`
  8148. // PrefFundPay interface{} `json:"pref_fund_pay"`
  8149. // } `json:"setldetail"`
  8150. // } `json:"output"`
  8151. // Infcode int `json:"infcode"`
  8152. // WarnMsg interface{} `json:"warn_msg"`
  8153. // Cainfo interface{} `json:"cainfo"`
  8154. // ErrMsg interface{} `json:"err_msg"`
  8155. // RefmsgTime string `json:"refmsg_time"`
  8156. // Signtype interface{} `json:"signtype"`
  8157. // RespondTime string `json:"respond_time"`
  8158. // InfRefmsgid string `json:"inf_refmsgid"`
  8159. //}
  8160. type ResultEleven struct {
  8161. Cainfo string `json:"cainfo"`
  8162. ErrMsg string `json:"err_msg"`
  8163. InfRefmsgid string `json:"inf_refmsgid"`
  8164. Infcode int64 `json:"infcode"`
  8165. Output struct {
  8166. Setlinfo struct {
  8167. SetlTime string `json:"setl_time"`
  8168. CvlservPay float64 `json:"cvlserv_pay"`
  8169. Year string `json:"year"`
  8170. MedType string `json:"med_type"`
  8171. PsnPay float64 `json:"psn_pay"`
  8172. OpterID string `json:"opter_id"`
  8173. Begndate string `json:"begndate"`
  8174. FlxempeFlag string `json:"flxempe_flag"`
  8175. HifmiPay float64 `json:"hifmi_pay"`
  8176. PsnNo string `json:"psn_no"`
  8177. ActPayDedc float64 `json:"act_pay_dedc"`
  8178. MedinsSetlID interface{} `json:"medins_setl_id"`
  8179. AcctMulaidPay interface{} `json:"acct_mulaid_pay"`
  8180. ClrWay string `json:"clr_way"`
  8181. OthPay float64 `json:"oth_pay"`
  8182. Gend string `json:"gend"`
  8183. MdtrtID string `json:"mdtrt_id"`
  8184. AcctPay float64 `json:"acct_pay"`
  8185. InscpScpAmt float64 `json:"inscp_scp_amt"`
  8186. Insutype string `json:"insutype"`
  8187. Invono interface{} `json:"invono"`
  8188. Enddate string `json:"enddate"`
  8189. CashPayamt float64 `json:"cash_payamt"`
  8190. PsnType string `json:"psn_type"`
  8191. FixmedinsName string `json:"fixmedins_name"`
  8192. HifpPay float64 `json:"hifp_pay"`
  8193. NewFlag interface{} `json:"new_flag"`
  8194. OverlmtSelfpay float64 `json:"overlmt_selfpay"`
  8195. PreselfpayAmt float64 `json:"preselfpay_amt"`
  8196. PayLoc string `json:"pay_loc"`
  8197. ClrType string `json:"clr_type"`
  8198. RefdSetlFlag string `json:"refd_setl_flag"`
  8199. CvlservFlag string `json:"cvlserv_flag"`
  8200. EmpName string `json:"emp_name"`
  8201. Brdy string `json:"brdy"`
  8202. Naty string `json:"naty"`
  8203. Certno string `json:"certno"`
  8204. DiseCode string `json:"dise_code"`
  8205. FixmedinsCode string `json:"fixmedins_code"`
  8206. DedcHospLv string `json:"dedc_hosp_lv"`
  8207. OpterName string `json:"opter_name"`
  8208. Balc float64 `json:"balc"`
  8209. FixmedinsPoolarea string `json:"fixmedins_poolarea"`
  8210. PsnCertType string `json:"psn_cert_type"`
  8211. HifobPay float64 `json:"hifob_pay"`
  8212. MedfeeSumamt float64 `json:"medfee_sumamt"`
  8213. HifesPay float64 `json:"hifes_pay"`
  8214. FundPaySumamt float64 `json:"fund_pay_sumamt"`
  8215. OptTime string `json:"opt_time"`
  8216. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  8217. SetlID string `json:"setl_id"`
  8218. MafPay float64 `json:"maf_pay"`
  8219. PsnName string `json:"psn_name"`
  8220. InsuOptins interface{} `json:"insu_optins"`
  8221. PrefFundPay interface{} `json:"pref_fund_pay"`
  8222. ClrOptins string `json:"clr_optins"`
  8223. PoolPropSelfpay float64 `json:"pool_prop_selfpay"`
  8224. DiseName string `json:"dise_name"`
  8225. LmtpricHospLv string `json:"lmtpric_hosp_lv"`
  8226. Age float64 `json:"age"`
  8227. DtrtCertType string `json:"dtrt_cert_type"`
  8228. HospLv string `json:"hosp_lv"`
  8229. PsnCashPay float64
  8230. } `json:"setlinfo"`
  8231. } `json:"output"`
  8232. RefmsgTime string `json:"refmsg_time"`
  8233. RespondTime string `json:"respond_time"`
  8234. Signtype interface{} `json:"signtype"`
  8235. WarnMsg interface{} `json:"warn_msg"`
  8236. }
  8237. type ResultEleven10265 struct {
  8238. Cainfo string `json:"cainfo"`
  8239. ErrMsg string `json:"err_msg"`
  8240. InfRefmsgid string `json:"inf_refmsgid"`
  8241. Infcode string `json:"infcode"`
  8242. Output struct {
  8243. Setlinfo struct {
  8244. SetlTime string `json:"setl_time"`
  8245. CvlservPay float64 `json:"cvlserv_pay"`
  8246. Year string `json:"year"`
  8247. MedType string `json:"med_type"`
  8248. PsnPay float64 `json:"psn_pay"`
  8249. OpterID string `json:"opter_id"`
  8250. Begndate string `json:"begndate"`
  8251. FlxempeFlag string `json:"flxempe_flag"`
  8252. HifmiPay float64 `json:"hifmi_pay"`
  8253. PsnNo string `json:"psn_no"`
  8254. ActPayDedc float64 `json:"act_pay_dedc"`
  8255. MedinsSetlID interface{} `json:"medins_setl_id"`
  8256. AcctMulaidPay interface{} `json:"acct_mulaid_pay"`
  8257. ClrWay string `json:"clr_way"`
  8258. OthPay float64 `json:"oth_pay"`
  8259. Gend string `json:"gend"`
  8260. MdtrtID string `json:"mdtrt_id"`
  8261. AcctPay float64 `json:"acct_pay"`
  8262. InscpScpAmt float64 `json:"inscp_scp_amt"`
  8263. Insutype string `json:"insutype"`
  8264. Invono interface{} `json:"invono"`
  8265. Enddate string `json:"enddate"`
  8266. CashPayamt float64 `json:"cash_payamt"`
  8267. PsnType string `json:"psn_type"`
  8268. FixmedinsName string `json:"fixmedins_name"`
  8269. HifpPay float64 `json:"hifp_pay"`
  8270. NewFlag interface{} `json:"new_flag"`
  8271. OverlmtSelfpay float64 `json:"overlmt_selfpay"`
  8272. PreselfpayAmt float64 `json:"preselfpay_amt"`
  8273. PayLoc string `json:"pay_loc"`
  8274. ClrType string `json:"clr_type"`
  8275. RefdSetlFlag string `json:"refd_setl_flag"`
  8276. CvlservFlag string `json:"cvlserv_flag"`
  8277. EmpName string `json:"emp_name"`
  8278. Brdy string `json:"brdy"`
  8279. Naty string `json:"naty"`
  8280. Certno string `json:"certno"`
  8281. DiseCode string `json:"dise_code"`
  8282. FixmedinsCode string `json:"fixmedins_code"`
  8283. DedcHospLv string `json:"dedc_hosp_lv"`
  8284. OpterName string `json:"opter_name"`
  8285. Balc float64 `json:"balc"`
  8286. FixmedinsPoolarea string `json:"fixmedins_poolarea"`
  8287. PsnCertType string `json:"psn_cert_type"`
  8288. HifobPay float64 `json:"hifob_pay"`
  8289. MedfeeSumamt float64 `json:"medfee_sumamt"`
  8290. HifesPay float64 `json:"hifes_pay"`
  8291. FundPaySumamt float64 `json:"fund_pay_sumamt"`
  8292. OptTime string `json:"opt_time"`
  8293. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  8294. SetlID string `json:"setl_id"`
  8295. MafPay float64 `json:"maf_pay"`
  8296. PsnName string `json:"psn_name"`
  8297. InsuOptins interface{} `json:"insu_optins"`
  8298. PrefFundPay interface{} `json:"pref_fund_pay"`
  8299. ClrOptins string `json:"clr_optins"`
  8300. PoolPropSelfpay float64 `json:"pool_prop_selfpay"`
  8301. DiseName string `json:"dise_name"`
  8302. LmtpricHospLv string `json:"lmtpric_hosp_lv"`
  8303. Age float64 `json:"age"`
  8304. DtrtCertType string `json:"dtrt_cert_type"`
  8305. HospLv string `json:"hosp_lv"`
  8306. PsnCashPay float64
  8307. } `json:"setlinfo"`
  8308. } `json:"output"`
  8309. RefmsgTime string `json:"refmsg_time"`
  8310. RespondTime string `json:"respond_time"`
  8311. Signtype interface{} `json:"signtype"`
  8312. WarnMsg interface{} `json:"warn_msg"`
  8313. }
  8314. type ResultTwelve struct {
  8315. Cainfo string `json:"cainfo"`
  8316. ErrMsg string `json:"err_msg"`
  8317. InfRefmsgid string `json:"inf_refmsgid"`
  8318. Infcode int64 `json:"infcode"`
  8319. Output struct {
  8320. MdtrtId string `json:"mdtrt_id"`
  8321. ChrgBchno string `json:"chrg_bchno"`
  8322. PsnNo string `json:"psn_no"`
  8323. } `json:"output"`
  8324. RefmsgTime string `json:"refmsg_time"`
  8325. RespondTime string `json:"respond_time"`
  8326. Signtype interface{} `json:"signtype"`
  8327. WarnMsg interface{} `json:"warn_msg"`
  8328. }
  8329. type ResultThirteen struct {
  8330. ErrMsg string `json:"err_msg"`
  8331. InfRefmsgid string `json:"inf_refmsgid"`
  8332. Infcode int64 `json:"infcode"`
  8333. Output struct {
  8334. Result struct {
  8335. TrtDclaDetlSn string `json:"trt_dcla_detl_sn"`
  8336. } `json:"result"`
  8337. } `json:"output"`
  8338. RefmsgTime string `json:"refmsg_time"`
  8339. RespondTime string `json:"respond_time"`
  8340. Signtype interface{} `json:"signtype"`
  8341. WarnInfo interface{} `json:"warn_info"`
  8342. }
  8343. type ResultThirteen10265 struct {
  8344. ErrMsg string `json:"err_msg"`
  8345. InfRefmsgid string `json:"inf_refmsgid"`
  8346. Infcode string `json:"infcode"`
  8347. Output struct {
  8348. Result struct {
  8349. TrtDclaDetlSn string `json:"trt_dcla_detl_sn"`
  8350. } `json:"result"`
  8351. } `json:"output"`
  8352. RefmsgTime string `json:"refmsg_time"`
  8353. RespondTime string `json:"respond_time"`
  8354. Signtype interface{} `json:"signtype"`
  8355. WarnInfo interface{} `json:"warn_info"`
  8356. }
  8357. type ResultFourteen struct {
  8358. ErrMsg string `json:"err_msg"`
  8359. InfRefmsgid string `json:"inf_refmsgid"`
  8360. Infcode int64 `json:"infcode"`
  8361. Output struct {
  8362. } `json:"output"`
  8363. RefmsgTime string `json:"refmsg_time"`
  8364. RespondTime string `json:"respond_time"`
  8365. Signtype interface{} `json:"signtype"`
  8366. WarnInfo interface{} `json:"warn_info"`
  8367. }
  8368. type ResultFourteen10265 struct {
  8369. ErrMsg string `json:"err_msg"`
  8370. InfRefmsgid string `json:"inf_refmsgid"`
  8371. Infcode string `json:"infcode"`
  8372. Output struct {
  8373. } `json:"output"`
  8374. RefmsgTime string `json:"refmsg_time"`
  8375. RespondTime string `json:"respond_time"`
  8376. Signtype interface{} `json:"signtype"`
  8377. WarnInfo interface{} `json:"warn_info"`
  8378. }
  8379. type ResultSixteen struct {
  8380. Cainfo string `json:"cainfo"`
  8381. ErrMsg string `json:"err_msg"`
  8382. InfRefmsgid string `json:"inf_refmsgid"`
  8383. Infcode int64 `json:"infcode"`
  8384. Output struct {
  8385. Setldetail []interface{} `json:"setldetail"`
  8386. Setlinfo struct {
  8387. MdtrtID string `json:"mdtrt_id"`
  8388. SetlID string `json:"setl_id"`
  8389. ClrOptins string `json:"clr_optins"`
  8390. SetlTime string `json:"setl_time"`
  8391. MedfeeSumamt float64 `json:"medfee_sumamt"`
  8392. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  8393. OverlmtSelfpay float64 `json:"overlmt_selfpay"`
  8394. PreselfpayAmt float64 `json:"preselfpay_amt"`
  8395. InscpScpAmt float64 `json:"inscp_scp_amt"`
  8396. ActPayDedc float64 `json:"act_pay_dedc"`
  8397. HifpPay float64 `json:"hifp_pay"`
  8398. PoolPropSe float64 `json:"pool_prop_selfpay"`
  8399. Lfpay float64 `json:"selfpay"`
  8400. CvlservPay float64 `json:"cvlserv_pay"`
  8401. HifesPay float64 `json:"hifes_pay"`
  8402. HifmiPay float64 `json:"hifmi_pay"`
  8403. HifobPay float64 `json:"hifob_pay"`
  8404. MafPay float64 `json:"maf_pay"`
  8405. OthPay float64 `json:"oth_pay"`
  8406. FundPaySumamt float64 `json:"fund_pay_sumamt"`
  8407. PsnPartAmt float64 `json:"psn_part_amt"`
  8408. AcctPay float64 `json:"acct_pay"`
  8409. Balc float64 `json:"balc"`
  8410. AcctMulaidPay float64 `json:"acct_mulaid_pay"`
  8411. HospPartAmt float64 `json:"hosp_part_amt"`
  8412. MedinsSetlID string `json:"medins_setl_id"`
  8413. PdnCashPay string `json:"pdn_cash_pay"`
  8414. } `json:"setlinfo"`
  8415. } `json:"output"`
  8416. RefmsgTime string `json:"refmsg_time"`
  8417. RespondTime string `json:"respond_time"`
  8418. Signtype interface{} `json:"signtype"`
  8419. WarnMsg interface{} `json:"warn_msg"`
  8420. }
  8421. type ResultSixteen10265 struct {
  8422. Cainfo string `json:"cainfo"`
  8423. ErrMsg string `json:"err_msg"`
  8424. InfRefmsgid string `json:"inf_refmsgid"`
  8425. Infcode string `json:"infcode"`
  8426. Output struct {
  8427. Setldetail []interface{} `json:"setldetail"`
  8428. Setlinfo struct {
  8429. MdtrtID string `json:"mdtrt_id"`
  8430. SetlID string `json:"setl_id"`
  8431. ClrOptins string `json:"clr_optins"`
  8432. SetlTime string `json:"setl_time"`
  8433. MedfeeSumamt float64 `json:"medfee_sumamt"`
  8434. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  8435. OverlmtSelfpay float64 `json:"overlmt_selfpay"`
  8436. PreselfpayAmt float64 `json:"preselfpay_amt"`
  8437. InscpScpAmt float64 `json:"inscp_scp_amt"`
  8438. ActPayDedc float64 `json:"act_pay_dedc"`
  8439. HifpPay float64 `json:"hifp_pay"`
  8440. PoolPropSe float64 `json:"pool_prop_selfpay"`
  8441. Lfpay float64 `json:"selfpay"`
  8442. CvlservPay float64 `json:"cvlserv_pay"`
  8443. HifesPay float64 `json:"hifes_pay"`
  8444. HifmiPay float64 `json:"hifmi_pay"`
  8445. HifobPay float64 `json:"hifob_pay"`
  8446. MafPay float64 `json:"maf_pay"`
  8447. OthPay float64 `json:"oth_pay"`
  8448. FundPaySumamt float64 `json:"fund_pay_sumamt"`
  8449. PsnPartAmt float64 `json:"psn_part_amt"`
  8450. AcctPay float64 `json:"acct_pay"`
  8451. Balc float64 `json:"balc"`
  8452. AcctMulaidPay float64 `json:"acct_mulaid_pay"`
  8453. HospPartAmt float64 `json:"hosp_part_amt"`
  8454. MedinsSetlID string `json:"medins_setl_id"`
  8455. PdnCashPay string `json:"pdn_cash_pay"`
  8456. } `json:"setlinfo"`
  8457. } `json:"output"`
  8458. RefmsgTime string `json:"refmsg_time"`
  8459. RespondTime string `json:"respond_time"`
  8460. Signtype interface{} `json:"signtype"`
  8461. WarnMsg interface{} `json:"warn_msg"`
  8462. }
  8463. type ResultSeventeen struct {
  8464. ErrMsg string `json:"err_msg"`
  8465. InfRefmsgid string `json:"inf_refmsgid"`
  8466. Infcode int64 `json:"infcode"`
  8467. Output struct {
  8468. SetlListId string `json:"setl_list_id"`
  8469. } `json:"output"`
  8470. RefmsgTime string `json:"refmsg_time"`
  8471. RespondTime string `json:"respond_time"`
  8472. Signtype string `json:"signtype"`
  8473. WarnInfo string `json:"warn_info"`
  8474. }
  8475. type ResultSeventeenOther struct {
  8476. ErrMsg string `json:"err_msg"`
  8477. InfRefmsgid string `json:"inf_refmsgid"`
  8478. Infcode string `json:"infcode"`
  8479. Output struct {
  8480. SetlListId string `json:"setl_list_id"`
  8481. } `json:"output"`
  8482. RefmsgTime string `json:"refmsg_time"`
  8483. RespondTime string `json:"respond_time"`
  8484. Signtype string `json:"signtype"`
  8485. WarnInfo string `json:"warn_info"`
  8486. }
  8487. type Result90991 struct {
  8488. ErrMsg string `json:"err_msg"`
  8489. InfRefmsgid string `json:"inf_refmsgid"`
  8490. Infcode int64 `json:"infcode"`
  8491. Output struct {
  8492. Result struct {
  8493. PsnNo string `json:"psn_no"`
  8494. CardStat string `json:"card_stat"`
  8495. Certno string `json:"certno"`
  8496. PsnName string `json:"psn_name"`
  8497. CheckStat string `json:"check_stat"`
  8498. SscnoCheckStat string `json:"sscno_check_stat"`
  8499. } `json:"result"`
  8500. } `json:"output"`
  8501. RefmsgTime string `json:"refmsg_time"`
  8502. RespondTime string `json:"respond_time"`
  8503. Signtype interface{} `json:"signtype"`
  8504. WarnInfo interface{} `json:"warn_info"`
  8505. }
  8506. type Result90100 struct {
  8507. ErrMsg string `json:"err_msg"`
  8508. InfRefmsgid string `json:"inf_refmsgid"`
  8509. Infcode int64 `json:"infcode"`
  8510. Output struct {
  8511. PoolareaNo string `json:"poolarea_no"`
  8512. PoolareaNoName string `json:"poolarea_no_name"`
  8513. Insutype string `json:"insutype"`
  8514. InsutypeName string `json:"insutype_name"`
  8515. ClctType string `json:"clct_type"`
  8516. ClctTypeName string `json:"clct_type_name"`
  8517. ClctFlag string `json:"clct_flag"`
  8518. ClctFlagName string `json:"clct_flag_name"`
  8519. AccrymBegn string `json:"accrym_begn"`
  8520. AccrymEnd string `json:"accrym_end"`
  8521. ClctTime string `json:"clct_time"`
  8522. ClctstdCrtfRuleCodg string `json:"clctstd_crtf_rule_codg"`
  8523. } `json:"output"`
  8524. RefmsgTime string `json:"refmsg_time"`
  8525. RespondTime string `json:"respond_time"`
  8526. Signtype interface{} `json:"signtype"`
  8527. WarnInfo interface{} `json:"warn_info"`
  8528. }
  8529. type Custom struct {
  8530. DetItemFeeSumamt string
  8531. Cut string
  8532. FeedetlSn string
  8533. Price string
  8534. MedListCodg string
  8535. Type int64
  8536. AdviceId int64
  8537. ProjectId int64
  8538. ItemId int64
  8539. }
  8540. type Result5301 struct {
  8541. ErrMsg string `json:"err_msg"`
  8542. InfRefmsgid string `json:"inf_refmsgid"`
  8543. Infcode int64 `json:"infcode"`
  8544. Output struct {
  8545. Result []struct {
  8546. OpspDiseCode string `json:"opsp_dise_code"`
  8547. OpspDiseName string `json:"opsp_dise_name"`
  8548. Begndate string `json:"begndate"`
  8549. Enddate string `json:"enddate"`
  8550. } `json:"feedetail"`
  8551. } `json:"output"`
  8552. RefmsgTime string `json:"refmsg_time"`
  8553. RespondTime string `json:"respond_time"`
  8554. Signtype interface{} `json:"signtype"`
  8555. WarnInfo interface{} `json:"warn_info"`
  8556. }
  8557. type Result5301For10265 struct {
  8558. ErrMsg string `json:"err_msg"`
  8559. InfRefmsgid string `json:"inf_refmsgid"`
  8560. Infcode string `json:"infcode"`
  8561. Output struct {
  8562. Result []struct {
  8563. OpspDiseCode string `json:"opsp_dise_code"`
  8564. OpspDiseName string `json:"opsp_dise_name"`
  8565. Begndate string `json:"begndate"`
  8566. Enddate string `json:"enddate"`
  8567. } `json:"feedetail"`
  8568. } `json:"output"`
  8569. RefmsgTime string `json:"refmsg_time"`
  8570. RespondTime string `json:"respond_time"`
  8571. Signtype interface{} `json:"signtype"`
  8572. WarnInfo interface{} `json:"warn_info"`
  8573. }
  8574. //获取个人信息----挂号-----上传就诊信息
  8575. func (c *HisApiController) GetRegisterInfo() {
  8576. id, _ := c.GetInt64("id")
  8577. record_time := c.GetString("record_time")
  8578. settlementValue, _ := c.GetInt64("settlement_value")
  8579. medical_insurance_card := c.GetString("medical_insurance_card")
  8580. name := c.GetString("name")
  8581. id_card_type, _ := c.GetInt64("id_card_type")
  8582. certificates, _ := c.GetInt64("certificates")
  8583. medical_care, _ := c.GetInt64("medical_care")
  8584. birthday := c.GetString("birthday")
  8585. id_card := c.GetString("id_card")
  8586. register_type, _ := c.GetInt64("register")
  8587. doctor, _ := c.GetInt64("doctor")
  8588. department, _ := c.GetInt64("department")
  8589. gender, _ := c.GetInt64("sex")
  8590. registration_fee, _ := c.GetFloat("registration_fee")
  8591. medical_expenses, _ := c.GetFloat("medical_expenses")
  8592. social_type, _ := c.GetInt64("social_type")
  8593. admin_user_id, _ := c.GetInt64("admin_user_id")
  8594. insuplc_admdvs := c.GetString("insuplc_admdvs")
  8595. mdtrt_type := c.GetString("mdtrt_type")
  8596. timeLayout := "2006-01-02"
  8597. loc, _ := time.LoadLocation("Local")
  8598. birthdays, _ := time.ParseInLocation(timeLayout+" 15:04:05", birthday+" 00:00:00", loc)
  8599. birthUnix := birthdays.Unix()
  8600. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  8601. if err != nil {
  8602. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  8603. return
  8604. }
  8605. recordDateTime := theTime.Unix()
  8606. adminInfo := c.GetAdminUserInfo()
  8607. var patient service.Patients
  8608. if id == 0 {
  8609. patient, _ = service.GetPatientByIDCard(id_card, adminInfo.CurrentOrgId)
  8610. } else {
  8611. patient, _ = service.GetPatientByIDTwo(adminInfo.CurrentOrgId, id)
  8612. }
  8613. patientPrescription, _ := service.FindPatientPrescriptionInfo(adminInfo.CurrentOrgId, id, recordDateTime)
  8614. if patientPrescription.ID == 0 {
  8615. patientPrescription, _ = service.FindLastPatientPrescriptionInfo(adminInfo.CurrentOrgId, id, recordDateTime)
  8616. }
  8617. miConfig, _ := service.FindMedicalInsuranceInfo(adminInfo.CurrentOrgId)
  8618. if patient.ID == 0 {
  8619. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodePatientNoExist)
  8620. return
  8621. }
  8622. if len(patient.IdCardNo) == 0 {
  8623. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeIDCartNo)
  8624. return
  8625. }
  8626. config, _ := service.GetMedicalInsuranceConfig(adminInfo.CurrentOrgId)
  8627. roles, _ := service.GetAdminUserInfoByID(adminInfo.CurrentOrgId, admin_user_id)
  8628. doctor_info, _ := service.GetAdminUserInfoByID(adminInfo.CurrentOrgId, doctor)
  8629. //就诊结算未完成,不能进行二次挂号
  8630. his, _ := service.GetHisPatientInfoTwo(adminInfo.CurrentOrgId, patient.ID, recordDateTime)
  8631. if len(his) >= 1 {
  8632. order, _ := service.GetNewHisOrderTwo(adminInfo.CurrentOrgId, his[len(his)-1].Number, his[len(his)-1].PatientId, recordDateTime)
  8633. if len(his) >= 1 && order.ID == 0 {
  8634. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisPatientParamWrong)
  8635. return
  8636. }
  8637. }
  8638. //var register_log string
  8639. if config.IsOpen == 1 {
  8640. var res ResultTwo
  8641. var res10265 ResultTwo10265
  8642. var PsnNo string
  8643. var PsnCertType string
  8644. var Certno string
  8645. var PsnName string
  8646. var Gend string
  8647. var Naty string
  8648. var Brdy string
  8649. var Age float64
  8650. var infoStr string
  8651. var idetinfoStr string
  8652. var infocode int64
  8653. var verify_number string
  8654. fmt.Println(verify_number)
  8655. if miConfig.MdtrtareaAdmvs == "421300" {
  8656. psn_info, _ := service.GetPsnByPatientId(id)
  8657. PsnNo = psn_info.PsnNo
  8658. PsnCertType = psn_info.PsnCertType
  8659. Certno = psn_info.Certno
  8660. PsnName = psn_info.PsnName
  8661. Gend = psn_info.Gend
  8662. Naty = psn_info.Naty
  8663. Brdy = psn_info.Brdy
  8664. Age = psn_info.Age
  8665. infoStr = psn_info.Insuinfo
  8666. idetinfoStr = psn_info.Idetinfo
  8667. infocode = 0
  8668. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  8669. psn_info, _ := service.GetPsnByPatientId(id)
  8670. PsnNo = psn_info.PsnNo
  8671. PsnCertType = psn_info.PsnCertType
  8672. Certno = psn_info.Certno
  8673. PsnName = psn_info.PsnName
  8674. Gend = psn_info.Gend
  8675. Naty = psn_info.Naty
  8676. Brdy = psn_info.Brdy
  8677. Age = psn_info.Age
  8678. infoStr = psn_info.Insuinfo
  8679. idetinfoStr = psn_info.Idetinfo
  8680. infocode = 0
  8681. verify_number = psn_info.VerifyNumber
  8682. } else if miConfig.MdtrtareaAdmvs == "350500" {
  8683. if id_card_type == 1 {
  8684. psn_info, _ := service.GetPsnByPatientId(id)
  8685. PsnNo = psn_info.PsnNo
  8686. PsnCertType = psn_info.PsnCertType
  8687. Certno = psn_info.Certno
  8688. PsnName = psn_info.PsnName
  8689. Gend = psn_info.Gend
  8690. Naty = psn_info.Naty
  8691. Brdy = psn_info.Brdy
  8692. Age = psn_info.Age
  8693. infoStr = psn_info.Insuinfo
  8694. idetinfoStr = psn_info.Idetinfo
  8695. infocode = 0
  8696. verify_number = psn_info.VerifyNumber
  8697. } else if id_card_type == 2 {
  8698. 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)
  8699. fmt.Println(errMsgLog)
  8700. saveLog(result, requestLog, "1101", "人员基本信息获取")
  8701. if err := json.Unmarshal([]byte(result), &res); err != nil {
  8702. utils.ErrorLog("解析失败:%v", err)
  8703. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8704. return
  8705. }
  8706. PsnNo = res.Output.Baseinfo.PsnNo
  8707. PsnCertType = res.Output.Baseinfo.PsnCertType
  8708. Certno = res.Output.Baseinfo.Certno
  8709. PsnName = res.Output.Baseinfo.PsnName
  8710. Gend = res.Output.Baseinfo.Gend
  8711. Naty = res.Output.Baseinfo.Naty
  8712. Brdy = res.Output.Baseinfo.Brdy
  8713. Age = res.Output.Baseinfo.Age
  8714. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  8715. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  8716. infoStr = string(Iinfos)
  8717. idetinfoStr = string(Idetinfos)
  8718. infocode = res.Infcode
  8719. }
  8720. } else if miConfig.MdtrtareaAdmvs == "360399" {
  8721. if id_card_type == 1 {
  8722. psn_info, _ := service.GetPsnByPatientId(id)
  8723. PsnNo = psn_info.PsnNo
  8724. PsnCertType = psn_info.PsnCertType
  8725. Certno = psn_info.Certno
  8726. PsnName = psn_info.PsnName
  8727. Gend = psn_info.Gend
  8728. Naty = psn_info.Naty
  8729. Brdy = psn_info.Brdy
  8730. Age = psn_info.Age
  8731. infoStr = psn_info.Insuinfo
  8732. idetinfoStr = psn_info.Idetinfo
  8733. infocode = 0
  8734. verify_number = psn_info.VerifyNumber
  8735. } else if id_card_type == 2 {
  8736. 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, "")
  8737. saveLog(result, requestLog, "1101", "人员基本信息获取")
  8738. if err := json.Unmarshal([]byte(result), &res); err != nil {
  8739. utils.ErrorLog("解析失败:%v", err)
  8740. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8741. return
  8742. }
  8743. PsnNo = res.Output.Baseinfo.PsnNo
  8744. PsnCertType = res.Output.Baseinfo.PsnCertType
  8745. Certno = res.Output.Baseinfo.Certno
  8746. PsnName = res.Output.Baseinfo.PsnName
  8747. Gend = res.Output.Baseinfo.Gend
  8748. Naty = res.Output.Baseinfo.Naty
  8749. Brdy = res.Output.Baseinfo.Brdy
  8750. Age = res.Output.Baseinfo.Age
  8751. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  8752. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  8753. infoStr = string(Iinfos)
  8754. idetinfoStr = string(Idetinfos)
  8755. infocode = res.Infcode
  8756. }
  8757. } else if miConfig.MdtrtareaAdmvs == "430800" {
  8758. if id_card_type == 1 {
  8759. psn_info, _ := service.GetPsnByPatientId(id)
  8760. PsnNo = psn_info.PsnNo
  8761. PsnCertType = psn_info.PsnCertType
  8762. Certno = psn_info.Certno
  8763. PsnName = psn_info.PsnName
  8764. Gend = psn_info.Gend
  8765. Naty = psn_info.Naty
  8766. Brdy = psn_info.Brdy
  8767. Age = psn_info.Age
  8768. infoStr = psn_info.Insuinfo
  8769. idetinfoStr = psn_info.Idetinfo
  8770. infocode = 0
  8771. verify_number = psn_info.VerifyNumber
  8772. } else if id_card_type == 2 {
  8773. 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)
  8774. saveLog(result, requestLog, "1101", "人员基本信息获取")
  8775. if err := json.Unmarshal([]byte(result), &res); err != nil {
  8776. utils.ErrorLog("解析失败:%v", err)
  8777. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8778. return
  8779. }
  8780. PsnNo = res.Output.Baseinfo.PsnNo
  8781. PsnCertType = res.Output.Baseinfo.PsnCertType
  8782. Certno = res.Output.Baseinfo.Certno
  8783. PsnName = res.Output.Baseinfo.PsnName
  8784. Gend = res.Output.Baseinfo.Gend
  8785. Naty = res.Output.Baseinfo.Naty
  8786. Brdy = res.Output.Baseinfo.Brdy
  8787. Age = res.Output.Baseinfo.Age
  8788. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  8789. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  8790. infoStr = string(Iinfos)
  8791. idetinfoStr = string(Idetinfos)
  8792. infocode = res.Infcode
  8793. } else if id_card_type == 4 {
  8794. psn_info, _ := service.GetPsnByPatientId(id)
  8795. PsnNo = psn_info.PsnNo
  8796. PsnCertType = psn_info.PsnCertType
  8797. Certno = psn_info.Certno
  8798. PsnName = psn_info.PsnName
  8799. Gend = psn_info.Gend
  8800. Naty = psn_info.Naty
  8801. Brdy = psn_info.Brdy
  8802. Age = psn_info.Age
  8803. infoStr = psn_info.Insuinfo
  8804. idetinfoStr = psn_info.Idetinfo
  8805. infocode = 0
  8806. verify_number = psn_info.VerifyNumber
  8807. }
  8808. } else if miConfig.MdtrtareaAdmvs == "131023" {
  8809. var result string
  8810. var requestLog string
  8811. 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), "")
  8812. if id_card_type == 4 {
  8813. psn_info, _ := service.GetPsnByPatientId(id)
  8814. PsnNo = psn_info.PsnNo
  8815. PsnCertType = psn_info.PsnCertType
  8816. Certno = psn_info.Certno
  8817. PsnName = psn_info.PsnName
  8818. Gend = psn_info.Gend
  8819. Naty = psn_info.Naty
  8820. Brdy = psn_info.Brdy
  8821. Age = psn_info.Age
  8822. infoStr = psn_info.Insuinfo
  8823. idetinfoStr = psn_info.Idetinfo
  8824. infocode = 0
  8825. verify_number = psn_info.VerifyNumber
  8826. } else {
  8827. saveLog(result, requestLog, "1101", "人员基本信息获取")
  8828. if miConfig.Code == "H15049901371" {
  8829. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  8830. utils.ErrorLog("解析失败:%v", err)
  8831. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8832. return
  8833. }
  8834. res.ErrMsg = res10265.ErrMsg
  8835. res.Output = res10265.Output
  8836. res.InfRefmsgid = res10265.InfRefmsgid
  8837. } else {
  8838. if err := json.Unmarshal([]byte(result), &res); err != nil {
  8839. utils.ErrorLog("解析失败:%v", err)
  8840. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8841. return
  8842. }
  8843. }
  8844. PsnNo = res.Output.Baseinfo.PsnNo
  8845. PsnCertType = res.Output.Baseinfo.PsnCertType
  8846. Certno = res.Output.Baseinfo.Certno
  8847. PsnName = res.Output.Baseinfo.PsnName
  8848. Gend = res.Output.Baseinfo.Gend
  8849. Naty = res.Output.Baseinfo.Naty
  8850. Brdy = res.Output.Baseinfo.Brdy
  8851. Age = res.Output.Baseinfo.Age
  8852. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  8853. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  8854. infoStr = string(Iinfos)
  8855. idetinfoStr = string(Idetinfos)
  8856. if miConfig.Code == "H15049901371" {
  8857. infocode, _ = strconv.ParseInt(res10265.Infcode, 10, 64)
  8858. } else {
  8859. infocode = res.Infcode
  8860. }
  8861. }
  8862. } else {
  8863. var result string
  8864. var requestLog string
  8865. //if miConfig.UserOrgId == 10138 {
  8866. if id_card_type != 4 || id_card_type != 1 {
  8867. var insa string
  8868. if len(patient.InsuplcAdmdvs) > 0 {
  8869. insa = patient.InsuplcAdmdvs
  8870. } else {
  8871. insa = miConfig.InsuplcAdmdvs
  8872. }
  8873. //psn_info, _ := service.GetPsnByPatientId(id)
  8874. //result, requestLog = service.Gdyb1101ForEleCert(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, psn_info.VerifyNumber)
  8875. 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)
  8876. }
  8877. //}
  8878. //else {
  8879. // var insa string
  8880. // if len(patient.InsuplcAdmdvs) > 0 {
  8881. // insa = patient.InsuplcAdmdvs
  8882. // } else {
  8883. // insa = miConfig.InsuplcAdmdvs
  8884. // }
  8885. // 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)
  8886. //}
  8887. if id_card_type == 4 || id_card_type == 1 {
  8888. psn_info, _ := service.GetPsnByPatientId(id)
  8889. PsnNo = psn_info.PsnNo
  8890. PsnCertType = psn_info.PsnCertType
  8891. Certno = psn_info.Certno
  8892. PsnName = psn_info.PsnName
  8893. Gend = psn_info.Gend
  8894. Naty = psn_info.Naty
  8895. Brdy = psn_info.Brdy
  8896. Age = psn_info.Age
  8897. infoStr = psn_info.Insuinfo
  8898. idetinfoStr = psn_info.Idetinfo
  8899. infocode = 0
  8900. verify_number = psn_info.VerifyNumber
  8901. } else {
  8902. saveLog(result, requestLog, "1101", "人员基本信息获取")
  8903. if miConfig.Code == "H15049901371" {
  8904. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  8905. utils.ErrorLog("解析失败:%v", err)
  8906. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8907. return
  8908. }
  8909. res.ErrMsg = res10265.ErrMsg
  8910. res.Output = res10265.Output
  8911. res.InfRefmsgid = res10265.InfRefmsgid
  8912. } else {
  8913. if err := json.Unmarshal([]byte(result), &res); err != nil {
  8914. utils.ErrorLog("解析失败:%v", err)
  8915. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8916. return
  8917. }
  8918. }
  8919. PsnNo = res.Output.Baseinfo.PsnNo
  8920. PsnCertType = res.Output.Baseinfo.PsnCertType
  8921. Certno = res.Output.Baseinfo.Certno
  8922. PsnName = res.Output.Baseinfo.PsnName
  8923. Gend = res.Output.Baseinfo.Gend
  8924. Naty = res.Output.Baseinfo.Naty
  8925. Brdy = res.Output.Baseinfo.Brdy
  8926. Age = res.Output.Baseinfo.Age
  8927. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  8928. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  8929. infoStr = string(Iinfos)
  8930. idetinfoStr = string(Idetinfos)
  8931. if miConfig.Code == "H15049901371" {
  8932. infocode, _ = strconv.ParseInt(res10265.Infcode, 10, 64)
  8933. } else {
  8934. infocode = res.Infcode
  8935. }
  8936. }
  8937. }
  8938. if infocode == 0 {
  8939. his := models.VMHisPatient{
  8940. Name: name,
  8941. Gender: gender,
  8942. Birthday: birthUnix,
  8943. MedicalTreatmentType: medical_care,
  8944. IdType: certificates,
  8945. IdCardNo: id_card,
  8946. BalanceAccountsType: settlementValue,
  8947. SocialType: social_type,
  8948. MedicalInsuranceNumber: medical_insurance_card,
  8949. RegisterType: register_type,
  8950. RegisterCost: registration_fee,
  8951. TreatmentCost: medical_expenses,
  8952. Status: 1,
  8953. Ctime: time.Now().Unix(),
  8954. Mtime: time.Now().Unix(),
  8955. PsnNo: PsnNo,
  8956. PsnCertType: PsnCertType,
  8957. Certno: Certno,
  8958. PsnName: PsnName,
  8959. Gend: Gend,
  8960. Naty: Naty,
  8961. Brdy: Brdy,
  8962. Age: Age,
  8963. Iinfo: infoStr,
  8964. Idetinfo: idetinfoStr,
  8965. PatientId: patient.ID,
  8966. RecordDate: theTime.Unix(),
  8967. UserOrgId: adminInfo.CurrentOrgId,
  8968. AdminUserId: admin_user_id,
  8969. IsReturn: 1,
  8970. IdCardType: id_card_type,
  8971. Doctor: doctor,
  8972. Departments: department,
  8973. MdtrtGrpType: mdtrt_type,
  8974. }
  8975. timestamp := time.Now().Unix()
  8976. tempTime := time.Unix(timestamp, 0)
  8977. timeFormat := tempTime.Format("20060102150405")
  8978. chrgBchno := rand.Intn(100000) + 10000
  8979. ipt_otp_no := timeFormat + strconv.FormatInt(int64(chrgBchno), 10) + strconv.FormatInt(his.PatientId, 10)
  8980. his.Number = ipt_otp_no
  8981. //count, _ := service.FindHisRegisterRecord(theTime.Unix(), patient.ID, adminInfo.CurrentOrgId)
  8982. department, _ := service.GetDepartMentDetail(department)
  8983. //doctor_id := strconv.FormatInt(patientPrescription., 10)
  8984. IdCardNo := ""
  8985. if id_card_type == 1 {
  8986. // IdCardNo = medical_insurance_card
  8987. IdCardNo = patient.IdCardNo
  8988. } else {
  8989. IdCardNo = patient.IdCardNo
  8990. }
  8991. var rf []*ResultFive
  8992. json.Unmarshal([]byte(his.Iinfo), &rf)
  8993. var insutypes []*ResultFive
  8994. var insutype string
  8995. var insuplc_admdvs_temp string
  8996. var is390 int = 0
  8997. var is310 int = 0
  8998. for _, item := range rf {
  8999. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  9000. insutypes = append(insutypes, item)
  9001. }
  9002. }
  9003. if len(insutypes) == 1 {
  9004. insutype = insutypes[0].Insutype
  9005. insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  9006. } else {
  9007. for _, i := range insutypes {
  9008. if i.Insutype == "390" {
  9009. is390 = 1
  9010. }
  9011. if i.Insutype == "310" {
  9012. is310 = 1
  9013. }
  9014. }
  9015. }
  9016. if is390 == 1 {
  9017. insutype = "390"
  9018. }
  9019. if is310 == 1 {
  9020. insutype = "310"
  9021. }
  9022. fmt.Println(social_type)
  9023. if social_type > 0 {
  9024. insutype = strconv.FormatInt(social_type, 10)
  9025. }
  9026. var infocode int64
  9027. var resThree ResultThree
  9028. var resThree10265 ResultThree10265
  9029. if len(insuplc_admdvs) == 0 {
  9030. insuplc_admdvs_temp = miConfig.InsuplcAdmdvs
  9031. } else {
  9032. insuplc_admdvs_temp = insuplc_admdvs
  9033. }
  9034. if miConfig.MdtrtareaAdmvs == "421300" {
  9035. hb_doctor_info, _ := service.GetAdminUserInfoByID(adminInfo.CurrentOrgId, patientPrescription.DoctorId)
  9036. api := "http://192.168.124.4:9532/" + "hbyb/2201?psn_no=" + PsnNo + "&insutype=" + insutype + "&cert_no=" + Certno + "&ipt_otp_no=" + ipt_otp_no +
  9037. "&org_name=" + miConfig.OrgName + "&doctor=" + hb_doctor_info.UserName + "&fixmedins_code=" + miConfig.Code +
  9038. "&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
  9039. resp, requestErr := http.Get(api)
  9040. if requestErr != nil {
  9041. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9042. return
  9043. }
  9044. body, ioErr := ioutil.ReadAll(resp.Body)
  9045. if ioErr != nil {
  9046. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  9047. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9048. return
  9049. }
  9050. var respJSON map[string]interface{}
  9051. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  9052. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  9053. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9054. return
  9055. }
  9056. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  9057. result, _ := json.Marshal(respJSON)
  9058. if err := json.Unmarshal([]byte(result), &resThree); err != nil {
  9059. utils.ErrorLog("解析失败:%v", err)
  9060. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9061. return
  9062. }
  9063. infocode = resThree.Infcode
  9064. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  9065. psn_info, _ := service.GetPsnByPatientId(id)
  9066. his.PsnNo = psn_info.PsnNo
  9067. psn_info.VerifyNumber = strings.Replace(psn_info.VerifyNumber, "+", "%2B", -1)
  9068. var cert_no string
  9069. if id_card_type == 3 {
  9070. psn_info.VerifyNumber = IdCardNo + "|" + psn_info.VerifyNumber
  9071. cert_no = IdCardNo
  9072. } else if id_card_type == 4 {
  9073. cert_no = IdCardNo
  9074. psn_info.VerifyNumber = psn_info.VerifyNumber
  9075. } else {
  9076. bas := strings.Split(psn_info.CardInfo, "|")
  9077. cert_no = bas[2]
  9078. }
  9079. var hisPrescription []*models.HisPrescription
  9080. for _, item := range rf {
  9081. if item.Insutype == insutype {
  9082. //insuplc_admdvs = item.InsuplcAdmdvs
  9083. his.InsuplcAdmdvs = insuplc_admdvs
  9084. }
  9085. }
  9086. his.Insutype = insutype
  9087. res3101 := Check3101ForOne(c, patient.ID, his, admin_user_id, "1", record_time, hisPrescription)
  9088. fmt.Println(res3101)
  9089. fmt.Println(res3101.Infcode)
  9090. if res3101.Infcode == "0" {
  9091. fmt.Println("33333333")
  9092. if len(res3101.Output.Result) > 0 {
  9093. fmt.Println("222222")
  9094. for _, item := range res3101.Output.Result {
  9095. if len(res3101.ErrMsg) == 0 {
  9096. res3101.ErrMsg = item.VolaCont
  9097. } else {
  9098. res3101.ErrMsg = res3101.ErrMsg + "\n" + item.VolaCont
  9099. }
  9100. }
  9101. c.ServeSuccessJSON(map[string]interface{}{
  9102. "failed_code": -10,
  9103. "msg": res3101.ErrMsg,
  9104. })
  9105. return
  9106. } else {
  9107. fmt.Println("11111")
  9108. var api string
  9109. if miConfig.MdtrtareaAdmvs == "320921" {
  9110. api = "http://192.168.2.3:9532/" + "jsyb/2201?psn_no=" + PsnNo + "&insutype=" + insutype + "&cert_no=" + cert_no + "&ipt_otp_no=" + ipt_otp_no +
  9111. "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&doctor_name=" + doctor_info.UserName + "&fixmedins_code=" + miConfig.Code +
  9112. "&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
  9113. } else {
  9114. api = "http://192.168.5.251:9532/" + "jsyb/2201?psn_no=" + PsnNo + "&insutype=" + insutype + "&cert_no=" + cert_no + "&ipt_otp_no=" + ipt_otp_no +
  9115. "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&doctor_name=" + doctor_info.UserName + "&fixmedins_code=" + miConfig.Code +
  9116. "&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
  9117. }
  9118. resp, requestErr := http.Get(api)
  9119. if requestErr != nil {
  9120. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9121. return
  9122. }
  9123. body, ioErr := ioutil.ReadAll(resp.Body)
  9124. if ioErr != nil {
  9125. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  9126. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9127. return
  9128. }
  9129. var respJSON map[string]interface{}
  9130. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  9131. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  9132. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9133. return
  9134. }
  9135. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  9136. result, _ := json.Marshal(respJSON)
  9137. if err := json.Unmarshal([]byte(result), &resThree10265); err != nil {
  9138. utils.ErrorLog("解析失败:%v", err)
  9139. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9140. return
  9141. }
  9142. resThree.ErrMsg = resThree10265.ErrMsg
  9143. resThree.Output = resThree10265.Output
  9144. resThree.InfRefmsgid = resThree10265.InfRefmsgid
  9145. infocode, _ = strconv.ParseInt(resThree10265.Infcode, 10, 64)
  9146. }
  9147. } else if res3101.Infcode != "0" {
  9148. c.ServeSuccessJSON(map[string]interface{}{
  9149. "failed_code": -10,
  9150. "msg": res3101.ErrMsg,
  9151. })
  9152. return
  9153. }
  9154. } else if miConfig.MdtrtareaAdmvs == "350500" {
  9155. psn_info, _ := service.GetPsnByPatientId(id)
  9156. var cert_no string
  9157. if id_card_type == 1 {
  9158. cert_no = strings.Split(psn_info.CardInfo, "|")[0]
  9159. insuplc_admdvs_temp = psn_info.InsuplcAdmdvs
  9160. } else if id_card_type == 4 {
  9161. cert_no = psn_info.VerifyNumber
  9162. insuplc_admdvs_temp = psn_info.InsuplcAdmdvs
  9163. } else {
  9164. insuplc_admdvs_temp = psn_info.InsuplcAdmdvs
  9165. cert_no = psn_info.VerifyNumber
  9166. }
  9167. 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)
  9168. saveLog(result, requestLog, "2201", "挂号")
  9169. if miConfig.Code == "H15049901371" {
  9170. if err := json.Unmarshal([]byte(result), &resThree10265); err != nil {
  9171. utils.ErrorLog("解析失败:%v", err)
  9172. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9173. return
  9174. }
  9175. resThree.ErrMsg = resThree10265.ErrMsg
  9176. resThree.Output = resThree10265.Output
  9177. resThree.InfRefmsgid = resThree10265.InfRefmsgid
  9178. } else {
  9179. if err := json.Unmarshal([]byte(result), &resThree); err != nil {
  9180. utils.ErrorLog("解析失败:%v", err)
  9181. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9182. return
  9183. }
  9184. }
  9185. infocode, _ = strconv.ParseInt(resThree10265.Infcode, 10, 64)
  9186. } else if miConfig.MdtrtareaAdmvs == "360399" { //江西萍乡
  9187. psn_info, _ := service.GetPsnByPatientId(id)
  9188. var result string
  9189. var requestLog string
  9190. if id_card_type == 1 {
  9191. bas := strings.Split(psn_info.CardInfo, "|")
  9192. basNumber := bas[2]
  9193. card_sn := bas[3]
  9194. 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)
  9195. saveLog(result, requestLog, "2201A", "挂号")
  9196. } else if id_card_type == 2 {
  9197. 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, "", "")
  9198. saveLog(result, requestLog, "2201A", "挂号")
  9199. } else {
  9200. 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, "", "")
  9201. saveLog(result, requestLog, "2201A", "挂号")
  9202. }
  9203. if err := json.Unmarshal([]byte(result), &resThree); err != nil {
  9204. utils.ErrorLog("解析失败:%v", err)
  9205. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9206. return
  9207. }
  9208. infocode = resThree.Infcode
  9209. } else if miConfig.MdtrtareaAdmvs == "430800" { //江西萍乡
  9210. psn_info, _ := service.GetPsnByPatientId(id)
  9211. var result string
  9212. var requestLog string
  9213. if id_card_type == 1 {
  9214. bas := strings.Split(psn_info.CardInfo, "|")
  9215. basNumber := bas[2]
  9216. card_sn := bas[3]
  9217. 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)
  9218. saveLog(result, requestLog, "2201A", "挂号")
  9219. } else if id_card_type == 2 {
  9220. 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, "", "")
  9221. saveLog(result, requestLog, "2201A", "挂号")
  9222. } else {
  9223. 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, "", "")
  9224. saveLog(result, requestLog, "2201A", "挂号")
  9225. }
  9226. if err := json.Unmarshal([]byte(result), &resThree); err != nil {
  9227. utils.ErrorLog("解析失败:%v", err)
  9228. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9229. return
  9230. }
  9231. infocode = resThree.Infcode
  9232. } else if miConfig.MdtrtareaAdmvs == "131023" {
  9233. psn_info, _ := service.GetPsnByPatientId(id)
  9234. 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)
  9235. saveLog(result, requestLog, "2201A", "挂号")
  9236. if miConfig.Code == "H15049901371" {
  9237. if err := json.Unmarshal([]byte(result), &resThree10265); err != nil {
  9238. utils.ErrorLog("解析失败:%v", err)
  9239. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9240. return
  9241. }
  9242. resThree.ErrMsg = resThree10265.ErrMsg
  9243. resThree.Output = resThree10265.Output
  9244. resThree.InfRefmsgid = resThree10265.InfRefmsgid
  9245. } else {
  9246. if err := json.Unmarshal([]byte(result), &resThree); err != nil {
  9247. utils.ErrorLog("解析失败:%v", err)
  9248. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9249. return
  9250. }
  9251. }
  9252. if miConfig.Code == "H15049901371" {
  9253. infocode, _ = strconv.ParseInt(resThree10265.Infcode, 10, 64)
  9254. } else {
  9255. infocode = resThree.Infcode
  9256. }
  9257. } else {
  9258. psn_info, _ := service.GetPsnByPatientId(id)
  9259. if id_card_type == 4 || id_card_type == 1 {
  9260. insuplc_admdvs_temp = psn_info.InsuplcAdmdvs
  9261. }
  9262. var rf []*ResultFive
  9263. json.Unmarshal([]byte(psn_info.Insuinfo), &rf)
  9264. var insutypes []*ResultFive
  9265. var insutype string
  9266. var is390 int = 0
  9267. var is310 int = 0
  9268. for _, item := range rf {
  9269. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  9270. insutypes = append(insutypes, item)
  9271. }
  9272. }
  9273. if len(insutypes) == 1 {
  9274. insutype = insutypes[0].Insutype
  9275. insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  9276. } else {
  9277. for _, i := range insutypes {
  9278. if i.Insutype == "390" {
  9279. is390 = 1
  9280. }
  9281. if i.Insutype == "310" {
  9282. is310 = 1
  9283. }
  9284. }
  9285. }
  9286. if is390 == 1 {
  9287. insutype = "390"
  9288. }
  9289. if is310 == 1 {
  9290. insutype = "310"
  9291. }
  9292. fmt.Println(len(insutypes))
  9293. if len(insutypes) == 0 {
  9294. for index, item := range rf {
  9295. if index == 0 {
  9296. insutype = item.Insutype
  9297. insuplc_admdvs = item.InsuplcAdmdvs
  9298. }
  9299. }
  9300. fmt.Println(insutype)
  9301. fmt.Println(insuplc_admdvs)
  9302. }
  9303. if social_type > 0 {
  9304. insutype = strconv.FormatInt(social_type, 10)
  9305. }
  9306. 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)
  9307. saveLog(result, requestLog, "2201A", "挂号")
  9308. if miConfig.Code == "H15049901371" {
  9309. if err := json.Unmarshal([]byte(result), &resThree10265); err != nil {
  9310. utils.ErrorLog("解析失败:%v", err)
  9311. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9312. return
  9313. }
  9314. resThree.ErrMsg = resThree10265.ErrMsg
  9315. resThree.Output = resThree10265.Output
  9316. resThree.InfRefmsgid = resThree10265.InfRefmsgid
  9317. } else {
  9318. if err := json.Unmarshal([]byte(result), &resThree); err != nil {
  9319. utils.ErrorLog("解析失败:%v", err)
  9320. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9321. return
  9322. }
  9323. }
  9324. if miConfig.Code == "H15049901371" {
  9325. infocode, _ = strconv.ParseInt(resThree10265.Infcode, 10, 64)
  9326. } else {
  9327. infocode = resThree.Infcode
  9328. }
  9329. }
  9330. if infocode != 0 {
  9331. adminUser := c.GetAdminUserInfo()
  9332. errlog := &models.HisOrderError{
  9333. UserOrgId: adminUser.CurrentOrgId,
  9334. Ctime: time.Now().Unix(),
  9335. Mtime: time.Now().Unix(),
  9336. ErrMsg: resThree.ErrMsg,
  9337. Status: 1,
  9338. PatientId: id,
  9339. RecordTime: recordDateTime,
  9340. Stage: 2,
  9341. }
  9342. service.CreateErrMsgLog(errlog)
  9343. c.ServeSuccessJSON(map[string]interface{}{
  9344. "failed_code": -10,
  9345. "msg": resThree.ErrMsg,
  9346. })
  9347. return
  9348. }
  9349. his.Number = resThree.Output.Data.MdtrtID
  9350. his.PsnNo = resThree.Output.Data.PsnNo
  9351. his.IptOtpNo = resThree.Output.Data.IptOtpNo
  9352. his.IdCardNo = patient.IdCardNo
  9353. his.PhoneNumber = patient.Phone
  9354. his.UserOrgId = adminInfo.CurrentOrgId
  9355. his.Insutype = insutype
  9356. his.Ctime = time.Now().Unix()
  9357. his.Mtime = time.Now().Unix()
  9358. his.InsuplcAdmdvs = insuplc_admdvs_temp
  9359. his.Status = 1
  9360. his.MdtrtGrpType = mdtrt_type
  9361. service.UpdateHisPatientStatus(&his)
  9362. service.UpdateHisPrescriptionHisID(his.ID, patient.ID, recordDateTime, adminInfo.CurrentOrgId)
  9363. c.ServeSuccessJSON(map[string]interface{}{
  9364. "his_info": his,
  9365. })
  9366. } else {
  9367. adminUser := c.GetAdminUserInfo()
  9368. errlog := &models.HisOrderError{
  9369. UserOrgId: adminUser.CurrentOrgId,
  9370. Ctime: time.Now().Unix(),
  9371. Mtime: time.Now().Unix(),
  9372. ErrMsg: res.ErrMsg,
  9373. Status: 1,
  9374. PatientId: id,
  9375. RecordTime: recordDateTime,
  9376. Stage: 1,
  9377. }
  9378. service.CreateErrMsgLog(errlog)
  9379. c.ServeSuccessJSON(map[string]interface{}{
  9380. "failed_code": -10,
  9381. "msg": res.ErrMsg,
  9382. })
  9383. return
  9384. //c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeGdybOneException)
  9385. }
  9386. }
  9387. }
  9388. func (c *HisApiController) GetUploadInfo() {
  9389. id, _ := c.GetInt64("id")
  9390. record_time := c.GetString("record_time")
  9391. his_patient_id, _ := c.GetInt64("his_patient_id")
  9392. order_id, _ := c.GetInt64("order_id")
  9393. pay_way, _ := c.GetInt64("pay_way")
  9394. pay_ways := c.GetString("pay_ways")
  9395. oth_desc := c.GetString("oth_desc")
  9396. pay_price, _ := c.GetFloat("pay_price")
  9397. pay_card_no := c.GetString("pay_card_no")
  9398. discount_price, _ := c.GetFloat("discount_price")
  9399. preferential_price, _ := c.GetFloat("preferential_price")
  9400. reality_price, _ := c.GetFloat("reality_price")
  9401. found_price, _ := c.GetFloat("found_price")
  9402. medical_insurance_price, _ := c.GetFloat("medical_insurance_price")
  9403. private_price, _ := c.GetFloat("private_price")
  9404. settle_accounts_type, _ := c.GetInt64("settle_accounts_type")
  9405. admin_user_id, _ := c.GetInt64("admin_user_id")
  9406. fapiao_code := c.GetString("fapiao_code")
  9407. fapiao_number := c.GetString("fapiao_number")
  9408. diagnosis_id := c.GetString("diagnosis")
  9409. sick_type, _ := c.GetInt64("sick_type")
  9410. reg_type, _ := c.GetInt64("p_type")
  9411. begin_time := c.GetString("begin_time")
  9412. acct_used_flag_num, _ := c.GetInt64("acct_used_flag")
  9413. cash_pay := c.GetString("cash_pay")
  9414. band_card_pay := c.GetString("band_card_pay")
  9415. wechat_pay := c.GetString("wechat_pay")
  9416. ali_pay := c.GetString("ali_pay")
  9417. jifen_pay := c.GetString("jifen_pay")
  9418. acct_used_flag := strconv.FormatInt(acct_used_flag_num, 10)
  9419. fmt.Println(acct_used_flag)
  9420. id_str := c.GetString("ids")
  9421. ids_arr := strings.Split(id_str, ",")
  9422. timeLayout := "2006-01-02"
  9423. loc, _ := time.LoadLocation("Local")
  9424. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  9425. if err != nil {
  9426. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  9427. return
  9428. }
  9429. recordDateTime := theTime.Unix()
  9430. adminUser := c.GetAdminUserInfo()
  9431. var tempOrder models.HisOrder
  9432. tempOrder, _ = service.GetHisOrderByID(order_id)
  9433. var prescriptions []*models.HisPrescription
  9434. var start_time int64
  9435. var end_time int64
  9436. //押金模块
  9437. dec_way := c.GetString("dec_way") //是否使用押金支付bool类型
  9438. tmp_decimal := c.GetString("tmp_decimal")
  9439. var decimal float64 //本次使用的押金
  9440. var errmsg error
  9441. if dec_way == "true" && tmp_decimal == "0" || dec_way == "true" && tmp_decimal == "" {
  9442. c.ServeFailJsonSend(enums.ErrorCodeParamWrong, "押金不能为0")
  9443. return
  9444. }
  9445. if len(tmp_decimal) > 0 {
  9446. if tmp_decimal[0] == 45 {
  9447. c.ServeFailJsonSend(enums.ErrorCodeParamWrong, "押金不能为负数")
  9448. return
  9449. }
  9450. }
  9451. tt, errs := strconv.ParseFloat(tmp_decimal, 64)
  9452. fmt.Println(errs)
  9453. decimal = tt
  9454. //if adminUser.CurrentOrgId == 10106{
  9455. // if len(fapiao_code) == 0{
  9456. // fapiao_code = "144072080589"
  9457. // }
  9458. // if len(fapiao_number) == 0{
  9459. // order, _ := service.GetLastHisOrder(adminUser.CurrentOrgId)
  9460. // if order.ID == 0{
  9461. // fapiao_number = "00001520"
  9462. // }else{
  9463. // //fapiao_code = "00001520"
  9464. // fpNumber, _ := strconv.Atoi(order.FaPiaoNumber)
  9465. // var zero string
  9466. // if fpNumber >= 1000{
  9467. // zero = "0000" + strconv.Itoa(fpNumber)
  9468. // }else if fpNumber >= 10000{
  9469. // zero = "000" + strconv.Itoa(fpNumber)
  9470. // } else if fpNumber >= 100000{
  9471. // zero = "00" + strconv.Itoa(fpNumber)
  9472. // } else if fpNumber >= 1000000{
  9473. // zero = "0" + strconv.Itoa(fpNumber)
  9474. // }else {
  9475. // zero = strconv.Itoa(fpNumber)
  9476. // }
  9477. // fapiao_number = zero
  9478. // }
  9479. // }
  9480. //}
  9481. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  9482. his, _ := service.GetNewHisPatientInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  9483. var patientPrescription models.HisPrescriptionInfo
  9484. patientPrescription, _ = service.FindHisPatientPrescriptionInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  9485. if patientPrescription.ID == 0 {
  9486. patientPrescription, _ = service.FindLastPatientPrescriptionInfo(adminUser.CurrentOrgId, id, recordDateTime)
  9487. }
  9488. //if patientPrescription.Do
  9489. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  9490. department, _ := service.GetDepartMentDetail(patientPrescription.Departments)
  9491. doctor_info, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, patientPrescription.DoctorId)
  9492. diagnosis_ids := strings.Split(diagnosis_id, ",")
  9493. var config []*models.HisXtDiagnoseConfig
  9494. for _, item := range diagnosis_ids {
  9495. id, _ := strconv.ParseInt(item, 10, 64)
  9496. diagnosisConfig, _ := service.FindDiagnoseById(id)
  9497. config = append(config, &diagnosisConfig)
  9498. }
  9499. sickConfig, _ := service.FindSickById(sick_type)
  9500. //if tempOrder.ID == 0 {
  9501. // tempOrder, _ = service.GetTodayHisOrder(adminUser.CurrentOrgId, id, recordDateTime, his.Number)
  9502. //}
  9503. if tempOrder.ID == 0 {
  9504. var result string
  9505. var requestLog string
  9506. var res2 ResultSix
  9507. var ressix10265 ResultSix10265
  9508. if miConfig.MdtrtareaAdmvs == "421300" {
  9509. data := make(map[string]interface{})
  9510. client := &http.Client{}
  9511. data["psn_no"] = his.PsnNo
  9512. data["mdtrt_id"] = his.Number
  9513. data["opter"] = roles.UserName
  9514. data["org_name"] = miConfig.OrgName
  9515. data["med_type"] = strconv.FormatInt(reg_type, 10)
  9516. data["doctor_id"] = doctor_info.DoctorNumber
  9517. data["doctor_name"] = doctor_info.UserName
  9518. data["department"] = department.Name
  9519. data["fixmedins_code"] = miConfig.Code
  9520. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  9521. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  9522. data["secret_key"] = miConfig.SecretKey
  9523. data["sick_code"] = sickConfig.CountryCode
  9524. data["sick_name"] = sickConfig.ClassName
  9525. data["dept"] = strconv.FormatInt(department.ID, 10)
  9526. data["config"] = config
  9527. data["begin_time"] = begin_time
  9528. bytesData, _ := json.Marshal(data)
  9529. req, _ := http.NewRequest("POST", "http://192.168.124.4:9532/"+"hbyb/2203", bytes.NewReader(bytesData))
  9530. resp, _ := client.Do(req)
  9531. defer resp.Body.Close()
  9532. body, ioErr := ioutil.ReadAll(resp.Body)
  9533. if ioErr != nil {
  9534. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  9535. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9536. return
  9537. }
  9538. var respJSON map[string]interface{}
  9539. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  9540. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  9541. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9542. return
  9543. }
  9544. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  9545. userJSONBytes, _ := json.Marshal(respJSON)
  9546. fmt.Println("log")
  9547. fmt.Println(string(userJSONBytes))
  9548. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  9549. utils.ErrorLog("解析失败:%v", err)
  9550. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9551. return
  9552. }
  9553. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  9554. data := make(map[string]interface{})
  9555. client := &http.Client{}
  9556. data["psn_no"] = his.PsnNo
  9557. data["mdtrt_id"] = his.Number
  9558. data["doctor"] = roles.UserName
  9559. data["department"] = department.Name
  9560. data["org_name"] = miConfig.OrgName
  9561. data["med_type"] = strconv.FormatInt(reg_type, 10)
  9562. data["doctor_id"] = doctor_info.DoctorNumber
  9563. data["new_doctor_name"] = doctor_info.UserName
  9564. data["fixmedins_code"] = miConfig.Code
  9565. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  9566. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  9567. data["secret_key"] = miConfig.SecretKey
  9568. data["sick_code"] = sickConfig.CountryCode
  9569. data["sick_name"] = sickConfig.ClassName
  9570. data["url"] = miConfig.Url
  9571. data["ak"] = miConfig.AccessKey
  9572. data["begin_time"] = begin_time
  9573. data["cainfo"] = miConfig.Cainfo
  9574. data["dept"] = strconv.FormatInt(department.ID, 10)
  9575. data["config"] = config
  9576. bytesData, _ := json.Marshal(data)
  9577. var req *http.Request
  9578. if miConfig.MdtrtareaAdmvs == "320921" {
  9579. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/2203", bytes.NewReader(bytesData))
  9580. //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 +
  9581. // "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&cainfo=" + miConfig.Cainfo
  9582. } else {
  9583. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2203", bytes.NewReader(bytesData))
  9584. }
  9585. resp, _ := client.Do(req)
  9586. defer resp.Body.Close()
  9587. body, ioErr := ioutil.ReadAll(resp.Body)
  9588. if ioErr != nil {
  9589. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  9590. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9591. return
  9592. }
  9593. var respJSON map[string]interface{}
  9594. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  9595. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  9596. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9597. return
  9598. }
  9599. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  9600. userJSONBytes, _ := json.Marshal(respJSON)
  9601. fmt.Println("log")
  9602. fmt.Println(string(userJSONBytes))
  9603. if err := json.Unmarshal(userJSONBytes, &ressix10265); err != nil {
  9604. utils.ErrorLog("解析失败:%v", err)
  9605. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9606. return
  9607. }
  9608. res2.InfRefmsgid = ressix10265.InfRefmsgid
  9609. res2.Output = ressix10265.Output
  9610. res2.ErrMsg = ressix10265.ErrMsg
  9611. res2.Cainfo = ressix10265.Cainfo
  9612. res2.WarnMsg = ressix10265.WarnMsg
  9613. infocode, _ := strconv.ParseInt(ressix10265.Infcode, 10, 64)
  9614. res2.Infcode = infocode
  9615. } else if miConfig.MdtrtareaAdmvs == "350500" {
  9616. 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)
  9617. saveLog(result, requestLog, "2203", "上传就诊信息")
  9618. var respJSON2 map[string]interface{}
  9619. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  9620. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  9621. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9622. return
  9623. }
  9624. userJSONBytes2, _ := json.Marshal(respJSON2)
  9625. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  9626. utils.ErrorLog("解析失败:%v", err)
  9627. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9628. return
  9629. }
  9630. 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)
  9631. fmt.Println(result2)
  9632. fmt.Println(src_request)
  9633. } else {
  9634. if miConfig.MdtrtareaAdmvs == "440781" { //
  9635. 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)
  9636. } else {
  9637. if miConfig.Code == "H15049901371" {
  9638. //赤峰地区国家医保医疗类别
  9639. //职工透析:医疗类别选特殊情况门诊990502
  9640. //居民定额血透门慢: 医疗类别选门诊慢病140104
  9641. var med_type string
  9642. if his.Insutype == "390" {
  9643. if reg_type == 14 {
  9644. med_type = "9933"
  9645. } else if reg_type == 11 {
  9646. med_type = "11"
  9647. }
  9648. } else if his.Insutype == "310" {
  9649. if reg_type == 14 {
  9650. med_type = "990502"
  9651. } else if reg_type == 11 {
  9652. med_type = "11"
  9653. }
  9654. }
  9655. 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)
  9656. } else {
  9657. 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)
  9658. }
  9659. }
  9660. saveLog(result, requestLog, "2203", "上传就诊信息")
  9661. var respJSON2 map[string]interface{}
  9662. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  9663. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  9664. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9665. return
  9666. }
  9667. userJSONBytes2, _ := json.Marshal(respJSON2)
  9668. if miConfig.Code == "H15049901371" {
  9669. if err := json.Unmarshal(userJSONBytes2, &ressix10265); err != nil {
  9670. utils.ErrorLog("解析失败:%v", err)
  9671. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9672. return
  9673. }
  9674. res2.InfRefmsgid = ressix10265.InfRefmsgid
  9675. res2.Output = ressix10265.Output
  9676. res2.ErrMsg = ressix10265.ErrMsg
  9677. res2.Cainfo = ressix10265.Cainfo
  9678. res2.WarnMsg = ressix10265.WarnMsg
  9679. infocode, _ := strconv.ParseInt(ressix10265.Infcode, 10, 64)
  9680. res2.Infcode = infocode
  9681. } else {
  9682. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  9683. utils.ErrorLog("解析失败:%v", err)
  9684. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9685. return
  9686. }
  9687. }
  9688. }
  9689. if res2.Infcode != 0 {
  9690. adminUser := c.GetAdminUserInfo()
  9691. errlog := &models.HisOrderError{
  9692. UserOrgId: adminUser.CurrentOrgId,
  9693. Ctime: time.Now().Unix(),
  9694. Mtime: time.Now().Unix(),
  9695. ErrMsg: res2.ErrMsg,
  9696. Status: 1,
  9697. PatientId: id,
  9698. RecordTime: recordDateTime,
  9699. Stage: 3,
  9700. }
  9701. service.CreateErrMsgLog(errlog)
  9702. c.ServeSuccessJSON(map[string]interface{}{
  9703. "failed_code": -10,
  9704. "msg": res2.ErrMsg,
  9705. })
  9706. return
  9707. } else {
  9708. his.Diagnosis = diagnosis_id
  9709. his.SickType = sickConfig.ID
  9710. //var p_type int64
  9711. //if reg_type == 1111 || reg_type == 1112 {
  9712. // p_type = 11
  9713. //
  9714. //}
  9715. his.PType = fmt.Sprintf("%d", reg_type)
  9716. service.UpdateHisPatientThree(&his)
  9717. data := make(map[string]interface{})
  9718. if settle_accounts_type == 1 { //日结
  9719. if reg_type == 11 || reg_type == 1111 || reg_type == 1112 {
  9720. prescriptions, _ = service.GetPrescriptionByIds(ids_arr, adminUser.CurrentOrgId)
  9721. } else {
  9722. prescriptions, _ = service.GetNewHisPrescription(adminUser.CurrentOrgId, his_patient_id, recordDateTime, strconv.Itoa(int(reg_type)))
  9723. }
  9724. //prescriptions, _ = service.GetNewHisPrescriptionTwo(adminUser.CurrentOrgId, his_patient_id, recordDateTime, reg_type)
  9725. data["pre"] = prescriptions
  9726. } else { //月结
  9727. start_time_str := c.GetString("start_time")
  9728. end_time_str := c.GetString("end_time")
  9729. timeLayout := "2006-01-02"
  9730. loc, _ := time.LoadLocation("Local")
  9731. theStartTime, err := time.ParseInLocation(timeLayout+" 15:04:05", start_time_str+" 00:00:00", loc)
  9732. if err != nil {
  9733. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  9734. return
  9735. }
  9736. recordStartTime := theStartTime.Unix()
  9737. start_time = recordStartTime
  9738. theEndTime, err := time.ParseInLocation(timeLayout+" 15:04:05", end_time_str+" 00:00:00", loc)
  9739. if err != nil {
  9740. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  9741. return
  9742. }
  9743. recordEndTime := theEndTime.Unix()
  9744. end_time = recordEndTime
  9745. prescriptions, _ = service.GetMonthHisPrescriptionTwo(adminUser.CurrentOrgId, id, recordStartTime, recordEndTime, reg_type)
  9746. data["pre"] = prescriptions
  9747. }
  9748. timestamp := time.Now().Unix()
  9749. tempTime := time.Unix(timestamp, 0)
  9750. timeFormat := tempTime.Format("20060102150405")
  9751. chrgBchno := rand.Intn(100000) + 10000
  9752. chrg_bchno := timeFormat + strconv.FormatInt(int64(chrgBchno), 10) + strconv.FormatInt(his.PatientId, 10)
  9753. strconv.FormatInt(his.PatientId, 10)
  9754. client := &http.Client{}
  9755. data["psn_no"] = his.PsnNo
  9756. data["mdtrt_id"] = his.Number
  9757. data["chrg_bchno"] = chrg_bchno
  9758. data["org_name"] = miConfig.OrgName
  9759. data["doctor"] = doctor_info.UserName
  9760. data["doctor_id"] = doctor_info.DoctorNumber
  9761. data["dept"] = strconv.FormatInt(patientPrescription.Departments, 10)
  9762. data["fixmedins_code"] = miConfig.Code
  9763. data["opter"] = roles.UserName
  9764. data["dept_code"] = department.Number
  9765. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  9766. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  9767. data["secret_key"] = miConfig.SecretKey
  9768. data["balance_accounts_type"] = strconv.FormatInt(his.BalanceAccountsType, 10)
  9769. data["url"] = miConfig.Url
  9770. data["ak"] = miConfig.AccessKey
  9771. data["new_doctor_name"] = patientPrescription.Doctor
  9772. data["diag_code"] = sickConfig.CountryCode
  9773. data["cainfo"] = miConfig.Cainfo
  9774. data["opter"] = roles.UserName
  9775. var ids []int64
  9776. for _, item := range prescriptions {
  9777. ids = append(ids, item.ID)
  9778. }
  9779. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  9780. if config.IsOpen == 1 { //对接了医保,走医保流程
  9781. var res ResultFour
  9782. var resFour10265 ResultFour10265
  9783. if miConfig.MdtrtareaAdmvs == "421300" {
  9784. bytesData, _ := json.Marshal(data)
  9785. req, _ := http.NewRequest("POST", "http://192.168.124.4:9532/"+"hbyb/2204", bytes.NewReader(bytesData))
  9786. resp, _ := client.Do(req)
  9787. defer resp.Body.Close()
  9788. body, ioErr := ioutil.ReadAll(resp.Body)
  9789. if ioErr != nil {
  9790. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  9791. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9792. return
  9793. }
  9794. var respJSON map[string]interface{}
  9795. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  9796. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  9797. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9798. return
  9799. }
  9800. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  9801. userJSONBytes, _ := json.Marshal(respJSON)
  9802. fmt.Println("log")
  9803. fmt.Println(string(userJSONBytes))
  9804. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  9805. utils.ErrorLog("解析失败:%v", err)
  9806. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9807. return
  9808. }
  9809. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  9810. result3101 := Check3101(c, id, his_patient_id, admin_user_id, "2", record_time, prescriptions)
  9811. if result3101.Infcode == "0" {
  9812. if len(result3101.Output.Result) > 0 {
  9813. var errMsgs []string
  9814. for _, item := range result3101.Output.Result {
  9815. errMsgs = append(errMsgs, item.VolaCont)
  9816. }
  9817. c.ServeSuccessJSON(map[string]interface{}{
  9818. "failed_code": -10,
  9819. "msg": errMsgs,
  9820. })
  9821. return
  9822. }
  9823. }
  9824. if miConfig.MdtrtareaAdmvs == "320921" {
  9825. data["doctor_id"] = "D320923012139"
  9826. } else {
  9827. data["doctor_id"] = "D371621008686"
  9828. }
  9829. bytesData, _ := json.Marshal(data)
  9830. var req *http.Request
  9831. if miConfig.MdtrtareaAdmvs == "320921" {
  9832. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  9833. } else {
  9834. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  9835. }
  9836. resp, _ := client.Do(req)
  9837. defer resp.Body.Close()
  9838. body, ioErr := ioutil.ReadAll(resp.Body)
  9839. if ioErr != nil {
  9840. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  9841. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9842. return
  9843. }
  9844. var respJSON map[string]interface{}
  9845. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  9846. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  9847. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9848. return
  9849. }
  9850. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  9851. userJSONBytes, _ := json.Marshal(respJSON)
  9852. fmt.Println("log")
  9853. fmt.Println(string(userJSONBytes))
  9854. if err := json.Unmarshal(userJSONBytes, &resFour10265); err != nil {
  9855. utils.ErrorLog("解析失败:%v", err)
  9856. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9857. return
  9858. }
  9859. res.InfRefmsgid = resFour10265.InfRefmsgid
  9860. res.Output = resFour10265.Output
  9861. res.ErrMsg = resFour10265.ErrMsg
  9862. res.Cainfo = resFour10265.Cainfo
  9863. res.WarnMsg = resFour10265.WarnMsg
  9864. infocode, _ := strconv.ParseInt(resFour10265.Infcode, 10, 64)
  9865. res.Infcode = infocode
  9866. } else if miConfig.MdtrtareaAdmvs == "350500" {
  9867. 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)
  9868. var dat map[string]interface{}
  9869. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  9870. fmt.Println(dat)
  9871. } else {
  9872. fmt.Println(err)
  9873. }
  9874. saveLog(result, request_log, "2204", "上传费用明细")
  9875. userJSONBytes, _ := json.Marshal(dat)
  9876. if err := json.Unmarshal(userJSONBytes, &resFour10265); err != nil {
  9877. utils.ErrorLog("解析失败:%v", err)
  9878. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9879. return
  9880. }
  9881. res.InfRefmsgid = resFour10265.InfRefmsgid
  9882. res.Output = resFour10265.Output
  9883. res.ErrMsg = resFour10265.ErrMsg
  9884. res.Cainfo = resFour10265.Cainfo
  9885. res.WarnMsg = resFour10265.WarnMsg
  9886. infocode, _ := strconv.ParseInt(resFour10265.Infcode, 10, 64)
  9887. res.Infcode = infocode
  9888. } else {
  9889. if miConfig.Code == "H15049901371" {
  9890. 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)
  9891. var dat map[string]interface{}
  9892. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  9893. fmt.Println(dat)
  9894. } else {
  9895. fmt.Println(err)
  9896. }
  9897. saveLog(result, request_log, "2204", "上传费用明细")
  9898. userJSONBytes, _ := json.Marshal(dat)
  9899. if err := json.Unmarshal(userJSONBytes, &resFour10265); err != nil {
  9900. utils.ErrorLog("解析失败:%v", err)
  9901. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9902. return
  9903. }
  9904. res.InfRefmsgid = resFour10265.InfRefmsgid
  9905. res.Output = resFour10265.Output
  9906. res.ErrMsg = resFour10265.ErrMsg
  9907. res.Cainfo = resFour10265.Cainfo
  9908. res.WarnMsg = resFour10265.WarnMsg
  9909. infocode, _ := strconv.ParseInt(resFour10265.Infcode, 10, 64)
  9910. res.Infcode = infocode
  9911. } else {
  9912. 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)
  9913. var dat map[string]interface{}
  9914. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  9915. fmt.Println(dat)
  9916. } else {
  9917. fmt.Println(err)
  9918. }
  9919. saveLog(result, request_log, "2204", "上传费用明细")
  9920. userJSONBytes, _ := json.Marshal(dat)
  9921. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  9922. utils.ErrorLog("解析失败:%v", err)
  9923. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9924. return
  9925. }
  9926. }
  9927. }
  9928. if res.Infcode == 0 {
  9929. order := &models.HisOrder{
  9930. UserOrgId: adminUser.CurrentOrgId,
  9931. HisPatientId: his.ID,
  9932. PatientId: his.PatientId,
  9933. SettleAccountsDate: recordDateTime,
  9934. MdtrtId: his.Number,
  9935. PsnNo: his.PsnNo,
  9936. MedType: strconv.FormatInt(reg_type, 10),
  9937. Ctime: time.Now().Unix(),
  9938. Mtime: time.Now().Unix(),
  9939. Status: 1,
  9940. Number: chrg_bchno,
  9941. Infcode: res.Infcode,
  9942. WarnMsg: res.WarnMsg,
  9943. Cainfo: res.Cainfo,
  9944. ErrMsg: res.ErrMsg,
  9945. RespondTime: res.RefmsgTime,
  9946. InfRefmsgid: res.InfRefmsgid,
  9947. OrderStatus: 1,
  9948. PayWay: pay_way,
  9949. PayWays: pay_ways,
  9950. OthDesc: oth_desc,
  9951. PayPrice: pay_price,
  9952. PayCardNo: pay_card_no,
  9953. DiscountPrice: discount_price,
  9954. PreferentialPrice: preferential_price,
  9955. RealityPrice: reality_price,
  9956. FoundPrice: found_price,
  9957. MedicalInsurancePrice: medical_insurance_price,
  9958. PrivatePrice: private_price,
  9959. IsMedicineInsurance: 1,
  9960. SettleType: settle_accounts_type,
  9961. SettleStartTime: start_time,
  9962. SettleEndTime: end_time,
  9963. Creator: roles.AdminUserId,
  9964. Modify: roles.AdminUserId,
  9965. FaPiaoNumber: fapiao_number,
  9966. FaPiaoCode: fapiao_code,
  9967. PType: 2,
  9968. Diagnosis: diagnosis_id,
  9969. CashPay: cash_pay,
  9970. WechatPay: wechat_pay,
  9971. AliPay: ali_pay,
  9972. JifenPay: jifen_pay,
  9973. BandCardPay: band_card_pay,
  9974. }
  9975. err = service.CreateOrder(order)
  9976. if err != nil {
  9977. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCreatePreOrderException)
  9978. return
  9979. }
  9980. for _, item := range res.Output.Result {
  9981. temp := strings.Split(item.FeedetlSn, "-")
  9982. var advice_id int64 = 0
  9983. var project_id int64 = 0
  9984. var types int64 = 0
  9985. id, _ := strconv.ParseInt(temp[2], 10, 64)
  9986. types, _ = strconv.ParseInt(temp[1], 10, 64)
  9987. if temp[1] == "1" {
  9988. advice_id = id
  9989. project_id = 0
  9990. } else if temp[1] == "2" {
  9991. advice_id = 0
  9992. project_id = id
  9993. }
  9994. if item.MedChrgitmType == "9" {
  9995. item.MedChrgitmType = "09"
  9996. }
  9997. info := &models.HisOrderInfo{
  9998. OrderNumber: order.Number,
  9999. FeedetlSn: item.FeedetlSn,
  10000. UploadDate: time.Now().Unix(),
  10001. AdviceId: advice_id,
  10002. DetItemFeeSumamt: item.DetItemFeeSumamt,
  10003. Cnt: item.Cnt,
  10004. Pric: float64(item.Pric),
  10005. PatientId: his.PatientId,
  10006. PricUplmtAmt: item.PricUplmtAmt,
  10007. SelfpayProp: item.SelfpayProp,
  10008. FulamtOwnpayAmt: item.FulamtOwnpayAmt,
  10009. OverlmtAmt: item.OverlmtAmt,
  10010. PreselfpayAmt: item.PreselfpayAmt,
  10011. BasMednFlag: item.BasMednFlag,
  10012. MedChrgitmType: item.MedChrgitmType,
  10013. HiNegoDrugFlag: item.HiNegoDrugFlag,
  10014. Status: 1,
  10015. Memo: item.Memo,
  10016. Mtime: time.Now().Unix(),
  10017. InscpScpAmt: item.InscpScpAmt,
  10018. DrtReimFlag: item.DrtReimFlag,
  10019. Ctime: time.Now().Unix(),
  10020. ListSpItemFlag: item.ListSpItemFlag,
  10021. ChldMedcFlag: item.ChldMedcFlag,
  10022. LmtUsedFlag: item.LmtUsedFlag,
  10023. ChrgitmLv: item.ChrgitmLv,
  10024. UserOrgId: adminUser.CurrentOrgId,
  10025. HisPatientId: his.ID,
  10026. OrderId: order.ID,
  10027. ProjectId: project_id,
  10028. Type: types,
  10029. }
  10030. service.CreateOrderInfo(info)
  10031. }
  10032. service.UpDatePrescriptionNumber(adminUser.CurrentOrgId, ids, chrg_bchno)
  10033. service.UpDateHisPrescriptionInfoNumber(adminUser.CurrentOrgId, his_patient_id, chrg_bchno, recordDateTime)
  10034. var total float64
  10035. for _, item := range prescriptions {
  10036. if item.Type == 1 { //药品
  10037. for _, subItem := range item.HisDoctorAdviceInfo {
  10038. price, _ := strconv.ParseFloat(fmt.Sprintf("%.2f", subItem.Price), 64)
  10039. total_one := price * subItem.PrescribingNumber
  10040. total = total + total_one
  10041. }
  10042. }
  10043. if item.Type == 2 { //项目
  10044. for _, subItem := range item.HisPrescriptionProject {
  10045. cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  10046. price, _ := strconv.ParseFloat(fmt.Sprintf("%.2f", subItem.Price), 64)
  10047. total_one := price * cnt
  10048. total = total + total_one
  10049. }
  10050. }
  10051. }
  10052. allTotal := fmt.Sprintf("%f", total)
  10053. //if adminUser.CurrentOrgId == 9919 {
  10054. //
  10055. // allTotal = fmt.Sprintf("%.2f", total)
  10056. //
  10057. //} else {
  10058. //
  10059. // allTotal = fmt.Sprintf("%.2f", total)
  10060. //
  10061. //}
  10062. if res.Infcode == 0 {
  10063. var rf []*ResultFive
  10064. json.Unmarshal([]byte(his.Iinfo), &rf)
  10065. chrg_bchno := chrg_bchno
  10066. cert_no := his.Certno
  10067. var insutypes []string
  10068. var insutype string
  10069. var is390 int = 0
  10070. var is310 int = 0
  10071. for _, item := range rf {
  10072. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  10073. insutypes = append(insutypes, item.Insutype)
  10074. }
  10075. }
  10076. if len(insutypes) == 1 {
  10077. insutype = insutypes[0]
  10078. } else {
  10079. for _, i := range insutypes {
  10080. if i == "390" {
  10081. is390 = 1
  10082. }
  10083. if i == "310" {
  10084. is310 = 1
  10085. }
  10086. }
  10087. }
  10088. if is390 == 1 {
  10089. insutype = "390"
  10090. }
  10091. if is310 == 1 {
  10092. insutype = "310"
  10093. }
  10094. if len(insutypes) == 0 {
  10095. insutype = "310"
  10096. }
  10097. if len(insutypes) == 2 {
  10098. insutype = strconv.FormatInt(his.SocialType, 10)
  10099. }
  10100. insutype = strconv.FormatInt(his.SocialType, 10)
  10101. //insutype = "390"
  10102. if his.IdCardType == 1 {
  10103. // cert_no = his.MedicalInsuranceNumber
  10104. cert_no = his.Certno
  10105. } else {
  10106. cert_no = his.Certno
  10107. }
  10108. var res ResultSeven
  10109. var resSeven10265 ResultSeven10265
  10110. var src_resquest string
  10111. var result2 string
  10112. if miConfig.MdtrtareaAdmvs == "421300" {
  10113. api := "http://192.168.124.4:9532/" + "hbyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  10114. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  10115. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  10116. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  10117. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  10118. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  10119. "&insutype=" + insutype + "&total=" + allTotal + "&med_type=" + strconv.FormatInt(reg_type, 10) + "&acct_used_flag=" + acct_used_flag
  10120. resp, requestErr := http.Get(api)
  10121. if requestErr != nil {
  10122. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10123. return
  10124. }
  10125. body, ioErr := ioutil.ReadAll(resp.Body)
  10126. if ioErr != nil {
  10127. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  10128. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10129. return
  10130. }
  10131. var respJSON map[string]interface{}
  10132. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  10133. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  10134. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10135. return
  10136. }
  10137. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  10138. result, _ := json.Marshal(respJSON)
  10139. if miConfig.Code == "H15049901371" {
  10140. if err := json.Unmarshal([]byte(result), &resSeven10265); err != nil {
  10141. utils.ErrorLog("解析失败:%v", err)
  10142. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10143. return
  10144. }
  10145. res.InfRefmsgid = resSeven10265.InfRefmsgid
  10146. res.Output = resSeven10265.Output
  10147. res.ErrMsg = resSeven10265.ErrMsg
  10148. res.Cainfo = resSeven10265.Cainfo
  10149. res.WarnMsg = resSeven10265.WarnMsg
  10150. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  10151. res.Infcode = infocode
  10152. } else {
  10153. if err := json.Unmarshal([]byte(result), &res); err != nil {
  10154. utils.ErrorLog("解析失败:%v", err)
  10155. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10156. return
  10157. }
  10158. }
  10159. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  10160. result3101 := Check3102(c, id, his_patient_id, admin_user_id, "7", order.ID)
  10161. if result3101.Infcode == "0" {
  10162. if len(result3101.Output.Result) > 0 {
  10163. var errMsgs []string
  10164. for _, item := range result3101.Output.Result {
  10165. errMsgs = append(errMsgs, item.VolaCont)
  10166. }
  10167. c.ServeSuccessJSON(map[string]interface{}{
  10168. "failed_code": -10,
  10169. "msg": errMsgs,
  10170. })
  10171. return
  10172. } else {
  10173. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  10174. psn_info.VerifyNumber = strings.Replace(psn_info.VerifyNumber, "+", "%2B", -1)
  10175. bas := strings.Split(psn_info.CardInfo, "|")
  10176. if his.IdCardType == 1 {
  10177. cert_no = bas[2]
  10178. } else if his.IdCardType == 3 {
  10179. cert_no = his.Certno
  10180. psn_info.VerifyNumber = his.Certno + "|" + psn_info.VerifyNumber
  10181. } else if his.IdCardType == 4 {
  10182. cert_no = his.Certno
  10183. psn_info.VerifyNumber = psn_info.VerifyNumber
  10184. }
  10185. var api string
  10186. if miConfig.MdtrtareaAdmvs == "320921" {
  10187. api = "http://192.168.2.3:9532/" + "jsyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  10188. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  10189. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  10190. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  10191. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  10192. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  10193. "&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
  10194. } else {
  10195. api = "http://192.168.5.251:9532/" + "jsyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  10196. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  10197. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  10198. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  10199. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  10200. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  10201. "&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
  10202. }
  10203. resp, requestErr := http.Get(api)
  10204. if requestErr != nil {
  10205. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10206. return
  10207. }
  10208. body, ioErr := ioutil.ReadAll(resp.Body)
  10209. if ioErr != nil {
  10210. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  10211. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10212. return
  10213. }
  10214. var respJSON map[string]interface{}
  10215. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  10216. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  10217. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10218. return
  10219. }
  10220. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  10221. result, _ := json.Marshal(respJSON)
  10222. if err := json.Unmarshal([]byte(result), &resSeven10265); err != nil {
  10223. utils.ErrorLog("解析失败:%v", err)
  10224. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10225. return
  10226. }
  10227. res.InfRefmsgid = resSeven10265.InfRefmsgid
  10228. res.Output = resSeven10265.Output
  10229. res.ErrMsg = resSeven10265.ErrMsg
  10230. res.Cainfo = resSeven10265.Cainfo
  10231. res.WarnMsg = resSeven10265.WarnMsg
  10232. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  10233. res.Infcode = infocode
  10234. }
  10235. }
  10236. } else if miConfig.MdtrtareaAdmvs == "350500" {
  10237. var cert_no string
  10238. if his.IdCardType == 4 {
  10239. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  10240. cert_no = psn_info.VerifyNumber
  10241. 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)
  10242. } else if his.IdCardType == 1 {
  10243. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  10244. cert_no = strings.Split(psn_info.CardInfo, "|")[0]
  10245. 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)
  10246. }
  10247. //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)
  10248. var dat map[string]interface{}
  10249. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  10250. fmt.Println(dat)
  10251. } else {
  10252. fmt.Println(err)
  10253. }
  10254. saveLog(result2, src_resquest, "2207", "结算")
  10255. userJSONBytes, _ := json.Marshal(dat)
  10256. if err := json.Unmarshal(userJSONBytes, &resSeven10265); err != nil {
  10257. utils.ErrorLog("解析失败:%v", err)
  10258. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10259. return
  10260. }
  10261. res.InfRefmsgid = resSeven10265.InfRefmsgid
  10262. res.Output = resSeven10265.Output
  10263. res.ErrMsg = resSeven10265.ErrMsg
  10264. res.Cainfo = resSeven10265.Cainfo
  10265. res.WarnMsg = resSeven10265.WarnMsg
  10266. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  10267. res.Infcode = infocode
  10268. } else {
  10269. if miConfig.Code == "H15049901371" {
  10270. //赤峰地区国家医保医疗类别
  10271. //职工透析:医疗类别选特殊情况门诊990502
  10272. //居民定额血透门慢: 医疗类别选门诊慢病140104
  10273. var med_type string
  10274. if his.Insutype == "390" {
  10275. if reg_type == 14 {
  10276. med_type = "9933"
  10277. } else if reg_type == 11 {
  10278. med_type = "11"
  10279. }
  10280. } else if his.Insutype == "310" {
  10281. if reg_type == 14 {
  10282. med_type = "990502"
  10283. } else if reg_type == 11 {
  10284. med_type = "11"
  10285. }
  10286. }
  10287. 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, "")
  10288. } else {
  10289. if his.IdCardType == 4 {
  10290. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  10291. var token string
  10292. token = psn_info.VerifyNumber
  10293. 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)
  10294. } else {
  10295. 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, "")
  10296. }
  10297. }
  10298. //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)
  10299. var dat map[string]interface{}
  10300. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  10301. fmt.Println(dat)
  10302. } else {
  10303. fmt.Println(err)
  10304. }
  10305. saveLog(result2, src_resquest, "2207", "结算")
  10306. userJSONBytes, _ := json.Marshal(dat)
  10307. if miConfig.Code == "H15049901371" {
  10308. if err := json.Unmarshal(userJSONBytes, &resSeven10265); err != nil {
  10309. utils.ErrorLog("解析失败:%v", err)
  10310. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10311. return
  10312. }
  10313. res.InfRefmsgid = resSeven10265.InfRefmsgid
  10314. res.Output = resSeven10265.Output
  10315. res.ErrMsg = resSeven10265.ErrMsg
  10316. res.Cainfo = resSeven10265.Cainfo
  10317. res.WarnMsg = resSeven10265.WarnMsg
  10318. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  10319. res.Infcode = infocode
  10320. } else {
  10321. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  10322. utils.ErrorLog("解析失败:%v", err)
  10323. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10324. return
  10325. }
  10326. }
  10327. }
  10328. if res.Infcode != 0 {
  10329. errlog := &models.HisOrderError{
  10330. UserOrgId: adminUser.CurrentOrgId,
  10331. Ctime: time.Now().Unix(),
  10332. Mtime: time.Now().Unix(),
  10333. Number: chrg_bchno,
  10334. ErrMsg: res.ErrMsg,
  10335. Status: 1,
  10336. PatientId: id,
  10337. RecordTime: recordDateTime,
  10338. Stage: 6,
  10339. }
  10340. service.CreateErrMsgLog(errlog)
  10341. c.ServeSuccessJSON(map[string]interface{}{
  10342. "failed_code": -10,
  10343. "msg": res.ErrMsg,
  10344. })
  10345. return
  10346. } else {
  10347. order, _ := service.GetHisOrderTwo(adminUser.CurrentOrgId, chrg_bchno, id)
  10348. order.OrderStatus = 2
  10349. order.Status = 1
  10350. order.MdtrtId = res.Output.Setlinfo.MdtrtID
  10351. order.SetlId = res.Output.Setlinfo.SetlID
  10352. order.PsnNo = res.Output.Setlinfo.PsnNo
  10353. order.PsnName = res.Output.Setlinfo.PsnName
  10354. order.PsnCertType = res.Output.Setlinfo.PsnCertType
  10355. order.Certno = res.Output.Setlinfo.Certno
  10356. order.Gend = res.Output.Setlinfo.Gend
  10357. order.Naty = res.Output.Setlinfo.Naty
  10358. order.Age = res.Output.Setlinfo.Age
  10359. order.Insutype = res.Output.Setlinfo.Insutype
  10360. order.PsnType = res.Output.Setlinfo.PsnType
  10361. order.CvlservFlag = res.Output.Setlinfo.CvlservFlag
  10362. order.SetlTime = res.Output.Setlinfo.SetlTime
  10363. order.MdtrtCertType = res.Output.Setlinfo.MdtrtCertType
  10364. if res.Output.Setlinfo.MedType == "140101" {
  10365. order.MedType = "14"
  10366. } else {
  10367. order.MedType = res.Output.Setlinfo.MedType
  10368. }
  10369. if reg_type == 1112 {
  10370. order.MedType = "1112"
  10371. }
  10372. if reg_type == 1111 {
  10373. order.MedType = "1111"
  10374. }
  10375. order.MedfeeSumamt = res.Output.Setlinfo.MedfeeSumamt
  10376. order.FulamtOwnpayAmt = res.Output.Setlinfo.FulamtOwnpayAmt
  10377. order.OverlmtSelfPay = res.Output.Setlinfo.OverlmtSelfpay
  10378. order.PreselfpayAmt = res.Output.Setlinfo.PreselfpayAmt
  10379. order.InscpScpAmt = res.Output.Setlinfo.InscpScpAmt
  10380. order.ActPayDedc = res.Output.Setlinfo.ActPayDedc
  10381. order.HifpPay = res.Output.Setlinfo.HifpPay
  10382. order.CvlservPay = res.Output.Setlinfo.CvlservPay
  10383. order.PoolPropSelfpay = res.Output.Setlinfo.PoolPropSelfpay
  10384. order.HifesPay = res.Output.Setlinfo.HifesPay
  10385. order.HifobPay = res.Output.Setlinfo.HifobPay
  10386. order.MafPay = res.Output.Setlinfo.MafPay
  10387. order.HifmiPay = res.Output.Setlinfo.HifmiPay
  10388. order.OthPay = res.Output.Setlinfo.OthPay
  10389. order.FundPaySumamt = res.Output.Setlinfo.FundPaySumamt
  10390. order.PsnPartAmt = res.Output.Setlinfo.PsnPartAmt
  10391. order.AcctPay = res.Output.Setlinfo.AcctPay
  10392. order.PsnCashPay = res.Output.Setlinfo.PsnCashPay
  10393. order.HospPartAmt = res.Output.Setlinfo.HospPartAmt
  10394. order.Balc = res.Output.Setlinfo.Balc
  10395. order.AcctMulaidPay = res.Output.Setlinfo.AcctMulaidPay
  10396. order.MedinsSetlId = res.Output.Setlinfo.MedinsSetlID
  10397. order.ClrOptins = res.Output.Setlinfo.ClrOptins
  10398. order.ClrType = res.Output.Setlinfo.ClrType
  10399. order.ClrWay = res.Output.Setlinfo.ClrWay
  10400. order.Creator = order.Creator
  10401. order.Modify = roles.AdminUserId
  10402. order.RequestLog = src_resquest
  10403. setlDetail, _ := json.Marshal(res.Output.Setldetail)
  10404. detailStr := string(setlDetail)
  10405. order.SetlDetail = detailStr
  10406. err := service.UpdataOrderStatusTwo(chrg_bchno, adminUser.CurrentOrgId)
  10407. err = service.UpDateOrder(order)
  10408. if err == nil {
  10409. //判断是否使用了押金
  10410. if dec_way == "true" {
  10411. tmpstring := strconv.FormatInt(order.ID, 10)
  10412. order.Decimal = decimal
  10413. service.UpDateOrder(order)
  10414. //扣押金
  10415. errmsg = service.SpendDeposit(c.GetAdminUserInfo().CurrentOrgId, id, c.GetAdminUserInfo().AdminUser.Id, tmpstring, decimal)
  10416. if errmsg != nil {
  10417. c.ServeFailJsonSend(enums.ErrorCodeParamWrong, errmsg.Error())
  10418. return
  10419. }
  10420. }
  10421. c.ServeSuccessJSON(map[string]interface{}{
  10422. "msg": "结算成功",
  10423. })
  10424. } else {
  10425. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeAmountAccountException)
  10426. return
  10427. }
  10428. }
  10429. } else {
  10430. adminUser := c.GetAdminUserInfo()
  10431. errlog := &models.HisOrderError{
  10432. UserOrgId: adminUser.CurrentOrgId,
  10433. Ctime: time.Now().Unix(),
  10434. Mtime: time.Now().Unix(),
  10435. ErrMsg: res.ErrMsg,
  10436. Status: 1,
  10437. PatientId: id,
  10438. RecordTime: recordDateTime,
  10439. Stage: 4,
  10440. }
  10441. service.CreateErrMsgLog(errlog)
  10442. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeRegisterRepeatException)
  10443. return
  10444. }
  10445. } else {
  10446. adminUser := c.GetAdminUserInfo()
  10447. errlog := &models.HisOrderError{
  10448. UserOrgId: adminUser.CurrentOrgId,
  10449. Ctime: time.Now().Unix(),
  10450. Mtime: time.Now().Unix(),
  10451. ErrMsg: res.ErrMsg,
  10452. Status: 1,
  10453. PatientId: id,
  10454. RecordTime: recordDateTime,
  10455. Stage: 4,
  10456. }
  10457. service.CreateErrMsgLog(errlog)
  10458. c.ServeSuccessJSON(map[string]interface{}{
  10459. "failed_code": -10,
  10460. "msg": res.ErrMsg,
  10461. })
  10462. return
  10463. //c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCalOrderException)
  10464. //return
  10465. }
  10466. }
  10467. }
  10468. } else if tempOrder.ID > 0 {
  10469. if tempOrder.IsPre == 1 {
  10470. allTotal := fmt.Sprintf("%.2f", tempOrder.MedfeeSumamt)
  10471. var rf []*ResultFive
  10472. json.Unmarshal([]byte(his.Iinfo), &rf)
  10473. chrg_bchno := tempOrder.Number
  10474. cert_no := his.Certno
  10475. var insutypes []string
  10476. var insutype string
  10477. var is390 int = 0
  10478. var is310 int = 0
  10479. for _, item := range rf {
  10480. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  10481. insutypes = append(insutypes, item.Insutype)
  10482. }
  10483. }
  10484. if len(insutypes) == 1 {
  10485. insutype = insutypes[0]
  10486. } else {
  10487. for _, i := range insutypes {
  10488. if i == "390" {
  10489. is390 = 1
  10490. }
  10491. if i == "310" {
  10492. is310 = 1
  10493. }
  10494. }
  10495. }
  10496. if is390 == 1 {
  10497. insutype = "390"
  10498. }
  10499. if is310 == 1 {
  10500. insutype = "310"
  10501. }
  10502. if len(insutypes) == 0 {
  10503. insutype = "310"
  10504. }
  10505. if len(insutypes) == 2 {
  10506. insutype = strconv.FormatInt(his.SocialType, 10)
  10507. }
  10508. //insutype = "390"
  10509. if his.IdCardType == 1 {
  10510. // cert_no = his.MedicalInsuranceNumber
  10511. cert_no = his.Certno
  10512. } else {
  10513. cert_no = his.Certno
  10514. }
  10515. var res ResultSeven
  10516. var resSeven10265 ResultSeven10265
  10517. var src_resquest string
  10518. var result2 string
  10519. if miConfig.MdtrtareaAdmvs == "421300" {
  10520. api := "http://192.168.124.4:9532/" + "hbyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  10521. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  10522. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  10523. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  10524. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  10525. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  10526. "&insutype=" + insutype + "&total=" + allTotal + "&med_type=" + strconv.FormatInt(reg_type, 10) + "&acct_used_flag=" + acct_used_flag
  10527. resp, requestErr := http.Get(api)
  10528. if requestErr != nil {
  10529. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10530. return
  10531. }
  10532. body, ioErr := ioutil.ReadAll(resp.Body)
  10533. if ioErr != nil {
  10534. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  10535. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10536. return
  10537. }
  10538. var respJSON map[string]interface{}
  10539. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  10540. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  10541. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10542. return
  10543. }
  10544. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  10545. result, _ := json.Marshal(respJSON)
  10546. fmt.Println("log")
  10547. fmt.Println(string(result))
  10548. if err := json.Unmarshal([]byte(result), &res); err != nil {
  10549. utils.ErrorLog("解析失败:%v", err)
  10550. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10551. return
  10552. }
  10553. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  10554. result3101 := Check3102(c, id, his_patient_id, admin_user_id, "7", tempOrder.ID)
  10555. if result3101.Infcode == "0" {
  10556. if len(result3101.Output.Result) > 0 {
  10557. var errMsgs []string
  10558. for _, item := range result3101.Output.Result {
  10559. errMsgs = append(errMsgs, item.VolaCont)
  10560. }
  10561. c.ServeSuccessJSON(map[string]interface{}{
  10562. "failed_code": -10,
  10563. "msg": errMsgs,
  10564. })
  10565. return
  10566. } else {
  10567. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  10568. psn_info.VerifyNumber = strings.Replace(psn_info.VerifyNumber, "+", "%2B", -1)
  10569. bas := strings.Split(psn_info.CardInfo, "|")
  10570. if his.IdCardType == 1 {
  10571. cert_no = bas[2]
  10572. } else if his.IdCardType == 3 {
  10573. cert_no = his.Certno
  10574. psn_info.VerifyNumber = his.Certno + "|" + psn_info.VerifyNumber
  10575. } else if his.IdCardType == 4 {
  10576. cert_no = his.Certno
  10577. psn_info.VerifyNumber = psn_info.VerifyNumber
  10578. }
  10579. //江苏地区国家医保医疗类别
  10580. //职工透析:医疗类别选特殊情况门诊9933
  10581. //居民血透门慢: 医疗类别选门诊慢病1402
  10582. //var med_type string
  10583. //if his.Insutype == "310" {
  10584. // if reg_type == 14 {
  10585. // med_type = "9933"
  10586. // } else if reg_type == 11 {
  10587. // med_type = "11"
  10588. //
  10589. // }
  10590. //} else if his.Insutype == "390" {
  10591. // if reg_type == 14 {
  10592. // med_type = "1402"
  10593. // } else if reg_type == 11 {
  10594. // med_type = "11"
  10595. // }
  10596. //}
  10597. var api string
  10598. if miConfig.MdtrtareaAdmvs == "320921" {
  10599. api = "http://192.168.2.3:9532/" + "jsyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  10600. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  10601. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  10602. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  10603. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  10604. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  10605. "&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
  10606. //req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  10607. } else {
  10608. //req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  10609. api = "http://192.168.5.251:9532/" + "jsyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  10610. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  10611. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  10612. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  10613. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  10614. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  10615. "&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
  10616. }
  10617. resp, requestErr := http.Get(api)
  10618. if requestErr != nil {
  10619. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10620. return
  10621. }
  10622. body, ioErr := ioutil.ReadAll(resp.Body)
  10623. if ioErr != nil {
  10624. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  10625. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10626. return
  10627. }
  10628. var respJSON map[string]interface{}
  10629. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  10630. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  10631. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10632. return
  10633. }
  10634. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  10635. result, _ := json.Marshal(respJSON)
  10636. fmt.Println("log")
  10637. fmt.Println(string(result))
  10638. if err := json.Unmarshal([]byte(result), &resSeven10265); err != nil {
  10639. utils.ErrorLog("解析失败:%v", err)
  10640. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10641. return
  10642. }
  10643. res.InfRefmsgid = resSeven10265.InfRefmsgid
  10644. res.Output = resSeven10265.Output
  10645. res.ErrMsg = resSeven10265.ErrMsg
  10646. res.Cainfo = resSeven10265.Cainfo
  10647. res.WarnMsg = resSeven10265.WarnMsg
  10648. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  10649. res.Infcode = infocode
  10650. }
  10651. }
  10652. } else if miConfig.MdtrtareaAdmvs == "350500" {
  10653. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  10654. var cert_no string
  10655. if his.IdCardType == 1 {
  10656. cert_no = strings.Split(psn_info.CardInfo, "|")[0]
  10657. } else {
  10658. cert_no = psn_info.VerifyNumber
  10659. }
  10660. 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)
  10661. var dat map[string]interface{}
  10662. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  10663. fmt.Println(dat)
  10664. } else {
  10665. fmt.Println(err)
  10666. }
  10667. saveLog(result2, src_resquest, "2207", "结算")
  10668. userJSONBytes, _ := json.Marshal(dat)
  10669. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  10670. utils.ErrorLog("解析失败:%v", err)
  10671. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10672. return
  10673. }
  10674. } else if miConfig.MdtrtareaAdmvs == "360399" {
  10675. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  10676. var cert_no string
  10677. if his.IdCardType == 1 {
  10678. cert_no = strings.Split(psn_info.CardInfo, "|")[0]
  10679. } else if his.IdCardType == 2 {
  10680. cert_no = his.IdCardNo
  10681. } else {
  10682. cert_no = psn_info.VerifyNumber
  10683. }
  10684. 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, "")
  10685. var dat map[string]interface{}
  10686. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  10687. fmt.Println(dat)
  10688. } else {
  10689. fmt.Println(err)
  10690. }
  10691. saveLog(result2, src_resquest, "2207", "结算")
  10692. userJSONBytes, _ := json.Marshal(dat)
  10693. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  10694. utils.ErrorLog("解析失败:%v", err)
  10695. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10696. return
  10697. }
  10698. } else if miConfig.MdtrtareaAdmvs == "430800" {
  10699. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  10700. var cert_no string
  10701. if his.IdCardType == 1 {
  10702. cert_no = strings.Split(psn_info.CardInfo, "|")[0]
  10703. } else if his.IdCardType == 2 {
  10704. cert_no = his.IdCardNo
  10705. } else {
  10706. cert_no = psn_info.VerifyNumber
  10707. }
  10708. 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, "")
  10709. var dat map[string]interface{}
  10710. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  10711. fmt.Println(dat)
  10712. } else {
  10713. fmt.Println(err)
  10714. }
  10715. saveLog(result2, src_resquest, "2207", "结算")
  10716. userJSONBytes, _ := json.Marshal(dat)
  10717. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  10718. utils.ErrorLog("解析失败:%v", err)
  10719. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10720. return
  10721. }
  10722. } else {
  10723. var src_resquest string
  10724. if miConfig.Code == "H15049901371" {
  10725. //赤峰地区国家医保医疗类别
  10726. //职工透析:医疗类别选特殊情况门诊990502
  10727. //居民定额血透门慢: 医疗类别选门诊慢病140104
  10728. var med_type string
  10729. if his.Insutype == "390" {
  10730. if reg_type == 14 {
  10731. med_type = "9933"
  10732. } else if reg_type == 11 {
  10733. med_type = "11"
  10734. }
  10735. } else if his.Insutype == "310" {
  10736. if reg_type == 14 {
  10737. med_type = "990502"
  10738. } else if reg_type == 11 {
  10739. med_type = "11"
  10740. }
  10741. }
  10742. 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, "")
  10743. } else {
  10744. if his.IdCardType == 4 {
  10745. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  10746. token := psn_info.VerifyNumber
  10747. 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)
  10748. } else {
  10749. 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, "")
  10750. }
  10751. }
  10752. var dat map[string]interface{}
  10753. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  10754. fmt.Println(dat)
  10755. } else {
  10756. fmt.Println(err)
  10757. }
  10758. saveLog(result2, src_resquest, "2207", "结算")
  10759. userJSONBytes, _ := json.Marshal(dat)
  10760. if miConfig.Code == "H15049901371" {
  10761. if err := json.Unmarshal(userJSONBytes, &resSeven10265); err != nil {
  10762. utils.ErrorLog("解析失败:%v", err)
  10763. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10764. return
  10765. }
  10766. res.InfRefmsgid = resSeven10265.InfRefmsgid
  10767. res.Output = resSeven10265.Output
  10768. res.ErrMsg = resSeven10265.ErrMsg
  10769. res.Cainfo = resSeven10265.Cainfo
  10770. res.WarnMsg = resSeven10265.WarnMsg
  10771. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  10772. res.Infcode = infocode
  10773. } else {
  10774. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  10775. utils.ErrorLog("解析失败:%v", err)
  10776. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10777. return
  10778. }
  10779. }
  10780. }
  10781. if res.Infcode != 0 {
  10782. errlog := &models.HisOrderError{
  10783. UserOrgId: adminUser.CurrentOrgId,
  10784. Ctime: time.Now().Unix(),
  10785. Mtime: time.Now().Unix(),
  10786. Number: chrg_bchno,
  10787. ErrMsg: res.ErrMsg,
  10788. Status: 1,
  10789. PatientId: id,
  10790. RecordTime: recordDateTime,
  10791. Stage: 6,
  10792. }
  10793. service.CreateErrMsgLog(errlog)
  10794. c.ServeSuccessJSON(map[string]interface{}{
  10795. "failed_code": -10,
  10796. "msg": res.ErrMsg,
  10797. })
  10798. return
  10799. } else {
  10800. order, _ := service.GetHisOrderTwo(adminUser.CurrentOrgId, chrg_bchno, id)
  10801. order.OrderStatus = 2
  10802. order.MdtrtId = res.Output.Setlinfo.MdtrtID
  10803. order.SetlId = res.Output.Setlinfo.SetlID
  10804. order.PsnNo = res.Output.Setlinfo.PsnNo
  10805. order.PsnName = res.Output.Setlinfo.PsnName
  10806. order.PsnCertType = res.Output.Setlinfo.PsnCertType
  10807. order.Certno = res.Output.Setlinfo.Certno
  10808. order.Gend = res.Output.Setlinfo.Gend
  10809. order.Naty = res.Output.Setlinfo.Naty
  10810. order.Age = res.Output.Setlinfo.Age
  10811. order.Insutype = res.Output.Setlinfo.Insutype
  10812. order.PsnType = res.Output.Setlinfo.PsnType
  10813. order.CvlservFlag = res.Output.Setlinfo.CvlservFlag
  10814. order.SetlTime = res.Output.Setlinfo.SetlTime
  10815. order.MdtrtCertType = res.Output.Setlinfo.MdtrtCertType
  10816. order.PayWays = pay_ways
  10817. order.AcctUsedFlag = acct_used_flag
  10818. order.WechatPay = wechat_pay
  10819. order.AliPay = ali_pay
  10820. order.JifenPay = jifen_pay
  10821. order.BandCardPay = band_card_pay
  10822. order.CashPay = cash_pay
  10823. order.OthDesc = oth_desc
  10824. //order.MedType = res.Output.Setlinfo.MedType
  10825. if reg_type == 1112 {
  10826. order.MedType = "1112"
  10827. }
  10828. if reg_type == 1111 {
  10829. order.MedType = "1111"
  10830. }
  10831. order.MedfeeSumamt = res.Output.Setlinfo.MedfeeSumamt
  10832. order.FulamtOwnpayAmt = res.Output.Setlinfo.FulamtOwnpayAmt
  10833. order.OverlmtSelfPay = res.Output.Setlinfo.OverlmtSelfpay
  10834. order.PreselfpayAmt = res.Output.Setlinfo.PreselfpayAmt
  10835. order.InscpScpAmt = res.Output.Setlinfo.InscpScpAmt
  10836. order.ActPayDedc = res.Output.Setlinfo.ActPayDedc
  10837. order.HifpPay = res.Output.Setlinfo.HifpPay
  10838. order.CvlservPay = res.Output.Setlinfo.CvlservPay
  10839. order.PoolPropSelfpay = res.Output.Setlinfo.PoolPropSelfpay
  10840. order.HifesPay = res.Output.Setlinfo.HifesPay
  10841. order.HifobPay = res.Output.Setlinfo.HifobPay
  10842. order.MafPay = res.Output.Setlinfo.MafPay
  10843. order.HifmiPay = res.Output.Setlinfo.HifmiPay
  10844. order.OthPay = res.Output.Setlinfo.OthPay
  10845. order.FundPaySumamt = res.Output.Setlinfo.FundPaySumamt
  10846. order.PsnPartAmt = res.Output.Setlinfo.PsnPartAmt
  10847. order.AcctPay = res.Output.Setlinfo.AcctPay
  10848. order.PsnCashPay = res.Output.Setlinfo.PsnCashPay
  10849. order.HospPartAmt = res.Output.Setlinfo.HospPartAmt
  10850. order.Balc = res.Output.Setlinfo.Balc
  10851. order.AcctMulaidPay = res.Output.Setlinfo.AcctMulaidPay
  10852. order.MedinsSetlId = res.Output.Setlinfo.MedinsSetlID
  10853. order.ClrOptins = res.Output.Setlinfo.ClrOptins
  10854. order.ClrWay = res.Output.Setlinfo.ClrWay
  10855. order.Creator = order.Creator
  10856. order.Modify = roles.AdminUserId
  10857. order.RequestLog = src_resquest
  10858. order.Diagnosis = diagnosis_id
  10859. setlDetail, _ := json.Marshal(res.Output.Setldetail)
  10860. detailStr := string(setlDetail)
  10861. order.SetlDetail = detailStr
  10862. err := service.UpdataOrderStatusTwo(chrg_bchno, adminUser.CurrentOrgId)
  10863. err = service.UpDateOrder(order)
  10864. if err == nil {
  10865. //判断是否使用了押金
  10866. if dec_way == "true" {
  10867. tmpstring := strconv.FormatInt(order.ID, 10)
  10868. //扣押金
  10869. order.Decimal = decimal
  10870. service.UpDateOrder(order)
  10871. errmsg = service.SpendDeposit(c.GetAdminUserInfo().CurrentOrgId, id, c.GetAdminUserInfo().AdminUser.Id, tmpstring, decimal)
  10872. if errmsg != nil {
  10873. c.ServeFailJsonSend(enums.ErrorCodeParamWrong, errmsg.Error())
  10874. return
  10875. }
  10876. }
  10877. c.ServeSuccessJSON(map[string]interface{}{
  10878. "msg": "结算成功",
  10879. })
  10880. } else {
  10881. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeAmountAccountException)
  10882. return
  10883. }
  10884. }
  10885. }
  10886. }
  10887. }
  10888. //func (c *HisApiController) GetPreUploadInfo() {
  10889. // id, _ := c.GetInt64("id")
  10890. // record_time := c.GetString("record_time")
  10891. // settle_accounts_type, _ := c.GetInt64("settle_accounts_type")
  10892. // admin_user_id, _ := c.GetInt64("admin_user_id")
  10893. //
  10894. // timeLayout := "2006-01-02"
  10895. // loc, _ := time.LoadLocation("Local")
  10896. // theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  10897. // if err != nil {
  10898. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  10899. // return
  10900. // }
  10901. // recordDateTime := theTime.Unix()
  10902. // adminUser := c.GetAdminUserInfo()
  10903. //
  10904. // var prescriptions []*models.HisPrescription
  10905. //
  10906. // var start_time int64
  10907. // var end_time int64
  10908. //
  10909. // data := make(map[string]interface{})
  10910. // if settle_accounts_type == 1 { //日结
  10911. // prescriptions, _ = service.GetHisPrescription(adminUser.CurrentOrgId, id, recordDateTime)
  10912. // data["pre"] = prescriptions
  10913. //
  10914. // } else { //月结
  10915. // start_time_str := c.GetString("start_time")
  10916. // end_time_str := c.GetString("end_time")
  10917. // timeLayout := "2006-01-02"
  10918. // loc, _ := time.LoadLocation("Local")
  10919. // theStartTime, err := time.ParseInLocation(timeLayout+" 15:04:05", start_time_str+" 00:00:00", loc)
  10920. // if err != nil {
  10921. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  10922. // return
  10923. // }
  10924. // recordStartTime := theStartTime.Unix()
  10925. // start_time = recordStartTime
  10926. // theEndTime, err := time.ParseInLocation(timeLayout+" 15:04:05", end_time_str+" 00:00:00", loc)
  10927. // if err != nil {
  10928. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  10929. // return
  10930. // }
  10931. // recordEndTime := theEndTime.Unix()
  10932. // end_time = recordEndTime
  10933. // prescriptions, _ = service.GetMonthHisPrescription(adminUser.CurrentOrgId, id, recordStartTime, recordEndTime)
  10934. // data["pre"] = prescriptions
  10935. //
  10936. // }
  10937. //
  10938. // roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  10939. //
  10940. // his, _ := service.GetVMHisPatientInfo(adminUser.CurrentOrgId, id, recordDateTime)
  10941. // timestamp := time.Now().Unix()
  10942. // tempTime := time.Unix(timestamp, 0)
  10943. // timeFormat := tempTime.Format("20060102150405")
  10944. // chrgBchno := rand.Intn(100000) + 10000
  10945. // chrg_bchno := timeFormat + strconv.FormatInt(int64(chrgBchno), 10) + strconv.FormatInt(his.PatientId, 10)
  10946. // miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  10947. // patientPrescription, _ := service.FindPatientPrescriptionInfo(adminUser.CurrentOrgId, id, recordDateTime)
  10948. // department, _ := service.GetDepartMentDetail(patientPrescription.Departments)
  10949. // strconv.FormatInt(his.PatientId, 10)
  10950. // client := &http.Client{}
  10951. // data["psn_no"] = his.PsnNo
  10952. // data["mdtrt_id"] = his.Number
  10953. // data["chrg_bchno"] = chrg_bchno
  10954. // data["org_name"] = miConfig.OrgName
  10955. // data["doctor"] = roles.UserName
  10956. // data["doctor_id"] = strconv.FormatInt(roles.AdminUserId, 10)
  10957. // data["dept"] = strconv.FormatInt(patientPrescription.Departments, 10)
  10958. // data["fixmedins_code"] = miConfig.Code
  10959. // data["dept_code"] = department.Number
  10960. // data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  10961. // data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  10962. // data["secret_key"] = miConfig.SecretKey
  10963. // var ids []int64
  10964. //
  10965. // for _, item := range prescriptions {
  10966. // ids = append(ids, item.ID)
  10967. // }
  10968. // config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  10969. // if config.IsOpen == 1 { //对接了医保,走医保流程
  10970. // bytesData, _ := json.Marshal(data)
  10971. // req, _ := http.NewRequest("POST", "http://127.0.0.1:9532/"+"gdyb/five", bytes.NewReader(bytesData))
  10972. // resp, _ := client.Do(req)
  10973. // defer resp.Body.Close()
  10974. // body, ioErr := ioutil.ReadAll(resp.Body)
  10975. // if ioErr != nil {
  10976. // utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  10977. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10978. // return
  10979. // }
  10980. // var respJSON map[string]interface{}
  10981. // if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  10982. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  10983. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10984. // return
  10985. // }
  10986. //
  10987. // respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  10988. // userJSONBytes, _ := json.Marshal(respJSON)
  10989. // var res ResultFour
  10990. // if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  10991. // utils.ErrorLog("解析失败:%v", err)
  10992. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10993. // return
  10994. // }
  10995. //
  10996. // if res.Infcode == 0 {
  10997. // order := &models.HisOrder{
  10998. // UserOrgId: adminUser.CurrentOrgId,
  10999. // HisPatientId: his.ID,
  11000. // PatientId: his.PatientId,
  11001. // SettleAccountsDate: recordDateTime,
  11002. // Ctime: time.Now().Unix(),
  11003. // Mtime: time.Now().Unix(),
  11004. // Status: 1,
  11005. // Number: chrg_bchno,
  11006. // Infcode: res.Infcode,
  11007. // WarnMsg: res.WarnMsg,
  11008. // Cainfo: res.Cainfo,
  11009. // ErrMsg: res.ErrMsg,
  11010. // RespondTime: res.RefmsgTime,
  11011. // InfRefmsgid: res.InfRefmsgid,
  11012. // OrderStatus: 1,
  11013. // IsMedicineInsurance: 1,
  11014. // SettleType: settle_accounts_type,
  11015. // SettleStartTime: start_time,
  11016. // SettleEndTime: end_time,
  11017. // Creator: roles.ID,
  11018. // Modify: roles.ID,
  11019. // PType: 2,
  11020. // }
  11021. // err = service.CreateOrder(order)
  11022. // if err != nil {
  11023. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCreatePreOrderException)
  11024. // return
  11025. // }
  11026. //
  11027. // for _, item := range res.Output.Result {
  11028. // temp := strings.Split(item.FeedetlSn, "-")
  11029. // var advice_id int64 = 0
  11030. // var project_id int64 = 0
  11031. // var types int64 = 0
  11032. //
  11033. // id, _ := strconv.ParseInt(temp[2], 10, 64)
  11034. // types, _ = strconv.ParseInt(temp[1], 10, 64)
  11035. //
  11036. // if temp[1] == "1" {
  11037. // advice_id = id
  11038. // project_id = 0
  11039. // } else if temp[1] == "2" {
  11040. // advice_id = 0
  11041. // project_id = id
  11042. // }
  11043. //
  11044. // info := &models.HisOrderInfo{
  11045. // OrderNumber: order.Number,
  11046. // FeedetlSn: item.FeedetlSn,
  11047. // UploadDate: time.Now().Unix(),
  11048. // AdviceId: advice_id,
  11049. // DetItemFeeSumamt: item.DetItemFeeSumamt,
  11050. // Cnt: item.Cnt,
  11051. // Pric: float64(item.Pric),
  11052. // PatientId: his.PatientId,
  11053. // PricUplmtAmt: item.PricUplmtAmt,
  11054. // SelfpayProp: item.SelfpayProp,
  11055. // FulamtOwnpayAmt: item.FulamtOwnpayAmt,
  11056. // OverlmtAmt: item.OverlmtAmt,
  11057. // PreselfpayAmt: item.PreselfpayAmt,
  11058. // BasMednFlag: item.BasMednFlag,
  11059. // MedChrgitmType: item.MedChrgitmType,
  11060. // HiNegoDrugFlag: item.HiNegoDrugFlag,
  11061. // Status: 1,
  11062. // Memo: item.Memo,
  11063. // Mtime: time.Now().Unix(),
  11064. // InscpScpAmt: item.InscpScpAmt,
  11065. // DrtReimFlag: item.DrtReimFlag,
  11066. // Ctime: time.Now().Unix(),
  11067. // ListSpItemFlag: item.ListSpItemFlag,
  11068. // ChldMedcFlag: item.ChldMedcFlag,
  11069. // LmtUsedFlag: item.LmtUsedFlag,
  11070. // ChrgitmLv: item.ChrgitmLv,
  11071. // UserOrgId: adminUser.CurrentOrgId,
  11072. // HisPatientId: his.ID,
  11073. // OrderId: order.ID,
  11074. // ProjectId: project_id,
  11075. // Type: types,
  11076. // }
  11077. // service.CreateOrderInfo(info)
  11078. //
  11079. // }
  11080. // service.UpDatePrescriptionNumber(adminUser.CurrentOrgId, ids, chrg_bchno)
  11081. // service.UpDatePrescriptionInfoNumber(adminUser.CurrentOrgId, patientPrescription.PatientId, chrg_bchno, recordDateTime)
  11082. //
  11083. // var total float64
  11084. // for _, item := range prescriptions {
  11085. // if item.Type == 1 { //药品
  11086. // for _, subItem := range item.HisDoctorAdviceInfo {
  11087. // total = total + (subItem.Price * subItem.PrescribingNumber)
  11088. // }
  11089. // }
  11090. // if item.Type == 2 { //项目
  11091. // for _, subItem := range item.HisPrescriptionProject {
  11092. // total = total + (subItem.Price * float64(subItem.Count))
  11093. // }
  11094. // }
  11095. // }
  11096. //
  11097. // for _, item := range prescriptions {
  11098. // for _, subItem := range item.HisAdditionalCharge {
  11099. // total = total + (subItem.Price * float64(subItem.Count))
  11100. // }
  11101. // }
  11102. //
  11103. // allTotal := fmt.Sprintf("%.2f", total)
  11104. // if res.Infcode == 0 {
  11105. // var rf []*ResultFive
  11106. // json.Unmarshal([]byte(his.Iinfo), &rf)
  11107. // psn_no := his.PsnNo
  11108. // mdtrt_id := his.Number
  11109. // chrg_bchno := chrg_bchno
  11110. // cert_no := his.Certno
  11111. // insutype := rf[0].Insutype
  11112. //
  11113. // if his.IdCardType == 1 {
  11114. // cert_no = his.MedicalInsuranceNumber
  11115. //
  11116. // } else {
  11117. //
  11118. // cert_no = his.Certno
  11119. //
  11120. // }
  11121. //
  11122. // api := "http://127.0.0.1:9532/" + "gdyb/seven?cert_no=" + cert_no + "&insutype=" +
  11123. // insutype + "&psn_no=" + psn_no + "&chrg_bchno=" + chrg_bchno + "&mdtrt_id=" + mdtrt_id +
  11124. // "&total=" + allTotal + "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code + "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" +
  11125. // miConfig.SecretKey + "&med_type=" + strconv.FormatInt(patientPrescription.RegisterType, 10) + "&id_card_type=" + strconv.FormatInt(int64(his.IdCardType), 10)
  11126. // resp, requestErr := http.Get(api)
  11127. // if requestErr != nil {
  11128. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11129. // return
  11130. // }
  11131. // defer resp.Body.Close()
  11132. // body, ioErr := ioutil.ReadAll(resp.Body)
  11133. // if ioErr != nil {
  11134. // utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  11135. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11136. // return
  11137. // }
  11138. // var respJSON map[string]interface{}
  11139. // if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  11140. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  11141. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11142. // return
  11143. // }
  11144. // fmt.Println(respJSON)
  11145. // respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  11146. // userJSONBytes, _ := json.Marshal(respJSON)
  11147. // var res ResultSeven
  11148. // if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  11149. // utils.ErrorLog("解析失败:%v", err)
  11150. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11151. // return
  11152. // }
  11153. // if res.Infcode != 0 {
  11154. // errlog := &models.HisOrderError{
  11155. // UserOrgId: adminUser.CurrentOrgId,
  11156. // Ctime: time.Now().Unix(),
  11157. // Mtime: time.Now().Unix(),
  11158. // Number: chrg_bchno,
  11159. // ErrMsg: res.ErrMsg,
  11160. // Status: 1,
  11161. // PatientId: id,
  11162. // RecordTime: recordDateTime,
  11163. // Stage: 7,
  11164. // }
  11165. // service.CreateErrMsgLog(errlog)
  11166. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeRegisterRepeatException)
  11167. // return
  11168. // } else {
  11169. // order, _ := service.GetHisOrderTwo(adminUser.CurrentOrgId, chrg_bchno, id)
  11170. // order.OrderStatus = 1
  11171. // order.MdtrtId = res.Output.Setlinfo.MdtrtID
  11172. // order.SetlId = res.Output.Setlinfo.SetlID
  11173. // order.PsnNo = res.Output.Setlinfo.PsnNo
  11174. // order.PsnName = res.Output.Setlinfo.PsnName
  11175. // order.PsnCertType = res.Output.Setlinfo.PsnCertType
  11176. // order.Certno = res.Output.Setlinfo.Certno
  11177. // order.Gend = res.Output.Setlinfo.Gend
  11178. // order.Naty = res.Output.Setlinfo.Naty
  11179. // order.Age = res.Output.Setlinfo.Age
  11180. // order.Insutype = res.Output.Setlinfo.Insutype
  11181. // order.PsnType = res.Output.Setlinfo.PsnType
  11182. // order.CvlservFlag = res.Output.Setlinfo.CvlservFlag
  11183. // order.SetlTime = res.Output.Setlinfo.SetlTime
  11184. // order.MdtrtCertType = res.Output.Setlinfo.MdtrtCertType
  11185. // order.MedType = res.Output.Setlinfo.MedType
  11186. // order.MedfeeSumamt = res.Output.Setlinfo.MedfeeSumamt
  11187. // order.FulamtOwnpayAmt = res.Output.Setlinfo.FulamtOwnpayAmt
  11188. // order.OverlmtSelfPay = res.Output.Setlinfo.OverlmtSelfpay
  11189. // order.PreselfpayAmt = res.Output.Setlinfo.PreselfpayAmt
  11190. // order.InscpScpAmt = res.Output.Setlinfo.InscpScpAmt
  11191. // order.ActPayDedc = res.Output.Setlinfo.ActPayDedc
  11192. // order.HifpPay = res.Output.Setlinfo.HifpPay
  11193. // order.CvlservPay = res.Output.Setlinfo.CvlservPay
  11194. // order.PoolPropSelfpay = res.Output.Setlinfo.PoolPropSelfpay
  11195. // order.HifesPay = res.Output.Setlinfo.HifesPay
  11196. // order.HifobPay = res.Output.Setlinfo.HifobPay
  11197. // order.MafPay = res.Output.Setlinfo.MafPay
  11198. // order.OthPay = res.Output.Setlinfo.OthPay
  11199. // order.FundPaySumamt = res.Output.Setlinfo.FundPaySumamt
  11200. // order.PsnPartAmt = res.Output.Setlinfo.PsnPartAmt
  11201. // order.AcctPay = res.Output.Setlinfo.AcctPay
  11202. // order.PsnCashPay = res.Output.Setlinfo.PsnCashPay
  11203. // order.HospPartAmt = res.Output.Setlinfo.HospPartAmt
  11204. // order.Balc = res.Output.Setlinfo.Balc
  11205. // order.AcctMulaidPay = res.Output.Setlinfo.AcctMulaidPay
  11206. // order.MedinsSetlId = res.Output.Setlinfo.MedinsSetlID
  11207. // order.ClrOptins = res.Output.Setlinfo.ClrOptins
  11208. // order.ClrWay = res.Output.Setlinfo.ClrWay
  11209. // order.Creator = order.Creator
  11210. // order.Modify = roles.ID
  11211. // setlDetail, _ := json.Marshal(res.Output.Setldetail)
  11212. // detailStr := string(setlDetail)
  11213. // order.SetlDetail = detailStr
  11214. // //err := service.UpdataOrderStatusTwo(chrg_bchno, adminUser.CurrentOrgId)
  11215. // err = service.UpDateOrder(order)
  11216. // if err == nil {
  11217. // c.ServeSuccessJSON(map[string]interface{}{
  11218. // "msg": "预结算成功",
  11219. // })
  11220. // } else {
  11221. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeAmountAccountException)
  11222. // return
  11223. // }
  11224. // }
  11225. // } else {
  11226. // adminUser := c.GetAdminUserInfo()
  11227. // errlog := &models.HisOrderError{
  11228. // UserOrgId: adminUser.CurrentOrgId,
  11229. // Ctime: time.Now().Unix(),
  11230. // Mtime: time.Now().Unix(),
  11231. // ErrMsg: res.ErrMsg,
  11232. // Status: 1,
  11233. // PatientId: id,
  11234. // RecordTime: recordDateTime,
  11235. // Stage: 4,
  11236. // }
  11237. // service.CreateErrMsgLog(errlog)
  11238. //
  11239. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeRegisterRepeatException)
  11240. // return
  11241. // }
  11242. // } else {
  11243. // adminUser := c.GetAdminUserInfo()
  11244. // errlog := &models.HisOrderError{
  11245. // UserOrgId: adminUser.CurrentOrgId,
  11246. // Ctime: time.Now().Unix(),
  11247. // Mtime: time.Now().Unix(),
  11248. // ErrMsg: res.ErrMsg,
  11249. // Status: 1,
  11250. // PatientId: id,
  11251. // RecordTime: recordDateTime,
  11252. // Stage: 4,
  11253. // }
  11254. // service.CreateErrMsgLog(errlog)
  11255. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCalOrderException)
  11256. // return
  11257. // }
  11258. //
  11259. // } else {
  11260. // var total float64
  11261. // for _, item := range prescriptions {
  11262. // if item.Type == 1 { //药品
  11263. // for _, subItem := range item.HisDoctorAdviceInfo {
  11264. // total = total + (subItem.Price * subItem.PrescribingNumber)
  11265. // }
  11266. // }
  11267. // if item.Type == 2 { //项目
  11268. // for _, subItem := range item.HisPrescriptionProject {
  11269. // total = total + (subItem.Price * float64(subItem.Count))
  11270. // }
  11271. // }
  11272. //
  11273. // for _, subItem := range item.HisAdditionalCharge {
  11274. // total = total + (subItem.Price * float64(subItem.Count))
  11275. // }
  11276. // }
  11277. //
  11278. // allTotal := fmt.Sprintf("%.2f", total)
  11279. // totals, _ := strconv.ParseFloat(allTotal, 64)
  11280. // order := &models.HisOrder{
  11281. // UserOrgId: adminUser.CurrentOrgId,
  11282. // HisPatientId: his.ID,
  11283. // PatientId: id,
  11284. // SettleAccountsDate: recordDateTime,
  11285. // Ctime: time.Now().Unix(),
  11286. // Mtime: time.Now().Unix(),
  11287. // Status: 1,
  11288. // OrderStatus: 2,
  11289. // Number: chrg_bchno,
  11290. // MedfeeSumamt: totals,
  11291. // }
  11292. // err = service.CreateOrder(order)
  11293. // if err != nil {
  11294. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCreatePreOrderException)
  11295. // return
  11296. // }
  11297. //
  11298. // var customs []*Custom
  11299. // for _, item := range prescriptions {
  11300. //
  11301. // if item.Type == 1 { //药品
  11302. // for _, subItem := range item.HisDoctorAdviceInfo {
  11303. // cus := &Custom{
  11304. // AdviceId: subItem.ID,
  11305. // ProjectId: 0,
  11306. // DetItemFeeSumamt: fmt.Sprintf("%.2f", subItem.Price*subItem.PrescribingNumber),
  11307. // Cut: fmt.Sprintf("%.2f", subItem.PrescribingNumber),
  11308. // FeedetlSn: subItem.FeedetlSn,
  11309. // Price: fmt.Sprintf("%.2f", subItem.Price),
  11310. // MedListCodg: subItem.MedListCodg,
  11311. // Type: 1,
  11312. // }
  11313. // customs = append(customs, cus)
  11314. // }
  11315. // }
  11316. //
  11317. // if item.Type == 2 { //项目
  11318. // for _, subItem := range item.HisPrescriptionProject {
  11319. //
  11320. // cus := &Custom{
  11321. // AdviceId: 0,
  11322. // ProjectId: subItem.ID,
  11323. // DetItemFeeSumamt: fmt.Sprintf("%.2f", subItem.Price*float64(subItem.Count)),
  11324. // Cut: fmt.Sprintf("%.2f", float64(subItem.Count)),
  11325. // FeedetlSn: subItem.FeedetlSn,
  11326. // Price: fmt.Sprintf("%.2f", float64(subItem.Price)),
  11327. // MedListCodg: subItem.MedListCodg,
  11328. // Type: 2,
  11329. // }
  11330. //
  11331. // customs = append(customs, cus)
  11332. // }
  11333. // }
  11334. //
  11335. // for _, item := range item.HisAdditionalCharge {
  11336. // cus := &Custom{
  11337. // ItemId: item.ID,
  11338. // AdviceId: 0,
  11339. // ProjectId: 0,
  11340. // DetItemFeeSumamt: fmt.Sprintf("%.2f", item.Price),
  11341. // Cut: fmt.Sprintf("%.2f", float64(item.Count)),
  11342. // FeedetlSn: item.FeedetlSn,
  11343. // Price: fmt.Sprintf("%.2f", float64(item.Price)),
  11344. // MedListCodg: item.XtHisAddtionConfig.Code,
  11345. // Type: 3,
  11346. // }
  11347. //
  11348. // customs = append(customs, cus)
  11349. // }
  11350. //
  11351. // }
  11352. //
  11353. // for _, item := range customs {
  11354. // var advice_id int64 = 0
  11355. // var project_id int64 = 0
  11356. // var item_id int64 = 0
  11357. //
  11358. // var types int64 = 0
  11359. //
  11360. // if item.Type == 1 {
  11361. // advice_id = item.AdviceId
  11362. // project_id = 0
  11363. // item_id = 0
  11364. // } else if item.Type == 2 {
  11365. // advice_id = 0
  11366. // item_id = 0
  11367. //
  11368. // project_id = item.ProjectId
  11369. // } else if item.Type == 3 {
  11370. // advice_id = 0
  11371. // item_id = item.ItemId
  11372. // project_id = 0
  11373. // }
  11374. //
  11375. // detItemFeeSumamt, _ := strconv.ParseFloat(item.DetItemFeeSumamt, 32)
  11376. // cut, _ := strconv.ParseFloat(item.Cut, 32)
  11377. // pric, _ := strconv.ParseFloat(item.Price, 32)
  11378. //
  11379. // info := &models.HisOrderInfo{
  11380. // OrderNumber: order.Number,
  11381. // UploadDate: time.Now().Unix(),
  11382. // AdviceId: advice_id,
  11383. // DetItemFeeSumamt: detItemFeeSumamt,
  11384. // Cnt: cut,
  11385. // Pric: pric,
  11386. // PatientId: id,
  11387. // Status: 1,
  11388. // Mtime: time.Now().Unix(),
  11389. // Ctime: time.Now().Unix(),
  11390. // UserOrgId: adminUser.CurrentOrgId,
  11391. // HisPatientId: his.ID,
  11392. // OrderId: order.ID,
  11393. // ProjectId: project_id,
  11394. // Type: types,
  11395. // ItemId: item_id,
  11396. // }
  11397. // service.CreateOrderInfo(info)
  11398. // }
  11399. // //err := service.UpDateAddtionNumber(adminUser.CurrentOrgId, ids, chrg_bchno)
  11400. // err = service.UpDatePrescriptionNumber(adminUser.CurrentOrgId, ids, chrg_bchno)
  11401. // err = service.UpDatePrescriptionInfoNumber(adminUser.CurrentOrgId, id, chrg_bchno, recordDateTime)
  11402. // err = service.UpdataOrderStatusTwo(chrg_bchno, adminUser.CurrentOrgId)
  11403. // if err == nil {
  11404. // c.ServeSuccessJSON(map[string]interface{}{
  11405. // "msg": "结算成功",
  11406. // })
  11407. // } else {
  11408. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeAmountAccountException)
  11409. // return
  11410. // }
  11411. // }
  11412. //}
  11413. // 上传明细-预结算-
  11414. func (c *HisApiController) GetPreUploadInfo() {
  11415. id, _ := c.GetInt64("id")
  11416. record_time := c.GetString("record_time")
  11417. his_patient_id, _ := c.GetInt64("his_patient_id")
  11418. settle_accounts_type, _ := c.GetInt64("settle_accounts_type")
  11419. admin_user_id, _ := c.GetInt64("admin_user_id")
  11420. diagnosis_id := c.GetString("diagnosis")
  11421. sick_type, _ := c.GetInt64("sick_type")
  11422. reg_type, _ := c.GetInt64("p_type")
  11423. begin_time := c.GetString("begin_time")
  11424. acct_used_flag := c.GetString("acct_used_flag")
  11425. id_str := c.GetString("ids")
  11426. ids_arr := strings.Split(id_str, ",")
  11427. timeLayout := "2006-01-02"
  11428. loc, _ := time.LoadLocation("Local")
  11429. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  11430. if err != nil {
  11431. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  11432. return
  11433. }
  11434. recordDateTime := theTime.Unix()
  11435. adminUser := c.GetAdminUserInfo()
  11436. diagnosis_ids := strings.Split(diagnosis_id, ",")
  11437. var config []*models.HisXtDiagnoseConfig
  11438. for _, item := range diagnosis_ids {
  11439. id, _ := strconv.ParseInt(item, 10, 64)
  11440. diagnosisConfig, _ := service.FindDiagnoseById(id)
  11441. config = append(config, &diagnosisConfig)
  11442. }
  11443. //diagnosisConfig, _ := service.FindDiagnoseById(diagnosis_id)
  11444. sickConfig, _ := service.FindSickById(sick_type)
  11445. var prescriptions []*models.HisPrescription
  11446. var start_time int64
  11447. var end_time int64
  11448. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  11449. fmt.Println(his_patient_id)
  11450. his, _ := service.GetNewHisPatientInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  11451. timestamp := time.Now().Unix()
  11452. tempTime := time.Unix(timestamp, 0)
  11453. timeFormat := tempTime.Format("20060102150405")
  11454. chrgBchno := rand.Intn(100000) + 10000
  11455. chrg_bchno := timeFormat + strconv.FormatInt(int64(chrgBchno), 10) + strconv.FormatInt(his.PatientId, 10)
  11456. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  11457. var patientPrescription models.HisPrescriptionInfo
  11458. patientPrescription, _ = service.FindHisPatientPrescriptionInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  11459. if patientPrescription.ID == 0 {
  11460. patientPrescription, _ = service.FindLastPatientPrescriptionInfo(adminUser.CurrentOrgId, id, recordDateTime)
  11461. }
  11462. //miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  11463. department, _ := service.GetDepartMentDetail(patientPrescription.Departments)
  11464. doctor_info, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, patientPrescription.DoctorId)
  11465. strconv.FormatInt(his.PatientId, 10)
  11466. var res2 ResultSix
  11467. var resSix10265 ResultSix10265
  11468. //var time_stamp string
  11469. if miConfig.MdtrtareaAdmvs == "421300" {
  11470. data := make(map[string]interface{})
  11471. client := &http.Client{}
  11472. data["psn_no"] = his.PsnNo
  11473. data["mdtrt_id"] = his.Number
  11474. data["department"] = department.Name
  11475. data["org_name"] = miConfig.OrgName
  11476. data["med_type"] = strconv.FormatInt(reg_type, 10)
  11477. data["doctor_id"] = doctor_info.DoctorNumber
  11478. data["doctor_name"] = roles.UserName
  11479. data["fixmedins_code"] = miConfig.Code
  11480. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  11481. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  11482. data["secret_key"] = miConfig.SecretKey
  11483. data["sick_code"] = sickConfig.CountryCode
  11484. data["sick_name"] = sickConfig.ClassName
  11485. data["begin_time"] = begin_time
  11486. data["dept"] = strconv.FormatInt(department.ID, 10)
  11487. data["config"] = config
  11488. data["opter"] = roles.UserName
  11489. fmt.Println(data)
  11490. bytesData, _ := json.Marshal(data)
  11491. req, _ := http.NewRequest("POST", "http://192.168.124.4:9532/"+"hbyb/2203", bytes.NewReader(bytesData))
  11492. resp, _ := client.Do(req)
  11493. defer resp.Body.Close()
  11494. body, ioErr := ioutil.ReadAll(resp.Body)
  11495. if ioErr != nil {
  11496. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  11497. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11498. return
  11499. }
  11500. var respJSON map[string]interface{}
  11501. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  11502. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  11503. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11504. return
  11505. }
  11506. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  11507. userJSONBytes, _ := json.Marshal(respJSON)
  11508. fmt.Println("log")
  11509. fmt.Println(string(userJSONBytes))
  11510. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  11511. utils.ErrorLog("解析失败:%v", err)
  11512. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11513. return
  11514. }
  11515. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  11516. data := make(map[string]interface{})
  11517. client := &http.Client{}
  11518. data["psn_no"] = his.PsnNo
  11519. data["mdtrt_id"] = his.Number
  11520. data["doctor"] = roles.UserName
  11521. data["department"] = department.Name
  11522. data["org_name"] = miConfig.OrgName
  11523. data["med_type"] = strconv.FormatInt(reg_type, 10)
  11524. data["doctor_id"] = strconv.FormatInt(doctor_info.AdminUserId, 10)
  11525. data["fixmedins_code"] = miConfig.Code
  11526. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  11527. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  11528. data["secret_key"] = miConfig.SecretKey
  11529. data["sick_code"] = sickConfig.CountryCode
  11530. data["sick_name"] = sickConfig.ClassName
  11531. data["begin_time"] = begin_time
  11532. data["dept"] = strconv.FormatInt(department.ID, 10)
  11533. data["config"] = config
  11534. data["url"] = miConfig.Url
  11535. data["ak"] = miConfig.AccessKey
  11536. data["cainfo"] = miConfig.Cainfo
  11537. bytesData, _ := json.Marshal(data)
  11538. var req *http.Request
  11539. if miConfig.MdtrtareaAdmvs == "320921" {
  11540. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/2203", bytes.NewReader(bytesData))
  11541. } else {
  11542. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2203", bytes.NewReader(bytesData))
  11543. }
  11544. resp, _ := client.Do(req)
  11545. defer resp.Body.Close()
  11546. body, ioErr := ioutil.ReadAll(resp.Body)
  11547. if ioErr != nil {
  11548. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  11549. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11550. return
  11551. }
  11552. var respJSON map[string]interface{}
  11553. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  11554. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  11555. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11556. return
  11557. }
  11558. //time_stamp := strconv.FormatInt(int64(respJSON["data"].(map[string]interface{})["time_stamp"].(float64)), 10)
  11559. //fmt.Println(respJSON["data"].(map[string]interface{})["time_stamp"].(string))
  11560. //time_stamp = respJSON["data"].(map[string]interface{})["time_stamp"].(string)
  11561. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  11562. userJSONBytes, _ := json.Marshal(respJSON)
  11563. fmt.Println("log")
  11564. fmt.Println(string(userJSONBytes))
  11565. if err := json.Unmarshal(userJSONBytes, &resSix10265); err != nil {
  11566. utils.ErrorLog("解析失败:%v", err)
  11567. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11568. return
  11569. }
  11570. res2.InfRefmsgid = resSix10265.InfRefmsgid
  11571. res2.Output = resSix10265.Output
  11572. res2.ErrMsg = resSix10265.ErrMsg
  11573. res2.Cainfo = resSix10265.Cainfo
  11574. res2.WarnMsg = resSix10265.WarnMsg
  11575. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  11576. res2.Infcode = infocode
  11577. } else if miConfig.MdtrtareaAdmvs == "350500" {
  11578. 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)
  11579. saveLog(result, requestLog, "2203", "上传就诊信息")
  11580. var respJSON2 map[string]interface{}
  11581. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  11582. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  11583. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11584. return
  11585. }
  11586. userJSONBytes2, _ := json.Marshal(respJSON2)
  11587. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  11588. utils.ErrorLog("解析失败:%v", err)
  11589. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11590. return
  11591. }
  11592. } else if miConfig.MdtrtareaAdmvs == "360399" {
  11593. var result string
  11594. var requestLog string
  11595. 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, "")
  11596. saveLog(result, requestLog, "2203", "上传就诊信息")
  11597. var respJSON2 map[string]interface{}
  11598. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  11599. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  11600. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11601. return
  11602. }
  11603. userJSONBytes2, _ := json.Marshal(respJSON2)
  11604. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  11605. utils.ErrorLog("解析失败:%v", err)
  11606. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11607. return
  11608. }
  11609. } else if miConfig.MdtrtareaAdmvs == "430800" {
  11610. var result string
  11611. var requestLog string
  11612. 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, "")
  11613. saveLog(result, requestLog, "2203", "上传就诊信息")
  11614. var respJSON2 map[string]interface{}
  11615. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  11616. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  11617. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11618. return
  11619. }
  11620. userJSONBytes2, _ := json.Marshal(respJSON2)
  11621. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  11622. utils.ErrorLog("解析失败:%v", err)
  11623. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11624. return
  11625. }
  11626. } else {
  11627. var result string
  11628. var requestLog string
  11629. if miConfig.MdtrtareaAdmvs == "440781" { //
  11630. 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)
  11631. } else {
  11632. if miConfig.Code == "H15049901371" {
  11633. //赤峰地区国家医保医疗类别
  11634. //职工透析:医疗类别选特殊情况门诊990502
  11635. //居民定额血透门慢: 医疗类别选门诊慢病140104
  11636. var med_type string
  11637. if his.Insutype == "390" {
  11638. if reg_type == 14 {
  11639. med_type = "9933"
  11640. } else if reg_type == 11 {
  11641. med_type = "11"
  11642. }
  11643. } else if his.Insutype == "310" {
  11644. if reg_type == 14 {
  11645. med_type = "990502"
  11646. } else if reg_type == 11 {
  11647. med_type = "11"
  11648. }
  11649. }
  11650. 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)
  11651. } else {
  11652. 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)
  11653. }
  11654. saveLog(result, requestLog, "2203", "上传就诊信息")
  11655. var respJSON2 map[string]interface{}
  11656. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  11657. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  11658. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11659. return
  11660. }
  11661. userJSONBytes2, _ := json.Marshal(respJSON2)
  11662. if miConfig.Code == "H15049901371" {
  11663. if err := json.Unmarshal(userJSONBytes2, &resSix10265); err != nil {
  11664. utils.ErrorLog("解析失败:%v", err)
  11665. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11666. return
  11667. }
  11668. res2.InfRefmsgid = resSix10265.InfRefmsgid
  11669. res2.Output = resSix10265.Output
  11670. res2.ErrMsg = resSix10265.ErrMsg
  11671. res2.Cainfo = resSix10265.Cainfo
  11672. res2.WarnMsg = resSix10265.WarnMsg
  11673. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  11674. res2.Infcode = infocode
  11675. } else {
  11676. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  11677. utils.ErrorLog("解析失败:%v", err)
  11678. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11679. return
  11680. }
  11681. }
  11682. }
  11683. }
  11684. if res2.Infcode != 0 {
  11685. adminUser := c.GetAdminUserInfo()
  11686. errlog := &models.HisOrderError{
  11687. UserOrgId: adminUser.CurrentOrgId,
  11688. Ctime: time.Now().Unix(),
  11689. Mtime: time.Now().Unix(),
  11690. ErrMsg: res2.ErrMsg,
  11691. Status: 1,
  11692. PatientId: id,
  11693. RecordTime: recordDateTime,
  11694. Stage: 3,
  11695. }
  11696. service.CreateErrMsgLog(errlog)
  11697. c.ServeSuccessJSON(map[string]interface{}{
  11698. "failed_code": -10,
  11699. "msg": res2.ErrMsg,
  11700. })
  11701. return
  11702. } else {
  11703. his.Diagnosis = diagnosis_id
  11704. his.SickType = sickConfig.ID
  11705. his.PType = fmt.Sprintf("%d", reg_type)
  11706. service.UpdateHisPatientThree(&his)
  11707. data := make(map[string]interface{})
  11708. if settle_accounts_type == 1 { //日结
  11709. if reg_type == 11 || reg_type == 1111 || reg_type == 1112 {
  11710. prescriptions, _ = service.GetPrescriptionByIds(ids_arr, adminUser.CurrentOrgId)
  11711. } else {
  11712. prescriptions, _ = service.GetNewHisPrescription(adminUser.CurrentOrgId, his_patient_id, recordDateTime, strconv.Itoa(int(reg_type)))
  11713. }
  11714. data["pre"] = prescriptions
  11715. } else { //月结
  11716. start_time_str := c.GetString("start_time")
  11717. end_time_str := c.GetString("end_time")
  11718. timeLayout := "2006-01-02"
  11719. loc, _ := time.LoadLocation("Local")
  11720. theStartTime, err := time.ParseInLocation(timeLayout+" 15:04:05", start_time_str+" 00:00:00", loc)
  11721. if err != nil {
  11722. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  11723. return
  11724. }
  11725. recordStartTime := theStartTime.Unix()
  11726. start_time = recordStartTime
  11727. theEndTime, err := time.ParseInLocation(timeLayout+" 15:04:05", end_time_str+" 00:00:00", loc)
  11728. if err != nil {
  11729. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  11730. return
  11731. }
  11732. recordEndTime := theEndTime.Unix()
  11733. end_time = recordEndTime
  11734. prescriptions, _ = service.GetMonthHisPrescriptionTwo(adminUser.CurrentOrgId, id, recordStartTime, recordEndTime, reg_type)
  11735. data["pre"] = prescriptions
  11736. }
  11737. client := &http.Client{}
  11738. data["psn_no"] = his.PsnNo
  11739. data["mdtrt_id"] = his.Number
  11740. data["chrg_bchno"] = chrg_bchno
  11741. data["org_name"] = miConfig.OrgName
  11742. data["doctor"] = doctor_info.UserName
  11743. data["doctor_id"] = doctor_info.DoctorNumber
  11744. data["dept"] = department.Name
  11745. data["fixmedins_code"] = miConfig.Code
  11746. data["opter"] = roles.UserName
  11747. data["dept_code"] = department.Number
  11748. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  11749. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  11750. data["secret_key"] = miConfig.SecretKey
  11751. data["balance_accounts_type"] = strconv.FormatInt(his.BalanceAccountsType, 10)
  11752. data["url"] = miConfig.Url
  11753. data["ak"] = miConfig.AccessKey
  11754. data["new_doctor_name"] = patientPrescription.Doctor
  11755. data["diag_code"] = sickConfig.CountryCode
  11756. data["cainfo"] = miConfig.Cainfo
  11757. data["opter"] = roles.UserName
  11758. var ids []int64
  11759. for _, item := range prescriptions {
  11760. ids = append(ids, item.ID)
  11761. }
  11762. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  11763. if config.IsOpen == 1 { //对接了医保,走医保流程
  11764. var res ResultFour
  11765. var resFour10265 ResultFour10265
  11766. if miConfig.MdtrtareaAdmvs == "421300" {
  11767. bytesData, _ := json.Marshal(data)
  11768. req, _ := http.NewRequest("POST", "http://192.168.124.4:9532/"+"hbyb/2204", bytes.NewReader(bytesData))
  11769. resp, _ := client.Do(req)
  11770. defer resp.Body.Close()
  11771. body, ioErr := ioutil.ReadAll(resp.Body)
  11772. if ioErr != nil {
  11773. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  11774. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11775. return
  11776. }
  11777. var respJSON map[string]interface{}
  11778. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  11779. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  11780. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11781. return
  11782. }
  11783. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  11784. userJSONBytes, _ := json.Marshal(respJSON)
  11785. fmt.Println("log")
  11786. fmt.Println(string(userJSONBytes))
  11787. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  11788. utils.ErrorLog("解析失败:%v", err)
  11789. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11790. return
  11791. }
  11792. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  11793. result3101 := Check3101(c, id, his_patient_id, admin_user_id, "2", record_time, prescriptions)
  11794. if result3101.Infcode == "0" {
  11795. if len(result3101.Output.Result) > 0 {
  11796. var errMsgs []string
  11797. for _, item := range result3101.Output.Result {
  11798. errMsgs = append(errMsgs, item.VolaCont)
  11799. }
  11800. c.ServeSuccessJSON(map[string]interface{}{
  11801. "failed_code": -10,
  11802. "msg": errMsgs,
  11803. })
  11804. return
  11805. } else {
  11806. if miConfig.MdtrtareaAdmvs == "320921" {
  11807. data["doctor_id"] = "D320923012139"
  11808. } else {
  11809. data["doctor_id"] = "D371621008686"
  11810. }
  11811. bytesData, _ := json.Marshal(data)
  11812. var req *http.Request
  11813. if miConfig.MdtrtareaAdmvs == "320921" {
  11814. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  11815. } else {
  11816. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  11817. }
  11818. resp, _ := client.Do(req)
  11819. defer resp.Body.Close()
  11820. body, ioErr := ioutil.ReadAll(resp.Body)
  11821. if ioErr != nil {
  11822. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  11823. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11824. return
  11825. }
  11826. var respJSON map[string]interface{}
  11827. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  11828. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  11829. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11830. return
  11831. }
  11832. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  11833. userJSONBytes, _ := json.Marshal(respJSON)
  11834. fmt.Println("log")
  11835. fmt.Println(string(userJSONBytes))
  11836. if err := json.Unmarshal(userJSONBytes, &resFour10265); err != nil {
  11837. utils.ErrorLog("解析失败:%v", err)
  11838. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11839. return
  11840. }
  11841. res.InfRefmsgid = resFour10265.InfRefmsgid
  11842. res.Output = resFour10265.Output
  11843. res.ErrMsg = resFour10265.ErrMsg
  11844. res.Cainfo = resFour10265.Cainfo
  11845. res.WarnMsg = resFour10265.WarnMsg
  11846. infocode, _ := strconv.ParseInt(resFour10265.Infcode, 10, 64)
  11847. res.Infcode = infocode
  11848. }
  11849. }
  11850. } else if miConfig.MdtrtareaAdmvs == "350500" {
  11851. 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)
  11852. var dat map[string]interface{}
  11853. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  11854. fmt.Println(dat)
  11855. } else {
  11856. fmt.Println(err)
  11857. }
  11858. saveLog(result, request_log, "2204", "上传费用明细")
  11859. userJSONBytes, _ := json.Marshal(dat)
  11860. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  11861. utils.ErrorLog("解析失败:%v", err)
  11862. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11863. return
  11864. }
  11865. } else if miConfig.MdtrtareaAdmvs == "360399" {
  11866. 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, "", "")
  11867. var dat map[string]interface{}
  11868. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  11869. fmt.Println(dat)
  11870. } else {
  11871. fmt.Println(err)
  11872. }
  11873. saveLog(result, request_log, "2204", "上传费用明细")
  11874. userJSONBytes, _ := json.Marshal(dat)
  11875. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  11876. utils.ErrorLog("解析失败:%v", err)
  11877. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11878. return
  11879. }
  11880. } else if miConfig.MdtrtareaAdmvs == "430800" {
  11881. 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, "", "")
  11882. var dat map[string]interface{}
  11883. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  11884. fmt.Println(dat)
  11885. } else {
  11886. fmt.Println(err)
  11887. }
  11888. saveLog(result, request_log, "2204", "上传费用明细")
  11889. userJSONBytes, _ := json.Marshal(dat)
  11890. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  11891. utils.ErrorLog("解析失败:%v", err)
  11892. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11893. return
  11894. }
  11895. } else {
  11896. if miConfig.Code == "H15049901371" {
  11897. 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)
  11898. var dat map[string]interface{}
  11899. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  11900. fmt.Println(dat)
  11901. } else {
  11902. fmt.Println(err)
  11903. }
  11904. saveLog(result, request_log, "2204", "上传费用明细")
  11905. userJSONBytes, _ := json.Marshal(dat)
  11906. if err := json.Unmarshal(userJSONBytes, &resFour10265); err != nil {
  11907. utils.ErrorLog("解析失败:%v", err)
  11908. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11909. return
  11910. }
  11911. res.InfRefmsgid = resFour10265.InfRefmsgid
  11912. res.Output = resFour10265.Output
  11913. res.ErrMsg = resFour10265.ErrMsg
  11914. res.Cainfo = resFour10265.Cainfo
  11915. res.WarnMsg = resFour10265.WarnMsg
  11916. infocode, _ := strconv.ParseInt(resFour10265.Infcode, 10, 64)
  11917. res.Infcode = infocode
  11918. } else {
  11919. 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)
  11920. var dat map[string]interface{}
  11921. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  11922. fmt.Println(dat)
  11923. } else {
  11924. fmt.Println(err)
  11925. }
  11926. saveLog(result, request_log, "2204", "上传费用明细")
  11927. userJSONBytes, _ := json.Marshal(dat)
  11928. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  11929. utils.ErrorLog("解析失败:%v", err)
  11930. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11931. return
  11932. }
  11933. }
  11934. }
  11935. var total_two float64
  11936. if res.Infcode == 0 {
  11937. order := &models.HisOrder{
  11938. UserOrgId: adminUser.CurrentOrgId,
  11939. HisPatientId: his.ID,
  11940. PatientId: his.PatientId,
  11941. SettleAccountsDate: recordDateTime,
  11942. Ctime: time.Now().Unix(),
  11943. Mtime: time.Now().Unix(),
  11944. MdtrtId: his.Number,
  11945. PsnNo: his.PsnNo,
  11946. MedType: strconv.FormatInt(reg_type, 10),
  11947. Status: 1,
  11948. Number: chrg_bchno,
  11949. Infcode: res.Infcode,
  11950. WarnMsg: res.WarnMsg,
  11951. Cainfo: res.Cainfo,
  11952. ErrMsg: res.ErrMsg,
  11953. RespondTime: res.RefmsgTime,
  11954. InfRefmsgid: res.InfRefmsgid,
  11955. OrderStatus: 1,
  11956. IsMedicineInsurance: 1,
  11957. SettleType: settle_accounts_type,
  11958. SettleStartTime: start_time,
  11959. SettleEndTime: end_time,
  11960. Creator: roles.AdminUserId,
  11961. Modify: roles.AdminUserId,
  11962. PType: 2,
  11963. Diagnosis: diagnosis_id,
  11964. }
  11965. err = service.CreateOrder(order)
  11966. if err != nil {
  11967. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCreatePreOrderException)
  11968. return
  11969. }
  11970. for _, item := range res.Output.Result {
  11971. temp := strings.Split(item.FeedetlSn, "-")
  11972. var advice_id int64 = 0
  11973. var project_id int64 = 0
  11974. var types int64 = 0
  11975. id, _ := strconv.ParseInt(temp[2], 10, 64)
  11976. types, _ = strconv.ParseInt(temp[1], 10, 64)
  11977. if temp[1] == "1" {
  11978. advice_id = id
  11979. project_id = 0
  11980. } else if temp[1] == "2" {
  11981. advice_id = 0
  11982. project_id = id
  11983. }
  11984. total_two = total_two + item.DetItemFeeSumamt
  11985. info := &models.HisOrderInfo{
  11986. OrderNumber: order.Number,
  11987. FeedetlSn: item.FeedetlSn,
  11988. UploadDate: time.Now().Unix(),
  11989. AdviceId: advice_id,
  11990. DetItemFeeSumamt: item.DetItemFeeSumamt,
  11991. Cnt: item.Cnt,
  11992. Pric: float64(item.Pric),
  11993. PatientId: his.PatientId,
  11994. PricUplmtAmt: item.PricUplmtAmt,
  11995. SelfpayProp: item.SelfpayProp,
  11996. FulamtOwnpayAmt: item.FulamtOwnpayAmt,
  11997. OverlmtAmt: item.OverlmtAmt,
  11998. PreselfpayAmt: item.PreselfpayAmt,
  11999. BasMednFlag: item.BasMednFlag,
  12000. MedChrgitmType: item.MedChrgitmType,
  12001. HiNegoDrugFlag: item.HiNegoDrugFlag,
  12002. Status: 1,
  12003. Memo: item.Memo,
  12004. Mtime: time.Now().Unix(),
  12005. InscpScpAmt: item.InscpScpAmt,
  12006. DrtReimFlag: item.DrtReimFlag,
  12007. Ctime: time.Now().Unix(),
  12008. ListSpItemFlag: item.ListSpItemFlag,
  12009. ChldMedcFlag: item.ChldMedcFlag,
  12010. LmtUsedFlag: item.LmtUsedFlag,
  12011. ChrgitmLv: item.ChrgitmLv,
  12012. UserOrgId: adminUser.CurrentOrgId,
  12013. HisPatientId: his.ID,
  12014. OrderId: order.ID,
  12015. ProjectId: project_id,
  12016. Type: types,
  12017. }
  12018. service.CreateOrderInfo(info)
  12019. }
  12020. service.UpDatePrescriptionNumber(adminUser.CurrentOrgId, ids, chrg_bchno)
  12021. service.UpDateHisPrescriptionInfoNumber(adminUser.CurrentOrgId, his_patient_id, chrg_bchno, recordDateTime)
  12022. var total float64
  12023. for _, item := range prescriptions {
  12024. if item.Type == 1 { //药品
  12025. for _, subItem := range item.HisDoctorAdviceInfo {
  12026. price, _ := strconv.ParseFloat(fmt.Sprintf("%.2f", subItem.Price), 64)
  12027. total_one := price * subItem.PrescribingNumber
  12028. fmt.Println("subItem")
  12029. fmt.Println(subItem.Price)
  12030. fmt.Println("price")
  12031. fmt.Println(price)
  12032. fmt.Println("total_one")
  12033. fmt.Println(total_one)
  12034. total = total + total_one
  12035. fmt.Println(total)
  12036. }
  12037. }
  12038. if item.Type == 2 { //项目
  12039. for _, subItem := range item.HisPrescriptionProject {
  12040. cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  12041. price, _ := strconv.ParseFloat(fmt.Sprintf("%.2f", subItem.Price), 64)
  12042. total_one := price * cnt
  12043. total = total + total_one
  12044. }
  12045. }
  12046. }
  12047. allTotal := fmt.Sprintf("%2f", total)
  12048. if res.Infcode == 0 {
  12049. var rf []*ResultFive
  12050. json.Unmarshal([]byte(his.Iinfo), &rf)
  12051. chrg_bchno := chrg_bchno
  12052. cert_no := his.Certno
  12053. var insutypes []string
  12054. var insutype string
  12055. var is390 int = 0
  12056. var is310 int = 0
  12057. for _, item := range rf {
  12058. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  12059. insutypes = append(insutypes, item.Insutype)
  12060. }
  12061. }
  12062. if len(insutypes) == 1 {
  12063. insutype = insutypes[0]
  12064. } else {
  12065. for _, i := range insutypes {
  12066. if i == "390" {
  12067. is390 = 1
  12068. }
  12069. if i == "310" {
  12070. is310 = 1
  12071. }
  12072. }
  12073. }
  12074. if is390 == 1 {
  12075. insutype = "390"
  12076. }
  12077. if is310 == 1 {
  12078. insutype = "310"
  12079. }
  12080. if len(insutypes) == 0 {
  12081. insutype = "390"
  12082. }
  12083. if len(insutypes) == 2 {
  12084. insutype = strconv.FormatInt(his.SocialType, 10)
  12085. }
  12086. //insutype = "390"
  12087. if his.IdCardType == 1 {
  12088. cert_no = his.MedicalInsuranceNumber
  12089. } else {
  12090. cert_no = his.Certno
  12091. }
  12092. var res ResultSeven
  12093. var resSeven10265 ResultSeven10265
  12094. if miConfig.MdtrtareaAdmvs == "421300" {
  12095. api := "http://192.168.124.4:9532/" + "hbyb/2206?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  12096. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  12097. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  12098. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  12099. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  12100. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  12101. "&insutype=" + insutype + "&total=" + allTotal + "&med_type=" + strconv.FormatInt(reg_type, 10)
  12102. resp, requestErr := http.Get(api)
  12103. if requestErr != nil {
  12104. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12105. return
  12106. }
  12107. body, ioErr := ioutil.ReadAll(resp.Body)
  12108. if ioErr != nil {
  12109. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  12110. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12111. return
  12112. }
  12113. var respJSON map[string]interface{}
  12114. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  12115. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  12116. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12117. return
  12118. }
  12119. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  12120. result, _ := json.Marshal(respJSON)
  12121. fmt.Println("log")
  12122. fmt.Println(string(result))
  12123. if err := json.Unmarshal([]byte(result), &res); err != nil {
  12124. utils.ErrorLog("解析失败:%v", err)
  12125. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12126. return
  12127. }
  12128. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  12129. result3101 := Check3102(c, id, his_patient_id, admin_user_id, "6", order.ID)
  12130. if result3101.Infcode == "0" {
  12131. if len(result3101.Output.Result) > 0 {
  12132. var errMsgs []string
  12133. for _, item := range result3101.Output.Result {
  12134. errMsgs = append(errMsgs, item.VolaCont)
  12135. }
  12136. c.ServeSuccessJSON(map[string]interface{}{
  12137. "failed_code": -10,
  12138. "msg": errMsgs,
  12139. })
  12140. return
  12141. } else {
  12142. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  12143. if his.IdCardType != 4 {
  12144. psn_info.VerifyNumber = strings.Replace(psn_info.VerifyNumber, "+", "%2B", -1)
  12145. bas := strings.Split(psn_info.CardInfo, "|")
  12146. if his.IdCardType == 1 {
  12147. cert_no = bas[2]
  12148. } else {
  12149. cert_no = bas[1]
  12150. }
  12151. } else {
  12152. cert_no = his.Certno
  12153. }
  12154. //江苏地区国家医保医疗类别
  12155. //职工透析:医疗类别选特殊情况门诊9933
  12156. //居民血透门慢: 医疗类别选门诊慢病1402
  12157. //var med_type string
  12158. //if his.Insutype == "310" {
  12159. // if reg_type == 14 {
  12160. // med_type = "9933"
  12161. // } else if reg_type == 11 {
  12162. // med_type = "11"
  12163. //
  12164. // }
  12165. //} else if his.Insutype == "390" {
  12166. // if reg_type == 14 {
  12167. // med_type = "1402"
  12168. // } else if reg_type == 11 {
  12169. // med_type = "11"
  12170. // }
  12171. //}
  12172. var api string
  12173. if miConfig.MdtrtareaAdmvs == "320921" {
  12174. api = "http://192.168.2.3:9532/" + "jsyb/2206?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  12175. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  12176. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  12177. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  12178. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  12179. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  12180. "&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
  12181. //req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  12182. } else {
  12183. //req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  12184. api = "http://192.168.5.251:9532/" + "jsyb/2206?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  12185. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  12186. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  12187. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  12188. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  12189. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  12190. "&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
  12191. }
  12192. resp, requestErr := http.Get(api)
  12193. if requestErr != nil {
  12194. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12195. return
  12196. }
  12197. body, ioErr := ioutil.ReadAll(resp.Body)
  12198. if ioErr != nil {
  12199. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  12200. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12201. return
  12202. }
  12203. var respJSON map[string]interface{}
  12204. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  12205. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  12206. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12207. return
  12208. }
  12209. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  12210. result, _ := json.Marshal(respJSON)
  12211. fmt.Println("log")
  12212. fmt.Println(string(result))
  12213. if err := json.Unmarshal([]byte(result), &resSeven10265); err != nil {
  12214. utils.ErrorLog("解析失败:%v", err)
  12215. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12216. return
  12217. }
  12218. res.InfRefmsgid = resSeven10265.InfRefmsgid
  12219. res.Output = resSeven10265.Output
  12220. res.ErrMsg = resSeven10265.ErrMsg
  12221. res.Cainfo = resSeven10265.Cainfo
  12222. res.WarnMsg = resSeven10265.WarnMsg
  12223. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  12224. res.Infcode = infocode
  12225. }
  12226. }
  12227. } else if miConfig.MdtrtareaAdmvs == "350500" {
  12228. acct_used_flag := "1"
  12229. psn_info, _ := service.GetPsnByPatientIdTwo(his.PatientId)
  12230. var result string
  12231. var request_log string
  12232. if his.IdCardType == 4 && len(psn_info.VerifyNumber) > 0 {
  12233. 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)
  12234. } else {
  12235. 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)
  12236. }
  12237. var dat map[string]interface{}
  12238. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  12239. fmt.Println(dat)
  12240. } else {
  12241. fmt.Println(err)
  12242. }
  12243. saveLog(result, request_log, "2206", "预结算")
  12244. userJSONBytes, _ := json.Marshal(dat)
  12245. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  12246. utils.ErrorLog("解析失败:%v", err)
  12247. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12248. return
  12249. }
  12250. } else if miConfig.MdtrtareaAdmvs == "360399" {
  12251. var result string
  12252. var request_log string
  12253. if his.IdCardType == 2 {
  12254. 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, "")
  12255. } else if his.IdCardType == 1 {
  12256. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  12257. bas := strings.Split(psn_info.CardInfo, "|")
  12258. basNumber := bas[2]
  12259. card_sn := bas[3]
  12260. 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)
  12261. } else {
  12262. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  12263. 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, "")
  12264. }
  12265. var dat map[string]interface{}
  12266. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  12267. fmt.Println(dat)
  12268. } else {
  12269. fmt.Println(err)
  12270. }
  12271. saveLog(result, request_log, "2206", "预结算")
  12272. userJSONBytes, _ := json.Marshal(dat)
  12273. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  12274. utils.ErrorLog("解析失败:%v", err)
  12275. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12276. return
  12277. }
  12278. } else if miConfig.MdtrtareaAdmvs == "430800" {
  12279. var result string
  12280. var request_log string
  12281. if his.IdCardType == 2 {
  12282. 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")
  12283. } else if his.IdCardType == 1 {
  12284. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  12285. bas := strings.Split(psn_info.CardInfo, "|")
  12286. basNumber := bas[2]
  12287. card_sn := bas[3]
  12288. 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")
  12289. } else {
  12290. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  12291. 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")
  12292. }
  12293. var dat map[string]interface{}
  12294. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  12295. fmt.Println(dat)
  12296. } else {
  12297. fmt.Println(err)
  12298. }
  12299. saveLog(result, request_log, "2206", "预结算")
  12300. userJSONBytes, _ := json.Marshal(dat)
  12301. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  12302. utils.ErrorLog("解析失败:%v", err)
  12303. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12304. return
  12305. }
  12306. } else {
  12307. var result string
  12308. var request_log string
  12309. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  12310. allTotal = fmt.Sprintf("%2f", total_two)
  12311. if his.IdCardType == 4 {
  12312. 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)
  12313. } else {
  12314. 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)
  12315. }
  12316. var dat map[string]interface{}
  12317. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  12318. fmt.Println(dat)
  12319. } else {
  12320. fmt.Println(err)
  12321. }
  12322. saveLog(result, request_log, "2206", "预结算")
  12323. //userJSONBytes, _ := json.Marshal(dat)
  12324. //
  12325. //if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  12326. // utils.ErrorLog("解析失败:%v", err)
  12327. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12328. // return
  12329. //}
  12330. userJSONBytes, _ := json.Marshal(dat)
  12331. if miConfig.Code == "H15049901371" {
  12332. if err := json.Unmarshal(userJSONBytes, &resSeven10265); err != nil {
  12333. utils.ErrorLog("解析失败:%v", err)
  12334. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12335. return
  12336. }
  12337. res.InfRefmsgid = resSeven10265.InfRefmsgid
  12338. res.Output = resSeven10265.Output
  12339. res.ErrMsg = resSeven10265.ErrMsg
  12340. res.Cainfo = resSeven10265.Cainfo
  12341. res.WarnMsg = resSeven10265.WarnMsg
  12342. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  12343. res.Infcode = infocode
  12344. } else {
  12345. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  12346. utils.ErrorLog("解析失败:%v", err)
  12347. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12348. return
  12349. }
  12350. }
  12351. }
  12352. if res.Infcode != 0 {
  12353. errlog := &models.HisOrderError{
  12354. UserOrgId: adminUser.CurrentOrgId,
  12355. Ctime: time.Now().Unix(),
  12356. Mtime: time.Now().Unix(),
  12357. Number: chrg_bchno,
  12358. ErrMsg: res.ErrMsg,
  12359. Status: 1,
  12360. PatientId: id,
  12361. RecordTime: recordDateTime,
  12362. Stage: 20,
  12363. }
  12364. service.CreateErrMsgLog(errlog)
  12365. c.ServeSuccessJSON(map[string]interface{}{
  12366. "failed_code": -10,
  12367. "msg": res.ErrMsg,
  12368. })
  12369. return
  12370. } else {
  12371. order, _ := service.GetHisOrderTwo(adminUser.CurrentOrgId, chrg_bchno, id)
  12372. order.OrderStatus = 1
  12373. order.IsPre = 1
  12374. order.Status = 1
  12375. order.MdtrtId = res.Output.Setlinfo.MdtrtID
  12376. order.SetlId = res.Output.Setlinfo.SetlID
  12377. order.PsnNo = res.Output.Setlinfo.PsnNo
  12378. order.PsnName = res.Output.Setlinfo.PsnName
  12379. order.PsnCertType = res.Output.Setlinfo.PsnCertType
  12380. order.Certno = res.Output.Setlinfo.Certno
  12381. order.Gend = res.Output.Setlinfo.Gend
  12382. order.Naty = res.Output.Setlinfo.Naty
  12383. order.Age = res.Output.Setlinfo.Age
  12384. order.Insutype = res.Output.Setlinfo.Insutype
  12385. order.PsnType = res.Output.Setlinfo.PsnType
  12386. order.CvlservFlag = res.Output.Setlinfo.CvlservFlag
  12387. order.SetlTime = res.Output.Setlinfo.SetlTime
  12388. order.AcctUsedFlag = acct_used_flag
  12389. order.MdtrtCertType = res.Output.Setlinfo.MdtrtCertType
  12390. if res.Output.Setlinfo.MedType == "140101" {
  12391. order.MedType = "14"
  12392. } else {
  12393. order.MedType = res.Output.Setlinfo.MedType
  12394. }
  12395. if reg_type == 1112 {
  12396. order.MedType = "1112"
  12397. }
  12398. if reg_type == 1111 {
  12399. order.MedType = "1111"
  12400. }
  12401. order.MedfeeSumamt = res.Output.Setlinfo.MedfeeSumamt
  12402. order.FulamtOwnpayAmt = res.Output.Setlinfo.FulamtOwnpayAmt
  12403. order.OverlmtSelfPay = res.Output.Setlinfo.OverlmtSelfpay
  12404. order.PreselfpayAmt = res.Output.Setlinfo.PreselfpayAmt
  12405. order.InscpScpAmt = res.Output.Setlinfo.InscpScpAmt
  12406. order.ActPayDedc = res.Output.Setlinfo.ActPayDedc
  12407. order.HifpPay = res.Output.Setlinfo.HifpPay
  12408. order.CvlservPay = res.Output.Setlinfo.CvlservPay
  12409. order.PoolPropSelfpay = res.Output.Setlinfo.PoolPropSelfpay
  12410. order.HifesPay = res.Output.Setlinfo.HifesPay
  12411. order.HifobPay = res.Output.Setlinfo.HifobPay
  12412. order.MafPay = res.Output.Setlinfo.MafPay
  12413. order.HifmiPay = res.Output.Setlinfo.HifmiPay
  12414. order.OthPay = res.Output.Setlinfo.OthPay
  12415. order.FundPaySumamt = res.Output.Setlinfo.FundPaySumamt
  12416. order.PsnPartAmt = res.Output.Setlinfo.PsnPartAmt
  12417. order.AcctPay = res.Output.Setlinfo.AcctPay
  12418. order.PsnCashPay = res.Output.Setlinfo.PsnCashPay
  12419. order.HospPartAmt = res.Output.Setlinfo.HospPartAmt
  12420. order.Balc = res.Output.Setlinfo.Balc
  12421. order.AcctMulaidPay = res.Output.Setlinfo.AcctMulaidPay
  12422. order.MedinsSetlId = res.Output.Setlinfo.MedinsSetlID
  12423. order.ClrOptins = res.Output.Setlinfo.ClrOptins
  12424. order.ClrWay = res.Output.Setlinfo.ClrWay
  12425. order.Creator = order.Creator
  12426. order.Modify = roles.AdminUserId
  12427. setlDetail, _ := json.Marshal(res.Output.Setldetail)
  12428. detailStr := string(setlDetail)
  12429. order.SetlDetail = detailStr
  12430. //err := service.UpdataOrderStatusTwo(chrg_bchno, adminUser.CurrentOrgId)
  12431. err = service.UpDateOrder(order)
  12432. if err == nil {
  12433. c.ServeSuccessJSON(map[string]interface{}{
  12434. "msg": "预结算成功",
  12435. })
  12436. } else {
  12437. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeAmountAccountException)
  12438. return
  12439. }
  12440. }
  12441. } else {
  12442. adminUser := c.GetAdminUserInfo()
  12443. errlog := &models.HisOrderError{
  12444. UserOrgId: adminUser.CurrentOrgId,
  12445. Ctime: time.Now().Unix(),
  12446. Mtime: time.Now().Unix(),
  12447. ErrMsg: res.ErrMsg,
  12448. Status: 1,
  12449. PatientId: id,
  12450. RecordTime: recordDateTime,
  12451. Stage: 4,
  12452. }
  12453. service.CreateErrMsgLog(errlog)
  12454. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeRegisterRepeatException)
  12455. return
  12456. }
  12457. } else {
  12458. adminUser := c.GetAdminUserInfo()
  12459. errlog := &models.HisOrderError{
  12460. UserOrgId: adminUser.CurrentOrgId,
  12461. Ctime: time.Now().Unix(),
  12462. Mtime: time.Now().Unix(),
  12463. ErrMsg: res.ErrMsg,
  12464. Status: 1,
  12465. PatientId: id,
  12466. RecordTime: recordDateTime,
  12467. Stage: 4,
  12468. }
  12469. service.CreateErrMsgLog(errlog)
  12470. c.ServeSuccessJSON(map[string]interface{}{
  12471. "failed_code": -10,
  12472. "msg": res.ErrMsg,
  12473. })
  12474. return
  12475. }
  12476. }
  12477. }
  12478. }
  12479. // 退款
  12480. func (c *HisApiController) Refund() {
  12481. order_id, _ := c.GetInt64("order_id")
  12482. admin_user_id, _ := c.GetInt64("admin_user_id")
  12483. adminUser := c.GetAdminUserInfo()
  12484. var order models.HisOrder
  12485. order, _ = service.GetHisOrderByID(order_id)
  12486. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  12487. if order.ID == 0 {
  12488. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  12489. return
  12490. }
  12491. his, _ := service.GetHisPatientByNumber(order.MdtrtId)
  12492. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  12493. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  12494. if config.IsOpen == 1 { //对接了医保,走医保流程
  12495. var res ResultSixteen
  12496. var resSixteen10265 ResultSixteen10265
  12497. var src_resquest string
  12498. var result string
  12499. if miConfig.MdtrtareaAdmvs == "421300" {
  12500. api3 := "http://192.168.124.4:9532/" + "hbyb/2208?psn_no=" + order.PsnNo +
  12501. "&mdtrt_id=" + order.MdtrtId + "&setl_id=" + order.SetlId + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  12502. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  12503. resp3, requestErr3 := http.Get(api3)
  12504. if requestErr3 != nil {
  12505. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12506. return
  12507. }
  12508. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  12509. if ioErr3 != nil {
  12510. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  12511. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12512. return
  12513. }
  12514. var respJSON3 map[string]interface{}
  12515. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  12516. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  12517. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12518. return
  12519. }
  12520. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  12521. userJSONBytes3, _ := json.Marshal(respJSON3)
  12522. fmt.Println("log")
  12523. fmt.Println(string(userJSONBytes3))
  12524. if err := json.Unmarshal(userJSONBytes3, &res); err != nil {
  12525. utils.ErrorLog("解析失败:%v", err)
  12526. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12527. return
  12528. }
  12529. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  12530. var api3 string
  12531. if miConfig.MdtrtareaAdmvs == "320921" {
  12532. api3 = "http://192.168.2.3:9532/" + "jsyb/2208?psn_no=" + order.PsnNo +
  12533. "&mdtrt_id=" + order.MdtrtId + "&setl_id=" + order.SetlId + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  12534. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  12535. //req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  12536. } else {
  12537. //req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  12538. api3 = "http://192.168.5.251:9532/" + "jsyb/2208?psn_no=" + order.PsnNo +
  12539. "&mdtrt_id=" + order.MdtrtId + "&setl_id=" + order.SetlId + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  12540. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  12541. }
  12542. resp3, requestErr3 := http.Get(api3)
  12543. if requestErr3 != nil {
  12544. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12545. return
  12546. }
  12547. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  12548. if ioErr3 != nil {
  12549. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  12550. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12551. return
  12552. }
  12553. var respJSON3 map[string]interface{}
  12554. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  12555. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  12556. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12557. return
  12558. }
  12559. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  12560. userJSONBytes3, _ := json.Marshal(respJSON3)
  12561. if err := json.Unmarshal(userJSONBytes3, &resSixteen10265); err != nil {
  12562. utils.ErrorLog("解析失败:%v", err)
  12563. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12564. return
  12565. }
  12566. res.InfRefmsgid = resSixteen10265.InfRefmsgid
  12567. res.Output = resSixteen10265.Output
  12568. res.ErrMsg = resSixteen10265.ErrMsg
  12569. res.Cainfo = resSixteen10265.Cainfo
  12570. res.WarnMsg = resSixteen10265.WarnMsg
  12571. infocode, _ := strconv.ParseInt(resSixteen10265.Infcode, 10, 64)
  12572. res.Infcode = infocode
  12573. } else if miConfig.MdtrtareaAdmvs == "350500" {
  12574. 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)
  12575. var dat map[string]interface{}
  12576. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  12577. fmt.Println(dat)
  12578. } else {
  12579. fmt.Println(err)
  12580. }
  12581. saveLog(result, src_resquest, "2208", "退费")
  12582. userJSONBytes, _ := json.Marshal(dat)
  12583. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  12584. utils.ErrorLog("解析失败:%v", err)
  12585. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12586. return
  12587. }
  12588. } else if miConfig.MdtrtareaAdmvs == "360399" {
  12589. 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, "")
  12590. var dat map[string]interface{}
  12591. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  12592. fmt.Println(dat)
  12593. } else {
  12594. fmt.Println(err)
  12595. }
  12596. saveLog(result, src_resquest, "2208", "退费")
  12597. userJSONBytes, _ := json.Marshal(dat)
  12598. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  12599. utils.ErrorLog("解析失败:%v", err)
  12600. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12601. return
  12602. }
  12603. } else if miConfig.MdtrtareaAdmvs == "430800" {
  12604. 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, "")
  12605. var dat map[string]interface{}
  12606. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  12607. fmt.Println(dat)
  12608. } else {
  12609. fmt.Println(err)
  12610. }
  12611. saveLog(result, src_resquest, "2208", "退费")
  12612. userJSONBytes, _ := json.Marshal(dat)
  12613. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  12614. utils.ErrorLog("解析失败:%v", err)
  12615. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12616. return
  12617. }
  12618. } else {
  12619. if miConfig.Code == "H15049901371" {
  12620. result, src_resquest = service.Gdyb2208(order.PsnNo, order.MdtrtId, order.SetlId, miConfig.OrgName, roles.UserName, miConfig.SecretKey, miConfig.Code, his.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs)
  12621. var dat map[string]interface{}
  12622. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  12623. fmt.Println(dat)
  12624. } else {
  12625. fmt.Println(err)
  12626. }
  12627. saveLog(result, src_resquest, "2208", "退费")
  12628. userJSONBytes, _ := json.Marshal(dat)
  12629. if err := json.Unmarshal(userJSONBytes, &resSixteen10265); err != nil {
  12630. utils.ErrorLog("解析失败:%v", err)
  12631. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12632. return
  12633. }
  12634. res.InfRefmsgid = resSixteen10265.InfRefmsgid
  12635. res.Output = resSixteen10265.Output
  12636. res.ErrMsg = resSixteen10265.ErrMsg
  12637. res.Cainfo = resSixteen10265.Cainfo
  12638. res.WarnMsg = resSixteen10265.WarnMsg
  12639. infocode, _ := strconv.ParseInt(resSixteen10265.Infcode, 10, 64)
  12640. res.Infcode = infocode
  12641. } else {
  12642. result, src_resquest = service.Gdyb2208(order.PsnNo, order.MdtrtId, order.SetlId, miConfig.OrgName, roles.UserName, miConfig.SecretKey, miConfig.Code, his.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs)
  12643. var dat map[string]interface{}
  12644. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  12645. fmt.Println(dat)
  12646. } else {
  12647. fmt.Println(err)
  12648. }
  12649. saveLog(result, src_resquest, "2208", "退费")
  12650. userJSONBytes, _ := json.Marshal(dat)
  12651. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  12652. utils.ErrorLog("解析失败:%v", err)
  12653. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12654. return
  12655. }
  12656. }
  12657. }
  12658. if res.Infcode == 0 {
  12659. var res2 ResultSix
  12660. var resSix10265 ResultSix10265
  12661. if miConfig.MdtrtareaAdmvs == "421300" {
  12662. api3 := "http://192.168.124.4:9532/" + "hbyb/2205?psn_no=" + order.PsnNo +
  12663. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  12664. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  12665. resp3, requestErr3 := http.Get(api3)
  12666. if requestErr3 != nil {
  12667. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12668. return
  12669. }
  12670. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  12671. if ioErr3 != nil {
  12672. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  12673. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12674. return
  12675. }
  12676. var respJSON3 map[string]interface{}
  12677. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  12678. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  12679. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12680. return
  12681. }
  12682. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  12683. userJSONBytes3, _ := json.Marshal(respJSON3)
  12684. fmt.Println("log")
  12685. fmt.Println(string(userJSONBytes3))
  12686. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  12687. utils.ErrorLog("解析失败:%v", err)
  12688. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12689. return
  12690. }
  12691. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  12692. var api3 string
  12693. if miConfig.MdtrtareaAdmvs == "320921" {
  12694. api3 = "http://192.168.2.3:9532/" + "jsyb/2205?psn_no=" + order.PsnNo +
  12695. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  12696. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  12697. //req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  12698. } else {
  12699. //req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  12700. api3 = "http://192.168.5.251:9532/" + "jsyb/2205?psn_no=" + order.PsnNo +
  12701. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  12702. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  12703. }
  12704. resp3, requestErr3 := http.Get(api3)
  12705. if requestErr3 != nil {
  12706. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12707. return
  12708. }
  12709. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  12710. if ioErr3 != nil {
  12711. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  12712. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12713. return
  12714. }
  12715. var respJSON3 map[string]interface{}
  12716. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  12717. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  12718. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12719. return
  12720. }
  12721. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  12722. userJSONBytes3, _ := json.Marshal(respJSON3)
  12723. fmt.Println("log")
  12724. fmt.Println(string(userJSONBytes3))
  12725. if err := json.Unmarshal(userJSONBytes3, &resSix10265); err != nil {
  12726. utils.ErrorLog("解析失败:%v", err)
  12727. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12728. return
  12729. }
  12730. res2.InfRefmsgid = resSix10265.InfRefmsgid
  12731. res2.Output = resSix10265.Output
  12732. res2.ErrMsg = resSix10265.ErrMsg
  12733. res2.Cainfo = resSix10265.Cainfo
  12734. res2.WarnMsg = resSix10265.WarnMsg
  12735. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  12736. res2.Infcode = infocode
  12737. } else if miConfig.MdtrtareaAdmvs == "350500" {
  12738. 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)
  12739. var dat map[string]interface{}
  12740. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  12741. fmt.Println(dat)
  12742. } else {
  12743. fmt.Println(err)
  12744. }
  12745. saveLog(result2, src_request, "2205", "撤销明细")
  12746. userJSONBytes, _ := json.Marshal(dat)
  12747. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  12748. utils.ErrorLog("解析失败:%v", err)
  12749. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12750. return
  12751. }
  12752. } else if miConfig.MdtrtareaAdmvs == "360399" {
  12753. 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, "")
  12754. var dat map[string]interface{}
  12755. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  12756. fmt.Println(dat)
  12757. } else {
  12758. fmt.Println(err)
  12759. }
  12760. saveLog(result2, src_request, "2205", "撤销明细")
  12761. userJSONBytes, _ := json.Marshal(dat)
  12762. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  12763. utils.ErrorLog("解析失败:%v", err)
  12764. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12765. return
  12766. }
  12767. } else if miConfig.MdtrtareaAdmvs == "430800" {
  12768. 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, "")
  12769. var dat map[string]interface{}
  12770. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  12771. fmt.Println(dat)
  12772. } else {
  12773. fmt.Println(err)
  12774. }
  12775. saveLog(result2, src_request, "2205", "撤销明细")
  12776. userJSONBytes, _ := json.Marshal(dat)
  12777. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  12778. utils.ErrorLog("解析失败:%v", err)
  12779. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12780. return
  12781. }
  12782. } else {
  12783. if miConfig.Code == "H15049901371" {
  12784. result2, src_request := service.Gdyb2205(order.PsnNo, order.MdtrtId, order.Number, miConfig.OrgName, roles.UserName, his.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, miConfig.Code)
  12785. var dat map[string]interface{}
  12786. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  12787. fmt.Println(dat)
  12788. } else {
  12789. fmt.Println(err)
  12790. }
  12791. saveLog(result2, src_request, "2205", "撤销明细")
  12792. userJSONBytes, _ := json.Marshal(dat)
  12793. if err := json.Unmarshal(userJSONBytes, &resSix10265); err != nil {
  12794. utils.ErrorLog("解析失败:%v", err)
  12795. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12796. return
  12797. }
  12798. res2.InfRefmsgid = resSix10265.InfRefmsgid
  12799. res2.Output = resSix10265.Output
  12800. res2.ErrMsg = resSix10265.ErrMsg
  12801. res2.Cainfo = resSix10265.Cainfo
  12802. res2.WarnMsg = resSix10265.WarnMsg
  12803. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  12804. res2.Infcode = infocode
  12805. } else {
  12806. result2, src_request := service.Gdyb2205(order.PsnNo, order.MdtrtId, order.Number, miConfig.OrgName, roles.UserName, his.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, miConfig.Code)
  12807. var dat map[string]interface{}
  12808. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  12809. fmt.Println(dat)
  12810. } else {
  12811. fmt.Println(err)
  12812. }
  12813. saveLog(result2, src_request, "2205", "撤销明细")
  12814. userJSONBytes, _ := json.Marshal(dat)
  12815. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  12816. utils.ErrorLog("解析失败:%v", err)
  12817. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12818. return
  12819. }
  12820. }
  12821. }
  12822. if res2.Infcode == 0 {
  12823. err := service.UpdataOrderStatus(order_id, order.Number, adminUser.CurrentOrgId, src_resquest, result)
  12824. if err == nil {
  12825. //当押金不为零时产生退费记录
  12826. if order.Decimal != 0 {
  12827. tmp := strconv.FormatInt(order.ID, 10)
  12828. err = service.MoneyIncrease(adminUser.CurrentOrgId, order.PatientId, tmp, order.Decimal)
  12829. if err != nil {
  12830. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12831. return
  12832. }
  12833. }
  12834. c.ServeSuccessJSON(map[string]interface{}{
  12835. "msg": "退费成功",
  12836. })
  12837. } else {
  12838. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12839. return
  12840. }
  12841. } else {
  12842. c.ServeSuccessJSON(map[string]interface{}{
  12843. "code": -10,
  12844. "msg": res2.ErrMsg,
  12845. })
  12846. }
  12847. } else {
  12848. c.ServeSuccessJSON(map[string]interface{}{
  12849. "code": -10,
  12850. "msg": res.ErrMsg,
  12851. })
  12852. }
  12853. }
  12854. }
  12855. func (c *HisApiController) RefundNumber() {
  12856. record_time := c.GetString("record_time")
  12857. //patient_id, _ := c.GetInt64("patient_id")
  12858. admin_user_id, _ := c.GetInt64("admin_user_id")
  12859. his_patient_id, _ := c.GetInt64("id")
  12860. timeLayout := "2006-01-02"
  12861. loc, _ := time.LoadLocation("Local")
  12862. adminUser := c.GetAdminUserInfo()
  12863. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  12864. fmt.Println(err)
  12865. if err != nil {
  12866. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  12867. return
  12868. }
  12869. recordDateTime := theTime.Unix()
  12870. //his, _ := service.GetVMHisPatientInfo(adminUser.CurrentOrgId, patient_id, recordDateTime)
  12871. his, _ := service.GetHisPatientRecord(adminUser.CurrentOrgId, his_patient_id)
  12872. //patientPrescription, _ := service.FindPatientPrescriptionInfo(adminUser.CurrentOrgId, patient_id, recordDateTime)
  12873. //order, _ := service.GetHisOrderByID(order_id)
  12874. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  12875. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  12876. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  12877. count, _ := service.GetOrderCountByNumber(adminUser.CurrentOrgId, his.PatientId, recordDateTime, his.Number)
  12878. if count > 0 {
  12879. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeOrderParamWrong)
  12880. return
  12881. }
  12882. if config.IsOpen == 1 { //对接了医保,走医保流程
  12883. var res2 ResultSix
  12884. var resSix10265 ResultSix10265
  12885. if miConfig.MdtrtareaAdmvs == "421300" {
  12886. api3 := "http://192.168.124.4:9532/" + "hbyb/2202?psn_no=" + his.PsnNo +
  12887. "&mdtrt_id=" + his.Number + "&ipt_otp_no=" + his.IptOtpNo + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  12888. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  12889. resp3, requestErr3 := http.Get(api3)
  12890. if requestErr3 != nil {
  12891. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12892. return
  12893. }
  12894. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  12895. if ioErr3 != nil {
  12896. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  12897. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12898. return
  12899. }
  12900. var respJSON3 map[string]interface{}
  12901. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  12902. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  12903. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12904. return
  12905. }
  12906. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  12907. userJSONBytes3, _ := json.Marshal(respJSON3)
  12908. fmt.Println("log")
  12909. fmt.Println(string(userJSONBytes3))
  12910. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  12911. utils.ErrorLog("解析失败:%v", err)
  12912. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12913. return
  12914. }
  12915. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  12916. var api3 string
  12917. if miConfig.MdtrtareaAdmvs == "320921" {
  12918. api3 = "http://192.168.2.3:9532/" + "jsyb/2202?psn_no=" + his.PsnNo +
  12919. "&mdtrt_id=" + his.Number + "&ipt_otp_no=" + his.IptOtpNo + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  12920. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  12921. //req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  12922. } else {
  12923. //req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  12924. api3 = "http://192.168.5.251:9532/" + "jsyb/2202?psn_no=" + his.PsnNo +
  12925. "&mdtrt_id=" + his.Number + "&ipt_otp_no=" + his.IptOtpNo + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  12926. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  12927. }
  12928. resp3, requestErr3 := http.Get(api3)
  12929. if requestErr3 != nil {
  12930. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12931. return
  12932. }
  12933. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  12934. if ioErr3 != nil {
  12935. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  12936. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12937. return
  12938. }
  12939. var respJSON3 map[string]interface{}
  12940. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  12941. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  12942. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12943. return
  12944. }
  12945. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  12946. userJSONBytes3, _ := json.Marshal(respJSON3)
  12947. if err := json.Unmarshal(userJSONBytes3, &resSix10265); err != nil {
  12948. utils.ErrorLog("解析失败:%v", err)
  12949. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12950. return
  12951. }
  12952. res2.InfRefmsgid = resSix10265.InfRefmsgid
  12953. res2.Output = resSix10265.Output
  12954. res2.ErrMsg = resSix10265.ErrMsg
  12955. res2.Cainfo = resSix10265.Cainfo
  12956. res2.WarnMsg = resSix10265.WarnMsg
  12957. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  12958. res2.Infcode = infocode
  12959. } else if miConfig.MdtrtareaAdmvs == "350500" {
  12960. 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)
  12961. var dat map[string]interface{}
  12962. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  12963. fmt.Println(dat)
  12964. } else {
  12965. fmt.Println(err)
  12966. }
  12967. saveLog(result, request, "2202", "退号")
  12968. userJSONBytes, _ := json.Marshal(dat)
  12969. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  12970. utils.ErrorLog("解析失败:%v", err)
  12971. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12972. return
  12973. }
  12974. } else if miConfig.MdtrtareaAdmvs == "360399" {
  12975. 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, "")
  12976. var dat map[string]interface{}
  12977. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  12978. fmt.Println(dat)
  12979. } else {
  12980. fmt.Println(err)
  12981. }
  12982. saveLog(result, request, "2202", "退号")
  12983. userJSONBytes, _ := json.Marshal(dat)
  12984. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  12985. utils.ErrorLog("解析失败:%v", err)
  12986. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  12987. return
  12988. }
  12989. } else if miConfig.MdtrtareaAdmvs == "430800" {
  12990. 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, "")
  12991. var dat map[string]interface{}
  12992. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  12993. fmt.Println(dat)
  12994. } else {
  12995. fmt.Println(err)
  12996. }
  12997. saveLog(result, request, "2202", "退号")
  12998. userJSONBytes, _ := json.Marshal(dat)
  12999. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  13000. utils.ErrorLog("解析失败:%v", err)
  13001. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13002. return
  13003. }
  13004. } else {
  13005. var api3 string
  13006. if miConfig.Code == "H15049901371" {
  13007. api3 = "http://127.0.0.1:9532/" + "gdyb/three?psn_no=" + his.PsnNo +
  13008. "&mdtrt_id=" + his.Number + "&ipt_otp_no=" + his.IptOtpNo + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  13009. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  13010. } else {
  13011. api3 = "http://127.0.0.1:9532/" + "gdyb/three?psn_no=" + his.PsnNo +
  13012. "&mdtrt_id=" + his.Number + "&ipt_otp_no=" + his.IptOtpNo + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  13013. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  13014. }
  13015. resp3, requestErr3 := http.Get(api3)
  13016. if requestErr3 != nil {
  13017. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13018. return
  13019. }
  13020. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  13021. if ioErr3 != nil {
  13022. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  13023. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13024. return
  13025. }
  13026. var respJSON3 map[string]interface{}
  13027. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  13028. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  13029. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13030. return
  13031. }
  13032. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  13033. userJSONBytes3, _ := json.Marshal(respJSON3)
  13034. if miConfig.Code == "H15049901371" {
  13035. if err := json.Unmarshal(userJSONBytes3, &resSix10265); err != nil {
  13036. utils.ErrorLog("解析失败:%v", err)
  13037. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13038. return
  13039. }
  13040. res2.InfRefmsgid = resSix10265.InfRefmsgid
  13041. res2.Output = resSix10265.Output
  13042. res2.ErrMsg = resSix10265.ErrMsg
  13043. res2.Cainfo = resSix10265.Cainfo
  13044. res2.WarnMsg = resSix10265.WarnMsg
  13045. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  13046. res2.Infcode = infocode
  13047. } else {
  13048. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  13049. utils.ErrorLog("解析失败:%v", err)
  13050. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13051. return
  13052. }
  13053. }
  13054. }
  13055. if res2.Infcode == 0 {
  13056. if err == nil {
  13057. c.ServeSuccessJSON(map[string]interface{}{
  13058. "msg": "退号成功",
  13059. })
  13060. service.UpdataRegStatusTwo(his_patient_id, recordDateTime, adminUser.CurrentOrgId)
  13061. } else {
  13062. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13063. return
  13064. }
  13065. } else {
  13066. c.ServeSuccessJSON(map[string]interface{}{
  13067. "code": -10,
  13068. "msg": res2.ErrMsg,
  13069. })
  13070. }
  13071. } else {
  13072. //err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId)
  13073. //if err == nil {
  13074. // c.ServeSuccessJSON(map[string]interface{}{
  13075. // "msg": "退费成功",
  13076. // })
  13077. //} else {
  13078. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13079. // return
  13080. //}
  13081. }
  13082. }
  13083. func (c *HisApiController) RefundDetail() {
  13084. order_id, _ := c.GetInt64("order_id")
  13085. admin_user_id, _ := c.GetInt64("admin_user_id")
  13086. //his_patient_id, _ := c.GetInt64("his_patient_id")
  13087. number := c.GetString("number")
  13088. record_time := c.GetString("record_time")
  13089. patient_id, _ := c.GetInt64("patient_id")
  13090. //med_type, _ := c.GetInt64("med_type")
  13091. timeLayout := "2006-01-02"
  13092. loc, _ := time.LoadLocation("Local")
  13093. adminUser := c.GetAdminUserInfo()
  13094. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  13095. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  13096. fmt.Println(err)
  13097. if err != nil {
  13098. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  13099. return
  13100. }
  13101. recordDateTime := theTime.Unix()
  13102. //his, _ := service.GetNewVMHisPatientInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  13103. patientPrescription, _ := service.FindPatientPrescriptionInfo(adminUser.CurrentOrgId, patient_id, recordDateTime)
  13104. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  13105. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  13106. var order models.HisOrder
  13107. order, _ = service.GetHisOrderByID(order_id)
  13108. his, _ := service.GetHisPatientByNumber(order.MdtrtId)
  13109. if config.IsOpen == 1 { //对接了医保,走医保流程
  13110. var res2 ResultSix
  13111. if miConfig.MdtrtareaAdmvs == "421300" {
  13112. api3 := "http://192.168.124.4:9532/" + "hbyb/2205?psn_no=" + order.PsnNo +
  13113. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + patientPrescription.Doctor + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  13114. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  13115. resp3, requestErr3 := http.Get(api3)
  13116. if requestErr3 != nil {
  13117. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13118. return
  13119. }
  13120. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  13121. if ioErr3 != nil {
  13122. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  13123. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13124. return
  13125. }
  13126. var respJSON3 map[string]interface{}
  13127. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  13128. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  13129. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13130. return
  13131. }
  13132. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  13133. userJSONBytes3, _ := json.Marshal(respJSON3)
  13134. fmt.Println("log")
  13135. fmt.Println(string(userJSONBytes3))
  13136. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  13137. utils.ErrorLog("解析失败:%v", err)
  13138. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13139. return
  13140. }
  13141. err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId, "", "")
  13142. if err == nil {
  13143. c.ServeSuccessJSON(map[string]interface{}{
  13144. "msg": "撤销明细成功",
  13145. })
  13146. return
  13147. } else {
  13148. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13149. return
  13150. }
  13151. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  13152. var resSix10265 ResultSix10265
  13153. var api3 string
  13154. if miConfig.MdtrtareaAdmvs == "320921" {
  13155. api3 = "http://192.168.2.3:9532/" + "jsyb/2205?psn_no=" + order.PsnNo +
  13156. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + patientPrescription.Doctor + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  13157. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  13158. //req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  13159. } else {
  13160. //req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  13161. api3 = "http://192.168.5.251:9532/" + "jsyb/2205?psn_no=" + order.PsnNo +
  13162. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + patientPrescription.Doctor + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  13163. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  13164. }
  13165. resp3, requestErr3 := http.Get(api3)
  13166. if requestErr3 != nil {
  13167. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13168. return
  13169. }
  13170. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  13171. if ioErr3 != nil {
  13172. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  13173. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13174. return
  13175. }
  13176. var respJSON3 map[string]interface{}
  13177. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  13178. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  13179. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13180. return
  13181. }
  13182. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  13183. userJSONBytes3, _ := json.Marshal(respJSON3)
  13184. fmt.Println("log")
  13185. fmt.Println(string(userJSONBytes3))
  13186. if err := json.Unmarshal(userJSONBytes3, &resSix10265); err != nil {
  13187. utils.ErrorLog("解析失败:%v", err)
  13188. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13189. return
  13190. }
  13191. res2.InfRefmsgid = resSix10265.InfRefmsgid
  13192. res2.Output = resSix10265.Output
  13193. res2.ErrMsg = resSix10265.ErrMsg
  13194. res2.Cainfo = resSix10265.Cainfo
  13195. res2.WarnMsg = resSix10265.WarnMsg
  13196. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  13197. res2.Infcode = infocode
  13198. err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId, "", "")
  13199. if err == nil {
  13200. c.ServeSuccessJSON(map[string]interface{}{
  13201. "msg": "撤销明细成功",
  13202. })
  13203. return
  13204. } else {
  13205. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13206. return
  13207. }
  13208. } else if miConfig.MdtrtareaAdmvs == "350500" {
  13209. 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)
  13210. var dat map[string]interface{}
  13211. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  13212. fmt.Println(dat)
  13213. } else {
  13214. fmt.Println(err)
  13215. }
  13216. saveLog(result2, src_request, "2205", "撤销明细")
  13217. userJSONBytes, _ := json.Marshal(dat)
  13218. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  13219. utils.ErrorLog("解析失败:%v", err)
  13220. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13221. return
  13222. }
  13223. if res2.Infcode == 0 {
  13224. err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId, "", "")
  13225. if err == nil {
  13226. c.ServeSuccessJSON(map[string]interface{}{
  13227. "msg": "撤销明细成功",
  13228. })
  13229. return
  13230. } else {
  13231. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13232. return
  13233. }
  13234. } else {
  13235. c.ServeSuccessJSON(map[string]interface{}{
  13236. "code": -10,
  13237. "msg": res2.ErrMsg,
  13238. })
  13239. }
  13240. } else if miConfig.MdtrtareaAdmvs == "360399" {
  13241. 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, "")
  13242. var dat map[string]interface{}
  13243. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  13244. fmt.Println(dat)
  13245. } else {
  13246. fmt.Println(err)
  13247. }
  13248. saveLog(result2, src_request, "2205", "撤销明细")
  13249. userJSONBytes, _ := json.Marshal(dat)
  13250. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  13251. utils.ErrorLog("解析失败:%v", err)
  13252. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13253. return
  13254. }
  13255. if res2.Infcode == 0 {
  13256. err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId, "", "")
  13257. if err == nil {
  13258. c.ServeSuccessJSON(map[string]interface{}{
  13259. "msg": "撤销明细成功",
  13260. })
  13261. return
  13262. } else {
  13263. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13264. return
  13265. }
  13266. } else {
  13267. c.ServeSuccessJSON(map[string]interface{}{
  13268. "code": -10,
  13269. "msg": res2.ErrMsg,
  13270. })
  13271. }
  13272. } else if miConfig.MdtrtareaAdmvs == "430800" {
  13273. 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, "")
  13274. var dat map[string]interface{}
  13275. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  13276. fmt.Println(dat)
  13277. } else {
  13278. fmt.Println(err)
  13279. }
  13280. saveLog(result2, src_request, "2205", "撤销明细")
  13281. userJSONBytes, _ := json.Marshal(dat)
  13282. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  13283. utils.ErrorLog("解析失败:%v", err)
  13284. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13285. return
  13286. }
  13287. if res2.Infcode == 0 {
  13288. err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId, "", "")
  13289. if err == nil {
  13290. c.ServeSuccessJSON(map[string]interface{}{
  13291. "msg": "撤销明细成功",
  13292. })
  13293. return
  13294. } else {
  13295. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13296. return
  13297. }
  13298. } else {
  13299. c.ServeSuccessJSON(map[string]interface{}{
  13300. "code": -10,
  13301. "msg": res2.ErrMsg,
  13302. })
  13303. }
  13304. } else {
  13305. api2 := "http://127.0.0.1:9532/" + "gdyb/six?psn_no=" + his.PsnNo +
  13306. "&mdtrt_id=" + his.Number + "&chrg_bchno=" + order.Number + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  13307. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  13308. resp2, requestErr2 := http.Get(api2)
  13309. if requestErr2 != nil {
  13310. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13311. return
  13312. }
  13313. body2, ioErr2 := ioutil.ReadAll(resp2.Body)
  13314. if ioErr2 != nil {
  13315. utils.ErrorLog("接口返回数据读取失败: %v", ioErr2)
  13316. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13317. return
  13318. }
  13319. var respJSON2 map[string]interface{}
  13320. if err := json.Unmarshal([]byte(string(body2)), &respJSON2); err != nil {
  13321. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  13322. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13323. return
  13324. }
  13325. err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId, "", "")
  13326. if err == nil {
  13327. c.ServeSuccessJSON(map[string]interface{}{
  13328. "msg": "撤销明细成功",
  13329. })
  13330. return
  13331. } else {
  13332. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13333. return
  13334. }
  13335. }
  13336. } else {
  13337. err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId, "", "")
  13338. if err == nil {
  13339. c.ServeSuccessJSON(map[string]interface{}{
  13340. "msg": "退费成功",
  13341. })
  13342. } else {
  13343. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13344. return
  13345. }
  13346. }
  13347. }
  13348. // 对账
  13349. func (c *HisApiController) GetCheckAccount() {
  13350. start_time := c.GetString("start_time")
  13351. end_time := c.GetString("end_time")
  13352. insutype := c.GetString("insutype")
  13353. clr_type := c.GetString("clr_type")
  13354. clr_org := c.GetString("clr_optins")
  13355. admin_user_id, _ := c.GetInt64("admin_user_id")
  13356. adminUser := c.GetAdminUserInfo()
  13357. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  13358. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  13359. if len(clr_org) == 0 {
  13360. clr_org = miConfig.MdtrtareaAdmvs
  13361. }
  13362. timeLayout := "2006-01-02"
  13363. loc, _ := time.LoadLocation("Local")
  13364. startime, _ := time.ParseInLocation(timeLayout+" 15:04:05", start_time+" 00:00:00", loc)
  13365. endtime, _ := time.ParseInLocation(timeLayout+" 15:04:05", end_time+" 23:59:59", loc)
  13366. orders, _ := service.GetOrderByTime(startime.Unix(), endtime.Unix(), adminUser.CurrentOrgId, insutype, "", clr_type, miConfig.MdtrtareaAdmvs)
  13367. orders_two, _ := service.GetOrderByTimeFive(startime.Unix(), endtime.Unix(), adminUser.CurrentOrgId, insutype, "", clr_type, miConfig.MdtrtareaAdmvs)
  13368. fixmedins_setl_cnt := int64(len(orders))
  13369. var medfee_sumamt float64
  13370. var acct_pay float64
  13371. var fund_pay_sumamt float64
  13372. for _, item := range orders {
  13373. medfee_sumamt = medfee_sumamt + item.MedfeeSumamt
  13374. acct_pay = acct_pay + item.AcctPay
  13375. fund_pay_sumamt = fund_pay_sumamt + item.FundPaySumamt
  13376. }
  13377. var user_name string
  13378. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  13379. if role.ID == 0 {
  13380. user_name = "xxx"
  13381. } else {
  13382. user_name = role.UserName
  13383. }
  13384. var res ResultEight
  13385. var res10188 ResultEightFor10188
  13386. if config.IsOpen == 1 {
  13387. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  13388. api := "http://192.168.2.3:9532/" + "jsyb/3201?" +
  13389. "insutype=" + insutype +
  13390. "&clr_type=" + clr_type +
  13391. "&setl_optins=" + clr_org +
  13392. "&stmt_begndate=" + start_time +
  13393. "&stm_enddate=" + end_time +
  13394. "&medfee_sumamt=" + fmt.Sprintf("%.4f", medfee_sumamt) +
  13395. "&fund_pay_sumamt=" + fmt.Sprintf("%.4f", fund_pay_sumamt) +
  13396. "&acct_pay=" + fmt.Sprintf("%.4f", acct_pay) +
  13397. "&fixmedins_setl_cnt=" + strconv.FormatInt(fixmedins_setl_cnt+int64(len(orders_two)*2), 10) +
  13398. "&fixmedins_code=" + miConfig.Code +
  13399. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs +
  13400. "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  13401. "&secret_key=" + miConfig.SecretKey +
  13402. "&org_name=" + miConfig.OrgName +
  13403. "&doctor=" + user_name +
  13404. "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  13405. fmt.Println(api)
  13406. resp, requestErr := http.Get(api)
  13407. if requestErr != nil {
  13408. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13409. return
  13410. }
  13411. body, ioErr := ioutil.ReadAll(resp.Body)
  13412. fmt.Println(body)
  13413. if ioErr != nil {
  13414. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  13415. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13416. return
  13417. }
  13418. var respJSON map[string]interface{}
  13419. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  13420. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  13421. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13422. return
  13423. }
  13424. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  13425. userJSONBytes, _ := json.Marshal(respJSON)
  13426. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  13427. utils.ErrorLog("解析失败:%v", err)
  13428. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13429. return
  13430. }
  13431. res.InfRefmsgid = res10188.InfRefmsgid
  13432. res.Output = res10188.Output
  13433. res.ErrMsg = res10188.ErrMsg
  13434. res.Cainfo = res10188.Cainfo
  13435. res.WarnMsg = res10188.WarnMsg
  13436. infocode, _ := strconv.ParseInt(res10188.Infcode, 10, 64)
  13437. res.Infcode = infocode
  13438. } else if miConfig.MdtrtareaAdmvs == "150499" {
  13439. if clr_type == "11" {
  13440. fixmedins_setl_cnt = 0
  13441. }
  13442. //if clr_type == "21" {
  13443. // clr_type = "22"
  13444. //}
  13445. api := "http://172.16.13.254:9532/" + "nmyb/3201?" +
  13446. "insutype=" + insutype +
  13447. "&clr_type=" + clr_type +
  13448. "&setl_optins=" + clr_org +
  13449. "&stmt_begndate=" + start_time +
  13450. "&stm_enddate=" + end_time +
  13451. "&medfee_sumamt=" + fmt.Sprintf("%.4f", medfee_sumamt) +
  13452. "&fund_pay_sumamt=" + fmt.Sprintf("%.4f", fund_pay_sumamt) +
  13453. "&acct_pay=" + fmt.Sprintf("%.4f", acct_pay) +
  13454. "&fixmedins_setl_cnt=" + strconv.FormatInt(fixmedins_setl_cnt+int64(len(orders_two)*2), 10) +
  13455. "&fixmedins_code=" + miConfig.Code +
  13456. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs +
  13457. "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  13458. "&secret_key=" + miConfig.SecretKey +
  13459. "&org_name=" + miConfig.OrgName +
  13460. "&doctor=" + user_name
  13461. resp, requestErr := http.Get(api)
  13462. if requestErr != nil {
  13463. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13464. return
  13465. }
  13466. body, ioErr := ioutil.ReadAll(resp.Body)
  13467. if ioErr != nil {
  13468. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  13469. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13470. return
  13471. }
  13472. var respJSON map[string]interface{}
  13473. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  13474. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  13475. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13476. return
  13477. }
  13478. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  13479. result, _ := json.Marshal(respJSON)
  13480. fmt.Println("log")
  13481. fmt.Println(string(result))
  13482. if err := json.Unmarshal([]byte(result), &res10188); err != nil {
  13483. utils.ErrorLog("解析失败:%v", err)
  13484. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13485. return
  13486. }
  13487. res.InfRefmsgid = res10188.InfRefmsgid
  13488. res.Output = res10188.Output
  13489. res.ErrMsg = res10188.ErrMsg
  13490. res.Cainfo = res10188.Cainfo
  13491. res.WarnMsg = res10188.WarnMsg
  13492. infocode, _ := strconv.ParseInt(res10188.Infcode, 10, 64)
  13493. res.Infcode = infocode
  13494. } else if miConfig.MdtrtareaAdmvs == "350500" {
  13495. var baseParams models.BaseParams
  13496. baseParams.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  13497. baseParams.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  13498. baseParams.SecretKey = miConfig.SecretKey
  13499. baseParams.OrgName = miConfig.OrgName
  13500. baseParams.FixmedinsCode = miConfig.Code
  13501. baseParams.EncKey = miConfig.EncKey
  13502. baseParams.AppSecret = miConfig.AppSecret
  13503. baseParams.SignKey = miConfig.SignKey
  13504. baseParams.AppID = miConfig.Code
  13505. baseParams.Doctor = role.UserName
  13506. baseParams.RequestUrl = miConfig.Url
  13507. businessParams := models.BusinessParams{
  13508. Insutype: insutype,
  13509. ClrType: clr_type,
  13510. SetlOptins: clr_org,
  13511. StmtBegndate: start_time,
  13512. StmtEnddate: end_time,
  13513. MedfeeSumamt: medfee_sumamt,
  13514. FundPaySumamt: fund_pay_sumamt,
  13515. AcctPay: acct_pay,
  13516. FixmedinsSetlCnt: fixmedins_setl_cnt,
  13517. }
  13518. result, requestLog, err_msg := service.FJyb3201(baseParams, businessParams, fmt.Sprintf("%.4f", medfee_sumamt), fmt.Sprintf("%.4f", fund_pay_sumamt))
  13519. fmt.Println(requestLog)
  13520. fmt.Println(result)
  13521. fmt.Println(err_msg)
  13522. var dat map[string]interface{}
  13523. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  13524. fmt.Println(dat)
  13525. } else {
  13526. fmt.Println(err)
  13527. }
  13528. userJSONBytes, _ := json.Marshal(dat)
  13529. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  13530. utils.ErrorLog("解析失败:%v", err)
  13531. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13532. return
  13533. }
  13534. } else if miConfig.MdtrtareaAdmvs == "430800" {
  13535. var baseParams models.BaseParams
  13536. baseParams.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  13537. baseParams.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  13538. baseParams.SecretKey = miConfig.SecretKey
  13539. baseParams.OrgName = miConfig.OrgName
  13540. baseParams.FixmedinsCode = miConfig.Code
  13541. baseParams.EncKey = miConfig.EncKey
  13542. baseParams.AppSecret = miConfig.AppSecret
  13543. baseParams.SignKey = miConfig.SignKey
  13544. baseParams.AppID = miConfig.Code
  13545. baseParams.Doctor = role.UserName
  13546. baseParams.RequestUrl = miConfig.Url
  13547. baseParams.AccessKey = miConfig.AccessKey
  13548. businessParams := models.BusinessParams{
  13549. Insutype: insutype,
  13550. ClrType: clr_type,
  13551. SetlOptins: "430822",
  13552. StmtBegndate: start_time,
  13553. StmtEnddate: end_time,
  13554. MedfeeSumamt: medfee_sumamt,
  13555. FundPaySumamt: fund_pay_sumamt,
  13556. AcctPay: acct_pay,
  13557. FixmedinsSetlCnt: fixmedins_setl_cnt,
  13558. }
  13559. 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)
  13560. fmt.Println(requestLog)
  13561. fmt.Println(result)
  13562. var dat map[string]interface{}
  13563. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  13564. fmt.Println(dat)
  13565. } else {
  13566. fmt.Println(err)
  13567. }
  13568. userJSONBytes, _ := json.Marshal(dat)
  13569. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  13570. utils.ErrorLog("解析失败:%v", err)
  13571. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13572. return
  13573. }
  13574. } else if miConfig.MdtrtareaAdmvs == "350500" {
  13575. var baseParams models.BaseParams
  13576. baseParams.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  13577. baseParams.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  13578. baseParams.SecretKey = miConfig.SecretKey
  13579. baseParams.OrgName = miConfig.OrgName
  13580. baseParams.FixmedinsCode = miConfig.Code
  13581. baseParams.EncKey = miConfig.EncKey
  13582. baseParams.AppSecret = miConfig.AppSecret
  13583. baseParams.SignKey = miConfig.SignKey
  13584. baseParams.AppID = miConfig.Code
  13585. baseParams.Doctor = role.UserName
  13586. baseParams.RequestUrl = miConfig.Url
  13587. businessParams := models.BusinessParams{
  13588. Insutype: insutype,
  13589. ClrType: clr_type,
  13590. SetlOptins: clr_org,
  13591. StmtBegndate: start_time,
  13592. StmtEnddate: end_time,
  13593. MedfeeSumamt: medfee_sumamt,
  13594. FundPaySumamt: fund_pay_sumamt,
  13595. AcctPay: acct_pay,
  13596. FixmedinsSetlCnt: fixmedins_setl_cnt,
  13597. }
  13598. result, requestLog, err_msg := service.FJyb3201(baseParams, businessParams, fmt.Sprintf("%.4f", medfee_sumamt), fmt.Sprintf("%.4f", fund_pay_sumamt))
  13599. fmt.Println(requestLog)
  13600. fmt.Println(result)
  13601. fmt.Println(err_msg)
  13602. var dat map[string]interface{}
  13603. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  13604. fmt.Println(dat)
  13605. } else {
  13606. fmt.Println(err)
  13607. }
  13608. userJSONBytes, _ := json.Marshal(dat)
  13609. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  13610. utils.ErrorLog("解析失败:%v", err)
  13611. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13612. return
  13613. }
  13614. } else {
  13615. if len(clr_type) == 0 {
  13616. clr_type = "11"
  13617. }
  13618. api := "http://127.0.0.1:9532/" + "gdyb/ten?" +
  13619. "insutype=" + insutype +
  13620. "&clr_type=" + clr_type +
  13621. "&setl_optins=" + clr_org +
  13622. "&stmt_begndate=" + start_time +
  13623. "&stm_enddate=" + end_time +
  13624. "&medfee_sumamt=" + fmt.Sprintf("%.4f", medfee_sumamt) +
  13625. "&fund_pay_sumamt=" + fmt.Sprintf("%.4f", fund_pay_sumamt) +
  13626. "&acct_pay=" + fmt.Sprintf("%.4f", acct_pay) +
  13627. "&fixmedins_setl_cnt=" + strconv.FormatInt(fixmedins_setl_cnt, 10) +
  13628. "&fixmedins_code=" + miConfig.Code +
  13629. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs +
  13630. "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  13631. "&secret_key=" + miConfig.SecretKey +
  13632. "&org_name=" + miConfig.OrgName +
  13633. "&doctor=" + user_name
  13634. fmt.Println(api)
  13635. resp, requestErr := http.Get(api)
  13636. if requestErr != nil {
  13637. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13638. return
  13639. }
  13640. body, ioErr := ioutil.ReadAll(resp.Body)
  13641. fmt.Println(body)
  13642. if ioErr != nil {
  13643. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  13644. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13645. return
  13646. }
  13647. var respJSON map[string]interface{}
  13648. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  13649. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  13650. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13651. return
  13652. }
  13653. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  13654. userJSONBytes, _ := json.Marshal(respJSON)
  13655. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  13656. utils.ErrorLog("解析失败:%v", err)
  13657. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13658. return
  13659. }
  13660. }
  13661. if res.Infcode == 0 {
  13662. if res.Output.Stmtinfo.StmtRslt == "0" {
  13663. micc := &models.MedicalInsuranceCostCompare{
  13664. StartTime: startime.Unix(),
  13665. EndTime: endtime.Unix(),
  13666. Insutype: insutype,
  13667. CheckType: 1,
  13668. Num: fixmedins_setl_cnt,
  13669. Mtime: time.Now().Unix(),
  13670. Status: 1,
  13671. UserOrgId: adminUser.CurrentOrgId,
  13672. CostTotal: medfee_sumamt,
  13673. FuncTotal: fund_pay_sumamt,
  13674. PsnPay: acct_pay,
  13675. Creator: admin_user_id,
  13676. Ctime: time.Now().Unix(),
  13677. ClrType: clr_type,
  13678. }
  13679. err := service.CreateMedicalInsuranceCostCompareRecord(micc)
  13680. if err == nil {
  13681. c.ServeSuccessJSON(map[string]interface{}{
  13682. "stmt_rslt": res.Output.Stmtinfo.StmtRslt,
  13683. "stmt_rslt_dscr": res.Output.Stmtinfo.StmtRsltDscr,
  13684. })
  13685. } else {
  13686. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13687. }
  13688. } else {
  13689. c.ServeSuccessJSON(map[string]interface{}{
  13690. "stmt_rslt": res.Output.Stmtinfo.StmtRslt,
  13691. "stmt_rslt_dscr": res.Output.Stmtinfo.StmtRsltDscr,
  13692. })
  13693. }
  13694. } else {
  13695. c.ServeSuccessJSON(map[string]interface{}{
  13696. "code": -10,
  13697. "msg": res.ErrMsg,
  13698. })
  13699. }
  13700. }
  13701. }
  13702. func (c *HisApiController) Check310() {
  13703. adminUser := c.GetAdminUserInfo()
  13704. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  13705. var user_name string
  13706. user_name = "高慧裕"
  13707. api := "http://127.0.0.1:9532/" + "gdyb/ten?" +
  13708. "insutype=" + "310" +
  13709. "&clr_type=" + "" +
  13710. "&setl_optins=" + "441202" +
  13711. "&stmt_begndate=" + "2022-03-01" +
  13712. "&stm_enddate=" + "2022-03-31" +
  13713. "&medfee_sumamt=" + "194930.12" +
  13714. "&fund_pay_sumamt=" + "188741.46" +
  13715. "&acct_pay=" + "0" +
  13716. "&fixmedins_setl_cnt=" + "452" +
  13717. "&fixmedins_code=" + miConfig.Code +
  13718. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs +
  13719. "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  13720. "&secret_key=" + miConfig.SecretKey +
  13721. "&org_name=" + miConfig.OrgName +
  13722. "&doctor=" + user_name
  13723. fmt.Println(api)
  13724. resp, requestErr := http.Get(api)
  13725. if requestErr != nil {
  13726. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13727. return
  13728. }
  13729. body, ioErr := ioutil.ReadAll(resp.Body)
  13730. fmt.Println(body)
  13731. if ioErr != nil {
  13732. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  13733. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13734. return
  13735. }
  13736. var respJSON map[string]interface{}
  13737. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  13738. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  13739. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13740. return
  13741. }
  13742. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  13743. userJSONBytes, _ := json.Marshal(respJSON)
  13744. var res ResultEight
  13745. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  13746. utils.ErrorLog("解析失败:%v", err)
  13747. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13748. return
  13749. }
  13750. }
  13751. func (c *HisApiController) Check390() {
  13752. adminUser := c.GetAdminUserInfo()
  13753. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  13754. var user_name string
  13755. user_name = "高慧裕"
  13756. api := "http://127.0.0.1:9532/" + "gdyb/ten?" +
  13757. "insutype=" + "390" +
  13758. "&clr_type=" + "" +
  13759. "&setl_optins=" + "441202" +
  13760. "&stmt_begndate=" + "2022-03-01" +
  13761. "&stm_enddate=" + "2022-03-31" +
  13762. "&medfee_sumamt=" + "1068448.89" +
  13763. "&fund_pay_sumamt=" + "1014677.62" +
  13764. "&acct_pay=" + "0" +
  13765. "&fixmedins_setl_cnt=" + "1950" +
  13766. "&fixmedins_code=" + miConfig.Code +
  13767. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs +
  13768. "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  13769. "&secret_key=" + miConfig.SecretKey +
  13770. "&org_name=" + miConfig.OrgName +
  13771. "&doctor=" + user_name
  13772. fmt.Println(api)
  13773. resp, requestErr := http.Get(api)
  13774. if requestErr != nil {
  13775. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13776. return
  13777. }
  13778. body, ioErr := ioutil.ReadAll(resp.Body)
  13779. fmt.Println(body)
  13780. if ioErr != nil {
  13781. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  13782. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13783. return
  13784. }
  13785. var respJSON map[string]interface{}
  13786. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  13787. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  13788. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13789. return
  13790. }
  13791. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  13792. userJSONBytes, _ := json.Marshal(respJSON)
  13793. var res ResultEight
  13794. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  13795. utils.ErrorLog("解析失败:%v", err)
  13796. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13797. return
  13798. }
  13799. }
  13800. // 对账明细
  13801. func (c *HisApiController) GetCheckDetailAccount() {
  13802. start_time := c.GetString("start_time")
  13803. end_time := c.GetString("end_time")
  13804. admin_user_id, _ := c.GetInt64("admin_user_id")
  13805. adminUser := c.GetAdminUserInfo()
  13806. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  13807. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  13808. timeLayout := "2006-01-02"
  13809. loc, _ := time.LoadLocation("Local")
  13810. startime, _ := time.ParseInLocation(timeLayout+" 15:04:05", start_time+" 00:00:00", loc)
  13811. endtime, _ := time.ParseInLocation(timeLayout+" 15:04:05", end_time+" 23:59:59", loc)
  13812. orders, _ := service.GetOrderByTimeTwo(startime.Unix(), endtime.Unix(), adminUser.CurrentOrgId)
  13813. rand.Seed(time.Now().UnixNano())
  13814. num := rand.Intn(30000)
  13815. Mkdir(miConfig.OrgName)
  13816. file := strconv.FormatInt(int64(num), 10)
  13817. file_name := file + ".txt"
  13818. zip_name := file + ".zip"
  13819. zip_path := miConfig.OrgName + "/" + zip_name
  13820. file_path := miConfig.OrgName + "/" + file_name
  13821. decimal.DivisionPrecision = 2
  13822. var medfee_sumamt float64
  13823. var psn_cash_pay float64
  13824. var fund_pay_sumamt float64
  13825. fixmedins_setl_cnt := int64(len(orders))
  13826. for _, item := range orders {
  13827. medfee_sumamt = medfee_sumamt + item.MedfeeSumamt
  13828. psn_cash_pay = psn_cash_pay + item.PsnCashPay
  13829. fund_pay_sumamt = fund_pay_sumamt + item.FundPaySumamt
  13830. }
  13831. f, err := os.Create(miConfig.OrgName + "/" + file_name)
  13832. defer f.Close()
  13833. if err != nil {
  13834. fmt.Println(err.Error())
  13835. } else {
  13836. for _, item := range orders {
  13837. var refd_setl_flag string
  13838. if item.OrderStatus == 2 {
  13839. refd_setl_flag = "0"
  13840. var str string
  13841. str = item.SetlId + " " +
  13842. item.MdtrtId + " " +
  13843. item.PsnNo + " " +
  13844. fmt.Sprintf("%.4f", item.MedfeeSumamt) + " " +
  13845. fmt.Sprintf("%.4f", item.FundPaySumamt) + " " +
  13846. fmt.Sprintf("%.4f", item.AcctPay) + " " + refd_setl_flag + "\r\n"
  13847. _, err = f.Write([]byte(str))
  13848. }
  13849. if item.OrderStatus == 3 {
  13850. var str string
  13851. str = item.SetlId + " " +
  13852. item.MdtrtId + " " +
  13853. item.PsnNo + " " +
  13854. fmt.Sprintf("%.4f", item.MedfeeSumamt) + " " +
  13855. fmt.Sprintf("%.4f", item.FundPaySumamt) + " " +
  13856. fmt.Sprintf("%.4f", item.AcctPay) + " " + "1" + "\r\n"
  13857. _, err = f.Write([]byte(str))
  13858. var str2 string
  13859. str2 = item.SetlId + " " +
  13860. item.MdtrtId + " " +
  13861. item.PsnNo + " " +
  13862. fmt.Sprintf("%.4f", 0-item.MedfeeSumamt) + " " +
  13863. fmt.Sprintf("%.4f", 0-item.FundPaySumamt) + " " +
  13864. fmt.Sprintf("%.4f", 0-item.AcctPay) + " " + "1" + "\r\n"
  13865. _, err = f.Write([]byte(str2))
  13866. }
  13867. }
  13868. }
  13869. Zip(file_path, zip_path)
  13870. fmt.Println(ReadFile(zip_path))
  13871. fmt.Println(string(ReadFile(zip_path)))
  13872. if config.IsOpen == 1 {
  13873. var user_name string
  13874. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  13875. if role.ID == 0 {
  13876. user_name = "管理员"
  13877. } else {
  13878. user_name = role.UserName
  13879. }
  13880. baseParams := models.BaseParams{
  13881. SecretKey: miConfig.SecretKey,
  13882. FixmedinsCode: miConfig.Code,
  13883. InsuplcAdmdvs: miConfig.InsuplcAdmdvs,
  13884. MdtrtareaAdmvs: miConfig.MdtrtareaAdmvs,
  13885. OrgName: miConfig.OrgName,
  13886. Doctor: user_name,
  13887. }
  13888. result := service.Gdyb9101(baseParams, file_name, ReadFile(file_path))
  13889. var dat map[string]interface{}
  13890. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  13891. fmt.Println(dat)
  13892. } else {
  13893. fmt.Println(err)
  13894. }
  13895. userJSONBytes, _ := json.Marshal(dat)
  13896. var res ResultNine
  13897. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  13898. utils.ErrorLog("解析失败:%v", err)
  13899. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13900. return
  13901. }
  13902. if res.Infcode == 0 {
  13903. fileNo := res.Output.FileQuryNo
  13904. api := "http://127.0.0.1:9532/" + "gdyb/twelve?" +
  13905. "file_qury_no=" + fileNo +
  13906. "&setl_optins=" + "定点医保中心" +
  13907. "&stmt_begndate=" + start_time +
  13908. "&stm_enddate=" + end_time +
  13909. "&medfee_sumamt=" + fmt.Sprintf("%.4f", medfee_sumamt) +
  13910. "&fund_pay_sumamt=" + fmt.Sprintf("%.4f", fund_pay_sumamt) +
  13911. "&cash_payamt=" + fmt.Sprintf("%.4f", psn_cash_pay) +
  13912. "&fixmedins_setl_cnt=" + strconv.FormatInt(fixmedins_setl_cnt, 10) +
  13913. "&fixmedins_code=" + miConfig.Code +
  13914. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs +
  13915. "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  13916. "&secret_key=" + miConfig.SecretKey +
  13917. "&org_name=" + miConfig.OrgName +
  13918. "&doctor=" + user_name
  13919. resp, requestErr := http.Get(api)
  13920. if requestErr != nil {
  13921. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13922. return
  13923. }
  13924. body, ioErr := ioutil.ReadAll(resp.Body)
  13925. if ioErr != nil {
  13926. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  13927. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13928. return
  13929. }
  13930. var respJSON map[string]interface{}
  13931. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  13932. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  13933. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13934. return
  13935. }
  13936. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  13937. userJSONBytes, _ := json.Marshal(respJSON)
  13938. var res ResultTen
  13939. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  13940. utils.ErrorLog("解析失败:%v", err)
  13941. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  13942. return
  13943. }
  13944. if res.Infcode == 0 {
  13945. service.Gdyb9102(baseParams, zip_name, fileNo)
  13946. micc := &models.MedicalInsuranceCostCompare{
  13947. StartTime: startime.Unix(),
  13948. EndTime: endtime.Unix(),
  13949. Insutype: "0",
  13950. CheckType: 2,
  13951. Num: fixmedins_setl_cnt,
  13952. Mtime: time.Now().Unix(),
  13953. Status: 1,
  13954. UserOrgId: adminUser.CurrentOrgId,
  13955. CostTotal: medfee_sumamt,
  13956. FuncTotal: fund_pay_sumamt,
  13957. PsnPay: psn_cash_pay,
  13958. Creator: admin_user_id,
  13959. Ctime: time.Now().Unix(),
  13960. }
  13961. service.CreateMedicalInsuranceCostCompareRecord(micc)
  13962. c.ServeSuccessJSON(map[string]interface{}{
  13963. "msg": "明细对账成功",
  13964. })
  13965. }
  13966. } else {
  13967. }
  13968. }
  13969. }
  13970. type CustomOrderInfo struct {
  13971. Name string
  13972. Spec string
  13973. Unit string
  13974. Count float64
  13975. Price float64
  13976. Total float64
  13977. }
  13978. func (c *HisApiController) GetBatchSettleAccounts() {
  13979. admin_user_id, _ := c.GetInt64("admin_user_id")
  13980. order_ids := c.GetString("order_ids")
  13981. order_ids_arr := strings.Split(order_ids, ",")
  13982. data3 := []map[string]interface{}{}
  13983. for _, item := range order_ids_arr {
  13984. id, _ := strconv.ParseInt(item, 10, 64)
  13985. order_id := id
  13986. adminUser := c.GetAdminUserInfo()
  13987. order, _ := service.GetHisOrderByID(order_id)
  13988. his, _ := service.GetHisPatientByNumber(order.MdtrtId)
  13989. orderInfos, _ := service.GetHisOrderInfoByNumber(order.Number)
  13990. orderInfos_two, _ := service.GetHisOrderInfoByNumberTwo(order.Number)
  13991. orderInfos = append(orderInfos, orderInfos_two...)
  13992. his_hospital, _ := service.GetInHospitalRecordByNumber(order.MdtrtId)
  13993. //diagnosisConfig, _ := service.FindDiagnoseById(his.Diagnosis)
  13994. var diagnosis_ids []string
  13995. if his.ID > 0 {
  13996. diagnosis_ids = strings.Split(his.Diagnosis, ",")
  13997. } else {
  13998. diagnosis_ids = strings.Split(his_hospital.Diagnosis, ",")
  13999. }
  14000. patient, _ := service.GetPatientByIDTwo(adminUser.CurrentOrgId, order.PatientId)
  14001. var dia_config []*models.HisXtDiagnoseConfig
  14002. var name string
  14003. for _, item := range diagnosis_ids {
  14004. id, _ := strconv.ParseInt(item, 10, 64)
  14005. diagnosisConfig, _ := service.FindDiagnoseById(id)
  14006. dia_config = append(dia_config, &diagnosisConfig)
  14007. if len(name) == 0 {
  14008. name = diagnosisConfig.ClassName
  14009. } else {
  14010. name = name + "," + diagnosisConfig.ClassName
  14011. }
  14012. }
  14013. var bedCostTotal float64 = 0 //床位总费
  14014. var bedCostSelfTotal float64 = 0 //床位自费
  14015. var bedCostPartSelfTotal float64 = 0 //床位部分项目自费
  14016. var bedSelfTotal float64 = 0 //床位部分项目自费
  14017. var bedInscpTotal float64 = 0 //床位部分项目自费
  14018. var operationCostTotal float64 = 0 //手术费
  14019. var operationCostSelfTotal float64 = 0 //手术费
  14020. var operationCostPartSelfTotal float64 = 0 //手术费
  14021. var operationSelfTotal float64 = 0 //床位部分项目自费
  14022. var operationInscpTotal float64 = 0 //床位部分项目自费
  14023. var otherCostTotal float64 = 0 //其他费用
  14024. var otherCostSelfTotal float64 = 0 //其他费用
  14025. var otherCostPartSelfTotal float64 = 0 //其他费用
  14026. var otherSelfTotal float64 = 0 //床位部分项目自费
  14027. var otherInscpTotal float64 = 0 //床位部分项目自费
  14028. var materialCostTotal float64 = 0 //材料费
  14029. var materialCostSelfTotal float64 = 0 //材料费
  14030. var materialCostPartSelfTotal float64 = 0 //材料费
  14031. var materialSelfTotal float64 = 0 //床位部分项目自费
  14032. var materialInscpTotal float64 = 0 //床位部分项目自费
  14033. var westernMedicineCostTotal float64 = 0 //西药费
  14034. var westernMedicineCostSelfTotal float64 = 0 //西药费
  14035. var westernMedicineCostPartSelfTotal float64 = 0 //西药费
  14036. var westernMedicineSelfTotal float64 = 0 //床位部分项目自费
  14037. var westernMedicineInscpTotal float64 = 0 //床位部分项目自费
  14038. var chineseTraditionalMedicineCostTotal float64 = 0 //中成药
  14039. var chineseTraditionalMedicineCostSelfTotal float64 = 0 //中成药
  14040. var chineseTraditionalMedicineCostPartSelfTotal float64 = 0 //中成药
  14041. var chineseTraditionalSelfTotal float64 = 0 //床位部分项目自费
  14042. var chineseTraditionalInscpTotal float64 = 0 //床位部分项目自费
  14043. var checkCostTotal float64 = 0 //检查费
  14044. var checkCostSelfTotal float64 = 0 //检查费
  14045. var checkCostPartSelfTotal float64 = 0 //检查费
  14046. var checkSelfTotal float64 = 0 //床位部分项目自费
  14047. var checkInscpTotal float64 = 0 //床位部分项目自费
  14048. var laboratoryCostTotal float64 = 0 //化验费
  14049. var laboratoryCostSelfTotal float64 = 0 //化验费
  14050. var laboratoryCostPartSelfTotal float64 = 0 //化验费
  14051. var laboratorySelfTotal float64 = 0 //床位部分项目自费
  14052. var laboratoryInscpTotal float64 = 0 //床位部分项目自费
  14053. var treatCostTotal float64 = 0 //治疗费用
  14054. var treatCostSelfTotal float64 = 0 //治疗费用
  14055. var treatCostPartSelfTotal float64 = 0 //治疗费用
  14056. var treatSelfTotal float64 = 0 //床位部分项目自费
  14057. var treatInscpTotal float64 = 0 //床位部分项目自费
  14058. decimal.DivisionPrecision = 2
  14059. for _, item := range orderInfos {
  14060. if item.MedChrgitmType == "01" { //床位费
  14061. bedCostTotal, _ = decimal.NewFromFloat(bedCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  14062. bedCostSelfTotal, _ = decimal.NewFromFloat(bedCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  14063. bedCostPartSelfTotal, _ = decimal.NewFromFloat(bedCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  14064. bedSelfTotal, _ = decimal.NewFromFloat(bedSelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  14065. bedInscpTotal, _ = decimal.NewFromFloat(bedInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
  14066. }
  14067. if c.GetAdminUserInfo().CurrentOrgId == 10188 || c.GetAdminUserInfo().CurrentOrgId == 10217 {
  14068. if item.MedChrgitmType == "03" { //检查费
  14069. laboratoryCostTotal, _ = decimal.NewFromFloat(laboratoryCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  14070. laboratoryCostSelfTotal, _ = decimal.NewFromFloat(laboratoryCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  14071. laboratoryCostPartSelfTotal, _ = decimal.NewFromFloat(laboratoryCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  14072. laboratorySelfTotal, _ = decimal.NewFromFloat(laboratorySelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  14073. laboratoryInscpTotal, _ = decimal.NewFromFloat(laboratoryInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
  14074. }
  14075. } else {
  14076. if item.MedChrgitmType == "03" { //检查费
  14077. checkCostTotal, _ = decimal.NewFromFloat(checkCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  14078. checkCostSelfTotal, _ = decimal.NewFromFloat(checkCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  14079. checkCostPartSelfTotal, _ = decimal.NewFromFloat(checkCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  14080. checkSelfTotal, _ = decimal.NewFromFloat(checkSelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  14081. checkInscpTotal, _ = decimal.NewFromFloat(checkInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
  14082. }
  14083. }
  14084. if item.MedChrgitmType == "04" { //化验费
  14085. laboratoryCostTotal, _ = decimal.NewFromFloat(laboratoryCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  14086. laboratoryCostSelfTotal, _ = decimal.NewFromFloat(laboratoryCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  14087. laboratoryCostPartSelfTotal, _ = decimal.NewFromFloat(laboratoryCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  14088. laboratorySelfTotal, _ = decimal.NewFromFloat(laboratorySelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  14089. laboratoryInscpTotal, _ = decimal.NewFromFloat(laboratoryInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
  14090. }
  14091. if item.MedChrgitmType == "05" || item.MedChrgitmType == "1402" || item.MedChrgitmType == "1403" { //治疗费
  14092. treatCostTotal, _ = decimal.NewFromFloat(treatCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  14093. treatCostSelfTotal, _ = decimal.NewFromFloat(treatCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  14094. treatCostPartSelfTotal, _ = decimal.NewFromFloat(treatCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  14095. treatSelfTotal, _ = decimal.NewFromFloat(treatSelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  14096. treatInscpTotal, _ = decimal.NewFromFloat(treatInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
  14097. }
  14098. if item.MedChrgitmType == "06" { //手术费
  14099. operationCostTotal, _ = decimal.NewFromFloat(operationCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  14100. operationCostSelfTotal, _ = decimal.NewFromFloat(operationCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  14101. operationCostPartSelfTotal, _ = decimal.NewFromFloat(operationCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  14102. operationSelfTotal, _ = decimal.NewFromFloat(operationSelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  14103. operationInscpTotal, _ = decimal.NewFromFloat(operationInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
  14104. }
  14105. if item.MedChrgitmType == "08" { //材料费
  14106. materialCostTotal, _ = decimal.NewFromFloat(materialCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  14107. materialCostSelfTotal, _ = decimal.NewFromFloat(materialCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  14108. materialCostPartSelfTotal, _ = decimal.NewFromFloat(materialCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  14109. materialSelfTotal, _ = decimal.NewFromFloat(materialSelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  14110. materialInscpTotal, _ = decimal.NewFromFloat(materialInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
  14111. }
  14112. if item.MedChrgitmType == "09" { //西药费
  14113. westernMedicineCostTotal, _ = decimal.NewFromFloat(westernMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  14114. westernMedicineCostSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  14115. westernMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  14116. westernMedicineSelfTotal, _ = decimal.NewFromFloat(westernMedicineSelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  14117. westernMedicineInscpTotal, _ = decimal.NewFromFloat(westernMedicineInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
  14118. }
  14119. if item.MedChrgitmType == "11" { //中成费
  14120. chineseTraditionalMedicineCostTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  14121. chineseTraditionalMedicineCostSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  14122. chineseTraditionalMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  14123. chineseTraditionalSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalSelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  14124. chineseTraditionalInscpTotal, _ = decimal.NewFromFloat(chineseTraditionalInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
  14125. }
  14126. if item.MedChrgitmType == "14" || item.MedChrgitmType == "0" || item.MedChrgitmType == "12" || item.MedChrgitmType == "02" { //其他费
  14127. otherCostTotal, _ = decimal.NewFromFloat(otherCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  14128. otherCostSelfTotal, _ = decimal.NewFromFloat(otherCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  14129. otherCostPartSelfTotal, _ = decimal.NewFromFloat(otherCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  14130. otherSelfTotal, _ = decimal.NewFromFloat(otherSelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  14131. otherInscpTotal, _ = decimal.NewFromFloat(otherInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
  14132. }
  14133. }
  14134. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  14135. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  14136. var user_name string
  14137. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  14138. if role.ID == 0 {
  14139. user_name = "管理员"
  14140. } else {
  14141. user_name = role.UserName
  14142. }
  14143. baseParams := models.BaseParams{
  14144. SecretKey: miConfig.SecretKey,
  14145. FixmedinsCode: miConfig.Code,
  14146. InsuplcAdmdvs: miConfig.InsuplcAdmdvs,
  14147. MdtrtareaAdmvs: miConfig.MdtrtareaAdmvs,
  14148. OrgName: miConfig.OrgName,
  14149. Doctor: user_name,
  14150. RequestUrl: miConfig.Url,
  14151. AccessKey: miConfig.AccessKey,
  14152. }
  14153. businessParams := models.BusinessParams{
  14154. PsnNo: order.PsnNo,
  14155. MdtrtId: order.MdtrtId,
  14156. SetlId: order.SetlId,
  14157. }
  14158. var res ResultEleven
  14159. var resEleven10265 ResultEleven10265
  14160. if config.IsOpen == 1 {
  14161. baseParams.InsuplcAdmdvs = his.InsuplcAdmdvs
  14162. result := service.Gdyb5203(baseParams, businessParams)
  14163. //service.Gdyb5204(baseParams, businessParams)
  14164. //service.Gdyb5302(businessParams.PsnNo, baseParams.OrgName, baseParams.Doctor, baseParams.FixmedinsCode, baseParams.InsuplcAdmdvs, baseParams.MdtrtareaAdmvs, baseParams.SecretKey)
  14165. var dat map[string]interface{}
  14166. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  14167. fmt.Println(dat)
  14168. } else {
  14169. fmt.Println(err)
  14170. }
  14171. userJSONBytes, _ := json.Marshal(dat)
  14172. if miConfig.Code == "H15049901371" {
  14173. if err := json.Unmarshal(userJSONBytes, &resEleven10265); err != nil {
  14174. utils.ErrorLog("解析失败:%v", err)
  14175. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14176. return
  14177. }
  14178. res.InfRefmsgid = resEleven10265.InfRefmsgid
  14179. res.Output = resEleven10265.Output
  14180. res.ErrMsg = resEleven10265.ErrMsg
  14181. res.Cainfo = resEleven10265.Cainfo
  14182. res.WarnMsg = resEleven10265.WarnMsg
  14183. infocode, _ := strconv.ParseInt(resEleven10265.Infcode, 10, 64)
  14184. res.Infcode = infocode
  14185. } else {
  14186. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  14187. utils.ErrorLog("解析失败:%v", err)
  14188. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14189. return
  14190. }
  14191. }
  14192. printor_admin, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  14193. charge_admin, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, order.Creator)
  14194. patientPrescription, _ := service.FindPatientPrescriptionInfo(adminUser.CurrentOrgId, order.PatientId, order.SettleAccountsDate)
  14195. adminRole_two, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, patientPrescription.DoctorId)
  14196. doctor_info, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, his_hospital.Doctor)
  14197. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  14198. var doctor_name string
  14199. if roles.ID == 0 {
  14200. doctor_name = "管理员"
  14201. } else {
  14202. doctor_name = roles.UserName
  14203. }
  14204. yiliao_leibie := ""
  14205. switch order.MedType {
  14206. case "11":
  14207. yiliao_leibie = "普通门诊"
  14208. break
  14209. case "12":
  14210. yiliao_leibie = "门诊挂号"
  14211. break
  14212. case "13":
  14213. yiliao_leibie = "急诊"
  14214. break
  14215. case "14":
  14216. yiliao_leibie = "门诊特殊病"
  14217. break
  14218. case "15":
  14219. yiliao_leibie = "门诊统筹"
  14220. break
  14221. case "16":
  14222. yiliao_leibie = "门诊慢性病"
  14223. break
  14224. case "21":
  14225. yiliao_leibie = "普通住院"
  14226. break
  14227. }
  14228. departments, _ := service.GetDepartMentDetail(patientPrescription.Departments)
  14229. res.Output.Setlinfo.PsnCashPay = res.Output.Setlinfo.CashPayamt
  14230. if res.Infcode == 0 {
  14231. data2 := map[string]interface{}{
  14232. "diagnosis": name,
  14233. "order_infos": orderInfos,
  14234. "number": order.MdtrtId,
  14235. "date": order.SettleAccountsDate,
  14236. "charge_admin": charge_admin,
  14237. "printor_admin": printor_admin,
  14238. "info": res.Output.Setlinfo,
  14239. "order": order,
  14240. "bedCostTotal": bedCostTotal,
  14241. "bedCostSelfTotal": bedCostSelfTotal,
  14242. "bedCostPartSelfTotal": bedCostPartSelfTotal,
  14243. "bedSelfTotal": bedSelfTotal,
  14244. "bedInscpTotal": bedInscpTotal,
  14245. "operationCostTotal": operationCostTotal,
  14246. "operationCostSelfTotal": operationCostSelfTotal,
  14247. "operationCostPartSelfTotal": operationCostPartSelfTotal,
  14248. "operationSelfTotal": operationSelfTotal,
  14249. "operationInscpTotal": operationInscpTotal,
  14250. "otherCostTotal": otherCostTotal,
  14251. "otherCostSelfTotal": otherCostSelfTotal,
  14252. "otherCostPartSelfTotal": otherCostPartSelfTotal,
  14253. "otherSelfTotal": otherSelfTotal,
  14254. "otherInscpTotal": otherInscpTotal,
  14255. "materialCostTotal": materialCostTotal,
  14256. "materialCostSelfTotal": materialCostSelfTotal,
  14257. "materialCostPartSelfTotal": materialCostPartSelfTotal,
  14258. "materialSelfTotal": materialSelfTotal,
  14259. "materialInscpTotal": materialInscpTotal,
  14260. "westernMedicineCostTotal": westernMedicineCostTotal,
  14261. "westernMedicineCostSelfTotal": westernMedicineCostSelfTotal,
  14262. "westernMedicineCostPartSelfTotal": westernMedicineCostPartSelfTotal,
  14263. "westernMedicineSelfTotal": westernMedicineSelfTotal,
  14264. "westernMedicineInscpTotal": westernMedicineInscpTotal,
  14265. "chineseTraditionalMedicineCostTotal": chineseTraditionalMedicineCostTotal,
  14266. "chineseTraditionalMedicineCostSelfTotal": chineseTraditionalMedicineCostSelfTotal,
  14267. "chineseTraditionalMedicineCostPartSelfTotal": chineseTraditionalMedicineCostPartSelfTotal,
  14268. "chineseTraditionalSelfTotal": chineseTraditionalSelfTotal,
  14269. "chineseTraditionalInscpTotal": chineseTraditionalInscpTotal,
  14270. "checkCostTotal": checkCostTotal,
  14271. "checkCostSelfTotal": checkCostSelfTotal,
  14272. "checkCostPartSelfTotal": checkCostPartSelfTotal,
  14273. "checkSelfTotal": checkSelfTotal,
  14274. "checkInscpTotal": checkInscpTotal,
  14275. "laboratoryCostTotal": laboratoryCostTotal,
  14276. "laboratoryCostSelfTotal": laboratoryCostSelfTotal,
  14277. "laboratoryCostPartSelfTotal": laboratoryCostPartSelfTotal,
  14278. "laboratorySelfTotal": laboratorySelfTotal,
  14279. "laboratoryInscpTotal": laboratoryInscpTotal,
  14280. "treatCostTotal": treatCostTotal,
  14281. "treatCostSelfTotal": treatCostSelfTotal,
  14282. "treatCostPartSelfTotal": treatCostPartSelfTotal,
  14283. "treatSelfTotal": treatSelfTotal,
  14284. "treatInscpTotal": treatInscpTotal,
  14285. "doctor_info": doctor_info,
  14286. "doctor_code": adminRole_two.DoctorCode,
  14287. "doctor_name": doctor_name,
  14288. "health_card_no": order.PsnNo,
  14289. "department": departments.Name,
  14290. "yiliao_leibie": yiliao_leibie,
  14291. "after_money": order.AccountPrice,
  14292. "patient": patient,
  14293. "org_name": miConfig.OrgName,
  14294. "org_code": miConfig.Code,
  14295. "order_number": order.Number,
  14296. "his_hospital": his_hospital,
  14297. "his": his,
  14298. "dia_config": dia_config,
  14299. "psn_cash_pay": order.PsnCashPay,
  14300. //"check_order_info": cus_slice,
  14301. }
  14302. data3 = append(data3, data2)
  14303. }
  14304. }
  14305. }
  14306. c.ServeSuccessJSON(map[string]interface{}{
  14307. "infos": data3,
  14308. })
  14309. }
  14310. func (c *HisApiController) GetSettleAccounts() {
  14311. //id, _ := c.GetInt64("id")
  14312. //record_time := c.GetString("record_time")
  14313. order_id, _ := c.GetInt64("order_id")
  14314. admin_user_id, _ := c.GetInt64("admin_user_id")
  14315. //timeLayout := "2006-01-02"
  14316. //loc, _ := time.LoadLocation("Local")
  14317. //
  14318. //theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  14319. //if err != nil {
  14320. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  14321. // return
  14322. //}
  14323. //recordDateTime := theTime.Unix()
  14324. adminUser := c.GetAdminUserInfo()
  14325. order, _ := service.GetHisOrderByID(order_id)
  14326. his, _ := service.GetHisPatientByNumber(order.MdtrtId)
  14327. orderInfos, _ := service.GetHisOrderInfoByNumber(order.Number)
  14328. orderInfos_two, _ := service.GetHisOrderInfoByNumberTwo(order.Number)
  14329. orderInfos = append(orderInfos, orderInfos_two...)
  14330. his_hospital, _ := service.GetInHospitalRecordByNumber(order.MdtrtId)
  14331. //diagnosisConfig, _ := service.FindDiagnoseById(his.Diagnosis)
  14332. var diagnosis_ids []string
  14333. if his.ID > 0 {
  14334. diagnosis_ids = strings.Split(his.Diagnosis, ",")
  14335. } else {
  14336. diagnosis_ids = strings.Split(his_hospital.Diagnosis, ",")
  14337. }
  14338. patient, _ := service.GetPatientByIDTwo(adminUser.CurrentOrgId, order.PatientId)
  14339. var dia_config []*models.HisXtDiagnoseConfig
  14340. var name string
  14341. for _, item := range diagnosis_ids {
  14342. id, _ := strconv.ParseInt(item, 10, 64)
  14343. diagnosisConfig, _ := service.FindDiagnoseById(id)
  14344. dia_config = append(dia_config, &diagnosisConfig)
  14345. if len(name) == 0 {
  14346. name = diagnosisConfig.ClassName
  14347. } else {
  14348. name = name + "," + diagnosisConfig.ClassName
  14349. }
  14350. }
  14351. var bedCostTotal float64 = 0 //床位总费
  14352. var bedCostSelfTotal float64 = 0 //床位自费
  14353. var bedCostPartSelfTotal float64 = 0 //床位部分项目自费
  14354. var bedSelfTotal float64 = 0 //床位部分项目自费
  14355. var bedInscpTotal float64 = 0 //床位部分项目自费
  14356. var operationCostTotal float64 = 0 //手术费
  14357. var operationCostSelfTotal float64 = 0 //手术费
  14358. var operationCostPartSelfTotal float64 = 0 //手术费
  14359. var operationSelfTotal float64 = 0 //床位部分项目自费
  14360. var operationInscpTotal float64 = 0 //床位部分项目自费
  14361. var otherCostTotal float64 = 0 //其他费用
  14362. var otherCostSelfTotal float64 = 0 //其他费用
  14363. var otherCostPartSelfTotal float64 = 0 //其他费用
  14364. var otherSelfTotal float64 = 0 //床位部分项目自费
  14365. var otherInscpTotal float64 = 0 //床位部分项目自费
  14366. var materialCostTotal float64 = 0 //材料费
  14367. var materialCostSelfTotal float64 = 0 //材料费
  14368. var materialCostPartSelfTotal float64 = 0 //材料费
  14369. var materialSelfTotal float64 = 0 //床位部分项目自费
  14370. var materialInscpTotal float64 = 0 //床位部分项目自费
  14371. var westernMedicineCostTotal float64 = 0 //西药费
  14372. var westernMedicineCostSelfTotal float64 = 0 //西药费
  14373. var westernMedicineCostPartSelfTotal float64 = 0 //西药费
  14374. var westernMedicineSelfTotal float64 = 0 //床位部分项目自费
  14375. var westernMedicineInscpTotal float64 = 0 //床位部分项目自费
  14376. var chineseTraditionalMedicineCostTotal float64 = 0 //中成药
  14377. var chineseTraditionalMedicineCostSelfTotal float64 = 0 //中成药
  14378. var chineseTraditionalMedicineCostPartSelfTotal float64 = 0 //中成药
  14379. var chineseTraditionalSelfTotal float64 = 0 //床位部分项目自费
  14380. var chineseTraditionalInscpTotal float64 = 0 //床位部分项目自费
  14381. var checkCostTotal float64 = 0 //检查费
  14382. var checkCostSelfTotal float64 = 0 //检查费
  14383. var checkCostPartSelfTotal float64 = 0 //检查费
  14384. var checkSelfTotal float64 = 0 //床位部分项目自费
  14385. var checkInscpTotal float64 = 0 //床位部分项目自费
  14386. var laboratoryCostTotal float64 = 0 //化验费
  14387. var laboratoryCostSelfTotal float64 = 0 //化验费
  14388. var laboratoryCostPartSelfTotal float64 = 0 //化验费
  14389. var laboratorySelfTotal float64 = 0 //床位部分项目自费
  14390. var laboratoryInscpTotal float64 = 0 //床位部分项目自费
  14391. var treatCostTotal float64 = 0 //治疗费用
  14392. var treatCostSelfTotal float64 = 0 //治疗费用
  14393. var treatCostPartSelfTotal float64 = 0 //治疗费用
  14394. var treatSelfTotal float64 = 0 //床位部分项目自费
  14395. var treatInscpTotal float64 = 0 //床位部分项目自费
  14396. decimal.DivisionPrecision = 2
  14397. for _, item := range orderInfos {
  14398. if item.MedChrgitmType == "01" { //床位费
  14399. bedCostTotal, _ = decimal.NewFromFloat(bedCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  14400. bedCostSelfTotal, _ = decimal.NewFromFloat(bedCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  14401. bedCostPartSelfTotal, _ = decimal.NewFromFloat(bedCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  14402. bedSelfTotal, _ = decimal.NewFromFloat(bedSelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  14403. bedInscpTotal, _ = decimal.NewFromFloat(bedInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
  14404. }
  14405. if c.GetAdminUserInfo().CurrentOrgId == 10188 || c.GetAdminUserInfo().CurrentOrgId == 10217 {
  14406. if item.MedChrgitmType == "03" { //检查费
  14407. laboratoryCostTotal, _ = decimal.NewFromFloat(laboratoryCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  14408. laboratoryCostSelfTotal, _ = decimal.NewFromFloat(laboratoryCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  14409. laboratoryCostPartSelfTotal, _ = decimal.NewFromFloat(laboratoryCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  14410. laboratorySelfTotal, _ = decimal.NewFromFloat(laboratorySelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  14411. laboratoryInscpTotal, _ = decimal.NewFromFloat(laboratoryInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
  14412. }
  14413. } else {
  14414. if item.MedChrgitmType == "03" { //检查费
  14415. checkCostTotal, _ = decimal.NewFromFloat(checkCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  14416. checkCostSelfTotal, _ = decimal.NewFromFloat(checkCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  14417. checkCostPartSelfTotal, _ = decimal.NewFromFloat(checkCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  14418. checkSelfTotal, _ = decimal.NewFromFloat(checkSelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  14419. checkInscpTotal, _ = decimal.NewFromFloat(checkInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
  14420. }
  14421. }
  14422. if item.MedChrgitmType == "04" { //化验费
  14423. laboratoryCostTotal, _ = decimal.NewFromFloat(laboratoryCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  14424. laboratoryCostSelfTotal, _ = decimal.NewFromFloat(laboratoryCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  14425. laboratoryCostPartSelfTotal, _ = decimal.NewFromFloat(laboratoryCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  14426. laboratorySelfTotal, _ = decimal.NewFromFloat(laboratorySelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  14427. laboratoryInscpTotal, _ = decimal.NewFromFloat(laboratoryInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
  14428. }
  14429. if item.MedChrgitmType == "05" || item.MedChrgitmType == "1402" || item.MedChrgitmType == "1403" { //治疗费
  14430. treatCostTotal, _ = decimal.NewFromFloat(treatCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  14431. treatCostSelfTotal, _ = decimal.NewFromFloat(treatCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  14432. treatCostPartSelfTotal, _ = decimal.NewFromFloat(treatCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  14433. treatSelfTotal, _ = decimal.NewFromFloat(treatSelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  14434. treatInscpTotal, _ = decimal.NewFromFloat(treatInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
  14435. }
  14436. if item.MedChrgitmType == "06" { //手术费
  14437. operationCostTotal, _ = decimal.NewFromFloat(operationCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  14438. operationCostSelfTotal, _ = decimal.NewFromFloat(operationCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  14439. operationCostPartSelfTotal, _ = decimal.NewFromFloat(operationCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  14440. operationSelfTotal, _ = decimal.NewFromFloat(operationSelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  14441. operationInscpTotal, _ = decimal.NewFromFloat(operationInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
  14442. }
  14443. if item.MedChrgitmType == "08" { //材料费
  14444. materialCostTotal, _ = decimal.NewFromFloat(materialCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  14445. materialCostSelfTotal, _ = decimal.NewFromFloat(materialCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  14446. materialCostPartSelfTotal, _ = decimal.NewFromFloat(materialCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  14447. materialSelfTotal, _ = decimal.NewFromFloat(materialSelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  14448. materialInscpTotal, _ = decimal.NewFromFloat(materialInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
  14449. }
  14450. if item.MedChrgitmType == "09" { //西药费
  14451. westernMedicineCostTotal, _ = decimal.NewFromFloat(westernMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  14452. westernMedicineCostSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  14453. westernMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  14454. westernMedicineSelfTotal, _ = decimal.NewFromFloat(westernMedicineSelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  14455. westernMedicineInscpTotal, _ = decimal.NewFromFloat(westernMedicineInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
  14456. }
  14457. if item.MedChrgitmType == "11" { //中成费
  14458. chineseTraditionalMedicineCostTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  14459. chineseTraditionalMedicineCostSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  14460. chineseTraditionalMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  14461. chineseTraditionalSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalSelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  14462. chineseTraditionalInscpTotal, _ = decimal.NewFromFloat(chineseTraditionalInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
  14463. }
  14464. if item.MedChrgitmType == "14" || item.MedChrgitmType == "0" || item.MedChrgitmType == "12" || item.MedChrgitmType == "02" { //其他费
  14465. otherCostTotal, _ = decimal.NewFromFloat(otherCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  14466. otherCostSelfTotal, _ = decimal.NewFromFloat(otherCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  14467. otherCostPartSelfTotal, _ = decimal.NewFromFloat(otherCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  14468. otherSelfTotal, _ = decimal.NewFromFloat(otherSelfTotal).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  14469. otherInscpTotal, _ = decimal.NewFromFloat(otherInscpTotal).Add(decimal.NewFromFloat(item.InscpScpAmt)).Float64()
  14470. }
  14471. }
  14472. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  14473. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  14474. var user_name string
  14475. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  14476. if role.ID == 0 {
  14477. user_name = "管理员"
  14478. } else {
  14479. user_name = role.UserName
  14480. }
  14481. baseParams := models.BaseParams{
  14482. SecretKey: miConfig.SecretKey,
  14483. FixmedinsCode: miConfig.Code,
  14484. InsuplcAdmdvs: miConfig.InsuplcAdmdvs,
  14485. MdtrtareaAdmvs: miConfig.MdtrtareaAdmvs,
  14486. OrgName: miConfig.OrgName,
  14487. Doctor: user_name,
  14488. RequestUrl: miConfig.Url,
  14489. AccessKey: miConfig.AccessKey,
  14490. }
  14491. businessParams := models.BusinessParams{
  14492. PsnNo: order.PsnNo,
  14493. MdtrtId: order.MdtrtId,
  14494. SetlId: order.SetlId,
  14495. }
  14496. var res ResultEleven
  14497. var resEleven10265 ResultEleven10265
  14498. if config.IsOpen == 1 {
  14499. if miConfig.MdtrtareaAdmvs == "421300" {
  14500. api := "http://192.168.124.4:9532/" + "hbyb/5203?psn_no=" + businessParams.PsnNo + "&mdtrt_id=" + businessParams.MdtrtId + "&setl_id=" + businessParams.SetlId +
  14501. "&org_name=" + miConfig.OrgName + "&doctor=" + baseParams.Doctor + "&fixmedins_code=" + miConfig.Code +
  14502. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  14503. resp, requestErr := http.Get(api)
  14504. if requestErr != nil {
  14505. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14506. return
  14507. }
  14508. body, ioErr := ioutil.ReadAll(resp.Body)
  14509. if ioErr != nil {
  14510. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  14511. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14512. return
  14513. }
  14514. var respJSON map[string]interface{}
  14515. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  14516. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  14517. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14518. return
  14519. }
  14520. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  14521. result, _ := json.Marshal(respJSON)
  14522. fmt.Println("log")
  14523. fmt.Println(string(result))
  14524. if err := json.Unmarshal([]byte(result), &res); err != nil {
  14525. utils.ErrorLog("解析失败:%v", err)
  14526. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14527. return
  14528. }
  14529. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  14530. var api string
  14531. if miConfig.MdtrtareaAdmvs == "320921" {
  14532. api = "http://192.168.2.3:9532/" + "jsyb/5203?psn_no=" + businessParams.PsnNo + "&mdtrt_id=" + businessParams.MdtrtId + "&setl_id=" + businessParams.SetlId +
  14533. "&org_name=" + miConfig.OrgName + "&doctor=" + baseParams.Doctor + "&fixmedins_code=" + miConfig.Code +
  14534. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  14535. //req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  14536. } else {
  14537. //req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  14538. api = "http://192.168.5.251:9532/" + "jsyb/5203?psn_no=" + businessParams.PsnNo + "&mdtrt_id=" + businessParams.MdtrtId + "&setl_id=" + businessParams.SetlId +
  14539. "&org_name=" + miConfig.OrgName + "&doctor=" + baseParams.Doctor + "&fixmedins_code=" + miConfig.Code +
  14540. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  14541. }
  14542. resp, requestErr := http.Get(api)
  14543. if requestErr != nil {
  14544. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14545. return
  14546. }
  14547. body, ioErr := ioutil.ReadAll(resp.Body)
  14548. if ioErr != nil {
  14549. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  14550. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14551. return
  14552. }
  14553. var respJSON map[string]interface{}
  14554. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  14555. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  14556. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14557. return
  14558. }
  14559. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  14560. result, _ := json.Marshal(respJSON)
  14561. fmt.Println("log")
  14562. fmt.Println(string(result))
  14563. if err := json.Unmarshal([]byte(result), &resEleven10265); err != nil {
  14564. utils.ErrorLog("解析失败:%v", err)
  14565. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14566. return
  14567. }
  14568. res.InfRefmsgid = resEleven10265.InfRefmsgid
  14569. res.Output = resEleven10265.Output
  14570. res.ErrMsg = resEleven10265.ErrMsg
  14571. res.Cainfo = resEleven10265.Cainfo
  14572. res.WarnMsg = resEleven10265.WarnMsg
  14573. infocode, _ := strconv.ParseInt(resEleven10265.Infcode, 10, 64)
  14574. res.Infcode = infocode
  14575. } else if miConfig.MdtrtareaAdmvs == "350500" {
  14576. result, requestLog, _ := service.FJyb5203(baseParams, businessParams, miConfig.Url, miConfig.Code, miConfig.AppSecret, miConfig.SignKey, miConfig.EncKey)
  14577. saveLog(result, requestLog, "5203", "结算单")
  14578. var dat map[string]interface{}
  14579. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  14580. fmt.Println(dat)
  14581. } else {
  14582. fmt.Println(err)
  14583. }
  14584. userJSONBytes, _ := json.Marshal(dat)
  14585. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  14586. utils.ErrorLog("解析失败:%v", err)
  14587. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14588. return
  14589. }
  14590. } else if miConfig.MdtrtareaAdmvs == "360399" {
  14591. result, requestLog := service.Jxyb5203(baseParams, businessParams)
  14592. saveLog(result, requestLog, "5203", "结算单")
  14593. var dat map[string]interface{}
  14594. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  14595. fmt.Println(dat)
  14596. } else {
  14597. fmt.Println(err)
  14598. }
  14599. userJSONBytes, _ := json.Marshal(dat)
  14600. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  14601. utils.ErrorLog("解析失败:%v", err)
  14602. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14603. return
  14604. }
  14605. } else if miConfig.MdtrtareaAdmvs == "430800" {
  14606. result, requestLog := service.Hnyb5203(baseParams, businessParams)
  14607. saveLog(result, requestLog, "5203", "结算单")
  14608. var dat map[string]interface{}
  14609. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  14610. fmt.Println(dat)
  14611. } else {
  14612. fmt.Println(err)
  14613. }
  14614. userJSONBytes, _ := json.Marshal(dat)
  14615. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  14616. utils.ErrorLog("解析失败:%v", err)
  14617. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14618. return
  14619. }
  14620. } else if miConfig.MdtrtareaAdmvs == "150499" {
  14621. api := "http://172.16.13.254:9532/" + "nmyb/5203?psn_no=" + businessParams.PsnNo + "&mdtrt_id=" + businessParams.MdtrtId + "&setl_id=" + businessParams.SetlId +
  14622. "&org_name=" + miConfig.OrgName + "&doctor=" + baseParams.Doctor + "&fixmedins_code=" + miConfig.Code +
  14623. "&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. body, ioErr := ioutil.ReadAll(resp.Body)
  14630. if ioErr != nil {
  14631. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  14632. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14633. return
  14634. }
  14635. var respJSON map[string]interface{}
  14636. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  14637. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  14638. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14639. return
  14640. }
  14641. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  14642. result, _ := json.Marshal(respJSON)
  14643. fmt.Println("log")
  14644. fmt.Println(string(result))
  14645. if err := json.Unmarshal([]byte(result), &resEleven10265); err != nil {
  14646. utils.ErrorLog("解析失败:%v", err)
  14647. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14648. return
  14649. }
  14650. res.InfRefmsgid = resEleven10265.InfRefmsgid
  14651. res.Output = resEleven10265.Output
  14652. res.ErrMsg = resEleven10265.ErrMsg
  14653. res.Cainfo = resEleven10265.Cainfo
  14654. res.WarnMsg = resEleven10265.WarnMsg
  14655. infocode, _ := strconv.ParseInt(resEleven10265.Infcode, 10, 64)
  14656. res.Infcode = infocode
  14657. } else {
  14658. baseParams.InsuplcAdmdvs = his.InsuplcAdmdvs
  14659. result := service.Gdyb5203(baseParams, businessParams)
  14660. //service.Gdyb5204(baseParams, businessParams)
  14661. //service.Gdyb5302(businessParams.PsnNo, baseParams.OrgName, baseParams.Doctor, baseParams.FixmedinsCode, baseParams.InsuplcAdmdvs, baseParams.MdtrtareaAdmvs, baseParams.SecretKey)
  14662. var dat map[string]interface{}
  14663. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  14664. fmt.Println(dat)
  14665. } else {
  14666. fmt.Println(err)
  14667. }
  14668. userJSONBytes, _ := json.Marshal(dat)
  14669. if miConfig.Code == "H15049901371" {
  14670. if err := json.Unmarshal(userJSONBytes, &resEleven10265); err != nil {
  14671. utils.ErrorLog("解析失败:%v", err)
  14672. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14673. return
  14674. }
  14675. res.InfRefmsgid = resEleven10265.InfRefmsgid
  14676. res.Output = resEleven10265.Output
  14677. res.ErrMsg = resEleven10265.ErrMsg
  14678. res.Cainfo = resEleven10265.Cainfo
  14679. res.WarnMsg = resEleven10265.WarnMsg
  14680. infocode, _ := strconv.ParseInt(resEleven10265.Infcode, 10, 64)
  14681. res.Infcode = infocode
  14682. } else {
  14683. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  14684. utils.ErrorLog("解析失败:%v", err)
  14685. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14686. return
  14687. }
  14688. }
  14689. }
  14690. printor_admin, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  14691. charge_admin, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, order.Creator)
  14692. patientPrescription, _ := service.FindPatientPrescriptionInfo(adminUser.CurrentOrgId, order.PatientId, order.SettleAccountsDate)
  14693. adminRole_two, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, patientPrescription.DoctorId)
  14694. doctor_info, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, his_hospital.Doctor)
  14695. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  14696. var doctor_name string
  14697. if roles.ID == 0 {
  14698. doctor_name = "管理员"
  14699. } else {
  14700. doctor_name = roles.UserName
  14701. }
  14702. yiliao_leibie := ""
  14703. switch order.MedType {
  14704. case "11":
  14705. yiliao_leibie = "普通门诊"
  14706. break
  14707. case "12":
  14708. yiliao_leibie = "门诊挂号"
  14709. break
  14710. case "13":
  14711. yiliao_leibie = "急诊"
  14712. break
  14713. case "14":
  14714. yiliao_leibie = "门诊特殊病"
  14715. break
  14716. case "15":
  14717. yiliao_leibie = "门诊统筹"
  14718. break
  14719. case "16":
  14720. yiliao_leibie = "门诊慢性病"
  14721. break
  14722. case "21":
  14723. yiliao_leibie = "普通住院"
  14724. break
  14725. }
  14726. departments, _ := service.GetDepartMentDetail(patientPrescription.Departments)
  14727. res.Output.Setlinfo.PsnCashPay = res.Output.Setlinfo.CashPayamt
  14728. if res.Infcode == 0 {
  14729. c.ServeSuccessJSON(map[string]interface{}{
  14730. "diagnosis": name,
  14731. "order_infos": orderInfos,
  14732. "number": order.MdtrtId,
  14733. "date": order.SettleAccountsDate,
  14734. "charge_admin": charge_admin,
  14735. "printor_admin": printor_admin,
  14736. "info": res.Output.Setlinfo,
  14737. "order": order,
  14738. "bedCostTotal": bedCostTotal,
  14739. "bedCostSelfTotal": bedCostSelfTotal,
  14740. "bedCostPartSelfTotal": bedCostPartSelfTotal,
  14741. "bedSelfTotal": bedSelfTotal,
  14742. "bedInscpTotal": bedInscpTotal,
  14743. "operationCostTotal": operationCostTotal,
  14744. "operationCostSelfTotal": operationCostSelfTotal,
  14745. "operationCostPartSelfTotal": operationCostPartSelfTotal,
  14746. "operationSelfTotal": operationSelfTotal,
  14747. "operationInscpTotal": operationInscpTotal,
  14748. "otherCostTotal": otherCostTotal,
  14749. "otherCostSelfTotal": otherCostSelfTotal,
  14750. "otherCostPartSelfTotal": otherCostPartSelfTotal,
  14751. "otherSelfTotal": otherSelfTotal,
  14752. "otherInscpTotal": otherInscpTotal,
  14753. "materialCostTotal": materialCostTotal,
  14754. "materialCostSelfTotal": materialCostSelfTotal,
  14755. "materialCostPartSelfTotal": materialCostPartSelfTotal,
  14756. "materialSelfTotal": materialSelfTotal,
  14757. "materialInscpTotal": materialInscpTotal,
  14758. "westernMedicineCostTotal": westernMedicineCostTotal,
  14759. "westernMedicineCostSelfTotal": westernMedicineCostSelfTotal,
  14760. "westernMedicineCostPartSelfTotal": westernMedicineCostPartSelfTotal,
  14761. "westernMedicineSelfTotal": westernMedicineSelfTotal,
  14762. "westernMedicineInscpTotal": westernMedicineInscpTotal,
  14763. "chineseTraditionalMedicineCostTotal": chineseTraditionalMedicineCostTotal,
  14764. "chineseTraditionalMedicineCostSelfTotal": chineseTraditionalMedicineCostSelfTotal,
  14765. "chineseTraditionalMedicineCostPartSelfTotal": chineseTraditionalMedicineCostPartSelfTotal,
  14766. "chineseTraditionalSelfTotal": chineseTraditionalSelfTotal,
  14767. "chineseTraditionalInscpTotal": chineseTraditionalInscpTotal,
  14768. "checkCostTotal": checkCostTotal,
  14769. "checkCostSelfTotal": checkCostSelfTotal,
  14770. "checkCostPartSelfTotal": checkCostPartSelfTotal,
  14771. "checkSelfTotal": checkSelfTotal,
  14772. "checkInscpTotal": checkInscpTotal,
  14773. "laboratoryCostTotal": laboratoryCostTotal,
  14774. "laboratoryCostSelfTotal": laboratoryCostSelfTotal,
  14775. "laboratoryCostPartSelfTotal": laboratoryCostPartSelfTotal,
  14776. "laboratorySelfTotal": laboratorySelfTotal,
  14777. "laboratoryInscpTotal": laboratoryInscpTotal,
  14778. "treatCostTotal": treatCostTotal,
  14779. "treatCostSelfTotal": treatCostSelfTotal,
  14780. "treatCostPartSelfTotal": treatCostPartSelfTotal,
  14781. "treatSelfTotal": treatSelfTotal,
  14782. "treatInscpTotal": treatInscpTotal,
  14783. "doctor_info": doctor_info,
  14784. "doctor_code": adminRole_two.DoctorCode,
  14785. "doctor_name": doctor_name,
  14786. "health_card_no": order.PsnNo,
  14787. "department": departments.Name,
  14788. "yiliao_leibie": yiliao_leibie,
  14789. "after_money": order.AccountPrice,
  14790. "patient": patient,
  14791. "org_name": miConfig.OrgName,
  14792. "org_code": miConfig.Code,
  14793. "order_number": order.Number,
  14794. "his_hospital": his_hospital,
  14795. "his": his,
  14796. "dia_config": dia_config,
  14797. "psn_cash_pay": order.PsnCashPay,
  14798. //"check_order_info": cus_slice,
  14799. })
  14800. }
  14801. }
  14802. }
  14803. func (c *HisApiController) CheckTreatment() {
  14804. patient_id, _ := c.GetInt64("patient_id")
  14805. id_card_no := c.GetString("id_card_no")
  14806. insutype := c.GetString("insutype")
  14807. med_type := c.GetString("med_type")
  14808. admin_user_id, _ := c.GetInt64("admin_user_id")
  14809. adminUser := c.GetAdminUserInfo()
  14810. patient, _ := service.GetPatientByID(adminUser.CurrentOrgId, patient_id)
  14811. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  14812. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  14813. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  14814. if miConfig.MdtrtareaAdmvs == "421300" {
  14815. var res ResultTwo
  14816. api := "http://192.168.124.4:9532/" + "hbyb/1101?cert_no=" + "" +
  14817. "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  14818. "&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)
  14819. resp, requestErr := http.Get(api)
  14820. if requestErr != nil {
  14821. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14822. return
  14823. }
  14824. body, ioErr := ioutil.ReadAll(resp.Body)
  14825. if ioErr != nil {
  14826. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  14827. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14828. return
  14829. }
  14830. var respJSON map[string]interface{}
  14831. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  14832. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  14833. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14834. return
  14835. }
  14836. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  14837. result, _ := json.Marshal(respJSON)
  14838. if err := json.Unmarshal([]byte(result), &res); err != nil {
  14839. utils.ErrorLog("解析失败:%v", err)
  14840. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14841. return
  14842. }
  14843. if res.Infcode == 0 {
  14844. api := "http://192.168.124.4:9532/" + "hbyb/2001?cert_no=" + "" +
  14845. "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  14846. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&psn_no=" + res.Output.Baseinfo.PsnNo + "&insutype=" + insutype + "&med_type=" + med_type
  14847. resp, requestErr := http.Get(api)
  14848. if requestErr != nil {
  14849. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14850. return
  14851. }
  14852. body, ioErr := ioutil.ReadAll(resp.Body)
  14853. if ioErr != nil {
  14854. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  14855. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14856. return
  14857. }
  14858. var respJSON map[string]interface{}
  14859. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  14860. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  14861. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14862. return
  14863. }
  14864. var res Result2001
  14865. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  14866. result2, _ := json.Marshal(respJSON)
  14867. if err := json.Unmarshal([]byte(result2), &res); err != nil {
  14868. utils.ErrorLog("解析失败:%v", err)
  14869. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14870. return
  14871. }
  14872. if res.Infcode == 0 {
  14873. c.ServeSuccessJSON(map[string]interface{}{
  14874. "msg": res.Output.Trtinfo,
  14875. })
  14876. }
  14877. } else {
  14878. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  14879. return
  14880. }
  14881. } else {
  14882. result := service.Gdyb1101A(id_card_no, miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, patient.Name)
  14883. var dat map[string]interface{}
  14884. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  14885. fmt.Println(dat)
  14886. } else {
  14887. fmt.Println(err)
  14888. }
  14889. userJSONBytes, _ := json.Marshal(dat)
  14890. var res ResultTwo
  14891. var res10265 ResultTwo10265
  14892. if miConfig.Code == "H15049901371" {
  14893. if err := json.Unmarshal(userJSONBytes, &res10265); err != nil {
  14894. utils.ErrorLog("解析失败:%v", err)
  14895. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14896. return
  14897. }
  14898. res.ErrMsg = res10265.ErrMsg
  14899. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  14900. res.Infcode = infocode
  14901. res.Output = res10265.Output
  14902. res.InfRefmsgid = res10265.InfRefmsgid
  14903. } else {
  14904. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  14905. utils.ErrorLog("解析失败:%v", err)
  14906. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14907. return
  14908. }
  14909. }
  14910. var user_name string
  14911. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, adminUser.AdminUser.Id)
  14912. if role.ID == 0 {
  14913. user_name = "xxx"
  14914. } else {
  14915. user_name = role.UserName
  14916. }
  14917. baseParams := models.BaseParams{
  14918. SecretKey: miConfig.SecretKey,
  14919. FixmedinsCode: miConfig.Code,
  14920. InsuplcAdmdvs: miConfig.InsuplcAdmdvs,
  14921. MdtrtareaAdmvs: miConfig.MdtrtareaAdmvs,
  14922. OrgName: miConfig.OrgName,
  14923. Doctor: user_name,
  14924. }
  14925. if config.IsOpen == 1 {
  14926. if miConfig.Code == "H15049901371" {
  14927. if med_type == "14" {
  14928. if insutype == "390" {
  14929. med_type = "9933"
  14930. } else if insutype == "310" {
  14931. med_type = "990502"
  14932. }
  14933. } else if med_type == "11" {
  14934. med_type = "11"
  14935. }
  14936. }
  14937. result := service.Gdyb2001(baseParams, res.Output.Baseinfo.PsnNo, insutype, med_type)
  14938. var dat map[string]interface{}
  14939. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  14940. fmt.Println(dat)
  14941. } else {
  14942. fmt.Println(err)
  14943. }
  14944. var res Result2001
  14945. var res10265 Result2001Org10265
  14946. if miConfig.Code == "H15049901371" {
  14947. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  14948. utils.ErrorLog("解析失败:%v", err)
  14949. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14950. return
  14951. }
  14952. res.ErrMsg = res10265.ErrMsg
  14953. res.Output = res10265.Output
  14954. res.InfRefmsgid = res10265.InfRefmsgid
  14955. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  14956. res.Infcode = infocode
  14957. } else {
  14958. if err := json.Unmarshal([]byte(result), &res); err != nil {
  14959. utils.ErrorLog("解析失败:%v", err)
  14960. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  14961. return
  14962. }
  14963. }
  14964. if res.Infcode == 0 {
  14965. c.ServeSuccessJSON(map[string]interface{}{
  14966. "msg": res.Output.Trtinfo,
  14967. })
  14968. }
  14969. }
  14970. }
  14971. }
  14972. //func (c *HisApiController) PutRecord() {
  14973. // id, _ := c.GetInt64("id")
  14974. // record_time := c.GetString("record_time")
  14975. // timeLayout := "2006-01-02"
  14976. // loc, _ := time.LoadLocation("Local")
  14977. // theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  14978. // if err != nil {
  14979. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  14980. // return
  14981. // }
  14982. // recordDateTime := theTime.Unix()
  14983. //
  14984. // adminInfo := c.GetAdminUserInfo()
  14985. // patient, _ := service.GetPatientByID(adminInfo.CurrentOrgId, id)
  14986. // patientPrescription, _ := service.FindPatientPrescriptionInfo(adminInfo.CurrentOrgId, id, recordDateTime)
  14987. //
  14988. // miConfig, _ := service.FindMedicalInsuranceInfo(adminInfo.CurrentOrgId)
  14989. //
  14990. // fmt.Println(miConfig.SecretKey)
  14991. //
  14992. // if patient == nil {
  14993. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodePatientNoExist)
  14994. // return
  14995. // }
  14996. // if len(patient.IdCardNo) == 0 {
  14997. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeIDCartNo)
  14998. // return
  14999. // }
  15000. // config, _ := service.GetMedicalInsuranceConfig(adminInfo.CurrentOrgId)
  15001. // if config.IsOpen == 1 {
  15002. // 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
  15003. // resp, requestErr := http.Get(api)
  15004. // if requestErr != nil {
  15005. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  15006. // return
  15007. // }
  15008. // defer resp.Body.Close()
  15009. // body, ioErr := ioutil.ReadAll(resp.Body)
  15010. // if ioErr != nil {
  15011. // utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  15012. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  15013. // return
  15014. // }
  15015. // var respJSON map[string]interface{}
  15016. //
  15017. // if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  15018. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  15019. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  15020. // return
  15021. // }
  15022. //
  15023. // userJSON := respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  15024. // userJSONBytes, _ := json.Marshal(userJSON)
  15025. // var res ResultTwo
  15026. // if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  15027. // utils.ErrorLog("解析失败:%v", err)
  15028. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  15029. // return
  15030. // }
  15031. // Iinfos, _ := json.Marshal(res.Output.Iinfo)
  15032. // Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  15033. // infoStr := string(Iinfos)
  15034. // idetinfoStr := string(Idetinfos)
  15035. //
  15036. // if res.Infcode == 0 {
  15037. // his := models.VMHisPatient{
  15038. // Status: 1,
  15039. // Ctime: time.Now().Unix(),
  15040. // Mtime: time.Now().Unix(),
  15041. // PsnNo: res.Output.Baseinfo.PsnNo,
  15042. // PsnCertType: res.Output.Baseinfo.PsnCertType,
  15043. // Certno: res.Output.Baseinfo.Certno,
  15044. // PsnName: res.Output.Baseinfo.PsnName,
  15045. // Gend: res.Output.Baseinfo.Gend,
  15046. // Naty: res.Output.Baseinfo.Naty,
  15047. // Brdy: res.Output.Baseinfo.Brdy,
  15048. // Age: res.Output.Baseinfo.Age,
  15049. // Iinfo: infoStr,
  15050. // Idetinfo: idetinfoStr,
  15051. // PatientId: patient.ID,
  15052. // RecordDate: theTime.Unix(),
  15053. // UserOrgId: adminInfo.CurrentOrgId,
  15054. // AdminUserId: adminInfo.AdminUser.Id,
  15055. // IsReturn: 1,
  15056. // }
  15057. //
  15058. // //doctor_id := strconv.FormatInt(patientPrescription.DoctorId, 10)
  15059. // //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")
  15060. // //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")
  15061. //
  15062. // //var dat map[string]interface{}
  15063. // //if err := json.Unmarshal([]byte(result), &dat); err == nil {
  15064. // // fmt.Println(dat)
  15065. // //} else {
  15066. // // fmt.Println(err)
  15067. // //}
  15068. //
  15069. // var dat2 map[string]interface{}
  15070. // if err := json.Unmarshal([]byte(result2), &dat2); err == nil {
  15071. // fmt.Println(dat2)
  15072. // } else {
  15073. // fmt.Println(err)
  15074. // }
  15075. //
  15076. // } else {
  15077. // adminUser := c.GetAdminUserInfo()
  15078. // errlog := &models.HisOrderError{
  15079. // UserOrgId: adminUser.CurrentOrgId,
  15080. // Ctime: time.Now().Unix(),
  15081. // Mtime: time.Now().Unix(),
  15082. // ErrMsg: res.ErrMsg,
  15083. // Status: 1,
  15084. // PatientId: id,
  15085. // RecordTime: recordDateTime,
  15086. // Stage: 1,
  15087. // }
  15088. // service.CreateErrMsgLog(errlog)
  15089. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeGdybOneException)
  15090. // return
  15091. // }
  15092. // }
  15093. //
  15094. //}
  15095. //func (c *HisApiController) GetUploadDiag() {
  15096. // id, _ := c.GetInt64("id")
  15097. // record_time := c.GetString("record_time")
  15098. //
  15099. // diagnosis_id, _ := c.GetInt64("diagnosis")
  15100. // sick_type, _ := c.GetInt64("sick_type")
  15101. // reg_type, _ := c.GetInt64("reg_type")
  15102. //
  15103. // timeLayout := "2006-01-02"
  15104. // loc, _ := time.LoadLocation("Local")
  15105. // theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  15106. // if err != nil {
  15107. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  15108. // return
  15109. // }
  15110. //
  15111. // var patientPrescription models.HisPrescriptionInfo
  15112. // recordDateTime := theTime.Unix()
  15113. // adminInfo := c.GetAdminUserInfo()
  15114. // patientPrescription, _ = service.FindPatientPrescriptionInfo(adminInfo.CurrentOrgId, id, recordDateTime)
  15115. //
  15116. // if patientPrescription.ID == 0 {
  15117. // patientPrescription, _ = service.FindLastPatientPrescriptionInfo(adminInfo.CurrentOrgId, id, recordDateTime)
  15118. // }
  15119. //
  15120. // miConfig, _ := service.FindMedicalInsuranceInfo(adminInfo.CurrentOrgId)
  15121. // diagnosisConfig, _ := service.FindDiagnoseById(diagnosis_id)
  15122. // his, _ := service.GetVMHisPatientInfo(adminInfo.CurrentOrgId, id, recordDateTime)
  15123. // sickConfig, _ := service.FindSickById(sick_type)
  15124. // department, _ := service.GetDepartMentDetail(patientPrescription.Departments)
  15125. //
  15126. // api2 := "http://127.0.0.1:9532/" + "gdyb/four?psn_no=" + his.PsnNo +
  15127. // "&mdtrt_id=" + his.Number + "&doctor=" + patientPrescription.Doctor + "&department=" + department.Name +
  15128. // "&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 +
  15129. // "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&sick_code=" + sickConfig.ContentCode + "&sick_name=" + sickConfig.ClassName
  15130. // resp2, requestErr2 := http.Get(api2)
  15131. // if requestErr2 != nil {
  15132. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  15133. // return
  15134. // }
  15135. // body2, ioErr2 := ioutil.ReadAll(resp2.Body)
  15136. // if ioErr2 != nil {
  15137. // utils.ErrorLog("接口返回数据读取失败: %v", ioErr2)
  15138. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  15139. // return
  15140. // }
  15141. // var respJSON2 map[string]interface{}
  15142. // if err := json.Unmarshal([]byte(string(body2)), &respJSON2); err != nil {
  15143. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  15144. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  15145. // return
  15146. // }
  15147. // respJSON2 = respJSON2["data"].(map[string]interface{})["pre"].(map[string]interface{})
  15148. // userJSONBytes2, _ := json.Marshal(respJSON2)
  15149. //
  15150. // var res2 ResultSix
  15151. // if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  15152. // utils.ErrorLog("解析失败:%v", err)
  15153. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  15154. // return
  15155. // }
  15156. // if res2.Infcode != 0 {
  15157. // adminUser := c.GetAdminUserInfo()
  15158. // errlog := &models.HisOrderError{
  15159. // UserOrgId: adminUser.CurrentOrgId,
  15160. // Ctime: time.Now().Unix(),
  15161. // Mtime: time.Now().Unix(),
  15162. // ErrMsg: res2.ErrMsg,
  15163. // Status: 1,
  15164. // PatientId: id,
  15165. // RecordTime: recordDateTime,
  15166. // Stage: 3,
  15167. // }
  15168. // service.CreateErrMsgLog(errlog)
  15169. //
  15170. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeRegisterThreeException)
  15171. // return
  15172. // }
  15173. //
  15174. // c.ServeSuccessJSON(map[string]interface{}{
  15175. // "msg": "上传成功",
  15176. // })
  15177. //
  15178. //}
  15179. type QueryResult struct {
  15180. ID int64
  15181. Name string
  15182. Code string
  15183. List_type_code string
  15184. }
  15185. func (c *HisApiController) GetCheckCode() {
  15186. ids_str := c.GetString("ids")
  15187. record_type, _ := c.GetInt64("record_type") //1.药品 2.耗材 3.项目
  15188. ids_arr := strings.Split(ids_str, ",")
  15189. var queryResult []QueryResult
  15190. ids := make([]int64, 0)
  15191. for _, item := range ids_arr {
  15192. id, _ := strconv.ParseInt(item, 10, 64)
  15193. ids = append(ids, id)
  15194. }
  15195. if record_type == 1 {
  15196. drugs, _ := service.GetBatchDrugList(ids)
  15197. for _, item := range drugs {
  15198. result := QueryResult{
  15199. ID: item.ID,
  15200. Name: item.DrugName,
  15201. Code: item.MedicalInsuranceNumber,
  15202. List_type_code: "101",
  15203. }
  15204. queryResult = append(queryResult, result)
  15205. }
  15206. } else if record_type == 2 {
  15207. goods, _ := service.GetBatchGoodInformationList(ids)
  15208. for _, item := range goods {
  15209. result := QueryResult{
  15210. ID: item.ID,
  15211. Name: item.GoodName,
  15212. Code: item.MedicalInsuranceNumber,
  15213. List_type_code: "301",
  15214. }
  15215. queryResult = append(queryResult, result)
  15216. }
  15217. } else if record_type == 3 {
  15218. projects, _ := service.GetBathchMyPorjecgList(ids)
  15219. for _, item := range projects {
  15220. result := QueryResult{
  15221. ID: item.ID,
  15222. Name: item.ProjectName,
  15223. Code: item.MedicalCode,
  15224. List_type_code: "201",
  15225. }
  15226. queryResult = append(queryResult, result)
  15227. }
  15228. }
  15229. admin_user_id, _ := c.GetInt64("admin_user_id")
  15230. adminUser := c.GetAdminUserInfo()
  15231. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  15232. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  15233. var user_name string
  15234. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  15235. if role.ID == 0 {
  15236. user_name = "xxx"
  15237. } else {
  15238. user_name = role.UserName
  15239. }
  15240. baseParams := &models.BaseParams{
  15241. SecretKey: miConfig.SecretKey,
  15242. FixmedinsCode: miConfig.Code,
  15243. InsuplcAdmdvs: miConfig.InsuplcAdmdvs,
  15244. MdtrtareaAdmvs: miConfig.MdtrtareaAdmvs,
  15245. OrgName: miConfig.OrgName,
  15246. Doctor: user_name,
  15247. }
  15248. if config.IsOpen == 1 {
  15249. for _, item := range queryResult {
  15250. var result string
  15251. if record_type == 1 {
  15252. result = service.Gdyb3301(baseParams, item.Name, item.Code, item.List_type_code, "2021-04-26", "", item.List_type_code)
  15253. } else if record_type == 2 {
  15254. result = service.Gdyb3301(baseParams, item.Name, item.Code, item.List_type_code, "2021-04-26", "", item.List_type_code)
  15255. } else if record_type == 3 {
  15256. result = service.Gdyb3301(baseParams, item.Name, item.Code, item.List_type_code, "2021-04-26", "", item.List_type_code)
  15257. }
  15258. var dat map[string]interface{}
  15259. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  15260. fmt.Println(dat)
  15261. } else {
  15262. fmt.Println(err)
  15263. }
  15264. userJSONBytes, _ := json.Marshal(dat)
  15265. var res ResultSix
  15266. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  15267. utils.ErrorLog("解析失败:%v", err)
  15268. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  15269. return
  15270. }
  15271. if res.Infcode == 0 {
  15272. if record_type == 1 {
  15273. service.UpdateBaseDrugById(item.ID)
  15274. } else if record_type == 2 {
  15275. service.UpdateGoodInformaitonByDetail(item.ID)
  15276. } else if record_type == 3 {
  15277. service.UpdateProjectById(item.ID)
  15278. }
  15279. c.ServeSuccessJSON(map[string]interface{}{
  15280. "failed_code": 0,
  15281. "msg": "目录对照成功",
  15282. })
  15283. } else {
  15284. c.ServeSuccessJSON(map[string]interface{}{
  15285. "failed_code": -10,
  15286. "msg": res.ErrMsg,
  15287. })
  15288. }
  15289. }
  15290. }
  15291. }
  15292. func (c *HisApiController) UnCheckCode() {
  15293. ids_str := c.GetString("ids")
  15294. record_type, _ := c.GetInt64("record_type") //1.药品 2.耗材 3.项目
  15295. admin_user_id, _ := c.GetInt64("admin_user_id")
  15296. ids_arr := strings.Split(ids_str, ",")
  15297. var queryResult []QueryResult
  15298. ids := make([]int64, 0)
  15299. for _, item := range ids_arr {
  15300. id, _ := strconv.ParseInt(item, 10, 64)
  15301. ids = append(ids, id)
  15302. }
  15303. if record_type == 1 {
  15304. drugs, _ := service.GetBatchDrugList(ids)
  15305. for _, item := range drugs {
  15306. result := QueryResult{
  15307. ID: item.ID,
  15308. Name: item.DrugName,
  15309. Code: item.MedicalInsuranceNumber,
  15310. List_type_code: "101",
  15311. }
  15312. queryResult = append(queryResult, result)
  15313. }
  15314. } else if record_type == 2 {
  15315. goods, _ := service.GetBatchGoodInformationList(ids)
  15316. for _, item := range goods {
  15317. result := QueryResult{
  15318. ID: item.ID,
  15319. Name: item.GoodName,
  15320. Code: item.MedicalInsuranceNumber,
  15321. List_type_code: "301",
  15322. }
  15323. queryResult = append(queryResult, result)
  15324. }
  15325. } else if record_type == 3 {
  15326. projects, _ := service.GetBathchMyPorjecgList(ids)
  15327. for _, item := range projects {
  15328. result := QueryResult{
  15329. ID: item.ID,
  15330. Name: item.ProjectName,
  15331. Code: item.MedicalCode,
  15332. List_type_code: "201",
  15333. }
  15334. queryResult = append(queryResult, result)
  15335. }
  15336. }
  15337. adminUser := c.GetAdminUserInfo()
  15338. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  15339. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  15340. var user_name string
  15341. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  15342. if role.ID == 0 {
  15343. user_name = "xxx"
  15344. } else {
  15345. user_name = role.UserName
  15346. }
  15347. baseParams := &models.BaseParams{
  15348. SecretKey: miConfig.SecretKey,
  15349. FixmedinsCode: miConfig.Code,
  15350. InsuplcAdmdvs: miConfig.InsuplcAdmdvs,
  15351. MdtrtareaAdmvs: miConfig.MdtrtareaAdmvs,
  15352. OrgName: miConfig.OrgName,
  15353. Doctor: user_name,
  15354. }
  15355. if config.IsOpen == 1 {
  15356. for _, item := range queryResult {
  15357. var result string
  15358. if record_type == 1 {
  15359. result = service.Gdyb3302(baseParams, item.Name, item.Code, item.List_type_code)
  15360. } else if record_type == 2 {
  15361. result = service.Gdyb3302(baseParams, item.Name, item.Code, item.List_type_code)
  15362. } else if record_type == 3 {
  15363. result = service.Gdyb3302(baseParams, item.Name, item.Code, item.List_type_code)
  15364. }
  15365. var dat2 map[string]interface{}
  15366. if err := json.Unmarshal([]byte(result), &dat2); err == nil {
  15367. fmt.Println(dat2)
  15368. } else {
  15369. fmt.Println(err)
  15370. }
  15371. userJSONBytes, _ := json.Marshal(dat2)
  15372. var res ResultSix
  15373. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  15374. utils.ErrorLog("解析失败:%v", err)
  15375. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  15376. return
  15377. }
  15378. if res.Infcode == 0 {
  15379. if record_type == 1 {
  15380. service.UpdateDrugByIdDetail(item.ID)
  15381. } else if record_type == 2 {
  15382. service.UpdateGoodInfoById(item.ID)
  15383. } else if record_type == 3 {
  15384. service.UpdateMyProjectById(item.ID)
  15385. }
  15386. c.ServeSuccessJSON(map[string]interface{}{
  15387. "failed_code": 0,
  15388. "msg": "撤销目录对照成功",
  15389. })
  15390. } else {
  15391. c.ServeSuccessJSON(map[string]interface{}{
  15392. "failed_code": -10,
  15393. "msg": res.ErrMsg,
  15394. })
  15395. }
  15396. }
  15397. }
  15398. }
  15399. func (c *HisApiController) GetPatientInfo() {
  15400. id_card_no := c.GetString("id_card_no")
  15401. admin_user_id, _ := c.GetInt64("admin_user_id")
  15402. patient, _ := service.GetPatientByIDCard(id_card_no, c.GetAdminUserInfo().CurrentOrgId)
  15403. if patient.ID == 0 {
  15404. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodePatientNoExist)
  15405. return
  15406. }
  15407. role, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  15408. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  15409. config, _ := service.GetMedicalInsuranceConfig(c.GetAdminUserInfo().CurrentOrgId)
  15410. if config.IsOpen == 1 {
  15411. result := service.Gdyb1101A(id_card_no, miConfig.OrgName, role.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, patient.Name)
  15412. var dat map[string]interface{}
  15413. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  15414. fmt.Println(dat)
  15415. } else {
  15416. fmt.Println(err)
  15417. }
  15418. userJSONBytes, _ := json.Marshal(dat)
  15419. var res ResultTwo
  15420. var res10265 ResultTwo10265
  15421. if miConfig.Code == "H15049901371" {
  15422. if err := json.Unmarshal(userJSONBytes, &res10265); err != nil {
  15423. utils.ErrorLog("解析失败:%v", err)
  15424. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  15425. return
  15426. }
  15427. res.ErrMsg = res10265.ErrMsg
  15428. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  15429. res.Infcode = infocode
  15430. res.Output = res10265.Output
  15431. res.InfRefmsgid = res10265.InfRefmsgid
  15432. } else {
  15433. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  15434. utils.ErrorLog("解析失败:%v", err)
  15435. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  15436. return
  15437. }
  15438. }
  15439. //if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  15440. // utils.ErrorLog("解析失败:%v", err)
  15441. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  15442. // return
  15443. //}
  15444. for index, item := range res.Output.Iinfo {
  15445. if item.PsnInsuStas == "2" {
  15446. fmt.Println("--------")
  15447. res.Output.Iinfo[index].Insutype = "300"
  15448. res.Output.Iinfo[index].PsnInsuStas = "1"
  15449. }
  15450. }
  15451. fmt.Println(res.Output.Iinfo)
  15452. if res.Infcode != 0 {
  15453. c.ServeSuccessJSON(map[string]interface{}{
  15454. "failed_code": -10,
  15455. "msg": res.ErrMsg,
  15456. })
  15457. } else {
  15458. c.ServeSuccessJSON(map[string]interface{}{
  15459. "failed_code": 0,
  15460. "info": res,
  15461. })
  15462. }
  15463. }
  15464. }
  15465. func (c *HisApiController) PsnPutOnRecord() {
  15466. record_type, _ := c.GetInt64("type")
  15467. patient_id, _ := c.GetInt64("patient_id")
  15468. admin_user_id, _ := c.GetInt64("admin_user_id")
  15469. start_time := c.GetString("start_time")
  15470. end_time := c.GetString("end_time")
  15471. adminUser := c.GetAdminUserInfo()
  15472. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  15473. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  15474. var patients []*models.Patients
  15475. if record_type == 1 { //全部备案
  15476. patient, _ := service.GetAllPatient(adminUser.CurrentOrgId)
  15477. patients = append(patients, patient...)
  15478. } else { //单个备案
  15479. patient, _ := service.GetPatientByID(adminUser.CurrentOrgId, patient_id)
  15480. patients = append(patients, patient)
  15481. }
  15482. var user_name string
  15483. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  15484. if role.ID == 0 {
  15485. user_name = "xxx"
  15486. } else {
  15487. user_name = role.UserName
  15488. }
  15489. if config.IsOpen == 1 {
  15490. for _, item := range patients {
  15491. 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
  15492. resp, requestErr := http.Get(api)
  15493. if requestErr != nil {
  15494. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  15495. return
  15496. }
  15497. defer resp.Body.Close()
  15498. body, ioErr := ioutil.ReadAll(resp.Body)
  15499. if ioErr != nil {
  15500. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  15501. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  15502. return
  15503. }
  15504. var respJSON map[string]interface{}
  15505. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  15506. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  15507. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  15508. return
  15509. }
  15510. userJSON := respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  15511. userJSONBytes, _ := json.Marshal(userJSON)
  15512. var res ResultTwo
  15513. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  15514. utils.ErrorLog("解析失败:%v", err)
  15515. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  15516. return
  15517. }
  15518. if res.Infcode == 0 {
  15519. result := service.Gdyb2505(res.Output.Baseinfo.PsnNo, user_name, miConfig.OrgName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, start_time, end_time)
  15520. var dat map[string]interface{}
  15521. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  15522. fmt.Println(dat)
  15523. } else {
  15524. fmt.Println(err)
  15525. }
  15526. userJSONBytes, _ := json.Marshal(dat)
  15527. var res2 ResultThirteen
  15528. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  15529. utils.ErrorLog("解析失败:%v", err)
  15530. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  15531. return
  15532. }
  15533. if res2.Infcode == 0 {
  15534. psnResult := &models.GdybPsnRecord{
  15535. UserOrgId: adminUser.CurrentOrgId,
  15536. PatientId: item.ID,
  15537. PsnNo: res.Output.Baseinfo.PsnNo,
  15538. Ctime: time.Now().Unix(),
  15539. Mtime: time.Now().Unix(),
  15540. Status: 1,
  15541. IsCancel: 1,
  15542. TrtDclaDetlSn: res2.Output.Result.TrtDclaDetlSn,
  15543. }
  15544. service.CreatePsnRecord(psnResult)
  15545. } else {
  15546. c.ServeSuccessJSON(map[string]interface{}{
  15547. "failed_code": -10,
  15548. "msg": res2.ErrMsg,
  15549. })
  15550. return
  15551. }
  15552. }
  15553. }
  15554. }
  15555. }
  15556. func (c *HisApiController) PsnUnPutOnRecord() {
  15557. id, _ := c.GetInt64("id")
  15558. //record_type, _ := c.GetInt64("type")
  15559. admin_user_id, _ := c.GetInt64("admin_user_id")
  15560. adminUser := c.GetAdminUserInfo()
  15561. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  15562. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  15563. var user_name string
  15564. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  15565. if role.ID == 0 {
  15566. user_name = "xxx"
  15567. } else {
  15568. user_name = role.UserName
  15569. }
  15570. psn_record, _ := service.GetPsnRecordById(id)
  15571. if psn_record.ID == 0 {
  15572. c.ServeFailJSONWithSGJErrorCode(enums.ErrorPsnRecordNoExistWrong)
  15573. return
  15574. }
  15575. if config.IsOpen == 1 {
  15576. result := service.Gdyb2506(psn_record.PsnNo, user_name, miConfig.OrgName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, psn_record.TrtDclaDetlSn)
  15577. var dat map[string]interface{}
  15578. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  15579. fmt.Println(dat)
  15580. } else {
  15581. fmt.Println(err)
  15582. }
  15583. userJSONBytes, _ := json.Marshal(dat)
  15584. var res ResultFourteen
  15585. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  15586. utils.ErrorLog("解析失败:%v", err)
  15587. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  15588. return
  15589. }
  15590. if res.Infcode == 0 {
  15591. psn_record.IsCancel = 2
  15592. service.CreatePsnRecord(&psn_record)
  15593. } else {
  15594. c.ServeSuccessJSON(map[string]interface{}{
  15595. "failed_code": -10,
  15596. "msg": res.ErrMsg,
  15597. })
  15598. return
  15599. }
  15600. }
  15601. }
  15602. func (c *HisApiController) PsnPutNCDSOnRecord() {
  15603. patient_id, _ := c.GetInt64("patient_id")
  15604. insutype_two := c.GetString("insutype")
  15605. psn_no := c.GetString("psn_no")
  15606. doctor_id, _ := c.GetInt64("doctor_id")
  15607. sick_id, _ := c.GetInt64("sick_id")
  15608. department_id, _ := c.GetInt64("department_id")
  15609. start_time := c.GetString("start_time")
  15610. end_time := c.GetString("end_time")
  15611. check_time := c.GetString("check_time")
  15612. hospital_code := c.GetString("hospital_code")
  15613. hospital_name := c.GetString("hospital_name")
  15614. adminUser := c.GetAdminUserInfo()
  15615. patient, _ := service.GetPatientByID(adminUser.CurrentOrgId, patient_id)
  15616. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  15617. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  15618. sick, _ := service.FindSickById(sick_id)
  15619. doctor, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, doctor_id)
  15620. if len(hospital_code) == 0 {
  15621. hospital_code = miConfig.Code
  15622. }
  15623. if len(hospital_name) == 0 {
  15624. hospital_name = miConfig.OrgName
  15625. }
  15626. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, doctor_id)
  15627. var res ResultTwo
  15628. var res10265 ResultTwo10265
  15629. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  15630. psn_info, _ := service.GetPsnByPatientId(patient.ID)
  15631. api := "http://192.168.2.3:9532/" + "hbyb/1101?cert_no=" + "" +
  15632. "&org_name=" + miConfig.OrgName + "&doctor=" + role.UserName + "&fixmedins_code=" + miConfig.Code +
  15633. "&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
  15634. resp, requestErr := http.Get(api)
  15635. if requestErr != nil {
  15636. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  15637. return
  15638. }
  15639. body, ioErr := ioutil.ReadAll(resp.Body)
  15640. if ioErr != nil {
  15641. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  15642. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  15643. return
  15644. }
  15645. var respJSON map[string]interface{}
  15646. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  15647. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  15648. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  15649. return
  15650. }
  15651. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  15652. result, _ := json.Marshal(respJSON)
  15653. fmt.Println("log")
  15654. fmt.Println(string(result))
  15655. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  15656. utils.ErrorLog("解析失败:%v", err)
  15657. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  15658. return
  15659. }
  15660. res.ErrMsg = res10265.ErrMsg
  15661. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  15662. res.Infcode = infocode
  15663. res.Output = res10265.Output
  15664. res.InfRefmsgid = res10265.InfRefmsgid
  15665. } else {
  15666. result, _ := service.Gdyb1101(patient.IdCardNo, miConfig.OrgName, role.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, 2, "", "0", patient.Name)
  15667. if miConfig.Code == "H15049901371" {
  15668. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  15669. utils.ErrorLog("解析失败:%v", err)
  15670. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  15671. return
  15672. }
  15673. res.ErrMsg = res10265.ErrMsg
  15674. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  15675. res.Infcode = infocode
  15676. res.Output = res10265.Output
  15677. res.InfRefmsgid = res10265.InfRefmsgid
  15678. } else {
  15679. if err := json.Unmarshal([]byte(result), &res); err != nil {
  15680. utils.ErrorLog("解析失败:%v", err)
  15681. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  15682. return
  15683. }
  15684. }
  15685. }
  15686. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  15687. infoStr := string(Iinfos)
  15688. var rf []*ResultFive
  15689. json.Unmarshal([]byte(infoStr), &rf)
  15690. var insuplc_admdvs string
  15691. var insutype string
  15692. var is390 int = 0
  15693. var is310 int = 0
  15694. var insutypes []*ResultFive
  15695. for _, item := range rf {
  15696. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  15697. insutypes = append(insutypes, item)
  15698. }
  15699. }
  15700. if len(insutypes) == 1 {
  15701. insutype = insutypes[0].Insutype
  15702. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  15703. } else {
  15704. for _, i := range insutypes {
  15705. if i.Insutype == "390" {
  15706. is390 = 1
  15707. }
  15708. if i.Insutype == "310" {
  15709. is310 = 1
  15710. }
  15711. }
  15712. }
  15713. if is390 == 1 {
  15714. insutype = "390"
  15715. }
  15716. if is310 == 1 {
  15717. insutype = "310"
  15718. }
  15719. if len(insutypes) == 2 {
  15720. insutype = insutype_two
  15721. }
  15722. if len(insutypes) == 0 {
  15723. insutype = "310"
  15724. }
  15725. insutype = insutype_two
  15726. fmt.Println(insutype)
  15727. for _, item := range rf {
  15728. fmt.Println(item.Insutype)
  15729. fmt.Println(insutype)
  15730. if item.Insutype == insutype {
  15731. fmt.Println(item.Insutype)
  15732. fmt.Println(insutype)
  15733. insuplc_admdvs = item.InsuplcAdmdvs
  15734. }
  15735. }
  15736. fmt.Println(insuplc_admdvs)
  15737. var res2 ResultThirteen
  15738. var res10265_2 ResultThirteen10265
  15739. if config.IsOpen == 1 {
  15740. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  15741. } else {
  15742. 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)
  15743. var dat map[string]interface{}
  15744. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  15745. fmt.Println(dat)
  15746. } else {
  15747. fmt.Println(err)
  15748. }
  15749. userJSONBytes, _ := json.Marshal(dat)
  15750. if miConfig.Code == "H15049901371" {
  15751. if err := json.Unmarshal(userJSONBytes, &res10265_2); err != nil {
  15752. utils.ErrorLog("解析失败:%v", err)
  15753. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  15754. return
  15755. }
  15756. res2.ErrMsg = res10265_2.ErrMsg
  15757. infocode, _ := strconv.ParseInt(res10265_2.Infcode, 10, 64)
  15758. res2.Infcode = infocode
  15759. res2.Output = res10265_2.Output
  15760. res2.InfRefmsgid = res10265_2.InfRefmsgid
  15761. } else {
  15762. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  15763. utils.ErrorLog("解析失败:%v", err)
  15764. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  15765. return
  15766. }
  15767. }
  15768. }
  15769. if res2.Infcode == 0 {
  15770. psnResult := &models.GdybPsnNcdsRecord{
  15771. UserOrgId: adminUser.CurrentOrgId,
  15772. PatientId: patient.ID,
  15773. PsnNo: psn_no,
  15774. DoctorId: doctor.AdminUserId,
  15775. DepartmentId: department_id,
  15776. SickType: sick_id,
  15777. Insutype: insutype,
  15778. Ctime: time.Now().Unix(),
  15779. Mtime: time.Now().Unix(),
  15780. Status: 1,
  15781. IsCancel: 1,
  15782. TrtDclaDetlSn: res2.Output.Result.TrtDclaDetlSn,
  15783. }
  15784. service.CreatePsnNCDSRecord(psnResult)
  15785. c.ServeSuccessJSON(map[string]interface{}{
  15786. "failed_code": 0,
  15787. "msg": "备案成功",
  15788. "result": psnResult,
  15789. })
  15790. } else {
  15791. c.ServeSuccessJSON(map[string]interface{}{
  15792. "failed_code": -10,
  15793. "msg": res2.ErrMsg,
  15794. })
  15795. return
  15796. }
  15797. }
  15798. }
  15799. func (c *HisApiController) PsnPutUnNCDSOnRecord() {
  15800. id, _ := c.GetInt64("id")
  15801. admin_user_id, _ := c.GetInt64("admin_user_id")
  15802. adminUser := c.GetAdminUserInfo()
  15803. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  15804. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  15805. //config, _ := service.Ge(adminUser.CurrentOrgId)
  15806. patient, _ := service.GetPatientByID(c.GetAdminUserInfo().CurrentOrgId, id)
  15807. //role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  15808. //var user_name string
  15809. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  15810. //if role.ID == 0 {
  15811. // user_name = "xxx"
  15812. //} else {
  15813. // user_name = role.UserName
  15814. //}
  15815. psn_record, _ := service.GetPsnNCDSRecordById(id)
  15816. if psn_record.ID == 0 {
  15817. c.ServeFailJSONWithSGJErrorCode(enums.ErrorPsnRecordNoExistWrong)
  15818. return
  15819. }
  15820. result, _ := service.Gdyb1101(patient.IdCardNo, miConfig.OrgName, role.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, 2, "", "0", patient.Name)
  15821. var res ResultTwo
  15822. var res10265 ResultTwo10265
  15823. if miConfig.Code == "H15049901371" {
  15824. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  15825. utils.ErrorLog("解析失败:%v", err)
  15826. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  15827. return
  15828. }
  15829. res.ErrMsg = res10265.ErrMsg
  15830. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  15831. res.Infcode = infocode
  15832. res.Output = res10265.Output
  15833. res.InfRefmsgid = res10265.InfRefmsgid
  15834. } else {
  15835. if err := json.Unmarshal([]byte(result), &res); err != nil {
  15836. utils.ErrorLog("解析失败:%v", err)
  15837. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  15838. return
  15839. }
  15840. }
  15841. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  15842. infoStr := string(Iinfos)
  15843. var rf []*ResultFive
  15844. json.Unmarshal([]byte(infoStr), &rf)
  15845. var insuplc_admdvs string
  15846. var insutype string
  15847. var is390 int = 0
  15848. var is310 int = 0
  15849. var insutypes []*ResultFive
  15850. for _, item := range rf {
  15851. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  15852. insutypes = append(insutypes, item)
  15853. }
  15854. }
  15855. if len(insutypes) == 1 {
  15856. insutype = insutypes[0].Insutype
  15857. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  15858. } else {
  15859. for _, i := range insutypes {
  15860. if i.Insutype == "390" {
  15861. is390 = 1
  15862. }
  15863. if i.Insutype == "310" {
  15864. is310 = 1
  15865. }
  15866. }
  15867. }
  15868. if is390 == 1 {
  15869. insutype = "390"
  15870. }
  15871. if is310 == 1 {
  15872. insutype = "310"
  15873. }
  15874. if len(insutypes) == 0 {
  15875. insutype = "310"
  15876. }
  15877. insutype = psn_record.Insutype
  15878. for _, item := range rf {
  15879. if item.Insutype == insutype {
  15880. insuplc_admdvs = item.InsuplcAdmdvs
  15881. }
  15882. }
  15883. if config.IsOpen == 1 {
  15884. result := service.Gdyb2504(psn_record.PsnNo, miConfig.OrgName, role.UserName, miConfig.Code, insuplc_admdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, psn_record.TrtDclaDetlSn)
  15885. var dat map[string]interface{}
  15886. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  15887. fmt.Println(dat)
  15888. } else {
  15889. fmt.Println(err)
  15890. }
  15891. userJSONBytes, _ := json.Marshal(dat)
  15892. var res ResultFourteen
  15893. var res10265 ResultFourteen10265
  15894. if miConfig.Code == "H15049901371" {
  15895. if err := json.Unmarshal(userJSONBytes, &res10265); err != nil {
  15896. utils.ErrorLog("解析失败:%v", err)
  15897. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  15898. return
  15899. }
  15900. res.ErrMsg = res10265.ErrMsg
  15901. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  15902. res.Infcode = infocode
  15903. res.Output = res10265.Output
  15904. res.InfRefmsgid = res10265.InfRefmsgid
  15905. } else {
  15906. if err := json.Unmarshal([]byte(result), &res); err != nil {
  15907. utils.ErrorLog("解析失败:%v", err)
  15908. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  15909. return
  15910. }
  15911. }
  15912. //if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  15913. // utils.ErrorLog("解析失败:%v", err)
  15914. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  15915. // return
  15916. //}
  15917. if res.Infcode == 0 {
  15918. psn_record.IsCancel = 2
  15919. service.CreatePsnNCDSRecord(&psn_record)
  15920. c.ServeSuccessJSON(map[string]interface{}{
  15921. "failed_code": 0,
  15922. "msg": "撤销备案成功",
  15923. })
  15924. } else {
  15925. c.ServeSuccessJSON(map[string]interface{}{
  15926. "failed_code": -10,
  15927. "msg": res.ErrMsg,
  15928. })
  15929. return
  15930. }
  15931. }
  15932. }
  15933. func (c *HisApiController) TestTest() {
  15934. patient, _ := service.GetHisPatientInfo(4, 456, 1619712000)
  15935. fmt.Println(patient.Iinfo)
  15936. }
  15937. type CustomData struct {
  15938. MsgId string
  15939. PsnNo string
  15940. Info string
  15941. }
  15942. func (c *HisApiController) ReversalData() {
  15943. var customData []*CustomData
  15944. custom := &CustomData{
  15945. MsgId: "H44022900158202103301714472004",
  15946. PsnNo: "44020000001101329945",
  15947. Info: "2207",
  15948. }
  15949. customData = append(customData, custom)
  15950. custom1 := &CustomData{
  15951. MsgId: "H4402290015820210330172057803",
  15952. PsnNo: "44020000001101161813",
  15953. Info: "2207",
  15954. }
  15955. customData = append(customData, custom1)
  15956. custom2 := &CustomData{
  15957. MsgId: "H44022900158202103301705198813",
  15958. PsnNo: "44190000133097375417",
  15959. Info: "2207",
  15960. }
  15961. customData = append(customData, custom2)
  15962. custom3 := &CustomData{
  15963. MsgId: "H44022900158202103301715524756",
  15964. PsnNo: "44020000001100187221",
  15965. Info: "2207",
  15966. }
  15967. customData = append(customData, custom3)
  15968. custom4 := &CustomData{
  15969. MsgId: "H44022900158202103301730376224",
  15970. PsnNo: "44020000001101959155",
  15971. Info: "2207",
  15972. }
  15973. customData = append(customData, custom4)
  15974. custom5 := &CustomData{
  15975. MsgId: "H44022900158202103301748008725",
  15976. PsnNo: "44020000001104246641",
  15977. Info: "2207",
  15978. }
  15979. customData = append(customData, custom5)
  15980. custom6 := &CustomData{
  15981. MsgId: "H44022900158202103301718096755",
  15982. PsnNo: "44020000001102211860",
  15983. Info: "2207",
  15984. }
  15985. customData = append(customData, custom6)
  15986. custom7 := &CustomData{
  15987. MsgId: "H44022900158202103301736551640",
  15988. PsnNo: "44020000001102687718",
  15989. Info: "2207",
  15990. }
  15991. customData = append(customData, custom7)
  15992. custom8 := &CustomData{
  15993. MsgId: "H44022900158202103301743097676",
  15994. PsnNo: "44020000001102127785",
  15995. Info: "2207",
  15996. }
  15997. customData = append(customData, custom8)
  15998. custom9 := &CustomData{
  15999. MsgId: "H44022900158202103301712304203",
  16000. PsnNo: "44020000001101518097",
  16001. Info: "2207",
  16002. }
  16003. customData = append(customData, custom9)
  16004. custom10 := &CustomData{
  16005. MsgId: "H44022900158202103301738448785",
  16006. PsnNo: "44020000001100500813",
  16007. Info: "2207",
  16008. }
  16009. customData = append(customData, custom10)
  16010. custom11 := &CustomData{
  16011. MsgId: "H44022900158202103301732455843",
  16012. PsnNo: "44020000001102690557",
  16013. Info: "2207",
  16014. }
  16015. customData = append(customData, custom11)
  16016. custom12 := &CustomData{
  16017. MsgId: "H44022900158202103301745421708",
  16018. PsnNo: "44020000001102211928",
  16019. Info: "2207",
  16020. }
  16021. customData = append(customData, custom12)
  16022. custom1212 := &CustomData{
  16023. MsgId: "H440229001582021033017351627",
  16024. PsnNo: "44020000001102481733",
  16025. Info: "2207",
  16026. }
  16027. customData = append(customData, custom1212)
  16028. custom13 := &CustomData{
  16029. MsgId: "H44022900158202103301740327951",
  16030. PsnNo: "44020000001103174866",
  16031. Info: "2207",
  16032. }
  16033. customData = append(customData, custom13)
  16034. custom14 := &CustomData{
  16035. MsgId: "H4402290015820210330174922668",
  16036. PsnNo: "44020000001102927272",
  16037. Info: "2207",
  16038. }
  16039. customData = append(customData, custom14)
  16040. custom15 := &CustomData{
  16041. MsgId: "H44022900158202103301752362273",
  16042. PsnNo: "44020000001102942890",
  16043. Info: "2207",
  16044. }
  16045. customData = append(customData, custom15)
  16046. custom16 := &CustomData{
  16047. MsgId: "H44022900158202103301751082917",
  16048. PsnNo: "44020000001101662162",
  16049. Info: "2207",
  16050. }
  16051. customData = append(customData, custom16)
  16052. custom17 := &CustomData{
  16053. MsgId: "H44022900158202103301754147728",
  16054. PsnNo: "44020000000229014511",
  16055. Info: "2207",
  16056. }
  16057. customData = append(customData, custom17)
  16058. adminUser := c.GetAdminUserInfo()
  16059. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  16060. for _, item := range customData {
  16061. result := service.Gdyb2601(item.PsnNo, item.MsgId, item.Info, miConfig.OrgName, "张俊杰", miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey)
  16062. fmt.Println(result)
  16063. }
  16064. }
  16065. func (c *HisApiController) GetAllopatry() {
  16066. year := c.GetString("year")
  16067. month := c.GetString("month")
  16068. admin_user_id, _ := c.GetInt64("admin_user_id")
  16069. adminUser := c.GetAdminUserInfo()
  16070. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  16071. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  16072. result, _ := service.Gdyb9001Two(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, admin_user_id)
  16073. var dat map[string]interface{}
  16074. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  16075. fmt.Println(dat)
  16076. } else {
  16077. fmt.Println(err)
  16078. }
  16079. userJSONBytes, _ := json.Marshal(dat)
  16080. var res models.Result9001
  16081. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  16082. utils.ErrorLog("解析失败:%v", err)
  16083. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  16084. return
  16085. }
  16086. fmt.Println(res.Output.Signinoutb)
  16087. fmt.Println(res.Output.Signinoutb.SignNo)
  16088. fmt.Println(string(userJSONBytes))
  16089. result3, _ := service.Gdyb3260(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, year, month, res.Output.Signinoutb.SignNo, 0)
  16090. var dat3 map[string]interface{}
  16091. if err := json.Unmarshal([]byte(result3), &dat3); err == nil {
  16092. fmt.Println(dat3)
  16093. } else {
  16094. fmt.Println(err)
  16095. }
  16096. userJSONBytes3, _ := json.Marshal(dat3)
  16097. var res3 models.Result3260
  16098. if err := json.Unmarshal(userJSONBytes3, &res3); err != nil {
  16099. utils.ErrorLog("解析失败:%v", err)
  16100. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  16101. return
  16102. }
  16103. var curpage int
  16104. var pagesize int = 100
  16105. var start int = 1
  16106. //var stop int
  16107. //pagecount := 10
  16108. pagecount := int(math.Ceil(float64(res3.Output.Totalrow) / float64(pagesize)))
  16109. for curpage = 1; curpage <= pagecount; curpage++ {
  16110. if curpage == 1 {
  16111. start = 0
  16112. } else {
  16113. start = (curpage-1)*pagesize + 1
  16114. }
  16115. fmt.Println(start)
  16116. //stop = curpage * pagesize
  16117. //if stop > int(res3.Output.Totalrow) {
  16118. // stop =int(res3.Output.Totalrow)
  16119. //}
  16120. result2, _ := service.Gdyb3260(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, year, month, res.Output.Signinoutb.SignNo, start)
  16121. var dat2 map[string]interface{}
  16122. if err := json.Unmarshal([]byte(result2), &dat2); err == nil {
  16123. fmt.Println(dat)
  16124. } else {
  16125. fmt.Println(err)
  16126. }
  16127. userJSONBytes2, _ := json.Marshal(dat2)
  16128. var res2 models.Result3260
  16129. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  16130. utils.ErrorLog("解析失败:%v", err)
  16131. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  16132. return
  16133. }
  16134. if res2.Infcode == 0 {
  16135. service.Gdyb3261(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, year, month, res2, res.Output.Signinoutb.SignNo)
  16136. var dat2 map[string]interface{}
  16137. if err := json.Unmarshal([]byte(result3), &dat2); err == nil {
  16138. fmt.Println(dat)
  16139. } else {
  16140. fmt.Println(err)
  16141. }
  16142. //c.ServeSuccessJSON(map[string]interface{}{
  16143. // "list": res2.Output.Data,
  16144. //})
  16145. //continue
  16146. }
  16147. }
  16148. //result2, _ := service.Gdyb3260(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, year, month, res.Output.Signinoutb.SignNo, 101)
  16149. //var dat2 map[string]interface{}
  16150. //if err := json.Unmarshal([]byte(result2), &dat2); err == nil {
  16151. // fmt.Println(dat)
  16152. //} else {
  16153. // fmt.Println(err)
  16154. //}
  16155. //userJSONBytes2, _ := json.Marshal(dat2)
  16156. //var res2 models.Result3260
  16157. //if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  16158. // utils.ErrorLog("解析失败:%v", err)
  16159. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  16160. // return
  16161. //}
  16162. //if res2.Infcode == 0 {
  16163. // service.Gdyb3261(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, year, month, res2, res.Output.Signinoutb.SignNo)
  16164. // var dat2 map[string]interface{}
  16165. // if err := json.Unmarshal([]byte(result3), &dat2); err == nil {
  16166. // fmt.Println(dat)
  16167. // } else {
  16168. // fmt.Println(err)
  16169. // }
  16170. // c.ServeSuccessJSON(map[string]interface{}{
  16171. // "list": res2.Output.Data,
  16172. // })
  16173. //}
  16174. }
  16175. func (c *HisApiController) ComfirmAllopatry() {
  16176. year := c.GetString("year")
  16177. month := c.GetString("month")
  16178. admin_user_id, _ := c.GetInt64("admin_user_id")
  16179. adminUser := c.GetAdminUserInfo()
  16180. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  16181. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  16182. result, _ := service.Gdyb9001Two(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, admin_user_id)
  16183. var dat map[string]interface{}
  16184. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  16185. fmt.Println(dat)
  16186. } else {
  16187. fmt.Println(err)
  16188. }
  16189. userJSONBytes, _ := json.Marshal(dat)
  16190. var res models.Result9001
  16191. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  16192. utils.ErrorLog("解析失败:%v", err)
  16193. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  16194. return
  16195. }
  16196. result2, _ := service.Gdyb3260(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, year, month, res.Output.Signinoutb.SignNo, 0)
  16197. var dat2 map[string]interface{}
  16198. if err := json.Unmarshal([]byte(result2), &dat2); err == nil {
  16199. fmt.Println(dat)
  16200. } else {
  16201. fmt.Println(err)
  16202. }
  16203. userJSONBytes2, _ := json.Marshal(dat2)
  16204. var res2 models.Result3260
  16205. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  16206. utils.ErrorLog("解析失败:%v", err)
  16207. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  16208. return
  16209. }
  16210. //if res2.Infcode == 0 {
  16211. // result, _, msgId := service.Gdyb3261(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, year, month, res2, res.Output.Signinoutb.SignNo)
  16212. // var dat map[string]interface{}
  16213. // if err := json.Unmarshal([]byte(result), &dat); err == nil {
  16214. // fmt.Println(dat)
  16215. // } else {
  16216. // fmt.Println(err)
  16217. // }
  16218. // userJSONBytes, _ := json.Marshal(dat)
  16219. // var res3 models.Result3261
  16220. // if err := json.Unmarshal(userJSONBytes, &res3); err != nil {
  16221. // utils.ErrorLog("解析失败:%v", err)
  16222. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  16223. // return
  16224. // }
  16225. //
  16226. // if res3.Infcode == 0 {
  16227. // record := &models.HisYidiClearRecord{
  16228. // UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  16229. // Ctime: time.Now().Unix(),
  16230. // Mtime: time.Now().Unix(),
  16231. // Status: 1,
  16232. // MsgId: msgId,
  16233. // }
  16234. // service.SaveClearRecord(record)
  16235. // c.ServeSuccessJSON(map[string]interface{}{
  16236. // "msg": "提取成功",
  16237. // })
  16238. // }
  16239. //}
  16240. }
  16241. func (c *HisApiController) RefundAllopatry() {
  16242. year := c.GetString("year")
  16243. month := c.GetString("month")
  16244. //id, _ := c.GetInt64("id")
  16245. admin_user_id, _ := c.GetInt64("admin_user_id")
  16246. adminUser := c.GetAdminUserInfo()
  16247. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  16248. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  16249. //record, _ := service.GetClearRecordById(id)
  16250. result2, _ := service.Gdyb9001Two(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, admin_user_id)
  16251. var dat map[string]interface{}
  16252. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  16253. fmt.Println(dat)
  16254. } else {
  16255. fmt.Println(err)
  16256. }
  16257. userJSONBytes, _ := json.Marshal(dat)
  16258. var res models.Result9001
  16259. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  16260. utils.ErrorLog("解析失败:%v", err)
  16261. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  16262. return
  16263. }
  16264. result, _ := service.Gdyb3262(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, year, month, "", res.Output.Signinoutb.SignNo)
  16265. var dat2 map[string]interface{}
  16266. if err := json.Unmarshal([]byte(result), &dat2); err == nil {
  16267. fmt.Println(dat)
  16268. } else {
  16269. fmt.Println(err)
  16270. }
  16271. userJSONBytes2, _ := json.Marshal(dat2)
  16272. var empty ResultFourteen
  16273. if err := json.Unmarshal(userJSONBytes2, &empty); err != nil {
  16274. utils.ErrorLog("解析失败:%v", err)
  16275. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  16276. return
  16277. }
  16278. if empty.Infcode == 0 {
  16279. c.ServeSuccessJSON(map[string]interface{}{
  16280. "msg": "撤销成功",
  16281. })
  16282. return
  16283. }
  16284. }
  16285. func (c *HisApiController) ReversalOtherData() {
  16286. var customData []*CustomData
  16287. custom := &CustomData{
  16288. MsgId: "H44022900158202103301714472004",
  16289. PsnNo: "44020000001101329945",
  16290. Info: "2208",
  16291. }
  16292. customData = append(customData, custom)
  16293. custom1 := &CustomData{
  16294. MsgId: "H4402290015820210330172057803",
  16295. PsnNo: "44020000001101161813",
  16296. Info: "2208",
  16297. }
  16298. customData = append(customData, custom1)
  16299. custom2 := &CustomData{
  16300. MsgId: "H44022900158202103301705198813",
  16301. PsnNo: "44190000133097375417",
  16302. Info: "2208",
  16303. }
  16304. customData = append(customData, custom2)
  16305. custom3 := &CustomData{
  16306. MsgId: "H44022900158202103301715524756",
  16307. PsnNo: "44020000001100187221",
  16308. Info: "2208",
  16309. }
  16310. customData = append(customData, custom3)
  16311. custom4 := &CustomData{
  16312. MsgId: "H44022900158202103301730376224",
  16313. PsnNo: "44020000001101959155",
  16314. Info: "2208",
  16315. }
  16316. customData = append(customData, custom4)
  16317. custom5 := &CustomData{
  16318. MsgId: "H44022900158202103301748008725",
  16319. PsnNo: "44020000001104246641",
  16320. Info: "2208",
  16321. }
  16322. customData = append(customData, custom5)
  16323. custom6 := &CustomData{
  16324. MsgId: "H44022900158202103301718096755",
  16325. PsnNo: "44020000001102211860",
  16326. Info: "2208",
  16327. }
  16328. customData = append(customData, custom6)
  16329. custom7 := &CustomData{
  16330. MsgId: "H44022900158202103301736551640",
  16331. PsnNo: "44020000001102687718",
  16332. Info: "2208",
  16333. }
  16334. customData = append(customData, custom7)
  16335. custom8 := &CustomData{
  16336. MsgId: "H44022900158202103301743097676",
  16337. PsnNo: "44020000001102127785",
  16338. Info: "2208",
  16339. }
  16340. customData = append(customData, custom8)
  16341. custom9 := &CustomData{
  16342. MsgId: "H44022900158202103301712304203",
  16343. PsnNo: "44020000001101518097",
  16344. Info: "2208",
  16345. }
  16346. customData = append(customData, custom9)
  16347. custom10 := &CustomData{
  16348. MsgId: "H44022900158202103301738448785",
  16349. PsnNo: "44020000001100500813",
  16350. Info: "2208",
  16351. }
  16352. customData = append(customData, custom10)
  16353. custom11 := &CustomData{
  16354. MsgId: "H44022900158202103301732455843",
  16355. PsnNo: "44020000001102690557",
  16356. Info: "2208",
  16357. }
  16358. customData = append(customData, custom11)
  16359. custom12 := &CustomData{
  16360. MsgId: "H44022900158202103301745421708",
  16361. PsnNo: "44020000001102211928",
  16362. Info: "2208",
  16363. }
  16364. customData = append(customData, custom12)
  16365. custom1212 := &CustomData{
  16366. MsgId: "H440229001582021033017351627",
  16367. PsnNo: "44020000001102481733",
  16368. Info: "2208",
  16369. }
  16370. customData = append(customData, custom1212)
  16371. custom13 := &CustomData{
  16372. MsgId: "H44022900158202103301740327951",
  16373. PsnNo: "44020000001103174866",
  16374. Info: "2208",
  16375. }
  16376. customData = append(customData, custom13)
  16377. custom14 := &CustomData{
  16378. MsgId: "H4402290015820210330174922668",
  16379. PsnNo: "44020000001102927272",
  16380. Info: "2208",
  16381. }
  16382. customData = append(customData, custom14)
  16383. custom15 := &CustomData{
  16384. MsgId: "H44022900158202103301752362273",
  16385. PsnNo: "44020000001102942890",
  16386. Info: "2208",
  16387. }
  16388. customData = append(customData, custom15)
  16389. custom16 := &CustomData{
  16390. MsgId: "H44022900158202103301751082917",
  16391. PsnNo: "44020000001101662162",
  16392. Info: "2208",
  16393. }
  16394. customData = append(customData, custom16)
  16395. custom17 := &CustomData{
  16396. MsgId: "H44022900158202103301754147728",
  16397. PsnNo: "44020000000229014511",
  16398. Info: "2208",
  16399. }
  16400. customData = append(customData, custom17)
  16401. adminUser := c.GetAdminUserInfo()
  16402. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  16403. for _, item := range customData {
  16404. result := service.Gdyb2601(item.PsnNo, item.MsgId, item.Info, miConfig.OrgName, "张俊杰", miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey)
  16405. fmt.Println(result)
  16406. }
  16407. }
  16408. func PathExists(path string) (bool, error) {
  16409. _, err := os.Stat(path)
  16410. if err == nil {
  16411. return true, nil
  16412. }
  16413. if os.IsNotExist(err) {
  16414. return false, nil
  16415. }
  16416. return false, err
  16417. }
  16418. // 创建文件夹
  16419. func Mkdir(dir string) {
  16420. // 创建文件夹
  16421. exist, err := PathExists(dir)
  16422. if err != nil {
  16423. fmt.Println(err.Error())
  16424. } else {
  16425. if exist {
  16426. fmt.Println(dir + "文件夹已存在!")
  16427. } else {
  16428. // 文件夹名称,权限
  16429. err := os.Mkdir(dir, os.ModePerm)
  16430. if err != nil {
  16431. fmt.Println(dir+"文件夹创建失败:", err.Error())
  16432. } else {
  16433. fmt.Println(dir + "文件夹创建成功!")
  16434. }
  16435. }
  16436. }
  16437. }
  16438. // 压缩文件
  16439. func Zip(srcFile string, destZip string) error {
  16440. zipfile, err := os.Create(destZip)
  16441. if err != nil {
  16442. return err
  16443. }
  16444. defer zipfile.Close()
  16445. archive := zip.NewWriter(zipfile)
  16446. defer archive.Close()
  16447. filepath.Walk(srcFile, func(path string, info os.FileInfo, err error) error {
  16448. if err != nil {
  16449. return err
  16450. }
  16451. header, err := zip.FileInfoHeader(info)
  16452. if err != nil {
  16453. return err
  16454. }
  16455. header.Name = strings.TrimPrefix(path, filepath.Dir(srcFile)+"/")
  16456. // header.Name = path
  16457. if info.IsDir() {
  16458. header.Name += "/"
  16459. } else {
  16460. header.Method = zip.Deflate
  16461. }
  16462. writer, err := archive.CreateHeader(header)
  16463. if err != nil {
  16464. return err
  16465. }
  16466. if !info.IsDir() {
  16467. file, err := os.Open(path)
  16468. if err != nil {
  16469. return err
  16470. }
  16471. defer file.Close()
  16472. _, err = io.Copy(writer, file)
  16473. }
  16474. return err
  16475. })
  16476. return err
  16477. }
  16478. func ReadFile(filePath string) []byte {
  16479. f, err := os.Open(filePath)
  16480. if err != nil {
  16481. fmt.Println("read file fail", err)
  16482. return nil
  16483. }
  16484. defer f.Close()
  16485. fd, err := ioutil.ReadAll(f)
  16486. if err != nil {
  16487. fmt.Println("read to fd fail", err)
  16488. return nil
  16489. }
  16490. return fd
  16491. }
  16492. func saveLog(result string, request string, infno string, desc string) {
  16493. org_id, _ := beego.AppConfig.Int64("org_id")
  16494. miConfig, _ := service.FindMedicalInsuranceInfo(org_id)
  16495. dir := miConfig.OrgName + "日志"
  16496. utils.Mkdir(dir)
  16497. month := time.Unix(1557042972, 0).Format("1")
  16498. year := time.Now().Format("2006")
  16499. month = time.Now().Format("01")
  16500. day := time.Now().Format("02")
  16501. hour := time.Now().Format("15")
  16502. min := time.Now().Format("04")
  16503. sec := time.Now().Format("05")
  16504. result_time := year + "-" + month + "-" + day + " " + hour + ":" + min + ":" + sec
  16505. file := strconv.FormatInt(org_id, 10) + "_" + year + month + day + "_log"
  16506. file_name := file + ".txt"
  16507. file_path := miConfig.OrgName + "日志" + "/" + file_name
  16508. exist, _ := utils.PathExists(file_path)
  16509. if exist { //存在
  16510. fmt.Println("存在")
  16511. f, err := os.OpenFile(file_path, os.O_WRONLY, 0644)
  16512. if err != nil {
  16513. fmt.Println("read fail")
  16514. }
  16515. content := "\r\n" + "\r\n" + "\r\n" + result_time + " " + "【 " + desc + infno + "入参" + " 】:" + "\r\n" + request + "\r\n" + result_time + " " + "【 " + desc + infno + "出参" + " 】:" + "\r\n" + result
  16516. n, _ := f.Seek(0, 2)
  16517. _, err = f.WriteAt([]byte(content), n)
  16518. } else { //不存在
  16519. fmt.Println("文件不存在,创建文件")
  16520. f, err := os.Create(miConfig.OrgName + "日志" + "/" + file_name)
  16521. defer f.Close()
  16522. if err != nil {
  16523. } else {
  16524. _, err = f.Write([]byte("记录日志"))
  16525. }
  16526. }
  16527. }
  16528. type Charset string
  16529. const (
  16530. UTF8 = Charset("UTF-8")
  16531. GB18030 = Charset("GB18030")
  16532. )
  16533. func ConvertToString(src string, srcCode string, tagCode string) string {
  16534. srcCoder := mahonia.NewDecoder(srcCode)
  16535. srcResult := srcCoder.ConvertString(src)
  16536. tagCoder := mahonia.NewDecoder(tagCode)
  16537. _, cdata, _ := tagCoder.Translate([]byte(srcResult), true)
  16538. result := string(cdata)
  16539. return result
  16540. }
  16541. func ReadEleCard(admin_user_id int64, org_id int64, c *HisApiController) string {
  16542. roles, _ := service.GetAdminUserInfoByID(org_id, admin_user_id)
  16543. miConfig, _ := service.FindMedicalInsuranceInfo(org_id)
  16544. var token string
  16545. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  16546. var api string
  16547. if miConfig.MdtrtareaAdmvs == "320921" {
  16548. 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 +
  16549. "&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
  16550. fmt.Println(api)
  16551. } else {
  16552. 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 +
  16553. "&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
  16554. }
  16555. resp, requestErr := http.Get(api)
  16556. if requestErr != nil {
  16557. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  16558. return ""
  16559. }
  16560. body, ioErr := ioutil.ReadAll(resp.Body)
  16561. if ioErr != nil {
  16562. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  16563. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  16564. return ""
  16565. }
  16566. var respJSON map[string]interface{}
  16567. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  16568. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  16569. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  16570. return ""
  16571. }
  16572. var status string
  16573. status = respJSON["data"].(map[string]interface{})["status"].(string)
  16574. //card_type := respJSON["data"].(map[string]interface{})["type"].(string)
  16575. var res ResultTwo //1101结果
  16576. var res10265 ResultTwo10265 //1101结果
  16577. if status == "0" { //读卡成功
  16578. var card_info string //卡信息
  16579. var busi_card_info string
  16580. token = respJSON["data"].(map[string]interface{})["token"].(string)
  16581. busi_card_info = respJSON["data"].(map[string]interface{})["busi_card_info"].(string)
  16582. card_info = respJSON["data"].(map[string]interface{})["card_info"].(string)
  16583. fmt.Println(card_info)
  16584. fmt.Println(busi_card_info)
  16585. respJSON = respJSON["data"].(map[string]interface{})["result"].(map[string]interface{})
  16586. result, _ := json.Marshal(respJSON)
  16587. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  16588. utils.ErrorLog("解析失败:%v", err)
  16589. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  16590. return ""
  16591. }
  16592. res.ErrMsg = res10265.ErrMsg
  16593. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  16594. res.Infcode = infocode
  16595. res.Output = res10265.Output
  16596. res.InfRefmsgid = res10265.InfRefmsgid
  16597. if res.Infcode == 0 {
  16598. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  16599. if err == gorm.ErrRecordNotFound {
  16600. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  16601. return ""
  16602. } else if err != nil {
  16603. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  16604. return ""
  16605. } else {
  16606. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  16607. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  16608. infoStr := string(Iinfos)
  16609. idetinfoStr := string(Idetinfos)
  16610. psn := &models.HisPsn{
  16611. PsnNo: res.Output.Baseinfo.PsnNo,
  16612. Age: res.Output.Baseinfo.Age,
  16613. PatientId: patient.ID,
  16614. Certno: res.Output.Baseinfo.Certno,
  16615. Brdy: res.Output.Baseinfo.Brdy,
  16616. Gend: res.Output.Baseinfo.Gend,
  16617. Naty: res.Output.Baseinfo.Naty,
  16618. PsnCertType: res.Output.Baseinfo.PsnCertType,
  16619. PsnName: res.Output.Baseinfo.PsnName,
  16620. Idetinfo: idetinfoStr,
  16621. Insuinfo: infoStr,
  16622. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  16623. CardInfo: card_info,
  16624. VerifyNumber: token,
  16625. }
  16626. service.CreateHisPsn(psn)
  16627. return token
  16628. }
  16629. }
  16630. } else {
  16631. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  16632. return ""
  16633. }
  16634. } else { //读卡失败
  16635. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  16636. return ""
  16637. }
  16638. return token
  16639. }
  16640. func DeleteExtraSpaceTwo(s string) string {
  16641. //删除字符串中的多余空格,有多个空格时,仅保留一个空格
  16642. s1 := strings.Replace(s, " ", " ", -1) //替换tab为空格
  16643. regstr := "\\s{2,}" //两个及两个以上空格的正则表达式
  16644. reg, _ := regexp.Compile(regstr) //编译正则表达式
  16645. s2 := make([]byte, len(s1)) //定义字符数组切片
  16646. copy(s2, s1) //将字符串复制到切片
  16647. spc_index := reg.FindStringIndex(string(s2)) //在字符串中搜索
  16648. for len(spc_index) > 0 { //找到适配项
  16649. s2 = append(s2[:spc_index[0]+1], s2[spc_index[1]:]...) //删除多余空格
  16650. spc_index = reg.FindStringIndex(string(s2)) //继续在字符串中搜索
  16651. }
  16652. return string(s2)
  16653. }
  16654. func Remove0000(s string) string {
  16655. str := make([]rune, 0, len(s))
  16656. for _, v := range []rune(s) {
  16657. if v == 0 {
  16658. continue
  16659. }
  16660. str = append(str, v)
  16661. }
  16662. return string(str)
  16663. }
  16664. func (c *HisApiController) GetELeCertInfo(code string, operator_id string, operator_name string) (string, string) {
  16665. DllDef := syscall.MustLoadDLL("HeaSecReadInfo.dll")
  16666. readCard := DllDef.MustFindProc("EcQuery")
  16667. pCardInfo := make([]byte, 8192)
  16668. pBusiCardInfo := make([]byte, 8192)
  16669. data := make(map[string]interface{})
  16670. //pData := make(map[string]interface{})
  16671. inputData := make(map[string]interface{})
  16672. inputData["orgId"] = code
  16673. inputData["businessType"] = "01101"
  16674. inputData["operatorId"] = operator_id
  16675. inputData["operatorName"] = operator_name
  16676. inputData["officeId"] = "001"
  16677. inputData["officeName"] = "血透室"
  16678. //
  16679. data["data"] = inputData
  16680. data["transType"] = "ec.query"
  16681. data["orgId"] = code
  16682. bytesData, _ := json.Marshal(data)
  16683. pCardInfo = bytesData
  16684. ret2, _, _ := readCard.Call((uintptr)(unsafe.Pointer(&pCardInfo[0])), (uintptr)(unsafe.Pointer(&pBusiCardInfo[0])))
  16685. fmt.Println(ret2)
  16686. //fmt.Println(DeleteExtraSpace(string(bytesData)))
  16687. //fmt.Println(DeleteExtraSpace(string(pBusiCardInfo)))
  16688. fmt.Println(":", ConvertToString(DeleteExtraSpace(string(bytesData)), "gbk", "utf-8"))
  16689. fmt.Println(":", ConvertToString(DeleteExtraSpace(string(pBusiCardInfo)), "gbk", "utf-8"))
  16690. if ret2 != 0 {
  16691. return "", ""
  16692. }
  16693. return DeleteExtraSpace(string(bytesData)), DeleteExtraSpace(string(pBusiCardInfo))
  16694. }
  16695. func DeleteExtraSpace(s string) string {
  16696. //删除字符串中的多余空格,有多个空格时,仅保留一个空格
  16697. s1 := strings.Replace(s, " ", " ", -1) //替换tab为空格
  16698. regstr := "\\s{2,}" //两个及两个以上空格的正则表达式
  16699. reg, _ := regexp.Compile(regstr) //编译正则表达式
  16700. s2 := make([]byte, len(s1)) //定义字符数组切片
  16701. copy(s2, s1) //将字符串复制到切片
  16702. spc_index := reg.FindStringIndex(string(s2)) //在字符串中搜索
  16703. for len(spc_index) > 0 { //找到适配项
  16704. s2 = append(s2[:spc_index[0]+1], s2[spc_index[1]:]...) //删除多余空格
  16705. spc_index = reg.FindStringIndex(string(s2)) //继续在字符串中搜索
  16706. }
  16707. return string(s2)
  16708. }
  16709. // 对账
  16710. func (c *HisApiController) Post3202() {
  16711. start_time := c.GetString("start_time")
  16712. end_time := c.GetString("end_time")
  16713. //insutype := c.GetString("insutype")
  16714. clr_type := c.GetString("clr_type")
  16715. clr_org := c.GetString("clr_optins")
  16716. admin_user_id, _ := c.GetInt64("admin_user_id")
  16717. adminUser := c.GetAdminUserInfo()
  16718. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  16719. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  16720. if len(clr_org) == 0 {
  16721. clr_org = miConfig.MdtrtareaAdmvs
  16722. }
  16723. timeLayout := "2006-01-02"
  16724. loc, _ := time.LoadLocation("Local")
  16725. startime, _ := time.ParseInLocation(timeLayout+" 15:04:05", start_time+" 00:00:00", loc)
  16726. endtime, _ := time.ParseInLocation(timeLayout+" 15:04:05", end_time+" 23:59:59", loc)
  16727. orders, _ := service.GetOrderByTimeFour(startime.Unix(), endtime.Unix(), adminUser.CurrentOrgId)
  16728. //orders_two, _ := service.GetOrderByTimeFour(startime.Unix(), endtime.Unix(), adminUser.CurrentOrgId, "310", "", clr_type)
  16729. //fixmedins_setl_cnt := int64(len(orders))
  16730. var medfee_sumamt float64
  16731. var acct_pay float64
  16732. var fund_pay_sumamt float64
  16733. for _, item := range orders {
  16734. medfee_sumamt = medfee_sumamt + item.MedfeeSumamt
  16735. acct_pay = acct_pay + item.AcctPay
  16736. fund_pay_sumamt = fund_pay_sumamt + item.FundPaySumamt
  16737. }
  16738. //var medfee_sumamt_two float64
  16739. //var acct_pay_two float64
  16740. //var fund_pay_sumamt_two float64
  16741. //for _, item := range orders_two {
  16742. // medfee_sumamt_two = medfee_sumamt_two + item.MedfeeSumamt
  16743. // acct_pay_two = acct_pay_two + item.AcctPay
  16744. // fund_pay_sumamt_two = fund_pay_sumamt_two + item.FundPaySumamt
  16745. //}
  16746. //var user_name string
  16747. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  16748. //if role.ID == 0 {
  16749. // user_name = "xxx"
  16750. //} else {
  16751. // user_name = role.UserName
  16752. //}
  16753. var res ResultSix
  16754. if config.IsOpen == 1 {
  16755. var bps []*models.BusinessParamsTwo
  16756. var bp models.BusinessParamsTwo
  16757. medfee_sumamt_str := fmt.Sprintf("%.2f", medfee_sumamt)
  16758. acct_pay_str := fmt.Sprintf("%.2f", acct_pay)
  16759. fund_pay_sumamt_str := fmt.Sprintf("%.2f", fund_pay_sumamt)
  16760. bp.MedfeeSumamt = medfee_sumamt_str
  16761. bp.AcctPay = acct_pay_str
  16762. bp.FundPaySumamt = fund_pay_sumamt_str
  16763. bp.Insutype = "390"
  16764. bp.StmtBegndate = start_time
  16765. bp.ClrType = clr_type
  16766. bp.SetlOptins = clr_org
  16767. bp.StmtEnddate = end_time
  16768. bps = append(bps, &bp)
  16769. data := make(map[string]interface{})
  16770. data["bps"] = bps
  16771. data["org_name"] = miConfig.OrgName
  16772. data["doctor"] = role.UserName
  16773. data["fixmedins_code"] = miConfig.Code
  16774. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  16775. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  16776. if miConfig.MdtrtareaAdmvs == "421300" {
  16777. client := &http.Client{}
  16778. bytesData, _ := json.Marshal(data)
  16779. req, _ := http.NewRequest("POST", "http://192.168.124.4:9532/"+"hbyb/3202", bytes.NewReader(bytesData))
  16780. resp, _ := client.Do(req)
  16781. defer resp.Body.Close()
  16782. body, ioErr := ioutil.ReadAll(resp.Body)
  16783. if ioErr != nil {
  16784. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  16785. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  16786. return
  16787. }
  16788. var respJSON map[string]interface{}
  16789. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  16790. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  16791. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  16792. return
  16793. }
  16794. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  16795. userJSONBytes, _ := json.Marshal(respJSON)
  16796. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  16797. utils.ErrorLog("解析失败:%v", err)
  16798. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  16799. return
  16800. }
  16801. }
  16802. if res.Infcode == 0 {
  16803. c.ServeSuccessJSON(map[string]interface{}{
  16804. "msg": "发起成功",
  16805. })
  16806. } else {
  16807. c.ServeSuccessJSON(map[string]interface{}{
  16808. "code": -10,
  16809. "msg": res.ErrMsg,
  16810. })
  16811. }
  16812. }
  16813. }
  16814. func (c *HisApiController) Post3501() {
  16815. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  16816. data := make(map[string]interface{})
  16817. var struct3501s []models.Struct3501
  16818. var struct3501 models.Struct3501
  16819. struct3501.OrgName = miConfig.OrgName
  16820. struct3501.AccessKey = miConfig.AccessKey
  16821. struct3501.RequestUrl = miConfig.Url
  16822. struct3501.SecretKey = miConfig.SecretKey
  16823. struct3501.ManuDate = "2022-08-17"
  16824. struct3501.FixmedinsBchno = ""
  16825. struct3501.ManuLotnum = ""
  16826. struct3501.RxFlag = "0"
  16827. struct3501.ExpyEnd = "2022-08-17"
  16828. struct3501.Invdate = "2022-08-17"
  16829. struct3501.InvCnt = "20.25"
  16830. struct3501.Memo = ""
  16831. struct3501.MedListCodg = "XB01ABD056B002020200517"
  16832. struct3501.FixmedinsHilistId = miConfig.Code
  16833. struct3501.FixmedinsHilistName = miConfig.OrgName
  16834. struct3501s = append(struct3501s, struct3501)
  16835. data["struct_3501s"] = struct3501s
  16836. client := &http.Client{}
  16837. bytesData, _ := json.Marshal(data)
  16838. var req *http.Request
  16839. if miConfig.MdtrtareaAdmvs == "320921" {
  16840. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3501", bytes.NewReader(bytesData))
  16841. } else {
  16842. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3501", bytes.NewReader(bytesData))
  16843. }
  16844. resp, _ := client.Do(req)
  16845. defer resp.Body.Close()
  16846. body, ioErr := ioutil.ReadAll(resp.Body)
  16847. if ioErr != nil {
  16848. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  16849. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  16850. return
  16851. }
  16852. var respJSON map[string]interface{}
  16853. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  16854. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  16855. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  16856. return
  16857. }
  16858. var res ResultSix
  16859. var resSix10265 ResultSix10265 //1101结果
  16860. respJSON = respJSON["data"].(map[string]interface{})["request_log"].(map[string]interface{})
  16861. result, _ := json.Marshal(respJSON)
  16862. if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  16863. utils.ErrorLog("解析失败:%v", err)
  16864. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  16865. return
  16866. }
  16867. res.InfRefmsgid = resSix10265.InfRefmsgid
  16868. res.Output = resSix10265.Output
  16869. res.ErrMsg = resSix10265.ErrMsg
  16870. res.Cainfo = resSix10265.Cainfo
  16871. res.WarnMsg = resSix10265.WarnMsg
  16872. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  16873. res.Infcode = infocode
  16874. if infocode == 0 {
  16875. c.ServeSuccessJSON(map[string]interface{}{
  16876. "msg": "上传成功",
  16877. })
  16878. return
  16879. } else {
  16880. c.ServeSuccessJSON(map[string]interface{}{
  16881. "failed_code": -10,
  16882. "msg": res.ErrMsg,
  16883. })
  16884. return
  16885. }
  16886. }
  16887. func (c *HisApiController) Post3502() {
  16888. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  16889. data := make(map[string]interface{})
  16890. var struct3502s []models.Struct3502
  16891. var struct3502 models.Struct3502
  16892. struct3502.OrgName = miConfig.OrgName
  16893. struct3502.AccessKey = miConfig.AccessKey
  16894. struct3502.RequestUrl = miConfig.Url
  16895. struct3502.SecretKey = miConfig.SecretKey
  16896. struct3502.ManuDate = "2022-08-15"
  16897. struct3502.FixmedinsBchno = ""
  16898. struct3502.ManuLotnum = ""
  16899. struct3502.RxFlag = "0"
  16900. struct3502.ExpyEnd = "2022-08-15"
  16901. struct3502.Invdate = "2022-08-15"
  16902. struct3502.InvCnt = "20.25"
  16903. struct3502.Memo = ""
  16904. struct3502.MedListCodg = "XB01ABD056B002020200517"
  16905. struct3502.FixmedinsHilistId = miConfig.Code
  16906. struct3502.FixmedinsHilistName = miConfig.OrgName
  16907. struct3502s = append(struct3502s, struct3502)
  16908. data["struct_3502s"] = struct3502s
  16909. client := &http.Client{}
  16910. bytesData, _ := json.Marshal(data)
  16911. var req *http.Request
  16912. if miConfig.MdtrtareaAdmvs == "320921" {
  16913. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3501", bytes.NewReader(bytesData))
  16914. } else {
  16915. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3501", bytes.NewReader(bytesData))
  16916. }
  16917. resp, _ := client.Do(req)
  16918. defer resp.Body.Close()
  16919. body, ioErr := ioutil.ReadAll(resp.Body)
  16920. if ioErr != nil {
  16921. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  16922. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  16923. return
  16924. }
  16925. var respJSON map[string]interface{}
  16926. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  16927. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  16928. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  16929. return
  16930. }
  16931. var res ResultSix
  16932. var resSix10265 ResultSix10265 //1101结果
  16933. respJSON = respJSON["data"].(map[string]interface{})["request_log"].(map[string]interface{})
  16934. result, _ := json.Marshal(respJSON)
  16935. if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  16936. utils.ErrorLog("解析失败:%v", err)
  16937. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  16938. return
  16939. }
  16940. res.InfRefmsgid = resSix10265.InfRefmsgid
  16941. res.Output = resSix10265.Output
  16942. res.ErrMsg = resSix10265.ErrMsg
  16943. res.Cainfo = resSix10265.Cainfo
  16944. res.WarnMsg = resSix10265.WarnMsg
  16945. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  16946. res.Infcode = infocode
  16947. if infocode == 0 {
  16948. c.ServeSuccessJSON(map[string]interface{}{
  16949. "msg": "上传成功",
  16950. })
  16951. return
  16952. } else {
  16953. c.ServeSuccessJSON(map[string]interface{}{
  16954. "failed_code": -10,
  16955. "msg": res.ErrMsg,
  16956. })
  16957. return
  16958. }
  16959. }
  16960. func (c *HisApiController) Post3503() {
  16961. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  16962. data := make(map[string]interface{})
  16963. var struct3501s []models.Struct3501
  16964. var struct3501 models.Struct3501
  16965. struct3501.OrgName = miConfig.OrgName
  16966. struct3501.AccessKey = miConfig.AccessKey
  16967. struct3501.RequestUrl = miConfig.Url
  16968. struct3501.SecretKey = miConfig.SecretKey
  16969. struct3501.ManuDate = "2022-08-15"
  16970. struct3501.FixmedinsBchno = ""
  16971. struct3501.ManuLotnum = ""
  16972. struct3501.RxFlag = "0"
  16973. struct3501.ExpyEnd = "2022-08-15"
  16974. struct3501.Invdate = "2022-08-15"
  16975. struct3501.InvCnt = "20.25"
  16976. struct3501.Memo = ""
  16977. struct3501.MedListCodg = "XB01ABD056B002020200517"
  16978. struct3501.FixmedinsHilistId = miConfig.Code
  16979. struct3501.FixmedinsHilistName = miConfig.OrgName
  16980. struct3501s = append(struct3501s, struct3501)
  16981. data["struct_3501s"] = struct3501s
  16982. client := &http.Client{}
  16983. bytesData, _ := json.Marshal(data)
  16984. var req *http.Request
  16985. if miConfig.MdtrtareaAdmvs == "320921" {
  16986. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3501", bytes.NewReader(bytesData))
  16987. } else {
  16988. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3501", bytes.NewReader(bytesData))
  16989. }
  16990. resp, _ := client.Do(req)
  16991. defer resp.Body.Close()
  16992. body, ioErr := ioutil.ReadAll(resp.Body)
  16993. if ioErr != nil {
  16994. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  16995. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  16996. return
  16997. }
  16998. var respJSON map[string]interface{}
  16999. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  17000. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  17001. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  17002. return
  17003. }
  17004. var res ResultSix
  17005. var resSix10265 ResultSix10265 //1101结果
  17006. respJSON = respJSON["data"].(map[string]interface{})["request_log"].(map[string]interface{})
  17007. result, _ := json.Marshal(respJSON)
  17008. if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  17009. utils.ErrorLog("解析失败:%v", err)
  17010. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  17011. return
  17012. }
  17013. res.InfRefmsgid = resSix10265.InfRefmsgid
  17014. res.Output = resSix10265.Output
  17015. res.ErrMsg = resSix10265.ErrMsg
  17016. res.Cainfo = resSix10265.Cainfo
  17017. res.WarnMsg = resSix10265.WarnMsg
  17018. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  17019. res.Infcode = infocode
  17020. if infocode == 0 {
  17021. c.ServeSuccessJSON(map[string]interface{}{
  17022. "msg": "上传成功",
  17023. })
  17024. return
  17025. } else {
  17026. c.ServeSuccessJSON(map[string]interface{}{
  17027. "failed_code": -10,
  17028. "msg": res.ErrMsg,
  17029. })
  17030. return
  17031. }
  17032. }
  17033. func (c *HisApiController) Post3504() {
  17034. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  17035. data := make(map[string]interface{})
  17036. var struct3501s []models.Struct3501
  17037. var struct3501 models.Struct3501
  17038. struct3501.OrgName = miConfig.OrgName
  17039. struct3501.AccessKey = miConfig.AccessKey
  17040. struct3501.RequestUrl = miConfig.Url
  17041. struct3501.SecretKey = miConfig.SecretKey
  17042. struct3501.ManuDate = "2022-08-15"
  17043. struct3501.FixmedinsBchno = ""
  17044. struct3501.ManuLotnum = ""
  17045. struct3501.RxFlag = "0"
  17046. struct3501.ExpyEnd = "2022-08-15"
  17047. struct3501.Invdate = "2022-08-15"
  17048. struct3501.InvCnt = "20.25"
  17049. struct3501.Memo = ""
  17050. struct3501.MedListCodg = "XB01ABD056B002020200517"
  17051. struct3501.FixmedinsHilistId = miConfig.Code
  17052. struct3501.FixmedinsHilistName = miConfig.OrgName
  17053. struct3501s = append(struct3501s, struct3501)
  17054. data["struct_3501s"] = struct3501s
  17055. client := &http.Client{}
  17056. bytesData, _ := json.Marshal(data)
  17057. var req *http.Request
  17058. if miConfig.MdtrtareaAdmvs == "320921" {
  17059. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3501", bytes.NewReader(bytesData))
  17060. } else {
  17061. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3501", bytes.NewReader(bytesData))
  17062. }
  17063. resp, _ := client.Do(req)
  17064. defer resp.Body.Close()
  17065. body, ioErr := ioutil.ReadAll(resp.Body)
  17066. if ioErr != nil {
  17067. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  17068. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  17069. return
  17070. }
  17071. var respJSON map[string]interface{}
  17072. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  17073. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  17074. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  17075. return
  17076. }
  17077. var res ResultSix
  17078. var resSix10265 ResultSix10265 //1101结果
  17079. respJSON = respJSON["data"].(map[string]interface{})["request_log"].(map[string]interface{})
  17080. result, _ := json.Marshal(respJSON)
  17081. if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  17082. utils.ErrorLog("解析失败:%v", err)
  17083. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  17084. return
  17085. }
  17086. res.InfRefmsgid = resSix10265.InfRefmsgid
  17087. res.Output = resSix10265.Output
  17088. res.ErrMsg = resSix10265.ErrMsg
  17089. res.Cainfo = resSix10265.Cainfo
  17090. res.WarnMsg = resSix10265.WarnMsg
  17091. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  17092. res.Infcode = infocode
  17093. if infocode == 0 {
  17094. c.ServeSuccessJSON(map[string]interface{}{
  17095. "msg": "上传成功",
  17096. })
  17097. return
  17098. } else {
  17099. c.ServeSuccessJSON(map[string]interface{}{
  17100. "failed_code": -10,
  17101. "msg": res.ErrMsg,
  17102. })
  17103. return
  17104. }
  17105. }
  17106. func (c *HisApiController) Post3505() {
  17107. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  17108. data := make(map[string]interface{})
  17109. var struct3501s []models.Struct3501
  17110. var struct3501 models.Struct3501
  17111. struct3501.OrgName = miConfig.OrgName
  17112. struct3501.AccessKey = miConfig.AccessKey
  17113. struct3501.RequestUrl = miConfig.Url
  17114. struct3501.SecretKey = miConfig.SecretKey
  17115. struct3501.ManuDate = "2022-08-15"
  17116. struct3501.FixmedinsBchno = ""
  17117. struct3501.ManuLotnum = ""
  17118. struct3501.RxFlag = "0"
  17119. struct3501.ExpyEnd = "2022-08-15"
  17120. struct3501.Invdate = "2022-08-15"
  17121. struct3501.InvCnt = "20.25"
  17122. struct3501.Memo = ""
  17123. struct3501.MedListCodg = "XB01ABD056B002020200517"
  17124. struct3501.FixmedinsHilistId = miConfig.Code
  17125. struct3501.FixmedinsHilistName = miConfig.OrgName
  17126. struct3501s = append(struct3501s, struct3501)
  17127. data["struct_3501s"] = struct3501s
  17128. client := &http.Client{}
  17129. bytesData, _ := json.Marshal(data)
  17130. var req *http.Request
  17131. if miConfig.MdtrtareaAdmvs == "320921" {
  17132. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3501", bytes.NewReader(bytesData))
  17133. } else {
  17134. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3501", bytes.NewReader(bytesData))
  17135. }
  17136. resp, _ := client.Do(req)
  17137. defer resp.Body.Close()
  17138. body, ioErr := ioutil.ReadAll(resp.Body)
  17139. if ioErr != nil {
  17140. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  17141. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  17142. return
  17143. }
  17144. var respJSON map[string]interface{}
  17145. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  17146. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  17147. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  17148. return
  17149. }
  17150. var res ResultSix
  17151. var resSix10265 ResultSix10265 //1101结果
  17152. respJSON = respJSON["data"].(map[string]interface{})["request_log"].(map[string]interface{})
  17153. result, _ := json.Marshal(respJSON)
  17154. if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  17155. utils.ErrorLog("解析失败:%v", err)
  17156. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  17157. return
  17158. }
  17159. res.InfRefmsgid = resSix10265.InfRefmsgid
  17160. res.Output = resSix10265.Output
  17161. res.ErrMsg = resSix10265.ErrMsg
  17162. res.Cainfo = resSix10265.Cainfo
  17163. res.WarnMsg = resSix10265.WarnMsg
  17164. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  17165. res.Infcode = infocode
  17166. if infocode == 0 {
  17167. c.ServeSuccessJSON(map[string]interface{}{
  17168. "msg": "上传成功",
  17169. })
  17170. return
  17171. } else {
  17172. c.ServeSuccessJSON(map[string]interface{}{
  17173. "failed_code": -10,
  17174. "msg": res.ErrMsg,
  17175. })
  17176. return
  17177. }
  17178. }
  17179. func (c *HisApiController) Post3506() {
  17180. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  17181. data := make(map[string]interface{})
  17182. var struct3501s []models.Struct3501
  17183. var struct3501 models.Struct3501
  17184. struct3501.OrgName = miConfig.OrgName
  17185. struct3501.AccessKey = miConfig.AccessKey
  17186. struct3501.RequestUrl = miConfig.Url
  17187. struct3501.SecretKey = miConfig.SecretKey
  17188. struct3501.ManuDate = "2022-08-15"
  17189. struct3501.FixmedinsBchno = ""
  17190. struct3501.ManuLotnum = ""
  17191. struct3501.RxFlag = "0"
  17192. struct3501.ExpyEnd = "2022-08-15"
  17193. struct3501.Invdate = "2022-08-15"
  17194. struct3501.InvCnt = "20.25"
  17195. struct3501.Memo = ""
  17196. struct3501.MedListCodg = "XB01ABD056B002020200517"
  17197. struct3501.FixmedinsHilistId = miConfig.Code
  17198. struct3501.FixmedinsHilistName = miConfig.OrgName
  17199. struct3501s = append(struct3501s, struct3501)
  17200. data["struct_3501s"] = struct3501s
  17201. client := &http.Client{}
  17202. bytesData, _ := json.Marshal(data)
  17203. var req *http.Request
  17204. if miConfig.MdtrtareaAdmvs == "320921" {
  17205. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3501", bytes.NewReader(bytesData))
  17206. } else {
  17207. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3501", bytes.NewReader(bytesData))
  17208. }
  17209. resp, _ := client.Do(req)
  17210. defer resp.Body.Close()
  17211. body, ioErr := ioutil.ReadAll(resp.Body)
  17212. if ioErr != nil {
  17213. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  17214. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  17215. return
  17216. }
  17217. var respJSON map[string]interface{}
  17218. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  17219. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  17220. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  17221. return
  17222. }
  17223. var res ResultSix
  17224. var resSix10265 ResultSix10265 //1101结果
  17225. respJSON = respJSON["data"].(map[string]interface{})["request_log"].(map[string]interface{})
  17226. result, _ := json.Marshal(respJSON)
  17227. if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  17228. utils.ErrorLog("解析失败:%v", err)
  17229. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  17230. return
  17231. }
  17232. res.InfRefmsgid = resSix10265.InfRefmsgid
  17233. res.Output = resSix10265.Output
  17234. res.ErrMsg = resSix10265.ErrMsg
  17235. res.Cainfo = resSix10265.Cainfo
  17236. res.WarnMsg = resSix10265.WarnMsg
  17237. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  17238. res.Infcode = infocode
  17239. if infocode == 0 {
  17240. c.ServeSuccessJSON(map[string]interface{}{
  17241. "msg": "上传成功",
  17242. })
  17243. return
  17244. } else {
  17245. c.ServeSuccessJSON(map[string]interface{}{
  17246. "failed_code": -10,
  17247. "msg": res.ErrMsg,
  17248. })
  17249. return
  17250. }
  17251. }
  17252. func (c *HisApiController) Post3507() {
  17253. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  17254. data := make(map[string]interface{})
  17255. var struct3501s []models.Struct3501
  17256. var struct3501 models.Struct3501
  17257. struct3501.OrgName = miConfig.OrgName
  17258. struct3501.AccessKey = miConfig.AccessKey
  17259. struct3501.RequestUrl = miConfig.Url
  17260. struct3501.SecretKey = miConfig.SecretKey
  17261. struct3501.ManuDate = "2022-08-15"
  17262. struct3501.FixmedinsBchno = ""
  17263. struct3501.ManuLotnum = ""
  17264. struct3501.RxFlag = "0"
  17265. struct3501.ExpyEnd = "2022-08-15"
  17266. struct3501.Invdate = "2022-08-15"
  17267. struct3501.InvCnt = "20.25"
  17268. struct3501.Memo = ""
  17269. struct3501.MedListCodg = "XB01ABD056B002020200517"
  17270. struct3501.FixmedinsHilistId = miConfig.Code
  17271. struct3501.FixmedinsHilistName = miConfig.OrgName
  17272. struct3501s = append(struct3501s, struct3501)
  17273. data["struct_3501s"] = struct3501s
  17274. client := &http.Client{}
  17275. bytesData, _ := json.Marshal(data)
  17276. var req *http.Request
  17277. if miConfig.MdtrtareaAdmvs == "320921" {
  17278. req, _ = http.NewRequest("POST", "http://192.168.2.3:9532/"+"jsyb/3501", bytes.NewReader(bytesData))
  17279. } else {
  17280. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3501", bytes.NewReader(bytesData))
  17281. }
  17282. resp, _ := client.Do(req)
  17283. defer resp.Body.Close()
  17284. body, ioErr := ioutil.ReadAll(resp.Body)
  17285. if ioErr != nil {
  17286. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  17287. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  17288. return
  17289. }
  17290. var respJSON map[string]interface{}
  17291. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  17292. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  17293. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  17294. return
  17295. }
  17296. var res ResultSix
  17297. var resSix10265 ResultSix10265 //1101结果
  17298. respJSON = respJSON["data"].(map[string]interface{})["request_log"].(map[string]interface{})
  17299. result, _ := json.Marshal(respJSON)
  17300. if err := json.Unmarshal([]byte(result), &resSix10265); err != nil {
  17301. utils.ErrorLog("解析失败:%v", err)
  17302. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  17303. return
  17304. }
  17305. res.InfRefmsgid = resSix10265.InfRefmsgid
  17306. res.Output = resSix10265.Output
  17307. res.ErrMsg = resSix10265.ErrMsg
  17308. res.Cainfo = resSix10265.Cainfo
  17309. res.WarnMsg = resSix10265.WarnMsg
  17310. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  17311. res.Infcode = infocode
  17312. if infocode == 0 {
  17313. c.ServeSuccessJSON(map[string]interface{}{
  17314. "msg": "上传成功",
  17315. })
  17316. return
  17317. } else {
  17318. c.ServeSuccessJSON(map[string]interface{}{
  17319. "failed_code": -10,
  17320. "msg": res.ErrMsg,
  17321. })
  17322. return
  17323. }
  17324. }
  17325. func GetELeInfo(code string, operator_id string, operator_name string) (string, string) {
  17326. // WebSocket服务器地址
  17327. serverURL := "ws://127.0.0.1:8899"
  17328. // 解析WebSocket服务器地址
  17329. u, err := url.Parse(serverURL)
  17330. if err != nil {
  17331. }
  17332. // 建立WebSocket连接
  17333. conn, _, err := websocket.DefaultDialer.Dial(u.String(), nil)
  17334. if err != nil {
  17335. }
  17336. defer conn.Close()
  17337. input2 := make(map[string]interface{})
  17338. input := make(map[string]interface{})
  17339. inputData := make(map[string]interface{})
  17340. inputData["orgId"] = code
  17341. inputData["businessType"] = "01101"
  17342. inputData["operatorId"] = operator_id
  17343. inputData["operatorName"] = operator_name
  17344. inputData["officeId"] = "001"
  17345. inputData["officeName"] = "血透室"
  17346. inputData["deviceType"] = ""
  17347. input["data"] = inputData
  17348. input["orgId"] = code
  17349. input["transType"] = "ec.query"
  17350. input2["url"] = "http://igb.hsa.gdgov.cn/prd_nation_eccode/prd_eccode/localcfc/api/hsecfc/localQrCodeQuery"
  17351. input2["indata"] = input
  17352. bytesData, _ := json.Marshal(input2)
  17353. err = conn.WriteMessage(websocket.TextMessage, bytesData)
  17354. if err != nil {
  17355. fmt.Println(err)
  17356. }
  17357. // 接收消息
  17358. _, receivedMessage, err := conn.ReadMessage()
  17359. if err != nil {
  17360. fmt.Println(err)
  17361. }
  17362. return "", string(receivedMessage)
  17363. }
  17364. func GetELeInfoThree(code string, operator_id string, operator_name string) (string, string) {
  17365. // WebSocket服务器地址
  17366. serverURL := "ws://127.0.0.1:8899"
  17367. // 解析WebSocket服务器地址
  17368. u, err := url.Parse(serverURL)
  17369. if err != nil {
  17370. }
  17371. // 建立WebSocket连接
  17372. conn, _, err := websocket.DefaultDialer.Dial(u.String(), nil)
  17373. if err != nil {
  17374. }
  17375. defer conn.Close()
  17376. input2 := make(map[string]interface{})
  17377. input := make(map[string]interface{})
  17378. inputData := make(map[string]interface{})
  17379. inputData["orgId"] = code
  17380. inputData["businessType"] = "01301"
  17381. inputData["operatorId"] = operator_id
  17382. inputData["operatorName"] = operator_name
  17383. inputData["officeId"] = "001"
  17384. inputData["officeName"] = "血透室"
  17385. inputData["deviceType"] = ""
  17386. input["data"] = inputData
  17387. input["orgId"] = code
  17388. input["transType"] = "ec.query"
  17389. input2["url"] = "http://igb.hsa.gdgov.cn/prd_nation_eccode/prd_eccode/localcfc/api/hsecfc/localQrCodeQuery"
  17390. input2["indata"] = input
  17391. bytesData, _ := json.Marshal(input2)
  17392. err = conn.WriteMessage(websocket.TextMessage, bytesData)
  17393. if err != nil {
  17394. fmt.Println(err)
  17395. }
  17396. // 接收消息
  17397. _, receivedMessage, err := conn.ReadMessage()
  17398. if err != nil {
  17399. fmt.Println(err)
  17400. }
  17401. return "", string(receivedMessage)
  17402. }