his_api_controller.go 420KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504250525062507250825092510251125122513251425152516251725182519252025212522252325242525252625272528252925302531253225332534253525362537253825392540254125422543254425452546254725482549255025512552255325542555255625572558255925602561256225632564256525662567256825692570257125722573257425752576257725782579258025812582258325842585258625872588258925902591259225932594259525962597259825992600260126022603260426052606260726082609261026112612261326142615261626172618261926202621262226232624262526262627262826292630263126322633263426352636263726382639264026412642264326442645264626472648264926502651265226532654265526562657265826592660266126622663266426652666266726682669267026712672267326742675267626772678267926802681268226832684268526862687268826892690269126922693269426952696269726982699270027012702270327042705270627072708270927102711271227132714271527162717271827192720272127222723272427252726272727282729273027312732273327342735273627372738273927402741274227432744274527462747274827492750275127522753275427552756275727582759276027612762276327642765276627672768276927702771277227732774277527762777277827792780278127822783278427852786278727882789279027912792279327942795279627972798279928002801280228032804280528062807280828092810281128122813281428152816281728182819282028212822282328242825282628272828282928302831283228332834283528362837283828392840284128422843284428452846284728482849285028512852285328542855285628572858285928602861286228632864286528662867286828692870287128722873287428752876287728782879288028812882288328842885288628872888288928902891289228932894289528962897289828992900290129022903290429052906290729082909291029112912291329142915291629172918291929202921292229232924292529262927292829292930293129322933293429352936293729382939294029412942294329442945294629472948294929502951295229532954295529562957295829592960296129622963296429652966296729682969297029712972297329742975297629772978297929802981298229832984298529862987298829892990299129922993299429952996299729982999300030013002300330043005300630073008300930103011301230133014301530163017301830193020302130223023302430253026302730283029303030313032303330343035303630373038303930403041304230433044304530463047304830493050305130523053305430553056305730583059306030613062306330643065306630673068306930703071307230733074307530763077307830793080308130823083308430853086308730883089309030913092309330943095309630973098309931003101310231033104310531063107310831093110311131123113311431153116311731183119312031213122312331243125312631273128312931303131313231333134313531363137313831393140314131423143314431453146314731483149315031513152315331543155315631573158315931603161316231633164316531663167316831693170317131723173317431753176317731783179318031813182318331843185318631873188318931903191319231933194319531963197319831993200320132023203320432053206320732083209321032113212321332143215321632173218321932203221322232233224322532263227322832293230323132323233323432353236323732383239324032413242324332443245324632473248324932503251325232533254325532563257325832593260326132623263326432653266326732683269327032713272327332743275327632773278327932803281328232833284328532863287328832893290329132923293329432953296329732983299330033013302330333043305330633073308330933103311331233133314331533163317331833193320332133223323332433253326332733283329333033313332333333343335333633373338333933403341334233433344334533463347334833493350335133523353335433553356335733583359336033613362336333643365336633673368336933703371337233733374337533763377337833793380338133823383338433853386338733883389339033913392339333943395339633973398339934003401340234033404340534063407340834093410341134123413341434153416341734183419342034213422342334243425342634273428342934303431343234333434343534363437343834393440344134423443344434453446344734483449345034513452345334543455345634573458345934603461346234633464346534663467346834693470347134723473347434753476347734783479348034813482348334843485348634873488348934903491349234933494349534963497349834993500350135023503350435053506350735083509351035113512351335143515351635173518351935203521352235233524352535263527352835293530353135323533353435353536353735383539354035413542354335443545354635473548354935503551355235533554355535563557355835593560356135623563356435653566356735683569357035713572357335743575357635773578357935803581358235833584358535863587358835893590359135923593359435953596359735983599360036013602360336043605360636073608360936103611361236133614361536163617361836193620362136223623362436253626362736283629363036313632363336343635363636373638363936403641364236433644364536463647364836493650365136523653365436553656365736583659366036613662366336643665366636673668366936703671367236733674367536763677367836793680368136823683368436853686368736883689369036913692369336943695369636973698369937003701370237033704370537063707370837093710371137123713371437153716371737183719372037213722372337243725372637273728372937303731373237333734373537363737373837393740374137423743374437453746374737483749375037513752375337543755375637573758375937603761376237633764376537663767376837693770377137723773377437753776377737783779378037813782378337843785378637873788378937903791379237933794379537963797379837993800380138023803380438053806380738083809381038113812381338143815381638173818381938203821382238233824382538263827382838293830383138323833383438353836383738383839384038413842384338443845384638473848384938503851385238533854385538563857385838593860386138623863386438653866386738683869387038713872387338743875387638773878387938803881388238833884388538863887388838893890389138923893389438953896389738983899390039013902390339043905390639073908390939103911391239133914391539163917391839193920392139223923392439253926392739283929393039313932393339343935393639373938393939403941394239433944394539463947394839493950395139523953395439553956395739583959396039613962396339643965396639673968396939703971397239733974397539763977397839793980398139823983398439853986398739883989399039913992399339943995399639973998399940004001400240034004400540064007400840094010401140124013401440154016401740184019402040214022402340244025402640274028402940304031403240334034403540364037403840394040404140424043404440454046404740484049405040514052405340544055405640574058405940604061406240634064406540664067406840694070407140724073407440754076407740784079408040814082408340844085408640874088408940904091409240934094409540964097409840994100410141024103410441054106410741084109411041114112411341144115411641174118411941204121412241234124412541264127412841294130413141324133413441354136413741384139414041414142414341444145414641474148414941504151415241534154415541564157415841594160416141624163416441654166416741684169417041714172417341744175417641774178417941804181418241834184418541864187418841894190419141924193419441954196419741984199420042014202420342044205420642074208420942104211421242134214421542164217421842194220422142224223422442254226422742284229423042314232423342344235423642374238423942404241424242434244424542464247424842494250425142524253425442554256425742584259426042614262426342644265426642674268426942704271427242734274427542764277427842794280428142824283428442854286428742884289429042914292429342944295429642974298429943004301430243034304430543064307430843094310431143124313431443154316431743184319432043214322432343244325432643274328432943304331433243334334433543364337433843394340434143424343434443454346434743484349435043514352435343544355435643574358435943604361436243634364436543664367436843694370437143724373437443754376437743784379438043814382438343844385438643874388438943904391439243934394439543964397439843994400440144024403440444054406440744084409441044114412441344144415441644174418441944204421442244234424442544264427442844294430443144324433443444354436443744384439444044414442444344444445444644474448444944504451445244534454445544564457445844594460446144624463446444654466446744684469447044714472447344744475447644774478447944804481448244834484448544864487448844894490449144924493449444954496449744984499450045014502450345044505450645074508450945104511451245134514451545164517451845194520452145224523452445254526452745284529453045314532453345344535453645374538453945404541454245434544454545464547454845494550455145524553455445554556455745584559456045614562456345644565456645674568456945704571457245734574457545764577457845794580458145824583458445854586458745884589459045914592459345944595459645974598459946004601460246034604460546064607460846094610461146124613461446154616461746184619462046214622462346244625462646274628462946304631463246334634463546364637463846394640464146424643464446454646464746484649465046514652465346544655465646574658465946604661466246634664466546664667466846694670467146724673467446754676467746784679468046814682468346844685468646874688468946904691469246934694469546964697469846994700470147024703470447054706470747084709471047114712471347144715471647174718471947204721472247234724472547264727472847294730473147324733473447354736473747384739474047414742474347444745474647474748474947504751475247534754475547564757475847594760476147624763476447654766476747684769477047714772477347744775477647774778477947804781478247834784478547864787478847894790479147924793479447954796479747984799480048014802480348044805480648074808480948104811481248134814481548164817481848194820482148224823482448254826482748284829483048314832483348344835483648374838483948404841484248434844484548464847484848494850485148524853485448554856485748584859486048614862486348644865486648674868486948704871487248734874487548764877487848794880488148824883488448854886488748884889489048914892489348944895489648974898489949004901490249034904490549064907490849094910491149124913491449154916491749184919492049214922492349244925492649274928492949304931493249334934493549364937493849394940494149424943494449454946494749484949495049514952495349544955495649574958495949604961496249634964496549664967496849694970497149724973497449754976497749784979498049814982498349844985498649874988498949904991499249934994499549964997499849995000500150025003500450055006500750085009501050115012501350145015501650175018501950205021502250235024502550265027502850295030503150325033503450355036503750385039504050415042504350445045504650475048504950505051505250535054505550565057505850595060506150625063506450655066506750685069507050715072507350745075507650775078507950805081508250835084508550865087508850895090509150925093509450955096509750985099510051015102510351045105510651075108510951105111511251135114511551165117511851195120512151225123512451255126512751285129513051315132513351345135513651375138513951405141514251435144514551465147514851495150515151525153515451555156515751585159516051615162516351645165516651675168516951705171517251735174517551765177517851795180518151825183518451855186518751885189519051915192519351945195519651975198519952005201520252035204520552065207520852095210521152125213521452155216521752185219522052215222522352245225522652275228522952305231523252335234523552365237523852395240524152425243524452455246524752485249525052515252525352545255525652575258525952605261526252635264526552665267526852695270527152725273527452755276527752785279528052815282528352845285528652875288528952905291529252935294529552965297529852995300530153025303530453055306530753085309531053115312531353145315531653175318531953205321532253235324532553265327532853295330533153325333533453355336533753385339534053415342534353445345534653475348534953505351535253535354535553565357535853595360536153625363536453655366536753685369537053715372537353745375537653775378537953805381538253835384538553865387538853895390539153925393539453955396539753985399540054015402540354045405540654075408540954105411541254135414541554165417541854195420542154225423542454255426542754285429543054315432543354345435543654375438543954405441544254435444544554465447544854495450545154525453545454555456545754585459546054615462546354645465546654675468546954705471547254735474547554765477547854795480548154825483548454855486548754885489549054915492549354945495549654975498549955005501550255035504550555065507550855095510551155125513551455155516551755185519552055215522552355245525552655275528552955305531553255335534553555365537553855395540554155425543554455455546554755485549555055515552555355545555555655575558555955605561556255635564556555665567556855695570557155725573557455755576557755785579558055815582558355845585558655875588558955905591559255935594559555965597559855995600560156025603560456055606560756085609561056115612561356145615561656175618561956205621562256235624562556265627562856295630563156325633563456355636563756385639564056415642564356445645564656475648564956505651565256535654565556565657565856595660566156625663566456655666566756685669567056715672567356745675567656775678567956805681568256835684568556865687568856895690569156925693569456955696569756985699570057015702570357045705570657075708570957105711571257135714571557165717571857195720572157225723572457255726572757285729573057315732573357345735573657375738573957405741574257435744574557465747574857495750575157525753575457555756575757585759576057615762576357645765576657675768576957705771577257735774577557765777577857795780578157825783578457855786578757885789579057915792579357945795579657975798579958005801580258035804580558065807580858095810581158125813581458155816581758185819582058215822582358245825582658275828582958305831583258335834583558365837583858395840584158425843584458455846584758485849585058515852585358545855585658575858585958605861586258635864586558665867586858695870587158725873587458755876587758785879588058815882588358845885588658875888588958905891589258935894589558965897589858995900590159025903590459055906590759085909591059115912591359145915591659175918591959205921592259235924592559265927592859295930593159325933593459355936593759385939594059415942594359445945594659475948594959505951595259535954595559565957595859595960596159625963596459655966596759685969597059715972597359745975597659775978597959805981598259835984598559865987598859895990599159925993599459955996599759985999600060016002600360046005600660076008600960106011601260136014601560166017601860196020602160226023602460256026602760286029603060316032603360346035603660376038603960406041604260436044604560466047604860496050605160526053605460556056605760586059606060616062606360646065606660676068606960706071607260736074607560766077607860796080608160826083608460856086608760886089609060916092609360946095609660976098609961006101610261036104610561066107610861096110611161126113611461156116611761186119612061216122612361246125612661276128612961306131613261336134613561366137613861396140614161426143614461456146614761486149615061516152615361546155615661576158615961606161616261636164616561666167616861696170617161726173617461756176617761786179618061816182618361846185618661876188618961906191619261936194619561966197619861996200620162026203620462056206620762086209621062116212621362146215621662176218621962206221622262236224622562266227622862296230623162326233623462356236623762386239624062416242624362446245624662476248624962506251625262536254625562566257625862596260626162626263626462656266626762686269627062716272627362746275627662776278627962806281628262836284628562866287628862896290629162926293629462956296629762986299630063016302630363046305630663076308630963106311631263136314631563166317631863196320632163226323632463256326632763286329633063316332633363346335633663376338633963406341634263436344634563466347634863496350635163526353635463556356635763586359636063616362636363646365636663676368636963706371637263736374637563766377637863796380638163826383638463856386638763886389639063916392639363946395639663976398639964006401640264036404640564066407640864096410641164126413641464156416641764186419642064216422642364246425642664276428642964306431643264336434643564366437643864396440644164426443644464456446644764486449645064516452645364546455645664576458645964606461646264636464646564666467646864696470647164726473647464756476647764786479648064816482648364846485648664876488648964906491649264936494649564966497649864996500650165026503650465056506650765086509651065116512651365146515651665176518651965206521652265236524652565266527652865296530653165326533653465356536653765386539654065416542654365446545654665476548654965506551655265536554655565566557655865596560656165626563656465656566656765686569657065716572657365746575657665776578657965806581658265836584658565866587658865896590659165926593659465956596659765986599660066016602660366046605660666076608660966106611661266136614661566166617661866196620662166226623662466256626662766286629663066316632663366346635663666376638663966406641664266436644664566466647664866496650665166526653665466556656665766586659666066616662666366646665666666676668666966706671667266736674667566766677667866796680668166826683668466856686668766886689669066916692669366946695669666976698669967006701670267036704670567066707670867096710671167126713671467156716671767186719672067216722672367246725672667276728672967306731673267336734673567366737673867396740674167426743674467456746674767486749675067516752675367546755675667576758675967606761676267636764676567666767676867696770677167726773677467756776677767786779678067816782678367846785678667876788678967906791679267936794679567966797679867996800680168026803680468056806680768086809681068116812681368146815681668176818681968206821682268236824682568266827682868296830683168326833683468356836683768386839684068416842684368446845684668476848684968506851685268536854685568566857685868596860686168626863686468656866686768686869687068716872687368746875687668776878687968806881688268836884688568866887688868896890689168926893689468956896689768986899690069016902690369046905690669076908690969106911691269136914691569166917691869196920692169226923692469256926692769286929693069316932693369346935693669376938693969406941694269436944694569466947694869496950695169526953695469556956695769586959696069616962696369646965696669676968696969706971697269736974697569766977697869796980698169826983698469856986698769886989699069916992699369946995699669976998699970007001700270037004700570067007700870097010701170127013701470157016701770187019702070217022702370247025702670277028702970307031703270337034703570367037703870397040704170427043704470457046704770487049705070517052705370547055705670577058705970607061706270637064706570667067706870697070707170727073707470757076707770787079708070817082708370847085708670877088708970907091709270937094709570967097709870997100710171027103710471057106710771087109711071117112711371147115711671177118711971207121712271237124712571267127712871297130713171327133713471357136713771387139714071417142714371447145714671477148714971507151715271537154715571567157715871597160716171627163716471657166716771687169717071717172717371747175717671777178717971807181718271837184718571867187718871897190719171927193719471957196719771987199720072017202720372047205720672077208720972107211721272137214721572167217721872197220722172227223722472257226722772287229723072317232723372347235723672377238723972407241724272437244724572467247724872497250725172527253725472557256725772587259726072617262726372647265726672677268726972707271727272737274727572767277727872797280728172827283728472857286728772887289729072917292729372947295729672977298729973007301730273037304730573067307730873097310731173127313731473157316731773187319732073217322732373247325732673277328732973307331733273337334733573367337733873397340734173427343734473457346734773487349735073517352735373547355735673577358735973607361736273637364736573667367736873697370737173727373737473757376737773787379738073817382738373847385738673877388738973907391739273937394739573967397739873997400740174027403740474057406740774087409741074117412741374147415741674177418741974207421742274237424742574267427742874297430743174327433743474357436743774387439744074417442744374447445744674477448744974507451745274537454745574567457745874597460746174627463746474657466746774687469747074717472747374747475747674777478747974807481748274837484748574867487748874897490749174927493749474957496749774987499750075017502750375047505750675077508750975107511751275137514751575167517751875197520752175227523752475257526752775287529753075317532753375347535753675377538753975407541754275437544754575467547754875497550755175527553755475557556755775587559756075617562756375647565756675677568756975707571757275737574757575767577757875797580758175827583758475857586758775887589759075917592759375947595759675977598759976007601760276037604760576067607760876097610761176127613761476157616761776187619762076217622762376247625762676277628762976307631763276337634763576367637763876397640764176427643764476457646764776487649765076517652765376547655765676577658765976607661766276637664766576667667766876697670767176727673767476757676767776787679768076817682768376847685768676877688768976907691769276937694769576967697769876997700770177027703770477057706770777087709771077117712771377147715771677177718771977207721772277237724772577267727772877297730773177327733773477357736773777387739774077417742774377447745774677477748774977507751775277537754775577567757775877597760776177627763776477657766776777687769777077717772777377747775777677777778777977807781778277837784778577867787778877897790779177927793779477957796779777987799780078017802780378047805780678077808780978107811781278137814781578167817781878197820782178227823782478257826782778287829783078317832783378347835783678377838783978407841784278437844784578467847784878497850785178527853785478557856785778587859786078617862786378647865786678677868786978707871787278737874787578767877787878797880788178827883788478857886788778887889789078917892789378947895789678977898789979007901790279037904790579067907790879097910791179127913791479157916791779187919792079217922792379247925792679277928792979307931793279337934793579367937793879397940794179427943794479457946794779487949795079517952795379547955795679577958795979607961796279637964796579667967796879697970797179727973797479757976797779787979798079817982798379847985798679877988798979907991799279937994799579967997799879998000800180028003800480058006800780088009801080118012801380148015801680178018801980208021802280238024802580268027802880298030803180328033803480358036803780388039804080418042804380448045804680478048804980508051805280538054805580568057805880598060806180628063806480658066806780688069807080718072807380748075807680778078807980808081808280838084808580868087808880898090809180928093809480958096809780988099810081018102810381048105810681078108810981108111811281138114811581168117811881198120812181228123812481258126812781288129813081318132813381348135813681378138813981408141814281438144814581468147814881498150815181528153815481558156815781588159816081618162816381648165816681678168816981708171817281738174817581768177817881798180818181828183818481858186818781888189819081918192819381948195819681978198819982008201820282038204820582068207820882098210821182128213821482158216821782188219822082218222822382248225822682278228822982308231823282338234823582368237823882398240824182428243824482458246824782488249825082518252825382548255825682578258825982608261826282638264826582668267826882698270827182728273827482758276827782788279828082818282828382848285828682878288828982908291829282938294829582968297829882998300830183028303830483058306830783088309831083118312831383148315831683178318831983208321832283238324832583268327832883298330833183328333833483358336833783388339834083418342834383448345834683478348834983508351835283538354835583568357835883598360836183628363836483658366836783688369837083718372837383748375837683778378837983808381838283838384838583868387838883898390839183928393839483958396839783988399840084018402840384048405840684078408840984108411841284138414841584168417841884198420842184228423842484258426842784288429843084318432843384348435843684378438843984408441844284438444844584468447844884498450845184528453845484558456845784588459846084618462846384648465846684678468846984708471847284738474847584768477847884798480848184828483848484858486848784888489849084918492849384948495849684978498849985008501850285038504850585068507850885098510851185128513851485158516851785188519852085218522852385248525852685278528852985308531853285338534853585368537853885398540854185428543854485458546854785488549855085518552855385548555855685578558855985608561856285638564856585668567856885698570857185728573857485758576857785788579858085818582858385848585858685878588858985908591859285938594859585968597859885998600860186028603860486058606860786088609861086118612861386148615861686178618861986208621862286238624862586268627862886298630863186328633863486358636863786388639864086418642864386448645864686478648864986508651865286538654865586568657865886598660866186628663866486658666866786688669867086718672867386748675867686778678867986808681868286838684868586868687868886898690869186928693869486958696869786988699870087018702870387048705870687078708870987108711871287138714871587168717871887198720872187228723872487258726872787288729873087318732873387348735873687378738873987408741874287438744874587468747874887498750875187528753875487558756875787588759876087618762876387648765876687678768876987708771877287738774877587768777877887798780878187828783878487858786878787888789879087918792879387948795879687978798879988008801880288038804880588068807880888098810881188128813881488158816881788188819882088218822882388248825882688278828882988308831883288338834883588368837883888398840884188428843884488458846884788488849885088518852885388548855885688578858885988608861886288638864886588668867886888698870887188728873887488758876887788788879888088818882888388848885888688878888888988908891889288938894889588968897889888998900890189028903890489058906890789088909891089118912891389148915891689178918891989208921892289238924892589268927892889298930893189328933893489358936893789388939894089418942894389448945894689478948894989508951895289538954895589568957895889598960896189628963896489658966896789688969897089718972897389748975897689778978897989808981898289838984898589868987898889898990899189928993899489958996899789988999900090019002900390049005900690079008900990109011901290139014901590169017901890199020902190229023902490259026902790289029903090319032903390349035903690379038903990409041904290439044904590469047904890499050905190529053905490559056905790589059906090619062906390649065906690679068906990709071907290739074907590769077907890799080908190829083908490859086908790889089909090919092909390949095909690979098909991009101910291039104910591069107910891099110911191129113911491159116911791189119912091219122912391249125912691279128912991309131913291339134913591369137913891399140914191429143914491459146914791489149915091519152915391549155915691579158915991609161916291639164916591669167916891699170917191729173917491759176917791789179918091819182918391849185918691879188918991909191919291939194919591969197919891999200920192029203920492059206920792089209921092119212921392149215921692179218921992209221922292239224922592269227922892299230923192329233923492359236923792389239924092419242924392449245924692479248924992509251925292539254925592569257925892599260926192629263926492659266926792689269927092719272927392749275927692779278927992809281928292839284928592869287928892899290929192929293929492959296929792989299930093019302930393049305930693079308930993109311931293139314931593169317931893199320932193229323932493259326932793289329933093319332933393349335933693379338933993409341934293439344934593469347934893499350935193529353935493559356935793589359936093619362936393649365936693679368936993709371937293739374937593769377937893799380938193829383938493859386938793889389939093919392939393949395939693979398939994009401940294039404940594069407940894099410941194129413941494159416941794189419942094219422942394249425942694279428942994309431943294339434943594369437943894399440944194429443944494459446944794489449945094519452945394549455945694579458945994609461946294639464946594669467946894699470947194729473947494759476947794789479948094819482948394849485948694879488948994909491949294939494949594969497949894999500950195029503950495059506950795089509951095119512951395149515951695179518951995209521952295239524952595269527952895299530953195329533953495359536953795389539954095419542954395449545954695479548954995509551955295539554955595569557955895599560956195629563956495659566956795689569957095719572957395749575957695779578957995809581958295839584958595869587958895899590959195929593959495959596959795989599960096019602960396049605960696079608960996109611961296139614961596169617961896199620962196229623962496259626962796289629963096319632963396349635963696379638963996409641964296439644964596469647964896499650965196529653965496559656965796589659966096619662966396649665966696679668966996709671967296739674967596769677967896799680968196829683968496859686968796889689969096919692969396949695969696979698969997009701970297039704970597069707970897099710971197129713971497159716971797189719972097219722972397249725972697279728972997309731973297339734973597369737973897399740974197429743974497459746974797489749975097519752975397549755975697579758975997609761976297639764976597669767976897699770977197729773977497759776977797789779978097819782978397849785978697879788978997909791979297939794979597969797979897999800980198029803980498059806980798089809981098119812981398149815981698179818981998209821982298239824982598269827982898299830983198329833983498359836983798389839984098419842984398449845984698479848984998509851985298539854985598569857985898599860986198629863986498659866986798689869987098719872987398749875987698779878987998809881988298839884988598869887988898899890989198929893989498959896989798989899990099019902990399049905990699079908990999109911991299139914991599169917991899199920992199229923992499259926992799289929993099319932993399349935993699379938993999409941994299439944994599469947994899499950995199529953995499559956995799589959996099619962996399649965996699679968996999709971997299739974997599769977997899799980998199829983998499859986998799889989999099919992999399949995999699979998999910000100011000210003100041000510006100071000810009100101001110012100131001410015100161001710018100191002010021100221002310024100251002610027100281002910030100311003210033100341003510036100371003810039100401004110042100431004410045100461004710048100491005010051100521005310054100551005610057100581005910060100611006210063100641006510066100671006810069100701007110072100731007410075100761007710078100791008010081100821008310084100851008610087100881008910090100911009210093100941009510096100971009810099101001010110102101031010410105101061010710108101091011010111101121011310114101151011610117101181011910120101211012210123101241012510126101271012810129101301013110132101331013410135101361013710138101391014010141101421014310144101451014610147101481014910150101511015210153101541015510156101571015810159101601016110162101631016410165101661016710168101691017010171101721017310174101751017610177101781017910180101811018210183101841018510186101871018810189101901019110192101931019410195101961019710198101991020010201102021020310204102051020610207102081020910210102111021210213102141021510216102171021810219102201022110222102231022410225102261022710228102291023010231102321023310234102351023610237102381023910240102411024210243102441024510246102471024810249102501025110252102531025410255102561025710258102591026010261102621026310264102651026610267102681026910270102711027210273102741027510276102771027810279102801028110282102831028410285102861028710288102891029010291102921029310294102951029610297102981029910300103011030210303103041030510306103071030810309103101031110312103131031410315103161031710318103191032010321103221032310324103251032610327103281032910330103311033210333103341033510336103371033810339103401034110342103431034410345103461034710348103491035010351103521035310354103551035610357103581035910360103611036210363103641036510366103671036810369103701037110372103731037410375103761037710378103791038010381103821038310384103851038610387103881038910390103911039210393103941039510396103971039810399104001040110402104031040410405104061040710408104091041010411104121041310414104151041610417104181041910420104211042210423104241042510426104271042810429104301043110432104331043410435104361043710438104391044010441104421044310444104451044610447104481044910450104511045210453104541045510456104571045810459104601046110462104631046410465104661046710468104691047010471104721047310474104751047610477104781047910480104811048210483104841048510486104871048810489104901049110492104931049410495104961049710498104991050010501105021050310504105051050610507105081050910510105111051210513105141051510516105171051810519105201052110522105231052410525105261052710528105291053010531105321053310534105351053610537105381053910540105411054210543105441054510546105471054810549105501055110552105531055410555105561055710558105591056010561105621056310564105651056610567105681056910570105711057210573105741057510576105771057810579105801058110582105831058410585105861058710588105891059010591105921059310594105951059610597105981059910600106011060210603106041060510606106071060810609106101061110612106131061410615106161061710618106191062010621106221062310624106251062610627106281062910630106311063210633106341063510636106371063810639106401064110642106431064410645106461064710648106491065010651106521065310654106551065610657106581065910660106611066210663106641066510666106671066810669106701067110672106731067410675106761067710678106791068010681106821068310684106851068610687106881068910690106911069210693106941069510696106971069810699107001070110702107031070410705107061070710708107091071010711107121071310714107151071610717107181071910720107211072210723107241072510726107271072810729107301073110732107331073410735107361073710738107391074010741107421074310744107451074610747107481074910750107511075210753107541075510756107571075810759107601076110762107631076410765107661076710768107691077010771107721077310774107751077610777107781077910780107811078210783107841078510786107871078810789107901079110792107931079410795107961079710798107991080010801108021080310804108051080610807108081080910810108111081210813108141081510816108171081810819108201082110822108231082410825108261082710828108291083010831108321083310834108351083610837108381083910840108411084210843108441084510846108471084810849108501085110852108531085410855108561085710858108591086010861108621086310864108651086610867108681086910870108711087210873108741087510876108771087810879108801088110882108831088410885108861088710888108891089010891108921089310894108951089610897108981089910900109011090210903109041090510906109071090810909109101091110912109131091410915109161091710918109191092010921109221092310924109251092610927109281092910930109311093210933109341093510936109371093810939109401094110942109431094410945109461094710948109491095010951109521095310954109551095610957109581095910960109611096210963109641096510966109671096810969109701097110972109731097410975109761097710978109791098010981109821098310984109851098610987109881098910990109911099210993109941099510996109971099810999110001100111002110031100411005110061100711008110091101011011110121101311014110151101611017110181101911020110211102211023110241102511026110271102811029110301103111032110331103411035110361103711038110391104011041110421104311044110451104611047110481104911050110511105211053110541105511056110571105811059110601106111062110631106411065110661106711068110691107011071110721107311074110751107611077110781107911080110811108211083110841108511086110871108811089110901109111092110931109411095110961109711098110991110011101111021110311104111051110611107111081110911110111111111211113111141111511116111171111811119111201112111122111231112411125111261112711128111291113011131111321113311134111351113611137111381113911140111411114211143111441114511146111471114811149111501115111152111531115411155111561115711158111591116011161111621116311164111651116611167111681116911170111711117211173111741117511176111771117811179111801118111182111831118411185111861118711188111891119011191111921119311194111951119611197111981119911200112011120211203112041120511206112071120811209112101121111212112131121411215112161121711218112191122011221112221122311224112251122611227112281122911230112311123211233112341123511236112371123811239112401124111242112431124411245112461124711248112491125011251112521125311254112551125611257112581125911260112611126211263112641126511266112671126811269112701127111272112731127411275112761127711278112791128011281112821128311284112851128611287112881128911290112911129211293112941129511296112971129811299113001130111302113031130411305113061130711308113091131011311113121131311314113151131611317113181131911320113211132211323113241132511326113271132811329113301133111332113331133411335113361133711338113391134011341113421134311344113451134611347113481134911350113511135211353113541135511356113571135811359113601136111362113631136411365113661136711368113691137011371113721137311374113751137611377113781137911380113811138211383113841138511386113871138811389113901139111392113931139411395113961139711398113991140011401114021140311404114051140611407114081140911410114111141211413114141141511416114171141811419114201142111422114231142411425114261142711428114291143011431114321143311434114351143611437114381143911440114411144211443114441144511446114471144811449114501145111452114531145411455114561145711458114591146011461114621146311464114651146611467114681146911470114711147211473114741147511476114771147811479114801148111482
  1. package sg
  2. import (
  3. "archive/zip"
  4. "bytes"
  5. "encoding/json"
  6. "fmt"
  7. "gdyb/controllers"
  8. "gdyb/enums"
  9. "gdyb/models"
  10. "gdyb/service"
  11. "gdyb/utils"
  12. "github.com/astaxie/beego"
  13. "github.com/axgle/mahonia"
  14. "github.com/jinzhu/gorm"
  15. "github.com/shopspring/decimal"
  16. "io"
  17. "io/ioutil"
  18. "math/rand"
  19. "net/http"
  20. "os"
  21. "path/filepath"
  22. "strconv"
  23. "strings"
  24. "syscall"
  25. "time"
  26. "unsafe"
  27. )
  28. type HisApiController struct {
  29. controllers.BaseAuthAPIController
  30. }
  31. func HisManagerApiRegistRouters() {
  32. //挂号
  33. beego.Router("/api/register/get", &HisApiController{}, "get:GetRegisterInfo")
  34. //上传就诊信息-上传明细-结算
  35. beego.Router("/api/upload/get", &HisApiController{}, "get:GetUploadInfo")
  36. //查询
  37. beego.Router("/api/settle/query", &HisApiController{}, "get:GetSettleAccounts")
  38. //对总账
  39. beego.Router("/api/checkaccount/get", &HisApiController{}, "get:GetCheckAccount")
  40. //对明细
  41. beego.Router("/api/checkdetailaccount/get", &HisApiController{}, "get:GetCheckDetailAccount")
  42. //退费,退明细
  43. beego.Router("/api/refund/post", &HisApiController{}, "get:Refund")
  44. //退号
  45. beego.Router("/api/refundnumber/post", &HisApiController{}, "get:RefundNumber")
  46. //退明细
  47. beego.Router("/api/refunddetail/post", &HisApiController{}, "get:RefundDetail")
  48. beego.Router("/api/treatment/check", &HisApiController{}, "get:CheckTreatment")
  49. beego.Router("/api/org/info", &HisApiController{}, "get:GetOrgInfo")
  50. beego.Router("/api/readcard", &HisApiController{}, "get:ReadCard")
  51. beego.Router("/api/presettle/get", &HisApiController{}, "get:GetPreUploadInfo")
  52. beego.Router("/api/310", &HisApiController{}, "get:Check310")
  53. beego.Router("/api/390", &HisApiController{}, "get:Check390")
  54. beego.Router("/api/patient/info", &HisApiController{}, "get:GetPatientInfo")
  55. beego.Router("/api/checkcode/get", &HisApiController{}, "get:GetCheckCode")
  56. beego.Router("/api/uncheckcode/get", &HisApiController{}, "get:UnCheckCode")
  57. beego.Router("/api/psn/putonrecord", &HisApiController{}, "get:PsnPutOnRecord")
  58. beego.Router("/api/psn/unputonrecord", &HisApiController{}, "get:PsnUnPutOnRecord")
  59. beego.Router("/api/psn/ncds/putonrecord", &HisApiController{}, "get:PsnPutNCDSOnRecord")
  60. beego.Router("/api/psn/ncds/unputonrecord", &HisApiController{}, "get:PsnPutUnNCDSOnRecord")
  61. beego.Router("/api/reversal", &HisApiController{}, "get:ReversalData")
  62. beego.Router("/api/reversal/other", &HisApiController{}, "get:ReversalOtherData")
  63. beego.Router("/api/settlelist/get", &HisApiController{}, "get:GetSettleList")
  64. beego.Router("/api/settlelisthosptial/get", &HisApiController{}, "get:GetSettleListHospital")
  65. beego.Router("/api/pwd/check", &HisApiController{}, "get:CheckCardPWD")
  66. beego.Router("/api/insutype/check", &HisApiController{}, "get:CheckInsutype")
  67. beego.Router("/api/batchsettlelist/get", &HisApiController{}, "get:GetBatchSettleList")
  68. beego.Router("/api/psn/info", &HisApiController{}, "get:GetPsnNcdsInfo")
  69. beego.Router("/api/allopatry/get", &HisApiController{}, "get:GetAllopatry")
  70. beego.Router("/api/comfirmallopatry/post", &HisApiController{}, "post:ComfirmAllopatry")
  71. beego.Router("/api/allopatry/refund", &HisApiController{}, "post:RefundAllopatry")
  72. beego.Router("/api/check", &HisApiController{}, "get:Check")
  73. beego.Router("/api/check3101", &HisApiController{}, "get:Check3101")
  74. beego.Router("/api/check3102", &HisApiController{}, "get:Check3102")
  75. }
  76. func (c *HisApiController) Check3101() {
  77. patient_id, _ := c.GetInt64("patient_id")
  78. his_patient_id, _ := c.GetInt64("his_patient_id")
  79. admin_user_id, _ := c.GetInt64("admin_user_id")
  80. adminUser := c.GetAdminUserInfo()
  81. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  82. his, _ := service.GetNewHisPatientInfoFour(c.GetAdminUserInfo().CurrentOrgId, his_patient_id)
  83. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  84. record_time := c.GetString("record_time")
  85. trig_scen := "1"
  86. timeLayout := "2006-01-02"
  87. loc, _ := time.LoadLocation("Local")
  88. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  89. if err != nil {
  90. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  91. return
  92. }
  93. recordDateTime := theTime.Unix()
  94. var patientPrescription models.HisPrescriptionInfo
  95. patientPrescription, _ = service.FindHisPatientPrescriptionInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  96. if patientPrescription.ID == 0 {
  97. patientPrescription, _ = service.FindLastPatientPrescriptionInfo(adminUser.CurrentOrgId, patient_id, recordDateTime)
  98. }
  99. department, _ := service.GetDepartMentDetail(patientPrescription.Departments)
  100. doctor_info, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, patientPrescription.DoctorId)
  101. //
  102. diagnosis_ids := strings.Split(patientPrescription.Diagnosis, ",")
  103. prescriptions, _ := service.GetNewHisPrescriptionTen(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  104. var pp models.PublicParams
  105. pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  106. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  107. pp.FixmedinsName = miConfig.OrgName
  108. pp.RequestUrl = miConfig.Url
  109. pp.Cainfo = miConfig.Cainfo
  110. pp.SecretKey = miConfig.SecretKey
  111. pp.AccessKey = miConfig.AccessKey
  112. pp.OpterName = roles.UserName
  113. var config []*models.HisXtDiagnoseConfig
  114. for _, item := range diagnosis_ids {
  115. id, _ := strconv.ParseInt(item, 10, 64)
  116. diagnosisConfig, _ := service.FindDiagnoseById(id)
  117. config = append(config, &diagnosisConfig)
  118. }
  119. var pd models.PatientDtos
  120. pd.PatnID = his.PsnNo
  121. pd.PatnName = his.Name
  122. pd.Gend = his.Gend
  123. pd.Brdy = his.Brdy
  124. pd.Poolarea = his.InsuplcAdmdvs
  125. pd.CurrMdtrtID = his.Number
  126. var fed models.FsiEncounterDtos
  127. fed.MdtrtID = his.Number
  128. fed.MedinsID = miConfig.Code
  129. fed.MedinsName = miConfig.OrgName
  130. fed.MedinsAdmdvs = miConfig.MdtrtareaAdmvs
  131. fed.MedMdtrtType = "1"
  132. fed.MedinsLv = "11"
  133. tm := time.Unix(his.RecordDate, 0)
  134. s_tm := tm.Format("2006-01-02 15:04:05")
  135. fed.AdmDate = s_tm
  136. fed.DscgDate = s_tm
  137. fed.DscgMainDiseCodg = config[0].CountryCode
  138. fed.DscgMainDiseName = config[0].CountryContentName
  139. //诊断信息
  140. var fdds []*models.FsiDiagnoseDtos
  141. for index, item := range config {
  142. if index == 0 {
  143. var fdd *models.FsiDiagnoseDtos
  144. fdd.DiseID = strconv.FormatInt(item.ID, 10)
  145. fdd.InoutDiseType = "1"
  146. fdd.MaindiseFlag = "1"
  147. fdd.DiseDate = s_tm
  148. fdd.DiasSrtNo = "1"
  149. fdd.DiseName = item.CountryContentName
  150. fdd.DiseCodg = item.CountryCode
  151. fdds = append(fdds, fdd)
  152. } else {
  153. var fdd *models.FsiDiagnoseDtos
  154. fdd.DiseID = strconv.FormatInt(item.ID, 10)
  155. fdd.InoutDiseType = "1"
  156. fdd.MaindiseFlag = "1"
  157. fdd.DiseDate = s_tm
  158. fdd.DiasSrtNo = strconv.FormatInt(int64(index), 10)
  159. fdd.DiseName = item.CountryContentName
  160. fdd.DiseCodg = item.CountryCode
  161. fdds = append(fdds, fdd)
  162. }
  163. }
  164. fed.DrCodg = strconv.FormatInt(doctor_info.ID, 10)
  165. fed.AdmDeptCodg = strconv.FormatInt(department.ID, 10)
  166. fed.AdmDeptName = department.Name
  167. fed.DscgDeptCodg = strconv.FormatInt(department.ID, 10)
  168. fed.DscgDeptName = department.Name
  169. fed.MedMdtrtType = ""
  170. if his.Insutype == "390" {
  171. fed.MedType = "1402"
  172. } else {
  173. fed.MedType = "9933"
  174. }
  175. if trig_scen == "2" {
  176. //处方医嘱信息
  177. var orders []*models.FsiOrderDtos
  178. for _, item := range prescriptions {
  179. for _, subItem := range item.HisDoctorAdviceInfo {
  180. var order models.FsiOrderDtos
  181. order.RxID = strconv.FormatInt(item.ID, 10)
  182. order.Rxno = strconv.FormatInt(item.ID, 10)
  183. order.LongDrordFlag = "0"
  184. order.HilistType = "1"
  185. order.ChrgType = "1"
  186. order.DrordBhvr = "-"
  187. order.HilistCode = subItem.BaseDrugLib.MedicalInsuranceNumber
  188. order.HosplistName = subItem.BaseDrugLib.DrugName
  189. order.HilistLv = "1"
  190. order.HilistPric = strconv.FormatFloat(subItem.Price, 'E', -1, 64)
  191. order.HosplistCode = subItem.BaseDrugLib.MedicalInsuranceNumber
  192. order.HosplistName = subItem.BaseDrugLib.DrugName
  193. order.Cnt = strconv.FormatFloat(subItem.PrescribingNumber, 'E', -1, 64)
  194. order.Pric = strconv.FormatFloat(subItem.Price, 'E', -1, 64)
  195. order.Sumamt = strconv.FormatFloat((subItem.Price * subItem.PrescribingNumber), 'E', -1, 64)
  196. order.OwnpayAmt = ""
  197. order.SelfpayAmt = ""
  198. order.Spec = ""
  199. order.SpecUnt = ""
  200. order.DrordBegnDate = s_tm
  201. order.DrordStopDate = ""
  202. order.DrordDrCodg = "1"
  203. order.DrordDeptName = department.Name
  204. order.DrordDrCodg = "1"
  205. order.DrordDrName = doctor_info.UserName
  206. order.DrordDrProfttl = ""
  207. order.CurrDrordFlag = "1"
  208. orders = append(orders, &order)
  209. }
  210. for _, subItem := range item.HisPrescriptionProject {
  211. if subItem.Type == 2 {
  212. var order models.FsiOrderDtos
  213. order.RxID = strconv.FormatInt(item.ID, 10)
  214. order.Rxno = strconv.FormatInt(item.ID, 10)
  215. order.LongDrordFlag = "0"
  216. order.HilistType = "1"
  217. order.ChrgType = "1"
  218. order.DrordBhvr = "-"
  219. order.HilistCode = subItem.HisProject.MedicalCode
  220. order.HosplistName = subItem.HisProject.ProjectName
  221. order.HilistLv = "1"
  222. order.HilistPric = strconv.FormatFloat(subItem.Price, 'E', -1, 64)
  223. order.HosplistCode = subItem.HisProject.MedicalCode
  224. order.HosplistName = subItem.HisProject.ProjectName
  225. order.Cnt = subItem.Count
  226. cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  227. order.Pric = strconv.FormatFloat(subItem.Price, 'E', -1, 64)
  228. order.Sumamt = strconv.FormatFloat((subItem.Price * cnt), 'E', -1, 64)
  229. order.OwnpayAmt = ""
  230. order.SelfpayAmt = ""
  231. order.Spec = ""
  232. order.SpecUnt = ""
  233. order.DrordBegnDate = s_tm
  234. order.DrordStopDate = ""
  235. order.DrordDrCodg = "1"
  236. order.DrordDeptName = department.Name
  237. order.DrordDrCodg = "1"
  238. order.DrordDrName = doctor_info.UserName
  239. order.DrordDrProfttl = ""
  240. order.CurrDrordFlag = "1"
  241. orders = append(orders, &order)
  242. }
  243. if subItem.Type == 3 {
  244. var order models.FsiOrderDtos
  245. order.RxID = strconv.FormatInt(item.ID, 10)
  246. order.Rxno = strconv.FormatInt(item.ID, 10)
  247. order.LongDrordFlag = "0"
  248. order.HilistType = "1"
  249. order.ChrgType = "1"
  250. order.DrordBhvr = "-"
  251. order.HilistCode = subItem.GoodInfo.MedicalInsuranceNumber
  252. order.HosplistName = subItem.GoodInfo.GoodName
  253. order.HilistLv = "1"
  254. order.HilistPric = strconv.FormatFloat(subItem.Price, 'E', -1, 64)
  255. order.HosplistCode = subItem.GoodInfo.MedicalInsuranceNumber
  256. order.HosplistName = subItem.GoodInfo.GoodName
  257. order.Cnt = subItem.Count
  258. cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  259. order.Pric = strconv.FormatFloat(subItem.Price, 'E', -1, 64)
  260. order.Sumamt = strconv.FormatFloat((subItem.Price * cnt), 'E', -1, 64)
  261. order.OwnpayAmt = ""
  262. order.SelfpayAmt = ""
  263. order.Spec = ""
  264. order.SpecUnt = ""
  265. order.DrordBegnDate = s_tm
  266. order.DrordStopDate = ""
  267. order.DrordDrCodg = "1"
  268. order.DrordDeptName = department.Name
  269. order.DrordDrCodg = "1"
  270. order.DrordDrName = doctor_info.UserName
  271. order.DrordDrProfttl = ""
  272. order.CurrDrordFlag = "1"
  273. orders = append(orders, &order)
  274. }
  275. }
  276. }
  277. //处方医嘱信息
  278. }
  279. fed.MatnStas = "0"
  280. fed.MedfeeSumamt = "0"
  281. fed.OwnpayAmt = "0"
  282. fed.SelfpayAmt = "0"
  283. fed.AcctPayamt = "0"
  284. fed.MaAmt = "0"
  285. fed.HifpPayamt = "0"
  286. fed.SetlTotlnum = "0"
  287. fed.Insutype = his.Insutype
  288. fed.ReimFlag = "0"
  289. fed.OutSetlFlag = "0"
  290. //手术操作集合
  291. //手术操作集合
  292. }
  293. func (c *HisApiController) Check3102() {
  294. patient_id, _ := c.GetInt64("patient_id")
  295. his_patient_id, _ := c.GetInt64("his_patient_id")
  296. admin_user_id, _ := c.GetInt64("admin_user_id")
  297. adminUser := c.GetAdminUserInfo()
  298. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  299. his, _ := service.GetNewHisPatientInfoFour(c.GetAdminUserInfo().CurrentOrgId, his_patient_id)
  300. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  301. record_time := c.GetString("record_time")
  302. trig_scen := "1"
  303. timeLayout := "2006-01-02"
  304. loc, _ := time.LoadLocation("Local")
  305. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  306. if err != nil {
  307. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  308. return
  309. }
  310. recordDateTime := theTime.Unix()
  311. var patientPrescription models.HisPrescriptionInfo
  312. patientPrescription, _ = service.FindHisPatientPrescriptionInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  313. if patientPrescription.ID == 0 {
  314. patientPrescription, _ = service.FindLastPatientPrescriptionInfo(adminUser.CurrentOrgId, patient_id, recordDateTime)
  315. }
  316. department, _ := service.GetDepartMentDetail(patientPrescription.Departments)
  317. doctor_info, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, patientPrescription.DoctorId)
  318. //
  319. diagnosis_ids := strings.Split(patientPrescription.Diagnosis, ",")
  320. prescriptions, _ := service.GetNewHisPrescriptionTen(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  321. var pp models.PublicParams
  322. pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  323. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  324. pp.FixmedinsName = miConfig.OrgName
  325. pp.RequestUrl = miConfig.Url
  326. pp.Cainfo = miConfig.Cainfo
  327. pp.SecretKey = miConfig.SecretKey
  328. pp.AccessKey = miConfig.AccessKey
  329. pp.OpterName = roles.UserName
  330. var config []*models.HisXtDiagnoseConfig
  331. for _, item := range diagnosis_ids {
  332. id, _ := strconv.ParseInt(item, 10, 64)
  333. diagnosisConfig, _ := service.FindDiagnoseById(id)
  334. config = append(config, &diagnosisConfig)
  335. }
  336. var pd models.PatientDtos
  337. pd.PatnID = his.PsnNo
  338. pd.PatnName = his.Name
  339. pd.Gend = his.Gend
  340. pd.Brdy = his.Brdy
  341. pd.Poolarea = his.InsuplcAdmdvs
  342. pd.CurrMdtrtID = his.Number
  343. var fed models.FsiEncounterDtos
  344. fed.MdtrtID = his.Number
  345. fed.MedinsID = miConfig.Code
  346. fed.MedinsName = miConfig.OrgName
  347. fed.MedinsAdmdvs = miConfig.MdtrtareaAdmvs
  348. fed.MedMdtrtType = "1"
  349. fed.MedinsLv = "11"
  350. tm := time.Unix(his.RecordDate, 0)
  351. s_tm := tm.Format("2006-01-02 15:04:05")
  352. fed.AdmDate = s_tm
  353. fed.DscgDate = s_tm
  354. fed.DscgMainDiseCodg = config[0].CountryCode
  355. fed.DscgMainDiseName = config[0].CountryContentName
  356. //诊断信息
  357. var fdds []*models.FsiDiagnoseDtos
  358. for index, item := range config {
  359. if index == 0 {
  360. var fdd *models.FsiDiagnoseDtos
  361. fdd.DiseID = strconv.FormatInt(item.ID, 10)
  362. fdd.InoutDiseType = "1"
  363. fdd.MaindiseFlag = "1"
  364. fdd.DiseDate = s_tm
  365. fdd.DiasSrtNo = "1"
  366. fdd.DiseName = item.CountryContentName
  367. fdd.DiseCodg = item.CountryCode
  368. fdds = append(fdds, fdd)
  369. } else {
  370. var fdd *models.FsiDiagnoseDtos
  371. fdd.DiseID = strconv.FormatInt(item.ID, 10)
  372. fdd.InoutDiseType = "1"
  373. fdd.MaindiseFlag = "1"
  374. fdd.DiseDate = s_tm
  375. fdd.DiasSrtNo = strconv.FormatInt(int64(index), 10)
  376. fdd.DiseName = item.CountryContentName
  377. fdd.DiseCodg = item.CountryCode
  378. fdds = append(fdds, fdd)
  379. }
  380. }
  381. fed.DrCodg = strconv.FormatInt(doctor_info.ID, 10)
  382. fed.AdmDeptCodg = strconv.FormatInt(department.ID, 10)
  383. fed.AdmDeptName = department.Name
  384. fed.DscgDeptCodg = strconv.FormatInt(department.ID, 10)
  385. fed.DscgDeptName = department.Name
  386. fed.MedMdtrtType = ""
  387. if his.Insutype == "390" {
  388. fed.MedType = "1402"
  389. } else {
  390. fed.MedType = "9933"
  391. }
  392. if trig_scen == "2" {
  393. //处方医嘱信息
  394. var orders []*models.FsiOrderDtos
  395. for _, item := range prescriptions {
  396. for _, subItem := range item.HisDoctorAdviceInfo {
  397. var order models.FsiOrderDtos
  398. order.RxID = strconv.FormatInt(item.ID, 10)
  399. order.Rxno = strconv.FormatInt(item.ID, 10)
  400. order.LongDrordFlag = "0"
  401. order.HilistType = "1"
  402. order.ChrgType = "1"
  403. order.DrordBhvr = "-"
  404. order.HilistCode = subItem.BaseDrugLib.MedicalInsuranceNumber
  405. order.HosplistName = subItem.BaseDrugLib.DrugName
  406. order.HilistLv = "1"
  407. order.HilistPric = strconv.FormatFloat(subItem.Price, 'E', -1, 64)
  408. order.HosplistCode = subItem.BaseDrugLib.MedicalInsuranceNumber
  409. order.HosplistName = subItem.BaseDrugLib.DrugName
  410. order.Cnt = strconv.FormatFloat(subItem.PrescribingNumber, 'E', -1, 64)
  411. order.Pric = strconv.FormatFloat(subItem.Price, 'E', -1, 64)
  412. order.Sumamt = strconv.FormatFloat((subItem.Price * subItem.PrescribingNumber), 'E', -1, 64)
  413. order.OwnpayAmt = ""
  414. order.SelfpayAmt = ""
  415. order.Spec = ""
  416. order.SpecUnt = ""
  417. order.DrordBegnDate = s_tm
  418. order.DrordStopDate = ""
  419. order.DrordDrCodg = "1"
  420. order.DrordDeptName = department.Name
  421. order.DrordDrCodg = "1"
  422. order.DrordDrName = doctor_info.UserName
  423. order.DrordDrProfttl = ""
  424. order.CurrDrordFlag = "1"
  425. orders = append(orders, &order)
  426. }
  427. for _, subItem := range item.HisPrescriptionProject {
  428. if subItem.Type == 2 {
  429. var order models.FsiOrderDtos
  430. order.RxID = strconv.FormatInt(item.ID, 10)
  431. order.Rxno = strconv.FormatInt(item.ID, 10)
  432. order.LongDrordFlag = "0"
  433. order.HilistType = "1"
  434. order.ChrgType = "1"
  435. order.DrordBhvr = "-"
  436. order.HilistCode = subItem.HisProject.MedicalCode
  437. order.HosplistName = subItem.HisProject.ProjectName
  438. order.HilistLv = "1"
  439. order.HilistPric = strconv.FormatFloat(subItem.Price, 'E', -1, 64)
  440. order.HosplistCode = subItem.HisProject.MedicalCode
  441. order.HosplistName = subItem.HisProject.ProjectName
  442. order.Cnt = subItem.Count
  443. cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  444. order.Pric = strconv.FormatFloat(subItem.Price, 'E', -1, 64)
  445. order.Sumamt = strconv.FormatFloat((subItem.Price * cnt), 'E', -1, 64)
  446. order.OwnpayAmt = ""
  447. order.SelfpayAmt = ""
  448. order.Spec = ""
  449. order.SpecUnt = ""
  450. order.DrordBegnDate = s_tm
  451. order.DrordStopDate = ""
  452. order.DrordDrCodg = "1"
  453. order.DrordDeptName = department.Name
  454. order.DrordDrCodg = "1"
  455. order.DrordDrName = doctor_info.UserName
  456. order.DrordDrProfttl = ""
  457. order.CurrDrordFlag = "1"
  458. orders = append(orders, &order)
  459. }
  460. if subItem.Type == 3 {
  461. var order models.FsiOrderDtos
  462. order.RxID = strconv.FormatInt(item.ID, 10)
  463. order.Rxno = strconv.FormatInt(item.ID, 10)
  464. order.LongDrordFlag = "0"
  465. order.HilistType = "1"
  466. order.ChrgType = "1"
  467. order.DrordBhvr = "-"
  468. order.HilistCode = subItem.GoodInfo.MedicalInsuranceNumber
  469. order.HosplistName = subItem.GoodInfo.GoodName
  470. order.HilistLv = "1"
  471. order.HilistPric = strconv.FormatFloat(subItem.Price, 'E', -1, 64)
  472. order.HosplistCode = subItem.GoodInfo.MedicalInsuranceNumber
  473. order.HosplistName = subItem.GoodInfo.GoodName
  474. order.Cnt = subItem.Count
  475. cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  476. order.Pric = strconv.FormatFloat(subItem.Price, 'E', -1, 64)
  477. order.Sumamt = strconv.FormatFloat((subItem.Price * cnt), 'E', -1, 64)
  478. order.OwnpayAmt = ""
  479. order.SelfpayAmt = ""
  480. order.Spec = ""
  481. order.SpecUnt = ""
  482. order.DrordBegnDate = s_tm
  483. order.DrordStopDate = ""
  484. order.DrordDrCodg = "1"
  485. order.DrordDeptName = department.Name
  486. order.DrordDrCodg = "1"
  487. order.DrordDrName = doctor_info.UserName
  488. order.DrordDrProfttl = ""
  489. order.CurrDrordFlag = "1"
  490. orders = append(orders, &order)
  491. }
  492. }
  493. }
  494. //处方医嘱信息
  495. }
  496. fed.MatnStas = "0"
  497. fed.MedfeeSumamt = "0"
  498. fed.OwnpayAmt = "0"
  499. fed.SelfpayAmt = "0"
  500. fed.AcctPayamt = "0"
  501. fed.MaAmt = "0"
  502. fed.HifpPayamt = "0"
  503. fed.SetlTotlnum = "0"
  504. fed.Insutype = his.Insutype
  505. fed.ReimFlag = "0"
  506. fed.OutSetlFlag = "0"
  507. //手术操作集合
  508. //手术操作集合
  509. }
  510. func (c *HisApiController) Check() {
  511. psn_no := c.GetString("psn_no")
  512. in := c.GetString("in")
  513. mt := c.GetString("mt")
  514. baseParams := models.BaseParams{
  515. SecretKey: "MSDBYGxXm1Mtyi3PtOUB7n1ktcxwyW57",
  516. FixmedinsCode: "H15049901371",
  517. InsuplcAdmdvs: "150499",
  518. MdtrtareaAdmvs: "150499",
  519. OrgName: "赤峰费森血液透析中心",
  520. Doctor: "1111",
  521. }
  522. service.Gdyb2001(baseParams, psn_no, in, mt)
  523. }
  524. func (c *HisApiController) GetPsnNcdsInfo() {
  525. admin_user_id, _ := c.GetInt64("admin_user_id")
  526. patient_id, _ := c.GetInt64("patient_id")
  527. id, _ := c.GetInt64("id")
  528. adminUser := c.GetAdminUserInfo()
  529. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  530. //config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  531. //patient, _ := service.GetPatientByID(c.GetAdminUserInfo().CurrentOrgId, id)
  532. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  533. psn_record, _ := service.GetPsnNCDSRecordById(id)
  534. //
  535. //if psn_record.ID == 0 {
  536. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorPsnRecordNoExistWrong)
  537. // return
  538. //}
  539. var res Result5301
  540. var res10265 Result5301For10265
  541. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  542. psn_info, _ := service.GetPsnByPatientId(patient_id)
  543. var api string
  544. if miConfig.MdtrtareaAdmvs == "320921" {
  545. api = "http://192.168.3.111:9532/" + "jsyb/5301?" + "fixmedins_code=" + miConfig.Code + "&secret_key=" + miConfig.SecretKey + "&ak=" + miConfig.AccessKey + "&org_name=" + miConfig.OrgName + "&doctor=" + role.UserName +
  546. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&psn_no=" + psn_info.PsnNo + "&cainfo=" + miConfig.Cainfo
  547. } else {
  548. 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 +
  549. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&psn_no=" + psn_info.PsnNo + "&cainfo=" + miConfig.Cainfo
  550. }
  551. resp, requestErr := http.Get(api)
  552. if requestErr != nil {
  553. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  554. return
  555. }
  556. body, ioErr := ioutil.ReadAll(resp.Body)
  557. if ioErr != nil {
  558. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  559. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  560. return
  561. }
  562. var respJSON map[string]interface{}
  563. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  564. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  565. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  566. return
  567. }
  568. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  569. result, _ := json.Marshal(respJSON)
  570. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  571. utils.ErrorLog("解析失败:%v", err)
  572. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  573. return
  574. }
  575. res.ErrMsg = res10265.ErrMsg
  576. res.Output = res10265.Output
  577. res.InfRefmsgid = res10265.InfRefmsgid
  578. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  579. res.Infcode = infocode
  580. } else {
  581. result := service.Gdyb5301(psn_record.PsnNo, miConfig.OrgName, role.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey)
  582. var dat map[string]interface{}
  583. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  584. fmt.Println(dat)
  585. } else {
  586. fmt.Println(err)
  587. }
  588. userJSONBytes, _ := json.Marshal(dat)
  589. if miConfig.Code == "H15049901371" {
  590. if err := json.Unmarshal(userJSONBytes, &res10265); err != nil {
  591. utils.ErrorLog("解析失败:%v", err)
  592. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  593. return
  594. }
  595. res.InfRefmsgid = res10265.InfRefmsgid
  596. res.Output = res10265.Output
  597. res.ErrMsg = res10265.ErrMsg
  598. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  599. res.Infcode = infocode
  600. } else {
  601. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  602. utils.ErrorLog("解析失败:%v", err)
  603. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  604. return
  605. }
  606. }
  607. }
  608. if res.Infcode == 0 {
  609. c.ServeSuccessJSON(map[string]interface{}{
  610. "result": res.Output.Result,
  611. })
  612. }
  613. }
  614. func (c *HisApiController) CheckInsutype() {
  615. his_patient_id, _ := c.GetInt64("his_patient_id")
  616. admin_user_id, _ := c.GetInt64("admin_user_id")
  617. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  618. his, _ := service.GetNewHisPatientInfoFour(c.GetAdminUserInfo().CurrentOrgId, his_patient_id)
  619. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  620. result := service.Gdyb90100(his.PsnNo, miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey)
  621. var dat map[string]interface{}
  622. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  623. fmt.Println(dat)
  624. } else {
  625. fmt.Println(err)
  626. }
  627. userJSONBytes, _ := json.Marshal(dat)
  628. var res Result90100
  629. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  630. utils.ErrorLog("解析失败:%v", err)
  631. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  632. return
  633. }
  634. if res.Infcode != 0 {
  635. c.ServeSuccessJSON(map[string]interface{}{
  636. "failed_code": -10,
  637. "msg": res.ErrMsg,
  638. })
  639. return
  640. } else {
  641. fmt.Println(res)
  642. }
  643. }
  644. func (c *HisApiController) CheckCardPWD() {
  645. card_pwd := c.GetString("card_pwd")
  646. his_patient_id, _ := c.GetInt64("his_patient_id")
  647. admin_user_id, _ := c.GetInt64("admin_user_id")
  648. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  649. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  650. his, _ := service.GetNewHisPatientInfoFour(c.GetAdminUserInfo().CurrentOrgId, his_patient_id)
  651. psn, _ := service.GetPsnByPatientId(his.PatientId)
  652. bas := strings.Split(psn.CardInfo, "|")
  653. basNumber := bas[2]
  654. result := service.Gdyb90991(his.PsnNo, miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, card_pwd, basNumber)
  655. var dat map[string]interface{}
  656. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  657. fmt.Println(dat)
  658. } else {
  659. fmt.Println(err)
  660. }
  661. userJSONBytes, _ := json.Marshal(dat)
  662. var res Result90991
  663. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  664. utils.ErrorLog("解析失败:%v", err)
  665. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  666. return
  667. }
  668. if res.Infcode != 0 {
  669. c.ServeSuccessJSON(map[string]interface{}{
  670. "failed_code": -10,
  671. "msg": res.ErrMsg,
  672. })
  673. return
  674. } else {
  675. if res.Output.Result.CheckStat == "0" {
  676. var msg string
  677. switch res.Output.Result.CardStat {
  678. case "00":
  679. msg = "未激活"
  680. break
  681. case "10":
  682. msg = "激活"
  683. break
  684. case "20":
  685. msg = "窗口挂失"
  686. break
  687. case "21":
  688. msg = "电话挂失"
  689. break
  690. case "22":
  691. msg = "单位网上申报挂失"
  692. break
  693. case "23":
  694. msg = "保健办挂失"
  695. break
  696. case "24":
  697. msg = "个人网上挂失"
  698. break
  699. case "25":
  700. msg = "网上服务大厅挂失"
  701. break
  702. case "30":
  703. msg = "注销"
  704. break
  705. case "40":
  706. msg = "回收"
  707. break
  708. case "99":
  709. msg = "制卡中(无效卡)"
  710. break
  711. }
  712. c.ServeSuccessJSON(map[string]interface{}{
  713. "failed_code": -10,
  714. "msg": msg,
  715. })
  716. return
  717. } else {
  718. c.ServeSuccessJSON(map[string]interface{}{
  719. "msg": "校验成功",
  720. })
  721. return
  722. }
  723. }
  724. }
  725. func (c *HisApiController) ReadCard() {
  726. id_card_type, _ := c.GetInt64("id_card_type")
  727. admin_user_id, _ := c.GetInt64("admin_user_id")
  728. certificates, _ := c.GetInt64("certificates")
  729. fmt.Println(c.GetAdminUserInfo().CurrentOrgId)
  730. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  731. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  732. switch id_card_type {
  733. case 1:
  734. if miConfig.MdtrtareaAdmvs == "421300" {
  735. var res ResultTwo
  736. api := "http://192.168.124.4:9532/" + "hbyb/1101?cert_no=" + "" +
  737. "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  738. "&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)
  739. resp, requestErr := http.Get(api)
  740. if requestErr != nil {
  741. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  742. return
  743. }
  744. body, ioErr := ioutil.ReadAll(resp.Body)
  745. if ioErr != nil {
  746. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  747. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  748. return
  749. }
  750. var respJSON map[string]interface{}
  751. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  752. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  753. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  754. return
  755. }
  756. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  757. result, _ := json.Marshal(respJSON)
  758. fmt.Println("log")
  759. fmt.Println(string(result))
  760. if err := json.Unmarshal([]byte(result), &res); err != nil {
  761. utils.ErrorLog("解析失败:%v", err)
  762. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  763. return
  764. }
  765. if res.Infcode == 0 {
  766. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  767. if err == gorm.ErrRecordNotFound {
  768. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  769. return
  770. } else if err != nil {
  771. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  772. return
  773. } else {
  774. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  775. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  776. infoStr := string(Iinfos)
  777. idetinfoStr := string(Idetinfos)
  778. psn := &models.HisPsn{
  779. PsnNo: res.Output.Baseinfo.PsnNo,
  780. Age: res.Output.Baseinfo.Age,
  781. PatientId: patient.ID,
  782. Certno: res.Output.Baseinfo.Certno,
  783. Brdy: res.Output.Baseinfo.Brdy,
  784. Gend: res.Output.Baseinfo.Gend,
  785. Naty: res.Output.Baseinfo.Naty,
  786. PsnCertType: res.Output.Baseinfo.PsnCertType,
  787. PsnName: res.Output.Baseinfo.PsnName,
  788. Idetinfo: idetinfoStr,
  789. Insuinfo: infoStr,
  790. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  791. }
  792. service.CreateHisPsn(psn)
  793. c.ServeSuccessJSON(map[string]interface{}{
  794. "patient": patient,
  795. "number": res.Output.Baseinfo.Certno,
  796. })
  797. }
  798. } else {
  799. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  800. return
  801. }
  802. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  803. var api string
  804. if miConfig.MdtrtareaAdmvs == "320921" {
  805. api = "http://192.168.3.111:9532/" + "jsyb/readcard?" + "fixmedins_code=" + miConfig.Code + "&secret_key=" + miConfig.SecretKey + "&ak=" + miConfig.AccessKey + "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName +
  806. "&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
  807. fmt.Println(api)
  808. } else {
  809. 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 +
  810. "&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)
  811. }
  812. resp, requestErr := http.Get(api)
  813. if requestErr != nil {
  814. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  815. return
  816. }
  817. body, ioErr := ioutil.ReadAll(resp.Body)
  818. if ioErr != nil {
  819. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  820. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  821. return
  822. }
  823. var respJSON map[string]interface{}
  824. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  825. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  826. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  827. return
  828. }
  829. var status string
  830. status = respJSON["data"].(map[string]interface{})["status"].(string)
  831. card_type := respJSON["data"].(map[string]interface{})["type"].(string)
  832. //console.log()
  833. fmt.Println("type===")
  834. fmt.Println(card_type)
  835. var token string
  836. var res ResultTwo //1101结果
  837. var res10265 ResultTwo10265 //1101结果
  838. var card_info string //卡信息
  839. var busi_card_info string
  840. card_info = respJSON["data"].(map[string]interface{})["card_info"].(string)
  841. busi_card_info = respJSON["data"].(map[string]interface{})["busi_card_info"].(string)
  842. if status == "0" { //读卡成功
  843. if card_type == "1" {
  844. respJSON = respJSON["data"].(map[string]interface{})["result"].(map[string]interface{})
  845. result, _ := json.Marshal(respJSON)
  846. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  847. utils.ErrorLog("解析失败:%v", err)
  848. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  849. return
  850. }
  851. res.ErrMsg = res10265.ErrMsg
  852. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  853. res.Infcode = infocode
  854. res.Output = res10265.Output
  855. res.InfRefmsgid = res10265.InfRefmsgid
  856. } else {
  857. //var card_info string //卡信息
  858. //var busi_card_info string
  859. token = respJSON["data"].(map[string]interface{})["token"].(string)
  860. //busi_card_info = respJSON["data"].(map[string]interface{})["busi_card_info"].(string)
  861. //fmt.Println(card_info)
  862. //fmt.Println(busi_card_info)
  863. respJSON = respJSON["data"].(map[string]interface{})["result"].(map[string]interface{})
  864. result, _ := json.Marshal(respJSON)
  865. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  866. utils.ErrorLog("解析失败:%v", err)
  867. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  868. return
  869. }
  870. res.ErrMsg = res10265.ErrMsg
  871. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  872. res.Infcode = infocode
  873. res.Output = res10265.Output
  874. res.InfRefmsgid = res10265.InfRefmsgid
  875. }
  876. if res.Infcode == 0 {
  877. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  878. if err == gorm.ErrRecordNotFound {
  879. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  880. return
  881. } else if err != nil {
  882. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  883. return
  884. } else {
  885. if card_type == "1" {
  886. bas := strings.Split(card_info, "|")
  887. basNumber := bas[2]
  888. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  889. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  890. infoStr := string(Iinfos)
  891. idetinfoStr := string(Idetinfos)
  892. psn := &models.HisPsn{
  893. PsnNo: res.Output.Baseinfo.PsnNo,
  894. Age: res.Output.Baseinfo.Age,
  895. PatientId: patient.ID,
  896. Certno: res.Output.Baseinfo.Certno,
  897. Brdy: res.Output.Baseinfo.Brdy,
  898. Gend: res.Output.Baseinfo.Gend,
  899. Naty: res.Output.Baseinfo.Naty,
  900. PsnCertType: res.Output.Baseinfo.PsnCertType,
  901. PsnName: res.Output.Baseinfo.PsnName,
  902. Idetinfo: idetinfoStr,
  903. Insuinfo: infoStr,
  904. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  905. CardInfo: card_info,
  906. VerifyNumber: busi_card_info,
  907. }
  908. service.CreateHisPsn(psn)
  909. c.ServeSuccessJSON(map[string]interface{}{
  910. "patient": patient,
  911. "number": basNumber,
  912. })
  913. } else {
  914. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  915. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  916. infoStr := string(Iinfos)
  917. idetinfoStr := string(Idetinfos)
  918. psn := &models.HisPsn{
  919. PsnNo: res.Output.Baseinfo.PsnNo,
  920. Age: res.Output.Baseinfo.Age,
  921. PatientId: patient.ID,
  922. Certno: res.Output.Baseinfo.Certno,
  923. Brdy: res.Output.Baseinfo.Brdy,
  924. Gend: res.Output.Baseinfo.Gend,
  925. Naty: res.Output.Baseinfo.Naty,
  926. PsnCertType: res.Output.Baseinfo.PsnCertType,
  927. PsnName: res.Output.Baseinfo.PsnName,
  928. Idetinfo: idetinfoStr,
  929. Insuinfo: infoStr,
  930. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  931. CardInfo: card_info,
  932. VerifyNumber: token,
  933. }
  934. service.CreateHisPsn(psn)
  935. c.ServeSuccessJSON(map[string]interface{}{
  936. "patient": patient,
  937. "number": token,
  938. })
  939. }
  940. }
  941. } else {
  942. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  943. return
  944. }
  945. } else { //读卡失败
  946. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  947. return
  948. }
  949. } else {
  950. if initFlag == 0 {
  951. c.TestGetBasBaseInit()
  952. }
  953. basStr := c.GetBasBaseInfo()
  954. if len(basStr) == 0 {
  955. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeReadCardException)
  956. return
  957. }
  958. fmt.Println(basStr)
  959. bas := strings.Split(basStr, "|")
  960. basNumber := bas[1]
  961. fmt.Println(basNumber)
  962. card_sn := bas[3]
  963. fmt.Println(card_sn)
  964. result := service.Gdyb1101B(basNumber, miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, id_card_type, card_sn, certificates)
  965. var dat map[string]interface{}
  966. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  967. fmt.Println(dat)
  968. } else {
  969. fmt.Println(err)
  970. }
  971. userJSONBytes, _ := json.Marshal(dat)
  972. var res ResultTwo
  973. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  974. utils.ErrorLog("解析失败:%v", err)
  975. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  976. return
  977. }
  978. if res.Infcode == 0 {
  979. patient, err := service.GetPatientByNumber(basNumber, c.GetAdminUserInfo().CurrentOrgId)
  980. if err == gorm.ErrRecordNotFound {
  981. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  982. return
  983. } else if err != nil {
  984. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  985. return
  986. } else {
  987. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  988. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  989. infoStr := string(Iinfos)
  990. idetinfoStr := string(Idetinfos)
  991. psn := &models.HisPsn{
  992. PsnNo: res.Output.Baseinfo.PsnNo,
  993. Age: res.Output.Baseinfo.Age,
  994. PatientId: patient.ID,
  995. Certno: res.Output.Baseinfo.Certno,
  996. Brdy: res.Output.Baseinfo.Brdy,
  997. Gend: res.Output.Baseinfo.Gend,
  998. Naty: res.Output.Baseinfo.Naty,
  999. PsnCertType: res.Output.Baseinfo.PsnCertType,
  1000. PsnName: res.Output.Baseinfo.PsnName,
  1001. Idetinfo: idetinfoStr,
  1002. Insuinfo: infoStr,
  1003. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  1004. CardInfo: basStr,
  1005. VerifyNumber: "",
  1006. }
  1007. service.CreateHisPsn(psn)
  1008. c.ServeSuccessJSON(map[string]interface{}{
  1009. "patient": patient,
  1010. "number": basNumber,
  1011. })
  1012. }
  1013. } else {
  1014. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  1015. return
  1016. }
  1017. break
  1018. }
  1019. case 2:
  1020. SFZStr := c.GetSFZBaseInfo()
  1021. id_card_str := strings.Split(SFZStr, "^")
  1022. id_card_number := id_card_str[0]
  1023. card_sn := ""
  1024. result := service.Gdyb1101B(id_card_number, miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, id_card_type, card_sn, certificates)
  1025. var dat map[string]interface{}
  1026. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  1027. fmt.Println(dat)
  1028. } else {
  1029. fmt.Println(err)
  1030. }
  1031. userJSONBytes, _ := json.Marshal(dat)
  1032. var res ResultTwo
  1033. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  1034. utils.ErrorLog("解析失败:%v", err)
  1035. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1036. return
  1037. }
  1038. if res.Infcode == 0 {
  1039. patient, err := service.GetPatientByNumber(id_card_number, c.GetAdminUserInfo().CurrentOrgId)
  1040. if err == gorm.ErrRecordNotFound {
  1041. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  1042. return
  1043. } else if err != nil {
  1044. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  1045. return
  1046. } else {
  1047. c.ServeSuccessJSON(map[string]interface{}{
  1048. "patient": patient,
  1049. "number": id_card_number,
  1050. })
  1051. }
  1052. } else {
  1053. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  1054. return
  1055. }
  1056. break
  1057. case 3:
  1058. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  1059. var api string
  1060. if miConfig.MdtrtareaAdmvs == "320921" {
  1061. api = "http://192.168.3.111:9532/" + "jsyb/readcard?" + "fixmedins_code=" + miConfig.Code + "&secret_key=" + miConfig.SecretKey + "&ak=" + miConfig.AccessKey + "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName +
  1062. "&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
  1063. fmt.Println(api)
  1064. } else {
  1065. 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 +
  1066. "&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)
  1067. }
  1068. resp, requestErr := http.Get(api)
  1069. if requestErr != nil {
  1070. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1071. return
  1072. }
  1073. body, ioErr := ioutil.ReadAll(resp.Body)
  1074. if ioErr != nil {
  1075. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  1076. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1077. return
  1078. }
  1079. var respJSON map[string]interface{}
  1080. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  1081. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  1082. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1083. return
  1084. }
  1085. var status string
  1086. status = respJSON["data"].(map[string]interface{})["status"].(string)
  1087. card_type := respJSON["data"].(map[string]interface{})["type"].(string)
  1088. var token string
  1089. var res ResultTwo //1101结果
  1090. var res10265 ResultTwo10265 //1101结果
  1091. var card_info string //卡信息
  1092. var busi_card_info string
  1093. //card_info = respJSON["data"].(map[string]interface{})["card_info"].(string)
  1094. busi_card_info = respJSON["data"].(map[string]interface{})["busi_card_info"].(string)
  1095. if status == "0" { //读卡成功
  1096. if card_type == "1" {
  1097. respJSON = respJSON["data"].(map[string]interface{})["result"].(map[string]interface{})
  1098. result, _ := json.Marshal(respJSON)
  1099. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  1100. utils.ErrorLog("解析失败:%v", err)
  1101. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1102. return
  1103. }
  1104. res.ErrMsg = res10265.ErrMsg
  1105. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  1106. res.Infcode = infocode
  1107. res.Output = res10265.Output
  1108. res.InfRefmsgid = res10265.InfRefmsgid
  1109. } else {
  1110. //var card_info string //卡信息
  1111. //var busi_card_info string
  1112. token = respJSON["data"].(map[string]interface{})["token"].(string)
  1113. //busi_card_info = respJSON["data"].(map[string]interface{})["busi_card_info"].(string)
  1114. //fmt.Println(card_info)
  1115. //fmt.Println(busi_card_info)
  1116. respJSON = respJSON["data"].(map[string]interface{})["result"].(map[string]interface{})
  1117. result, _ := json.Marshal(respJSON)
  1118. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  1119. utils.ErrorLog("解析失败:%v", err)
  1120. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1121. return
  1122. }
  1123. res.ErrMsg = res10265.ErrMsg
  1124. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  1125. res.Infcode = infocode
  1126. res.Output = res10265.Output
  1127. res.InfRefmsgid = res10265.InfRefmsgid
  1128. }
  1129. if res.Infcode == 0 {
  1130. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  1131. if err == gorm.ErrRecordNotFound {
  1132. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  1133. return
  1134. } else if err != nil {
  1135. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  1136. return
  1137. } else {
  1138. if card_type == "1" {
  1139. bas := strings.Split(card_info, "|")
  1140. basNumber := bas[2]
  1141. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  1142. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  1143. infoStr := string(Iinfos)
  1144. idetinfoStr := string(Idetinfos)
  1145. psn := &models.HisPsn{
  1146. PsnNo: res.Output.Baseinfo.PsnNo,
  1147. Age: res.Output.Baseinfo.Age,
  1148. PatientId: patient.ID,
  1149. Certno: res.Output.Baseinfo.Certno,
  1150. Brdy: res.Output.Baseinfo.Brdy,
  1151. Gend: res.Output.Baseinfo.Gend,
  1152. Naty: res.Output.Baseinfo.Naty,
  1153. PsnCertType: res.Output.Baseinfo.PsnCertType,
  1154. PsnName: res.Output.Baseinfo.PsnName,
  1155. Idetinfo: idetinfoStr,
  1156. Insuinfo: infoStr,
  1157. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  1158. CardInfo: card_info,
  1159. VerifyNumber: busi_card_info,
  1160. }
  1161. service.CreateHisPsn(psn)
  1162. c.ServeSuccessJSON(map[string]interface{}{
  1163. "patient": patient,
  1164. "number": basNumber,
  1165. })
  1166. } else {
  1167. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  1168. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  1169. infoStr := string(Iinfos)
  1170. idetinfoStr := string(Idetinfos)
  1171. psn := &models.HisPsn{
  1172. PsnNo: res.Output.Baseinfo.PsnNo,
  1173. Age: res.Output.Baseinfo.Age,
  1174. PatientId: patient.ID,
  1175. Certno: res.Output.Baseinfo.Certno,
  1176. Brdy: res.Output.Baseinfo.Brdy,
  1177. Gend: res.Output.Baseinfo.Gend,
  1178. Naty: res.Output.Baseinfo.Naty,
  1179. PsnCertType: res.Output.Baseinfo.PsnCertType,
  1180. PsnName: res.Output.Baseinfo.PsnName,
  1181. Idetinfo: idetinfoStr,
  1182. Insuinfo: infoStr,
  1183. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  1184. CardInfo: card_info,
  1185. VerifyNumber: token,
  1186. }
  1187. service.CreateHisPsn(psn)
  1188. c.ServeSuccessJSON(map[string]interface{}{
  1189. "patient": patient,
  1190. "number": token,
  1191. })
  1192. }
  1193. }
  1194. } else {
  1195. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  1196. return
  1197. }
  1198. } else { //读卡失败
  1199. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  1200. return
  1201. }
  1202. }
  1203. break
  1204. case 4:
  1205. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  1206. var api string
  1207. if miConfig.MdtrtareaAdmvs == "320921" {
  1208. api = "http://192.168.3.111:9532/" + "jsyb/readcard?" + "fixmedins_code=" + miConfig.Code + "&secret_key=" + miConfig.SecretKey + "&ak=" + miConfig.AccessKey + "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName +
  1209. "&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
  1210. fmt.Println(api)
  1211. } else {
  1212. 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 +
  1213. "&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)
  1214. }
  1215. resp, requestErr := http.Get(api)
  1216. if requestErr != nil {
  1217. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1218. return
  1219. }
  1220. body, ioErr := ioutil.ReadAll(resp.Body)
  1221. if ioErr != nil {
  1222. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  1223. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1224. return
  1225. }
  1226. var respJSON map[string]interface{}
  1227. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  1228. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  1229. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1230. return
  1231. }
  1232. var status string
  1233. status = respJSON["data"].(map[string]interface{})["status"].(string)
  1234. //card_type := respJSON["data"].(map[string]interface{})["type"].(string)
  1235. var token string
  1236. var res ResultTwo //1101结果
  1237. var res10265 ResultTwo10265 //1101结果
  1238. if status == "0" { //读卡成功
  1239. var card_info string //卡信息
  1240. var busi_card_info string
  1241. token = respJSON["data"].(map[string]interface{})["token"].(string)
  1242. busi_card_info = respJSON["data"].(map[string]interface{})["busi_card_info"].(string)
  1243. card_info = respJSON["data"].(map[string]interface{})["card_info"].(string)
  1244. fmt.Println(card_info)
  1245. fmt.Println(busi_card_info)
  1246. respJSON = respJSON["data"].(map[string]interface{})["result"].(map[string]interface{})
  1247. result, _ := json.Marshal(respJSON)
  1248. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  1249. utils.ErrorLog("解析失败:%v", err)
  1250. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1251. return
  1252. }
  1253. res.ErrMsg = res10265.ErrMsg
  1254. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  1255. res.Infcode = infocode
  1256. res.Output = res10265.Output
  1257. res.InfRefmsgid = res10265.InfRefmsgid
  1258. if res.Infcode == 0 {
  1259. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  1260. if err == gorm.ErrRecordNotFound {
  1261. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  1262. return
  1263. } else if err != nil {
  1264. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  1265. return
  1266. } else {
  1267. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  1268. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  1269. infoStr := string(Iinfos)
  1270. idetinfoStr := string(Idetinfos)
  1271. psn := &models.HisPsn{
  1272. PsnNo: res.Output.Baseinfo.PsnNo,
  1273. Age: res.Output.Baseinfo.Age,
  1274. PatientId: patient.ID,
  1275. Certno: res.Output.Baseinfo.Certno,
  1276. Brdy: res.Output.Baseinfo.Brdy,
  1277. Gend: res.Output.Baseinfo.Gend,
  1278. Naty: res.Output.Baseinfo.Naty,
  1279. PsnCertType: res.Output.Baseinfo.PsnCertType,
  1280. PsnName: res.Output.Baseinfo.PsnName,
  1281. Idetinfo: idetinfoStr,
  1282. Insuinfo: infoStr,
  1283. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  1284. CardInfo: card_info,
  1285. VerifyNumber: token,
  1286. }
  1287. service.CreateHisPsn(psn)
  1288. c.ServeSuccessJSON(map[string]interface{}{
  1289. "patient": patient,
  1290. "number": token,
  1291. })
  1292. }
  1293. } else {
  1294. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  1295. return
  1296. }
  1297. } else { //读卡失败
  1298. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  1299. return
  1300. }
  1301. }
  1302. break
  1303. }
  1304. }
  1305. var initFlag int64 = 0
  1306. func (c *HisApiController) TestGetBasBaseInit() {
  1307. DllDef := syscall.MustLoadDLL("SSCard.dll")
  1308. Iinit := DllDef.MustFindProc("Init")
  1309. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  1310. ret, _, err := Iinit.Call(StrPtr("http://igb.hsa.gdgov.cn/gdyb_api/prd/api/card/initDll"), StrPtr(miConfig.InsuplcAdmdvs))
  1311. if ret != 0 {
  1312. fmt.Println("SSCard的报错原因:", err)
  1313. fmt.Println("SSCard的运算结果为:", ret)
  1314. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeReadCardException)
  1315. return
  1316. }
  1317. result := int(ret)
  1318. fmt.Println("SSCard的运算结果为1:", result)
  1319. initFlag = 1
  1320. return
  1321. }
  1322. func (c *HisApiController) GetSFZBaseInfo() string {
  1323. DllDef := syscall.MustLoadDLL("SSCard.dll")
  1324. readCard := DllDef.MustFindProc("ReadSFZ")
  1325. if readCard == nil {
  1326. fmt.Println("readcard is nil")
  1327. readCard = DllDef.MustFindProc("ReadSFZ")
  1328. }
  1329. str := make([]byte, 256)
  1330. str1 := make([]byte, 256)
  1331. r, _, _ := readCard.Call((uintptr)(unsafe.Pointer(&str[0])), IntPtr(1024), (uintptr)(unsafe.Pointer(&str1[0])), IntPtr(1024))
  1332. fmt.Println(r)
  1333. return string(str)
  1334. }
  1335. func (c *HisApiController) GetBasBaseInfo() string {
  1336. DllDef := syscall.MustLoadDLL("SSCard.dll")
  1337. readCard := DllDef.MustFindProc("ReadCardBas")
  1338. if readCard == nil {
  1339. fmt.Println("readcard is nil")
  1340. readCard = DllDef.MustFindProc("ReadCardBas")
  1341. }
  1342. str := make([]byte, 1024)
  1343. str1 := make([]byte, 1024)
  1344. ret2, _, _ := readCard.Call((uintptr)(unsafe.Pointer(&str[0])), uintptr(1024), (uintptr)(unsafe.Pointer(&str1[0])), uintptr(1024))
  1345. fmt.Println(string(str1))
  1346. fmt.Println(string(str))
  1347. fmt.Println(":", ConvertToString(string(str1), "gbk", "utf-8"))
  1348. fmt.Println(":", ConvertToString(string(str), "gbk", "utf-8"))
  1349. if ret2 != 0 {
  1350. return ""
  1351. }
  1352. return string(str)
  1353. }
  1354. type CustomFundPay struct {
  1355. FundPayType string `json:"fund_pay_type"`
  1356. FundPayamt float64 `json:"fund_payamt"`
  1357. }
  1358. func (c *HisApiController) GetSettleList() {
  1359. order_id, _ := c.GetInt64("order_id")
  1360. admin_user_id, _ := c.GetInt64("admin_user_id")
  1361. order, _ := service.GetHisOrderByIDTwo(order_id)
  1362. roles, _ := service.GetDoctorListTwo(c.GetAdminUserInfo().CurrentOrgId)
  1363. his, _ := service.GetHisPatientByNumber(order.MdtrtId)
  1364. admin, _ := service.GetAdminUserByUserID(roles[0].AdminUserId)
  1365. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  1366. depart, _ := service.GetDepartMentDetail(curRoles.DepartmentId)
  1367. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  1368. if order.ID == 0 {
  1369. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisOrderNoExistParamWrong)
  1370. return
  1371. }
  1372. last_order, _ := service.GetLastHisOrder(c.GetAdminUserInfo().CurrentOrgId)
  1373. max_order, _ := service.GetLastHisOrderTwo(c.GetAdminUserInfo().CurrentOrgId)
  1374. count, _ := strconv.ParseInt(max_order.FaPiaoNumber, 10, 64)
  1375. fmt.Println(count)
  1376. var zero string
  1377. number := count + 1
  1378. if number >= 1000 {
  1379. zero = "0000" + strconv.FormatInt(number, 10)
  1380. } else if number >= 10000 {
  1381. zero = "000" + strconv.FormatInt(number, 10)
  1382. } else if number >= 100000 {
  1383. zero = "00" + strconv.FormatInt(number, 10)
  1384. } else if number >= 1000000 {
  1385. zero = "0" + strconv.FormatInt(number, 10)
  1386. } else {
  1387. zero = strconv.FormatInt(number, 10)
  1388. }
  1389. fmt.Println(zero)
  1390. struct4101 := service.Struct4101{
  1391. PsnNo: order.PsnNo,
  1392. MdtrtId: order.MdtrtId,
  1393. SetlId: order.SetlId,
  1394. PsnName: order.PsnName,
  1395. Gend: order.Gend,
  1396. Brdy: his.Brdy,
  1397. Age: his.Age,
  1398. Naty: order.Naty,
  1399. PatnCertType: "01",
  1400. Certno: order.Certno,
  1401. Prfs: "90",
  1402. ConerName: roles[0].UserName,
  1403. PatnRlts: "99",
  1404. ConerAddr: miConfig.OrgName,
  1405. ConerTel: admin.Mobile,
  1406. HiType: order.Insutype,
  1407. Insuplc: miConfig.InsuplcAdmdvs,
  1408. MaindiagFlag: "1",
  1409. BillCode: last_order.FaPiaoCode,
  1410. BillNo: zero,
  1411. BizSn: order.Number,
  1412. PsnSelfPay: order.PsnPartAmt,
  1413. PsnOwnPay: order.PsnPartAmt,
  1414. AcctPay: order.AcctPay,
  1415. PsnCashpay: order.PsnCashPay,
  1416. HiPaymtd: "1",
  1417. Hsorg: miConfig.InsuplcAdmdvs,
  1418. HsorgOpter: miConfig.InsuplcAdmdvs,
  1419. MedinsFillPsn: curRoles.UserName,
  1420. MedinsFillDept: depart.Name,
  1421. IptMedType: "2",
  1422. }
  1423. struct4101.SetlBegnDate = order.SetlTime
  1424. struct4101.SetlEndDate = order.SetlTime
  1425. time_arr := strings.Split(order.SetlTime, " ")
  1426. struct4101.AdmTime = time_arr[0]
  1427. struct4101.AdmEndTime = time_arr[0]
  1428. var rf []CustomFundPay
  1429. json.Unmarshal([]byte(order.SetlDetail), &rf)
  1430. var tempFunPays []service.CustomStruct
  1431. for _, item := range rf {
  1432. var tempFunPay service.CustomStruct
  1433. tempFunPay.FundPayamt = item.FundPayamt
  1434. tempFunPay.FundPayType = item.FundPayType
  1435. tempFunPays = append(tempFunPays, tempFunPay)
  1436. }
  1437. struct4101.CustomStruct = tempFunPays
  1438. var tempDiaginfos []service.DiaginfoStructTwo
  1439. var tempOpspdiseinfo2 service.OpspdiseinfoStruct
  1440. var tempOpspdiseinfos []service.OpspdiseinfoStruct
  1441. diagnosis_ids := strings.Split(order.Diagnosis, ",")
  1442. var config []*models.HisXtDiagnoseConfig
  1443. for _, item := range diagnosis_ids {
  1444. id, _ := strconv.ParseInt(item, 10, 64)
  1445. diagnosisConfig, _ := service.FindDiagnoseById(id)
  1446. config = append(config, &diagnosisConfig)
  1447. }
  1448. for index, item := range config {
  1449. if index == 0 {
  1450. var tempDiaginfo service.DiaginfoStructTwo
  1451. tempDiaginfo.DiagCode = item.CountryCode
  1452. tempDiaginfo.DiagName = item.CountryContentName
  1453. tempDiaginfo.DiagType = "1"
  1454. tempDiaginfo.MaindiagFlag = "1"
  1455. tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  1456. } else {
  1457. var tempDiaginfo service.DiaginfoStructTwo
  1458. tempDiaginfo.DiagCode = item.CountryCode
  1459. tempDiaginfo.DiagName = item.CountryContentName
  1460. tempDiaginfo.DiagType = "2"
  1461. tempDiaginfo.MaindiagFlag = "0"
  1462. tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  1463. }
  1464. }
  1465. struct4101.Diseinfo = tempDiaginfos
  1466. sickConfigTwo, _ := service.FindSickById(his.SickType)
  1467. tempOpspdiseinfo2.DiagCode = sickConfigTwo.ContentCode
  1468. tempOpspdiseinfo2.DiagName = sickConfigTwo.CountryContentName
  1469. tempOpspdiseinfo2.OprnOprtCode = ""
  1470. tempOpspdiseinfo2.OprnOprtName = ""
  1471. tempOpspdiseinfos = append(tempOpspdiseinfos, tempOpspdiseinfo2)
  1472. struct4101.OpspdiseinfoStruct = tempOpspdiseinfos
  1473. var iteminfo service.IteminfoStruct
  1474. var bedCostTotal float64 = 0 //床位总费
  1475. var bedCostSelfTotal float64 = 0 //床位自费
  1476. var bedCostPartSelfTotal float64 = 0 //床位部分项目自费
  1477. var operationCostTotal float64 = 0 //手术费
  1478. var operationCostSelfTotal float64 = 0 //手术费
  1479. var operationCostPartSelfTotal float64 = 0 //手术费
  1480. var otherCostTotal float64 = 0 //其他费用
  1481. var otherCostSelfTotal float64 = 0 //其他费用
  1482. var otherCostPartSelfTotal float64 = 0 //其他费用
  1483. var materialCostTotal float64 = 0 //材料费
  1484. var materialCostSelfTotal float64 = 0 //材料费
  1485. var materialCostPartSelfTotal float64 = 0 //材料费
  1486. var westernMedicineCostTotal float64 = 0 //西药费
  1487. var westernMedicineCostSelfTotal float64 = 0 //西药费
  1488. var westernMedicineCostPartSelfTotal float64 = 0 //西药费
  1489. var chineseTraditionalMedicineCostTotal float64 = 0 //中成药
  1490. var chineseTraditionalMedicineCostSelfTotal float64 = 0 //中成药
  1491. var chineseTraditionalMedicineCostPartSelfTotal float64 = 0 //中成药
  1492. var checkCostTotal float64 = 0 //检查费
  1493. var checkCostSelfTotal float64 = 0 //检查费
  1494. var checkCostPartSelfTotal float64 = 0 //检查费
  1495. var laboratoryCostTotal float64 = 0 //化验费
  1496. var laboratoryCostSelfTotal float64 = 0 //化验费
  1497. var laboratoryCostPartSelfTotal float64 = 0 //化验费
  1498. var treatCostTotal float64 = 0 //治疗费用
  1499. var treatCostSelfTotal float64 = 0 //治疗费用
  1500. var treatCostPartSelfTotal float64 = 0 //治疗费用
  1501. decimal.DivisionPrecision = 2
  1502. var bed_fulamt_ownpay_amt float64 = 0
  1503. var operation_fulamt_ownpay_amt float64 = 0
  1504. var other_fulamt_ownpay_amt float64 = 0
  1505. var westernMedicine_fulamt_ownpay_amt float64 = 0
  1506. var chineseTraditional_fulamt_ownpay_amt float64 = 0
  1507. var check_fulamt_ownpay_amt float64 = 0
  1508. var material_fulamt_ownpay_amt float64 = 0
  1509. var laboratory_fulamt_ownpay_amt float64 = 0
  1510. var treat_fulamt_ownpay_amt float64 = 0
  1511. var bed_claa_sunmfee float64 = 0
  1512. var bed_clab_amt float64 = 0
  1513. var bed_other_amt float64 = 0
  1514. var operation_claa_sunmfee float64 = 0
  1515. var operation_clab_amt float64 = 0
  1516. var operation_other_amt float64 = 0
  1517. var other_claa_sunmfee float64 = 0
  1518. var other_clab_amt float64 = 0
  1519. var other_other_amt float64 = 0
  1520. var westernMedicine_claa_sunmfee float64 = 0
  1521. var westernMedicine_clab_amt float64 = 0
  1522. var westernMedicine_other_amt float64 = 0
  1523. var chineseTraditional_claa_sunmfee float64 = 0
  1524. var chineseTraditional_clab_amt float64 = 0
  1525. var chineseTraditional_other_amt float64 = 0
  1526. var check_claa_sunmfee float64 = 0
  1527. var check_clab_amt float64 = 0
  1528. var check_other_amt float64 = 0
  1529. var material_claa_sunmfee float64 = 0
  1530. var material_clab_amt float64 = 0
  1531. var material_other_amt float64 = 0
  1532. var laboratory_claa_sunmfee float64 = 0
  1533. var laboratory_clab_amt float64 = 0
  1534. var laboratory_other_amt float64 = 0
  1535. var treat_claa_sunmfee float64 = 0
  1536. var treat_clab_amt float64 = 0
  1537. var treat_other_amt float64 = 0
  1538. for _, item := range order.HisOrderInfo {
  1539. if item.MedChrgitmType == "01" { //床位费
  1540. bedCostTotal, _ = decimal.NewFromFloat(bedCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  1541. bedCostSelfTotal, _ = decimal.NewFromFloat(bedCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  1542. bedCostPartSelfTotal, _ = decimal.NewFromFloat(bedCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  1543. bed_fulamt_ownpay_amt, _ = decimal.NewFromFloat(bed_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  1544. if item.ChrgitmLv == "1" {
  1545. bed_claa_sunmfee, _ = decimal.NewFromFloat(bed_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  1546. }
  1547. if item.ChrgitmLv == "2" {
  1548. bed_clab_amt, _ = decimal.NewFromFloat(bed_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  1549. }
  1550. if item.ChrgitmLv == "3" {
  1551. bed_other_amt, _ = decimal.NewFromFloat(bed_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  1552. }
  1553. }
  1554. if item.MedChrgitmType == "03" { //检查费
  1555. checkCostTotal, _ = decimal.NewFromFloat(checkCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  1556. checkCostSelfTotal, _ = decimal.NewFromFloat(checkCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  1557. checkCostPartSelfTotal, _ = decimal.NewFromFloat(checkCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  1558. check_fulamt_ownpay_amt, _ = decimal.NewFromFloat(check_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  1559. if item.ChrgitmLv == "1" {
  1560. check_claa_sunmfee, _ = decimal.NewFromFloat(check_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  1561. }
  1562. if item.ChrgitmLv == "2" {
  1563. check_clab_amt, _ = decimal.NewFromFloat(check_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  1564. }
  1565. if item.ChrgitmLv == "3" {
  1566. check_other_amt, _ = decimal.NewFromFloat(check_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  1567. }
  1568. }
  1569. if item.MedChrgitmType == "04" { //化验费
  1570. laboratoryCostTotal, _ = decimal.NewFromFloat(laboratoryCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  1571. laboratoryCostSelfTotal, _ = decimal.NewFromFloat(laboratoryCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  1572. laboratoryCostPartSelfTotal, _ = decimal.NewFromFloat(laboratoryCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  1573. laboratory_fulamt_ownpay_amt, _ = decimal.NewFromFloat(laboratory_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  1574. if item.ChrgitmLv == "1" {
  1575. laboratory_claa_sunmfee, _ = decimal.NewFromFloat(laboratory_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  1576. }
  1577. if item.ChrgitmLv == "2" {
  1578. laboratory_clab_amt, _ = decimal.NewFromFloat(laboratory_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  1579. }
  1580. if item.ChrgitmLv == "3" {
  1581. laboratory_other_amt, _ = decimal.NewFromFloat(laboratory_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  1582. }
  1583. }
  1584. if item.MedChrgitmType == "05" { //治疗费
  1585. treatCostTotal, _ = decimal.NewFromFloat(treatCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  1586. treatCostSelfTotal, _ = decimal.NewFromFloat(treatCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  1587. treatCostPartSelfTotal, _ = decimal.NewFromFloat(treatCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  1588. treat_fulamt_ownpay_amt, _ = decimal.NewFromFloat(treat_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  1589. if item.ChrgitmLv == "1" {
  1590. treat_claa_sunmfee, _ = decimal.NewFromFloat(treat_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  1591. }
  1592. if item.ChrgitmLv == "2" {
  1593. treat_clab_amt, _ = decimal.NewFromFloat(treat_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  1594. }
  1595. if item.ChrgitmLv == "3" {
  1596. treat_other_amt, _ = decimal.NewFromFloat(treat_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  1597. }
  1598. }
  1599. if item.MedChrgitmType == "06" { //手术费
  1600. operationCostTotal, _ = decimal.NewFromFloat(operationCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  1601. operationCostSelfTotal, _ = decimal.NewFromFloat(operationCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  1602. operationCostPartSelfTotal, _ = decimal.NewFromFloat(operationCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  1603. operation_fulamt_ownpay_amt, _ = decimal.NewFromFloat(operation_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  1604. if item.ChrgitmLv == "1" {
  1605. operation_claa_sunmfee, _ = decimal.NewFromFloat(operation_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  1606. }
  1607. if item.ChrgitmLv == "2" {
  1608. operation_clab_amt, _ = decimal.NewFromFloat(operation_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  1609. }
  1610. if item.ChrgitmLv == "3" {
  1611. operation_other_amt, _ = decimal.NewFromFloat(operation_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  1612. }
  1613. }
  1614. if item.MedChrgitmType == "08" { //材料费
  1615. materialCostTotal, _ = decimal.NewFromFloat(materialCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  1616. materialCostSelfTotal, _ = decimal.NewFromFloat(materialCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  1617. materialCostPartSelfTotal, _ = decimal.NewFromFloat(materialCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  1618. material_fulamt_ownpay_amt, _ = decimal.NewFromFloat(material_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  1619. if item.ChrgitmLv == "1" {
  1620. material_claa_sunmfee, _ = decimal.NewFromFloat(material_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  1621. }
  1622. if item.ChrgitmLv == "2" {
  1623. material_clab_amt, _ = decimal.NewFromFloat(material_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  1624. }
  1625. if item.ChrgitmLv == "3" {
  1626. material_other_amt, _ = decimal.NewFromFloat(material_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  1627. }
  1628. }
  1629. if item.MedChrgitmType == "09" { //西药费
  1630. westernMedicineCostTotal, _ = decimal.NewFromFloat(westernMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  1631. westernMedicineCostSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  1632. westernMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  1633. westernMedicine_fulamt_ownpay_amt, _ = decimal.NewFromFloat(westernMedicine_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  1634. if item.ChrgitmLv == "1" {
  1635. westernMedicine_claa_sunmfee, _ = decimal.NewFromFloat(westernMedicine_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  1636. }
  1637. if item.ChrgitmLv == "2" {
  1638. westernMedicine_clab_amt, _ = decimal.NewFromFloat(westernMedicine_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  1639. }
  1640. if item.ChrgitmLv == "3" {
  1641. westernMedicine_other_amt, _ = decimal.NewFromFloat(westernMedicine_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  1642. }
  1643. }
  1644. if item.MedChrgitmType == "11" { //中成费
  1645. chineseTraditionalMedicineCostTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  1646. chineseTraditionalMedicineCostSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  1647. chineseTraditionalMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  1648. chineseTraditional_fulamt_ownpay_amt, _ = decimal.NewFromFloat(chineseTraditional_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  1649. if item.ChrgitmLv == "1" {
  1650. chineseTraditional_claa_sunmfee, _ = decimal.NewFromFloat(chineseTraditional_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  1651. }
  1652. if item.ChrgitmLv == "2" {
  1653. chineseTraditional_clab_amt, _ = decimal.NewFromFloat(chineseTraditional_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  1654. }
  1655. if item.ChrgitmLv == "3" {
  1656. chineseTraditional_other_amt, _ = decimal.NewFromFloat(chineseTraditional_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  1657. }
  1658. }
  1659. if item.MedChrgitmType == "14" { //其他费
  1660. otherCostTotal, _ = decimal.NewFromFloat(otherCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  1661. otherCostSelfTotal, _ = decimal.NewFromFloat(otherCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  1662. otherCostPartSelfTotal, _ = decimal.NewFromFloat(otherCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  1663. other_fulamt_ownpay_amt, _ = decimal.NewFromFloat(other_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  1664. if item.ChrgitmLv == "1" {
  1665. other_claa_sunmfee, _ = decimal.NewFromFloat(other_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  1666. }
  1667. if item.ChrgitmLv == "2" {
  1668. other_clab_amt, _ = decimal.NewFromFloat(other_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  1669. }
  1670. if item.ChrgitmLv == "3" {
  1671. other_other_amt, _ = decimal.NewFromFloat(other_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  1672. }
  1673. }
  1674. }
  1675. var iteminfoStructs []service.IteminfoStruct
  1676. if bedCostTotal != 0 {
  1677. iteminfo.MedChrgitm = "01"
  1678. iteminfo.FulamtOwnpayAmt = bed_fulamt_ownpay_amt
  1679. iteminfo.Amt = bedCostTotal
  1680. iteminfo.ClaaSumfee = bed_claa_sunmfee
  1681. iteminfo.ClabAmt = bed_clab_amt
  1682. iteminfo.OthAmt = bed_other_amt
  1683. iteminfoStructs = append(iteminfoStructs, iteminfo)
  1684. }
  1685. if checkCostTotal != 0 {
  1686. iteminfo.MedChrgitm = "03"
  1687. iteminfo.FulamtOwnpayAmt = check_fulamt_ownpay_amt
  1688. iteminfo.Amt = checkCostTotal
  1689. iteminfo.ClaaSumfee = check_claa_sunmfee
  1690. iteminfo.ClabAmt = check_clab_amt
  1691. iteminfo.OthAmt = check_other_amt
  1692. iteminfoStructs = append(iteminfoStructs, iteminfo)
  1693. }
  1694. if laboratoryCostTotal != 0 {
  1695. iteminfo.MedChrgitm = "04"
  1696. iteminfo.FulamtOwnpayAmt = laboratory_fulamt_ownpay_amt
  1697. iteminfo.Amt = laboratoryCostTotal
  1698. iteminfo.ClaaSumfee = laboratory_claa_sunmfee
  1699. iteminfo.ClabAmt = laboratory_clab_amt
  1700. iteminfo.OthAmt = laboratory_other_amt
  1701. iteminfoStructs = append(iteminfoStructs, iteminfo)
  1702. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  1703. }
  1704. if treatCostTotal != 0 {
  1705. iteminfo.MedChrgitm = "05"
  1706. iteminfo.FulamtOwnpayAmt = treat_fulamt_ownpay_amt
  1707. iteminfo.Amt = treatCostTotal
  1708. iteminfo.ClaaSumfee = treat_claa_sunmfee
  1709. iteminfo.ClabAmt = treat_clab_amt
  1710. iteminfo.OthAmt = treat_other_amt
  1711. iteminfoStructs = append(iteminfoStructs, iteminfo)
  1712. //(struct4101.IteminfoStruct, iteminfo)
  1713. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  1714. }
  1715. if operationCostTotal != 0 {
  1716. iteminfo.MedChrgitm = "06"
  1717. iteminfo.FulamtOwnpayAmt = bed_fulamt_ownpay_amt
  1718. iteminfo.Amt = operationCostTotal
  1719. iteminfo.ClaaSumfee = operation_claa_sunmfee
  1720. iteminfo.ClabAmt = operation_clab_amt
  1721. iteminfo.OthAmt = operation_other_amt
  1722. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  1723. iteminfoStructs = append(iteminfoStructs, iteminfo)
  1724. }
  1725. if materialCostTotal != 0 {
  1726. iteminfo.MedChrgitm = "08"
  1727. iteminfo.FulamtOwnpayAmt = material_fulamt_ownpay_amt
  1728. iteminfo.Amt = materialCostTotal
  1729. iteminfo.ClaaSumfee = material_claa_sunmfee
  1730. iteminfo.ClabAmt = material_clab_amt
  1731. iteminfo.OthAmt = material_other_amt
  1732. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  1733. iteminfoStructs = append(iteminfoStructs, iteminfo)
  1734. }
  1735. if westernMedicineCostTotal != 0 {
  1736. iteminfo.MedChrgitm = "09"
  1737. iteminfo.FulamtOwnpayAmt = westernMedicine_fulamt_ownpay_amt
  1738. iteminfo.Amt = westernMedicineCostTotal
  1739. iteminfo.ClaaSumfee = westernMedicine_claa_sunmfee
  1740. iteminfo.ClabAmt = westernMedicine_clab_amt
  1741. iteminfo.OthAmt = westernMedicine_other_amt
  1742. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  1743. iteminfoStructs = append(iteminfoStructs, iteminfo)
  1744. }
  1745. if chineseTraditionalMedicineCostTotal != 0 {
  1746. iteminfo.MedChrgitm = "11"
  1747. iteminfo.FulamtOwnpayAmt = westernMedicine_fulamt_ownpay_amt
  1748. iteminfo.Amt = westernMedicineCostTotal
  1749. iteminfo.ClaaSumfee = westernMedicine_claa_sunmfee
  1750. iteminfo.ClabAmt = westernMedicine_clab_amt
  1751. iteminfo.OthAmt = westernMedicine_other_amt
  1752. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  1753. iteminfoStructs = append(iteminfoStructs, iteminfo)
  1754. }
  1755. if otherCostTotal != 0 {
  1756. iteminfo.MedChrgitm = "14"
  1757. iteminfo.FulamtOwnpayAmt = other_fulamt_ownpay_amt
  1758. iteminfo.Amt = otherCostTotal
  1759. iteminfo.ClaaSumfee = other_claa_sunmfee
  1760. iteminfo.ClabAmt = other_clab_amt
  1761. iteminfo.OthAmt = other_other_amt
  1762. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  1763. iteminfoStructs = append(iteminfoStructs, iteminfo)
  1764. }
  1765. struct4101.IteminfoStruct = iteminfoStructs
  1766. struct4101.Ntly = "中国"
  1767. struct4101.AdmCaty = "A03.06"
  1768. result := service.Gdyb4101(struct4101, miConfig.SecretKey, miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.UserOrgId)
  1769. fmt.Println(result)
  1770. var dat map[string]interface{}
  1771. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  1772. fmt.Println(dat)
  1773. } else {
  1774. fmt.Println(err)
  1775. }
  1776. userJSONBytes, _ := json.Marshal(dat)
  1777. var res ResultSeventeen
  1778. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  1779. utils.ErrorLog("解析失败:%v", err)
  1780. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1781. return
  1782. }
  1783. if res.Infcode != 0 {
  1784. c.ServeSuccessJSON(map[string]interface{}{
  1785. "failed_code": -10,
  1786. "msg": res.ErrMsg,
  1787. })
  1788. return
  1789. } else {
  1790. order.FaPiaoNumber = zero
  1791. order.FaPiaoCode = last_order.FaPiaoCode
  1792. service.UpdateOrder(order)
  1793. hisFundSettleListResult := &models.HisFundSettleListResult{
  1794. Number: res.Output.SetlListId,
  1795. Status: 1,
  1796. Ctime: time.Now().Unix(),
  1797. Mtime: time.Now().Unix(),
  1798. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  1799. IsUpload: 1,
  1800. OrderId: order_id,
  1801. }
  1802. service.CreateUploadRecord(hisFundSettleListResult)
  1803. c.ServeSuccessJSON(map[string]interface{}{
  1804. "msg": "上传成功",
  1805. "result": hisFundSettleListResult,
  1806. })
  1807. return
  1808. }
  1809. }
  1810. func (c *HisApiController) GetSettleListHospital() {
  1811. order_id, _ := c.GetInt64("order_id")
  1812. admin_user_id, _ := c.GetInt64("admin_user_id")
  1813. order, _ := service.GetHisOrderByIDTwo(order_id)
  1814. roles, _ := service.GetDoctorListTwo(c.GetAdminUserInfo().CurrentOrgId)
  1815. his, _ := service.GetInHospitalRecordByNumber(order.MdtrtId)
  1816. admin, _ := service.GetAdminUserByUserID(roles[0].AdminUserId)
  1817. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  1818. depart, _ := service.GetDepartMentDetail(curRoles.DepartmentId)
  1819. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  1820. if order.ID == 0 {
  1821. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisOrderNoExistParamWrong)
  1822. return
  1823. }
  1824. last_order, _ := service.GetLastHisOrder(c.GetAdminUserInfo().CurrentOrgId)
  1825. max_order, _ := service.GetLastHisOrderTwo(c.GetAdminUserInfo().CurrentOrgId)
  1826. count, _ := strconv.ParseInt(max_order.FaPiaoNumber, 10, 64)
  1827. fmt.Println(count)
  1828. var zero string
  1829. number := count + 1
  1830. if number >= 1000 {
  1831. zero = "0000" + strconv.FormatInt(number, 10)
  1832. } else if number >= 10000 {
  1833. zero = "000" + strconv.FormatInt(number, 10)
  1834. } else if number >= 100000 {
  1835. zero = "00" + strconv.FormatInt(number, 10)
  1836. } else if number >= 1000000 {
  1837. zero = "0" + strconv.FormatInt(number, 10)
  1838. } else {
  1839. zero = strconv.FormatInt(number, 10)
  1840. }
  1841. fmt.Println(zero)
  1842. struct4101 := service.Struct4101{
  1843. PsnNo: order.PsnNo,
  1844. MdtrtId: order.MdtrtId,
  1845. SetlId: order.SetlId,
  1846. PsnName: order.PsnName,
  1847. Gend: order.Gend,
  1848. Brdy: his.Brdy,
  1849. Age: int64(order.Age),
  1850. Naty: order.Naty,
  1851. PatnCertType: "01",
  1852. Certno: order.Certno,
  1853. Prfs: "90",
  1854. ConerName: roles[0].UserName,
  1855. PatnRlts: "99",
  1856. ConerAddr: miConfig.OrgName,
  1857. ConerTel: admin.Mobile,
  1858. HiType: order.Insutype,
  1859. Insuplc: miConfig.InsuplcAdmdvs,
  1860. MaindiagFlag: "1",
  1861. BillCode: last_order.FaPiaoCode,
  1862. BillNo: zero,
  1863. BizSn: order.Number,
  1864. PsnSelfPay: order.PsnPartAmt,
  1865. PsnOwnPay: order.PsnPartAmt,
  1866. AcctPay: order.AcctPay,
  1867. PsnCashpay: order.PsnCashPay,
  1868. HiPaymtd: "1",
  1869. Hsorg: miConfig.InsuplcAdmdvs,
  1870. HsorgOpter: miConfig.InsuplcAdmdvs,
  1871. MedinsFillPsn: curRoles.UserName,
  1872. MedinsFillDept: depart.Name,
  1873. IptMedType: "2",
  1874. AdmTime: his.InHosptialTime,
  1875. AdmEndTime: his.OutHosptialTime,
  1876. }
  1877. struct4101.SetlBegnDate = order.SetlTime
  1878. struct4101.SetlEndDate = order.SetlTime
  1879. var rf []CustomFundPay
  1880. json.Unmarshal([]byte(order.SetlDetail), &rf)
  1881. var tempFunPays []service.CustomStruct
  1882. for _, item := range rf {
  1883. var tempFunPay service.CustomStruct
  1884. tempFunPay.FundPayamt = item.FundPayamt
  1885. tempFunPay.FundPayType = item.FundPayType
  1886. tempFunPays = append(tempFunPays, tempFunPay)
  1887. }
  1888. struct4101.CustomStruct = tempFunPays
  1889. var tempDiaginfos []service.DiaginfoStructTwo
  1890. var tempOpspdiseinfo2 service.OpspdiseinfoStruct
  1891. var tempOpspdiseinfos []service.OpspdiseinfoStruct
  1892. diagnosis_ids := strings.Split(his.Diagnosis, ",")
  1893. var config []*models.HisXtDiagnoseConfig
  1894. for _, item := range diagnosis_ids {
  1895. id, _ := strconv.ParseInt(item, 10, 64)
  1896. diagnosisConfig, _ := service.FindDiagnoseById(id)
  1897. config = append(config, &diagnosisConfig)
  1898. }
  1899. for index, item := range config {
  1900. if index == 0 {
  1901. var tempDiaginfo service.DiaginfoStructTwo
  1902. tempDiaginfo.DiagCode = item.CountryCode
  1903. tempDiaginfo.DiagName = item.CountryContentName
  1904. tempDiaginfo.DiagType = "1"
  1905. tempDiaginfo.MaindiagFlag = "1"
  1906. tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  1907. } else {
  1908. var tempDiaginfo service.DiaginfoStructTwo
  1909. tempDiaginfo.DiagCode = item.CountryCode
  1910. tempDiaginfo.DiagName = item.CountryContentName
  1911. tempDiaginfo.DiagType = "2"
  1912. tempDiaginfo.MaindiagFlag = "0"
  1913. tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  1914. }
  1915. }
  1916. struct4101.Diseinfo = tempDiaginfos
  1917. sickConfigTwo, _ := service.FindSickById(his.SickType)
  1918. tempOpspdiseinfo2.DiagCode = sickConfigTwo.ContentCode
  1919. tempOpspdiseinfo2.DiagName = sickConfigTwo.CountryContentName
  1920. tempOpspdiseinfo2.OprnOprtCode = ""
  1921. tempOpspdiseinfo2.OprnOprtName = ""
  1922. tempOpspdiseinfos = append(tempOpspdiseinfos, tempOpspdiseinfo2)
  1923. struct4101.OpspdiseinfoStruct = tempOpspdiseinfos
  1924. var iteminfo service.IteminfoStruct
  1925. var bedCostTotal float64 = 0 //床位总费
  1926. var bedCostSelfTotal float64 = 0 //床位自费
  1927. var bedCostPartSelfTotal float64 = 0 //床位部分项目自费
  1928. var operationCostTotal float64 = 0 //手术费
  1929. var operationCostSelfTotal float64 = 0 //手术费
  1930. var operationCostPartSelfTotal float64 = 0 //手术费
  1931. var otherCostTotal float64 = 0 //其他费用
  1932. var otherCostSelfTotal float64 = 0 //其他费用
  1933. var otherCostPartSelfTotal float64 = 0 //其他费用
  1934. var materialCostTotal float64 = 0 //材料费
  1935. var materialCostSelfTotal float64 = 0 //材料费
  1936. var materialCostPartSelfTotal float64 = 0 //材料费
  1937. var westernMedicineCostTotal float64 = 0 //西药费
  1938. var westernMedicineCostSelfTotal float64 = 0 //西药费
  1939. var westernMedicineCostPartSelfTotal float64 = 0 //西药费
  1940. var chineseTraditionalMedicineCostTotal float64 = 0 //中成药
  1941. var chineseTraditionalMedicineCostSelfTotal float64 = 0 //中成药
  1942. var chineseTraditionalMedicineCostPartSelfTotal float64 = 0 //中成药
  1943. var checkCostTotal float64 = 0 //检查费
  1944. var checkCostSelfTotal float64 = 0 //检查费
  1945. var checkCostPartSelfTotal float64 = 0 //检查费
  1946. var laboratoryCostTotal float64 = 0 //化验费
  1947. var laboratoryCostSelfTotal float64 = 0 //化验费
  1948. var laboratoryCostPartSelfTotal float64 = 0 //化验费
  1949. var treatCostTotal float64 = 0 //治疗费用
  1950. var treatCostSelfTotal float64 = 0 //治疗费用
  1951. var treatCostPartSelfTotal float64 = 0 //治疗费用
  1952. decimal.DivisionPrecision = 2
  1953. var bed_fulamt_ownpay_amt float64 = 0
  1954. var operation_fulamt_ownpay_amt float64 = 0
  1955. var other_fulamt_ownpay_amt float64 = 0
  1956. var westernMedicine_fulamt_ownpay_amt float64 = 0
  1957. var chineseTraditional_fulamt_ownpay_amt float64 = 0
  1958. var check_fulamt_ownpay_amt float64 = 0
  1959. var material_fulamt_ownpay_amt float64 = 0
  1960. var laboratory_fulamt_ownpay_amt float64 = 0
  1961. var treat_fulamt_ownpay_amt float64 = 0
  1962. var bed_claa_sunmfee float64 = 0
  1963. var bed_clab_amt float64 = 0
  1964. var bed_other_amt float64 = 0
  1965. var operation_claa_sunmfee float64 = 0
  1966. var operation_clab_amt float64 = 0
  1967. var operation_other_amt float64 = 0
  1968. var other_claa_sunmfee float64 = 0
  1969. var other_clab_amt float64 = 0
  1970. var other_other_amt float64 = 0
  1971. var westernMedicine_claa_sunmfee float64 = 0
  1972. var westernMedicine_clab_amt float64 = 0
  1973. var westernMedicine_other_amt float64 = 0
  1974. var chineseTraditional_claa_sunmfee float64 = 0
  1975. var chineseTraditional_clab_amt float64 = 0
  1976. var chineseTraditional_other_amt float64 = 0
  1977. var check_claa_sunmfee float64 = 0
  1978. var check_clab_amt float64 = 0
  1979. var check_other_amt float64 = 0
  1980. var material_claa_sunmfee float64 = 0
  1981. var material_clab_amt float64 = 0
  1982. var material_other_amt float64 = 0
  1983. var laboratory_claa_sunmfee float64 = 0
  1984. var laboratory_clab_amt float64 = 0
  1985. var laboratory_other_amt float64 = 0
  1986. var treat_claa_sunmfee float64 = 0
  1987. var treat_clab_amt float64 = 0
  1988. var treat_other_amt float64 = 0
  1989. for _, item := range order.HisOrderInfo {
  1990. if item.MedChrgitmType == "01" { //床位费
  1991. bedCostTotal, _ = decimal.NewFromFloat(bedCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  1992. bedCostSelfTotal, _ = decimal.NewFromFloat(bedCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  1993. bedCostPartSelfTotal, _ = decimal.NewFromFloat(bedCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  1994. bed_fulamt_ownpay_amt, _ = decimal.NewFromFloat(bed_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  1995. if item.ChrgitmLv == "1" {
  1996. bed_claa_sunmfee, _ = decimal.NewFromFloat(bed_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  1997. }
  1998. if item.ChrgitmLv == "2" {
  1999. bed_clab_amt, _ = decimal.NewFromFloat(bed_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2000. }
  2001. if item.ChrgitmLv == "3" {
  2002. bed_other_amt, _ = decimal.NewFromFloat(bed_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2003. }
  2004. }
  2005. if item.MedChrgitmType == "03" { //检查费
  2006. checkCostTotal, _ = decimal.NewFromFloat(checkCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2007. checkCostSelfTotal, _ = decimal.NewFromFloat(checkCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2008. checkCostPartSelfTotal, _ = decimal.NewFromFloat(checkCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2009. check_fulamt_ownpay_amt, _ = decimal.NewFromFloat(check_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  2010. if item.ChrgitmLv == "1" {
  2011. check_claa_sunmfee, _ = decimal.NewFromFloat(check_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2012. }
  2013. if item.ChrgitmLv == "2" {
  2014. check_clab_amt, _ = decimal.NewFromFloat(check_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2015. }
  2016. if item.ChrgitmLv == "3" {
  2017. check_other_amt, _ = decimal.NewFromFloat(check_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2018. }
  2019. }
  2020. if item.MedChrgitmType == "04" { //化验费
  2021. laboratoryCostTotal, _ = decimal.NewFromFloat(laboratoryCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2022. laboratoryCostSelfTotal, _ = decimal.NewFromFloat(laboratoryCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2023. laboratoryCostPartSelfTotal, _ = decimal.NewFromFloat(laboratoryCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2024. laboratory_fulamt_ownpay_amt, _ = decimal.NewFromFloat(laboratory_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  2025. if item.ChrgitmLv == "1" {
  2026. laboratory_claa_sunmfee, _ = decimal.NewFromFloat(laboratory_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2027. }
  2028. if item.ChrgitmLv == "2" {
  2029. laboratory_clab_amt, _ = decimal.NewFromFloat(laboratory_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2030. }
  2031. if item.ChrgitmLv == "3" {
  2032. laboratory_other_amt, _ = decimal.NewFromFloat(laboratory_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2033. }
  2034. }
  2035. if item.MedChrgitmType == "05" { //治疗费
  2036. treatCostTotal, _ = decimal.NewFromFloat(treatCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2037. treatCostSelfTotal, _ = decimal.NewFromFloat(treatCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2038. treatCostPartSelfTotal, _ = decimal.NewFromFloat(treatCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2039. treat_fulamt_ownpay_amt, _ = decimal.NewFromFloat(treat_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  2040. if item.ChrgitmLv == "1" {
  2041. treat_claa_sunmfee, _ = decimal.NewFromFloat(treat_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2042. }
  2043. if item.ChrgitmLv == "2" {
  2044. treat_clab_amt, _ = decimal.NewFromFloat(treat_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2045. }
  2046. if item.ChrgitmLv == "3" {
  2047. treat_other_amt, _ = decimal.NewFromFloat(treat_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2048. }
  2049. }
  2050. if item.MedChrgitmType == "06" { //手术费
  2051. operationCostTotal, _ = decimal.NewFromFloat(operationCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2052. operationCostSelfTotal, _ = decimal.NewFromFloat(operationCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2053. operationCostPartSelfTotal, _ = decimal.NewFromFloat(operationCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2054. operation_fulamt_ownpay_amt, _ = decimal.NewFromFloat(operation_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  2055. if item.ChrgitmLv == "1" {
  2056. operation_claa_sunmfee, _ = decimal.NewFromFloat(operation_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2057. }
  2058. if item.ChrgitmLv == "2" {
  2059. operation_clab_amt, _ = decimal.NewFromFloat(operation_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2060. }
  2061. if item.ChrgitmLv == "3" {
  2062. operation_other_amt, _ = decimal.NewFromFloat(operation_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2063. }
  2064. }
  2065. if item.MedChrgitmType == "08" { //材料费
  2066. materialCostTotal, _ = decimal.NewFromFloat(materialCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2067. materialCostSelfTotal, _ = decimal.NewFromFloat(materialCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2068. materialCostPartSelfTotal, _ = decimal.NewFromFloat(materialCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2069. material_fulamt_ownpay_amt, _ = decimal.NewFromFloat(material_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  2070. if item.ChrgitmLv == "1" {
  2071. material_claa_sunmfee, _ = decimal.NewFromFloat(material_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2072. }
  2073. if item.ChrgitmLv == "2" {
  2074. material_clab_amt, _ = decimal.NewFromFloat(material_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2075. }
  2076. if item.ChrgitmLv == "3" {
  2077. material_other_amt, _ = decimal.NewFromFloat(material_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2078. }
  2079. }
  2080. if item.MedChrgitmType == "09" { //西药费
  2081. westernMedicineCostTotal, _ = decimal.NewFromFloat(westernMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2082. westernMedicineCostSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2083. westernMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2084. westernMedicine_fulamt_ownpay_amt, _ = decimal.NewFromFloat(westernMedicine_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  2085. if item.ChrgitmLv == "1" {
  2086. westernMedicine_claa_sunmfee, _ = decimal.NewFromFloat(westernMedicine_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2087. }
  2088. if item.ChrgitmLv == "2" {
  2089. westernMedicine_clab_amt, _ = decimal.NewFromFloat(westernMedicine_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2090. }
  2091. if item.ChrgitmLv == "3" {
  2092. westernMedicine_other_amt, _ = decimal.NewFromFloat(westernMedicine_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2093. }
  2094. }
  2095. if item.MedChrgitmType == "11" { //中成费
  2096. chineseTraditionalMedicineCostTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2097. chineseTraditionalMedicineCostSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2098. chineseTraditionalMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2099. chineseTraditional_fulamt_ownpay_amt, _ = decimal.NewFromFloat(chineseTraditional_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  2100. if item.ChrgitmLv == "1" {
  2101. chineseTraditional_claa_sunmfee, _ = decimal.NewFromFloat(chineseTraditional_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2102. }
  2103. if item.ChrgitmLv == "2" {
  2104. chineseTraditional_clab_amt, _ = decimal.NewFromFloat(chineseTraditional_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2105. }
  2106. if item.ChrgitmLv == "3" {
  2107. chineseTraditional_other_amt, _ = decimal.NewFromFloat(chineseTraditional_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2108. }
  2109. }
  2110. if item.MedChrgitmType == "14" { //其他费
  2111. otherCostTotal, _ = decimal.NewFromFloat(otherCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2112. otherCostSelfTotal, _ = decimal.NewFromFloat(otherCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2113. otherCostPartSelfTotal, _ = decimal.NewFromFloat(otherCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2114. other_fulamt_ownpay_amt, _ = decimal.NewFromFloat(other_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  2115. if item.ChrgitmLv == "1" {
  2116. other_claa_sunmfee, _ = decimal.NewFromFloat(other_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2117. }
  2118. if item.ChrgitmLv == "2" {
  2119. other_clab_amt, _ = decimal.NewFromFloat(other_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2120. }
  2121. if item.ChrgitmLv == "3" {
  2122. other_other_amt, _ = decimal.NewFromFloat(other_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2123. }
  2124. }
  2125. }
  2126. var iteminfoStructs []service.IteminfoStruct
  2127. if bedCostTotal != 0 {
  2128. iteminfo.MedChrgitm = "01"
  2129. iteminfo.FulamtOwnpayAmt = bed_fulamt_ownpay_amt
  2130. iteminfo.Amt = bedCostTotal
  2131. iteminfo.ClaaSumfee = bed_claa_sunmfee
  2132. iteminfo.ClabAmt = bed_clab_amt
  2133. iteminfo.OthAmt = bed_other_amt
  2134. iteminfoStructs = append(iteminfoStructs, iteminfo)
  2135. }
  2136. if checkCostTotal != 0 {
  2137. iteminfo.MedChrgitm = "03"
  2138. iteminfo.FulamtOwnpayAmt = check_fulamt_ownpay_amt
  2139. iteminfo.Amt = checkCostTotal
  2140. iteminfo.ClaaSumfee = check_claa_sunmfee
  2141. iteminfo.ClabAmt = check_clab_amt
  2142. iteminfo.OthAmt = check_other_amt
  2143. iteminfoStructs = append(iteminfoStructs, iteminfo)
  2144. }
  2145. if laboratoryCostTotal != 0 {
  2146. iteminfo.MedChrgitm = "04"
  2147. iteminfo.FulamtOwnpayAmt = laboratory_fulamt_ownpay_amt
  2148. iteminfo.Amt = laboratoryCostTotal
  2149. iteminfo.ClaaSumfee = laboratory_claa_sunmfee
  2150. iteminfo.ClabAmt = laboratory_clab_amt
  2151. iteminfo.OthAmt = laboratory_other_amt
  2152. iteminfoStructs = append(iteminfoStructs, iteminfo)
  2153. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  2154. }
  2155. if treatCostTotal != 0 {
  2156. iteminfo.MedChrgitm = "05"
  2157. iteminfo.FulamtOwnpayAmt = treat_fulamt_ownpay_amt
  2158. iteminfo.Amt = treatCostTotal
  2159. iteminfo.ClaaSumfee = treat_claa_sunmfee
  2160. iteminfo.ClabAmt = treat_clab_amt
  2161. iteminfo.OthAmt = treat_other_amt
  2162. iteminfoStructs = append(iteminfoStructs, iteminfo)
  2163. //(struct4101.IteminfoStruct, iteminfo)
  2164. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  2165. }
  2166. if operationCostTotal != 0 {
  2167. iteminfo.MedChrgitm = "06"
  2168. iteminfo.FulamtOwnpayAmt = bed_fulamt_ownpay_amt
  2169. iteminfo.Amt = operationCostTotal
  2170. iteminfo.ClaaSumfee = operation_claa_sunmfee
  2171. iteminfo.ClabAmt = operation_clab_amt
  2172. iteminfo.OthAmt = operation_other_amt
  2173. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  2174. iteminfoStructs = append(iteminfoStructs, iteminfo)
  2175. }
  2176. if materialCostTotal != 0 {
  2177. iteminfo.MedChrgitm = "08"
  2178. iteminfo.FulamtOwnpayAmt = material_fulamt_ownpay_amt
  2179. iteminfo.Amt = materialCostTotal
  2180. iteminfo.ClaaSumfee = material_claa_sunmfee
  2181. iteminfo.ClabAmt = material_clab_amt
  2182. iteminfo.OthAmt = material_other_amt
  2183. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  2184. iteminfoStructs = append(iteminfoStructs, iteminfo)
  2185. }
  2186. if westernMedicineCostTotal != 0 {
  2187. iteminfo.MedChrgitm = "09"
  2188. iteminfo.FulamtOwnpayAmt = westernMedicine_fulamt_ownpay_amt
  2189. iteminfo.Amt = westernMedicineCostTotal
  2190. iteminfo.ClaaSumfee = westernMedicine_claa_sunmfee
  2191. iteminfo.ClabAmt = westernMedicine_clab_amt
  2192. iteminfo.OthAmt = westernMedicine_other_amt
  2193. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  2194. iteminfoStructs = append(iteminfoStructs, iteminfo)
  2195. }
  2196. if chineseTraditionalMedicineCostTotal != 0 {
  2197. iteminfo.MedChrgitm = "11"
  2198. iteminfo.FulamtOwnpayAmt = westernMedicine_fulamt_ownpay_amt
  2199. iteminfo.Amt = westernMedicineCostTotal
  2200. iteminfo.ClaaSumfee = westernMedicine_claa_sunmfee
  2201. iteminfo.ClabAmt = westernMedicine_clab_amt
  2202. iteminfo.OthAmt = westernMedicine_other_amt
  2203. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  2204. iteminfoStructs = append(iteminfoStructs, iteminfo)
  2205. }
  2206. if otherCostTotal != 0 {
  2207. iteminfo.MedChrgitm = "14"
  2208. iteminfo.FulamtOwnpayAmt = other_fulamt_ownpay_amt
  2209. iteminfo.Amt = otherCostTotal
  2210. iteminfo.ClaaSumfee = other_claa_sunmfee
  2211. iteminfo.ClabAmt = other_clab_amt
  2212. iteminfo.OthAmt = other_other_amt
  2213. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  2214. iteminfoStructs = append(iteminfoStructs, iteminfo)
  2215. }
  2216. struct4101.IteminfoStruct = iteminfoStructs
  2217. struct4101.Ntly = "中国"
  2218. struct4101.AdmCaty = "A03.06"
  2219. result := service.Gdyb4101(struct4101, miConfig.SecretKey, miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.UserOrgId)
  2220. fmt.Println(result)
  2221. var dat map[string]interface{}
  2222. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  2223. fmt.Println(dat)
  2224. } else {
  2225. fmt.Println(err)
  2226. }
  2227. userJSONBytes, _ := json.Marshal(dat)
  2228. var res ResultSeventeen
  2229. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  2230. utils.ErrorLog("解析失败:%v", err)
  2231. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2232. return
  2233. }
  2234. if res.Infcode != 0 {
  2235. c.ServeSuccessJSON(map[string]interface{}{
  2236. "failed_code": -10,
  2237. "msg": res.ErrMsg,
  2238. })
  2239. return
  2240. } else {
  2241. order.FaPiaoNumber = zero
  2242. order.FaPiaoCode = last_order.FaPiaoCode
  2243. service.UpdateOrder(order)
  2244. hisFundSettleListResult := &models.HisFundSettleListResult{
  2245. Number: res.Output.SetlListId,
  2246. Status: 1,
  2247. Ctime: time.Now().Unix(),
  2248. Mtime: time.Now().Unix(),
  2249. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  2250. IsUpload: 1,
  2251. OrderId: order_id,
  2252. }
  2253. service.CreateUploadRecord(hisFundSettleListResult)
  2254. c.ServeSuccessJSON(map[string]interface{}{
  2255. "msg": "上传成功",
  2256. "result": hisFundSettleListResult,
  2257. })
  2258. return
  2259. }
  2260. }
  2261. func (c *HisApiController) GetBatchSettleList() {
  2262. orders, _ := service.GetAllHisOrder(10106)
  2263. for _, item := range orders {
  2264. order_id := item.ID
  2265. order, _ := service.GetHisOrderByIDTwo(order_id)
  2266. roles, _ := service.GetDoctorListTwo(c.GetAdminUserInfo().CurrentOrgId)
  2267. his, _ := service.GetHisPatientByNumber(order.MdtrtId)
  2268. admin, _ := service.GetAdminUserByUserID(roles[0].AdminUserId)
  2269. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, 2495)
  2270. depart, _ := service.GetDepartMentDetail(curRoles.DepartmentId)
  2271. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  2272. if order.ID == 0 {
  2273. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisOrderNoExistParamWrong)
  2274. return
  2275. }
  2276. if his.BalanceAccountsType == 2 {
  2277. continue
  2278. }
  2279. struct4101 := service.Struct4101{
  2280. PsnNo: order.PsnNo,
  2281. MdtrtId: order.MdtrtId,
  2282. SetlId: order.SetlId,
  2283. PsnName: order.PsnName,
  2284. Gend: order.Gend,
  2285. Brdy: his.Brdy,
  2286. Age: his.Age,
  2287. Naty: order.Naty,
  2288. PatnCertType: "01",
  2289. Certno: order.Certno,
  2290. Prfs: "90",
  2291. ConerName: roles[0].UserName,
  2292. PatnRlts: "99",
  2293. ConerAddr: miConfig.OrgName,
  2294. ConerTel: admin.Mobile,
  2295. HiType: order.Insutype,
  2296. Insuplc: his.InsuplcAdmdvs,
  2297. MaindiagFlag: "1",
  2298. BillCode: order.FaPiaoCode,
  2299. BillNo: order.FaPiaoNumber,
  2300. BizSn: order.Number,
  2301. PsnSelfPay: order.PsnPartAmt,
  2302. PsnOwnPay: order.PsnPartAmt,
  2303. AcctPay: order.AcctPay,
  2304. PsnCashpay: order.PsnCashPay,
  2305. HiPaymtd: "1",
  2306. Hsorg: his.InsuplcAdmdvs,
  2307. HsorgOpter: his.InsuplcAdmdvs,
  2308. MedinsFillPsn: curRoles.UserName,
  2309. MedinsFillDept: depart.Name,
  2310. IptMedType: "2",
  2311. }
  2312. struct4101.SetlBegnDate = order.SetlTime
  2313. struct4101.SetlEndDate = order.SetlTime
  2314. //if order.SettleType == 1 {
  2315. // t := time.Unix(int64(order.SettleAccountsDate), 0)
  2316. // dateStr := t.Format("2006-01-02")
  2317. // struct4101.SetlBegnDate = dateStr
  2318. // struct4101.SetlEndDate = dateStr
  2319. //} else {
  2320. // t := time.Unix(int64(order.SettleStartTime), 0)
  2321. // t2 := time.Unix(int64(order.SettleEndTime), 0)
  2322. // dateStartStr := t.Format("2006-01-02")
  2323. // dateEndStr := t2.Format("2006-01-02")
  2324. // struct4101.SetlBegnDate = dateStartStr
  2325. // struct4101.SetlEndDate = dateEndStr
  2326. //}
  2327. var rf []CustomFundPay
  2328. json.Unmarshal([]byte(order.SetlDetail), &rf)
  2329. var tempFunPays []service.CustomStruct
  2330. var tempFunPay610100 service.CustomStruct
  2331. for _, item := range rf {
  2332. if item.FundPayType == "610100" {
  2333. tempFunPay610100.FundPayamt, _ = decimal.NewFromFloat(tempFunPay610100.FundPayamt).Add(decimal.NewFromFloat(item.FundPayamt)).Float64()
  2334. tempFunPay610100.FundPayType = item.FundPayType
  2335. } else {
  2336. var tempFunPay service.CustomStruct
  2337. tempFunPay.FundPayamt = item.FundPayamt
  2338. tempFunPay.FundPayType = item.FundPayType
  2339. tempFunPays = append(tempFunPays, tempFunPay)
  2340. }
  2341. }
  2342. tempFunPays = append(tempFunPays, tempFunPay610100)
  2343. struct4101.CustomStruct = tempFunPays
  2344. var tempDiaginfos []service.DiaginfoStructTwo
  2345. var tempOpspdiseinfo2 service.OpspdiseinfoStruct
  2346. var tempOpspdiseinfos []service.OpspdiseinfoStruct
  2347. diagnosis_ids := strings.Split(his.Diagnosis, ",")
  2348. var config []*models.HisXtDiagnoseConfig
  2349. for _, item := range diagnosis_ids {
  2350. id, _ := strconv.ParseInt(item, 10, 64)
  2351. diagnosisConfig, _ := service.FindDiagnoseById(id)
  2352. config = append(config, &diagnosisConfig)
  2353. }
  2354. for index, item := range config {
  2355. if index == 0 {
  2356. var tempDiaginfo service.DiaginfoStructTwo
  2357. tempDiaginfo.DiagCode = item.CountryCode
  2358. tempDiaginfo.DiagName = item.CountryContentName
  2359. tempDiaginfo.DiagType = "1"
  2360. tempDiaginfo.MaindiagFlag = "1"
  2361. tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  2362. } else {
  2363. var tempDiaginfo service.DiaginfoStructTwo
  2364. tempDiaginfo.DiagCode = item.CountryCode
  2365. tempDiaginfo.DiagName = item.CountryContentName
  2366. tempDiaginfo.DiagType = "2"
  2367. tempDiaginfo.MaindiagFlag = "0"
  2368. tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  2369. }
  2370. }
  2371. struct4101.Diseinfo = tempDiaginfos
  2372. sickConfigTwo, _ := service.FindSickById(his.SickType)
  2373. tempOpspdiseinfo2.DiagCode = sickConfigTwo.ContentCode
  2374. tempOpspdiseinfo2.DiagName = sickConfigTwo.CountryContentName
  2375. tempOpspdiseinfo2.OprnOprtCode = ""
  2376. tempOpspdiseinfo2.OprnOprtName = ""
  2377. tempOpspdiseinfos = append(tempOpspdiseinfos, tempOpspdiseinfo2)
  2378. struct4101.OpspdiseinfoStruct = tempOpspdiseinfos
  2379. var iteminfo service.IteminfoStruct
  2380. var bedCostTotal float64 = 0 //床位总费
  2381. var bedCostSelfTotal float64 = 0 //床位自费
  2382. var bedCostPartSelfTotal float64 = 0 //床位部分项目自费
  2383. var examineCostTotal float64 = 0 //诊查总费
  2384. var examineCostSelfTotal float64 = 0 //诊查自费
  2385. var examineCostPartSelfTotal float64 = 0 //诊查部分项目自费
  2386. var nursingCostTotal float64 = 0 //护理总费
  2387. var nursingCostSelfTotal float64 = 0 //护理自费
  2388. var nursingCostPartSelfTotal float64 = 0 //护理部分项目自费
  2389. var chineseMedicineCostTotal float64 = 0 //中成药
  2390. var chineseMedicineCostSelfTotal float64 = 0 //中成药
  2391. var chineseMedicineCostPartSelfTotal float64 = 0 //中成药
  2392. var commonlyTreatmentCostTotal float64 = 0 //一般诊疗费
  2393. var commonlyTreatmentCostSelfTotal float64 = 0 //一般诊疗费
  2394. var commonlyTreatmentCostPartSelfTotal float64 = 0 //一般诊疗费
  2395. var registerCostTotal float64 = 0 //一般诊疗费
  2396. var registerCostSelfTotal float64 = 0 //一般诊疗费
  2397. var registerPartSelfTotal float64 = 0 //一般诊疗费
  2398. var operationCostTotal float64 = 0 //手术费
  2399. var operationCostSelfTotal float64 = 0 //手术费
  2400. var operationCostPartSelfTotal float64 = 0 //手术费
  2401. var otherCostTotal float64 = 0 //其他费用
  2402. var otherCostSelfTotal float64 = 0 //其他费用
  2403. var otherCostPartSelfTotal float64 = 0 //其他费用
  2404. var materialCostTotal float64 = 0 //材料费
  2405. var materialCostSelfTotal float64 = 0 //材料费
  2406. var materialCostPartSelfTotal float64 = 0 //材料费
  2407. var westernMedicineCostTotal float64 = 0 //西药费
  2408. var westernMedicineCostSelfTotal float64 = 0 //西药费
  2409. var westernMedicineCostPartSelfTotal float64 = 0 //西药费
  2410. var chineseTraditionalMedicineCostTotal float64 = 0 //中成药
  2411. var chineseTraditionalMedicineCostSelfTotal float64 = 0 //中成药
  2412. var chineseTraditionalMedicineCostPartSelfTotal float64 = 0 //中成药
  2413. var checkCostTotal float64 = 0 //检查费
  2414. var checkCostSelfTotal float64 = 0 //检查费
  2415. var checkCostPartSelfTotal float64 = 0 //检查费
  2416. var laboratoryCostTotal float64 = 0 //化验费
  2417. var laboratoryCostSelfTotal float64 = 0 //化验费
  2418. var laboratoryCostPartSelfTotal float64 = 0 //化验费
  2419. var treatCostTotal float64 = 0 //治疗费用
  2420. var treatCostSelfTotal float64 = 0 //治疗费用
  2421. var treatCostPartSelfTotal float64 = 0 //治疗费用
  2422. decimal.DivisionPrecision = 2
  2423. var bed_fulamt_ownpay_amt float64 = 0
  2424. var examine_fulamt_ownpay_amt float64 = 0
  2425. var nursing_fulamt_ownpay_amt float64 = 0
  2426. var chinese_medicine_fulamt_ownpay_amt float64 = 0
  2427. var commonly_treatment_fulamt_ownpay_amt float64 = 0
  2428. var register_fulamt_ownpay_amt float64 = 0
  2429. var operation_fulamt_ownpay_amt float64 = 0
  2430. var other_fulamt_ownpay_amt float64 = 0
  2431. var westernMedicine_fulamt_ownpay_amt float64 = 0
  2432. var chineseTraditional_fulamt_ownpay_amt float64 = 0
  2433. var check_fulamt_ownpay_amt float64 = 0
  2434. var material_fulamt_ownpay_amt float64 = 0
  2435. var laboratory_fulamt_ownpay_amt float64 = 0
  2436. var treat_fulamt_ownpay_amt float64 = 0
  2437. var bed_claa_sunmfee float64 = 0
  2438. var bed_clab_amt float64 = 0
  2439. var bed_other_amt float64 = 0
  2440. var examine_claa_sunmfee float64 = 0
  2441. var examine_clab_amt float64 = 0
  2442. var examine_other_amt float64 = 0
  2443. var nursing_claa_sunmfee float64 = 0
  2444. var nursing_clab_amt float64 = 0
  2445. var nursing_other_amt float64 = 0
  2446. var chinese_medicine_claa_sunmfee float64 = 0
  2447. var chinese_medicine_clab_amt float64 = 0
  2448. var chinese_medicine_other_amt float64 = 0
  2449. var commonly_treatment_claa_sunmfee float64 = 0
  2450. var commonly_treatment_clab_amt float64 = 0
  2451. var commonly_treatment_other_amt float64 = 0
  2452. var operation_claa_sunmfee float64 = 0
  2453. var operation_clab_amt float64 = 0
  2454. var operation_other_amt float64 = 0
  2455. var other_claa_sunmfee float64 = 0
  2456. var other_clab_amt float64 = 0
  2457. var other_other_amt float64 = 0
  2458. var westernMedicine_claa_sunmfee float64 = 0
  2459. var westernMedicine_clab_amt float64 = 0
  2460. var westernMedicine_other_amt float64 = 0
  2461. var chineseTraditional_claa_sunmfee float64 = 0
  2462. var chineseTraditional_clab_amt float64 = 0
  2463. var chineseTraditional_other_amt float64 = 0
  2464. var check_claa_sunmfee float64 = 0
  2465. var check_clab_amt float64 = 0
  2466. var check_other_amt float64 = 0
  2467. var material_claa_sunmfee float64 = 0
  2468. var material_clab_amt float64 = 0
  2469. var material_other_amt float64 = 0
  2470. var laboratory_claa_sunmfee float64 = 0
  2471. var laboratory_clab_amt float64 = 0
  2472. var laboratory_other_amt float64 = 0
  2473. var treat_claa_sunmfee float64 = 0
  2474. var treat_clab_amt float64 = 0
  2475. var treat_other_amt float64 = 0
  2476. var register_claa_sunmfee float64 = 0
  2477. var register_clab_amt float64 = 0
  2478. var register_other_amt float64 = 0
  2479. for _, item := range order.HisOrderInfo {
  2480. if item.MedChrgitmType == "01" { //床位费
  2481. bedCostTotal, _ = decimal.NewFromFloat(bedCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2482. bedCostSelfTotal, _ = decimal.NewFromFloat(bedCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2483. bedCostPartSelfTotal, _ = decimal.NewFromFloat(bedCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2484. bed_fulamt_ownpay_amt, _ = decimal.NewFromFloat(bed_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  2485. if item.ChrgitmLv == "1" {
  2486. bed_claa_sunmfee, _ = decimal.NewFromFloat(bed_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2487. }
  2488. if item.ChrgitmLv == "2" {
  2489. bed_clab_amt, _ = decimal.NewFromFloat(bed_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2490. }
  2491. if item.ChrgitmLv == "3" {
  2492. bed_other_amt, _ = decimal.NewFromFloat(bed_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2493. }
  2494. }
  2495. if item.MedChrgitmType == "02" { //诊查
  2496. examineCostTotal, _ = decimal.NewFromFloat(examineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2497. examineCostSelfTotal, _ = decimal.NewFromFloat(examineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2498. examineCostPartSelfTotal, _ = decimal.NewFromFloat(examineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2499. examine_fulamt_ownpay_amt, _ = decimal.NewFromFloat(examine_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  2500. if item.ChrgitmLv == "1" {
  2501. examine_claa_sunmfee, _ = decimal.NewFromFloat(examine_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2502. }
  2503. if item.ChrgitmLv == "2" {
  2504. examine_clab_amt, _ = decimal.NewFromFloat(examine_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2505. }
  2506. if item.ChrgitmLv == "3" {
  2507. examine_other_amt, _ = decimal.NewFromFloat(examine_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2508. }
  2509. }
  2510. if item.MedChrgitmType == "03" { //检查费
  2511. checkCostTotal, _ = decimal.NewFromFloat(checkCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2512. checkCostSelfTotal, _ = decimal.NewFromFloat(checkCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2513. checkCostPartSelfTotal, _ = decimal.NewFromFloat(checkCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2514. check_fulamt_ownpay_amt, _ = decimal.NewFromFloat(check_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  2515. if item.ChrgitmLv == "1" {
  2516. check_claa_sunmfee, _ = decimal.NewFromFloat(check_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2517. }
  2518. if item.ChrgitmLv == "2" {
  2519. check_clab_amt, _ = decimal.NewFromFloat(check_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2520. }
  2521. if item.ChrgitmLv == "3" {
  2522. check_other_amt, _ = decimal.NewFromFloat(check_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2523. }
  2524. }
  2525. if item.MedChrgitmType == "04" { //化验费
  2526. laboratoryCostTotal, _ = decimal.NewFromFloat(laboratoryCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2527. laboratoryCostSelfTotal, _ = decimal.NewFromFloat(laboratoryCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2528. laboratoryCostPartSelfTotal, _ = decimal.NewFromFloat(laboratoryCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2529. laboratory_fulamt_ownpay_amt, _ = decimal.NewFromFloat(laboratory_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  2530. if item.ChrgitmLv == "1" {
  2531. laboratory_claa_sunmfee, _ = decimal.NewFromFloat(laboratory_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2532. }
  2533. if item.ChrgitmLv == "2" {
  2534. laboratory_clab_amt, _ = decimal.NewFromFloat(laboratory_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2535. }
  2536. if item.ChrgitmLv == "3" {
  2537. laboratory_other_amt, _ = decimal.NewFromFloat(laboratory_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2538. }
  2539. }
  2540. if item.MedChrgitmType == "05" { //治疗费
  2541. treatCostTotal, _ = decimal.NewFromFloat(treatCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2542. treatCostSelfTotal, _ = decimal.NewFromFloat(treatCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2543. treatCostPartSelfTotal, _ = decimal.NewFromFloat(treatCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2544. treat_fulamt_ownpay_amt, _ = decimal.NewFromFloat(treat_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  2545. if item.ChrgitmLv == "1" {
  2546. treat_claa_sunmfee, _ = decimal.NewFromFloat(treat_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2547. }
  2548. if item.ChrgitmLv == "2" {
  2549. treat_clab_amt, _ = decimal.NewFromFloat(treat_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2550. }
  2551. if item.ChrgitmLv == "3" {
  2552. treat_other_amt, _ = decimal.NewFromFloat(treat_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2553. }
  2554. }
  2555. if item.MedChrgitmType == "06" { //手术费
  2556. operationCostTotal, _ = decimal.NewFromFloat(operationCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2557. operationCostSelfTotal, _ = decimal.NewFromFloat(operationCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2558. operationCostPartSelfTotal, _ = decimal.NewFromFloat(operationCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2559. operation_fulamt_ownpay_amt, _ = decimal.NewFromFloat(operation_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  2560. if item.ChrgitmLv == "1" {
  2561. operation_claa_sunmfee, _ = decimal.NewFromFloat(operation_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2562. }
  2563. if item.ChrgitmLv == "2" {
  2564. operation_clab_amt, _ = decimal.NewFromFloat(operation_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2565. }
  2566. if item.ChrgitmLv == "3" {
  2567. operation_other_amt, _ = decimal.NewFromFloat(operation_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2568. }
  2569. }
  2570. if item.MedChrgitmType == "07" { //手术费
  2571. nursingCostTotal, _ = decimal.NewFromFloat(nursingCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2572. nursingCostSelfTotal, _ = decimal.NewFromFloat(nursingCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2573. nursingCostPartSelfTotal, _ = decimal.NewFromFloat(nursingCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2574. nursing_fulamt_ownpay_amt, _ = decimal.NewFromFloat(nursing_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  2575. if item.ChrgitmLv == "1" {
  2576. nursing_claa_sunmfee, _ = decimal.NewFromFloat(nursing_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2577. }
  2578. if item.ChrgitmLv == "2" {
  2579. nursing_clab_amt, _ = decimal.NewFromFloat(nursing_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2580. }
  2581. if item.ChrgitmLv == "3" {
  2582. nursing_other_amt, _ = decimal.NewFromFloat(nursing_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2583. }
  2584. }
  2585. if item.MedChrgitmType == "08" { //材料费
  2586. materialCostTotal, _ = decimal.NewFromFloat(materialCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2587. materialCostSelfTotal, _ = decimal.NewFromFloat(materialCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2588. materialCostPartSelfTotal, _ = decimal.NewFromFloat(materialCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2589. material_fulamt_ownpay_amt, _ = decimal.NewFromFloat(material_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  2590. if item.ChrgitmLv == "1" {
  2591. material_claa_sunmfee, _ = decimal.NewFromFloat(material_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2592. }
  2593. if item.ChrgitmLv == "2" {
  2594. material_clab_amt, _ = decimal.NewFromFloat(material_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2595. }
  2596. if item.ChrgitmLv == "3" {
  2597. material_other_amt, _ = decimal.NewFromFloat(material_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2598. }
  2599. }
  2600. if item.MedChrgitmType == "09" { //西药费
  2601. westernMedicineCostTotal, _ = decimal.NewFromFloat(westernMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2602. westernMedicineCostSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2603. westernMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2604. westernMedicine_fulamt_ownpay_amt, _ = decimal.NewFromFloat(westernMedicine_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  2605. if item.ChrgitmLv == "1" {
  2606. westernMedicine_claa_sunmfee, _ = decimal.NewFromFloat(westernMedicine_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2607. }
  2608. if item.ChrgitmLv == "2" {
  2609. westernMedicine_clab_amt, _ = decimal.NewFromFloat(westernMedicine_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2610. }
  2611. if item.ChrgitmLv == "3" {
  2612. westernMedicine_other_amt, _ = decimal.NewFromFloat(westernMedicine_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2613. }
  2614. }
  2615. if item.MedChrgitmType == "10" { //中药饮片
  2616. chineseMedicineCostTotal, _ = decimal.NewFromFloat(chineseMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2617. chineseMedicineCostSelfTotal, _ = decimal.NewFromFloat(chineseMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2618. chineseMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(chineseMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2619. chinese_medicine_fulamt_ownpay_amt, _ = decimal.NewFromFloat(chinese_medicine_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  2620. if item.ChrgitmLv == "1" {
  2621. chinese_medicine_claa_sunmfee, _ = decimal.NewFromFloat(chinese_medicine_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2622. }
  2623. if item.ChrgitmLv == "2" {
  2624. chinese_medicine_clab_amt, _ = decimal.NewFromFloat(chinese_medicine_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2625. }
  2626. if item.ChrgitmLv == "3" {
  2627. chinese_medicine_other_amt, _ = decimal.NewFromFloat(chinese_medicine_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2628. }
  2629. }
  2630. if item.MedChrgitmType == "11" { //中成费
  2631. chineseTraditionalMedicineCostTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2632. chineseTraditionalMedicineCostSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2633. chineseTraditionalMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2634. chineseTraditional_fulamt_ownpay_amt, _ = decimal.NewFromFloat(chineseTraditional_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  2635. if item.ChrgitmLv == "1" {
  2636. chineseTraditional_claa_sunmfee, _ = decimal.NewFromFloat(chineseTraditional_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2637. }
  2638. if item.ChrgitmLv == "2" {
  2639. chineseTraditional_clab_amt, _ = decimal.NewFromFloat(chineseTraditional_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2640. }
  2641. if item.ChrgitmLv == "3" {
  2642. chineseTraditional_other_amt, _ = decimal.NewFromFloat(chineseTraditional_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2643. }
  2644. }
  2645. if item.MedChrgitmType == "12" { //中成费
  2646. commonlyTreatmentCostTotal, _ = decimal.NewFromFloat(commonlyTreatmentCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2647. commonlyTreatmentCostSelfTotal, _ = decimal.NewFromFloat(commonlyTreatmentCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2648. commonlyTreatmentCostPartSelfTotal, _ = decimal.NewFromFloat(commonlyTreatmentCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2649. commonly_treatment_fulamt_ownpay_amt, _ = decimal.NewFromFloat(commonly_treatment_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  2650. if item.ChrgitmLv == "1" {
  2651. commonly_treatment_claa_sunmfee, _ = decimal.NewFromFloat(commonly_treatment_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2652. }
  2653. if item.ChrgitmLv == "2" {
  2654. commonly_treatment_clab_amt, _ = decimal.NewFromFloat(commonly_treatment_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2655. }
  2656. if item.ChrgitmLv == "3" {
  2657. commonly_treatment_other_amt, _ = decimal.NewFromFloat(commonly_treatment_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2658. }
  2659. }
  2660. if item.MedChrgitmType == "13" { //中成费
  2661. registerCostTotal, _ = decimal.NewFromFloat(registerCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2662. registerCostSelfTotal, _ = decimal.NewFromFloat(registerCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2663. registerPartSelfTotal, _ = decimal.NewFromFloat(registerPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2664. register_fulamt_ownpay_amt, _ = decimal.NewFromFloat(register_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  2665. if item.ChrgitmLv == "1" {
  2666. register_claa_sunmfee, _ = decimal.NewFromFloat(register_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2667. }
  2668. if item.ChrgitmLv == "2" {
  2669. register_clab_amt, _ = decimal.NewFromFloat(register_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2670. }
  2671. if item.ChrgitmLv == "3" {
  2672. register_other_amt, _ = decimal.NewFromFloat(register_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2673. }
  2674. }
  2675. if item.MedChrgitmType == "14" { //其他费
  2676. otherCostTotal, _ = decimal.NewFromFloat(otherCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2677. otherCostSelfTotal, _ = decimal.NewFromFloat(otherCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2678. otherCostPartSelfTotal, _ = decimal.NewFromFloat(otherCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2679. other_fulamt_ownpay_amt, _ = decimal.NewFromFloat(other_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  2680. if item.ChrgitmLv == "1" {
  2681. other_claa_sunmfee, _ = decimal.NewFromFloat(other_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2682. }
  2683. if item.ChrgitmLv == "2" {
  2684. other_clab_amt, _ = decimal.NewFromFloat(other_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2685. }
  2686. if item.ChrgitmLv == "3" {
  2687. other_other_amt, _ = decimal.NewFromFloat(other_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2688. }
  2689. }
  2690. }
  2691. var iteminfoStructs []service.IteminfoStruct
  2692. if bedCostTotal != 0 {
  2693. iteminfo.MedChrgitm = "01"
  2694. iteminfo.FulamtOwnpayAmt = bed_fulamt_ownpay_amt
  2695. iteminfo.Amt = bedCostTotal
  2696. iteminfo.ClaaSumfee = bed_claa_sunmfee
  2697. iteminfo.ClabAmt = bed_clab_amt
  2698. iteminfo.OthAmt = bed_other_amt
  2699. iteminfoStructs = append(iteminfoStructs, iteminfo)
  2700. }
  2701. if examineCostTotal != 0 {
  2702. iteminfo.MedChrgitm = "02"
  2703. iteminfo.FulamtOwnpayAmt = examine_fulamt_ownpay_amt
  2704. iteminfo.Amt = examineCostTotal
  2705. iteminfo.ClaaSumfee = examine_claa_sunmfee
  2706. iteminfo.ClabAmt = examine_clab_amt
  2707. iteminfo.OthAmt = examine_other_amt
  2708. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  2709. iteminfoStructs = append(iteminfoStructs, iteminfo)
  2710. }
  2711. if checkCostTotal != 0 {
  2712. iteminfo.MedChrgitm = "03"
  2713. iteminfo.FulamtOwnpayAmt = check_fulamt_ownpay_amt
  2714. iteminfo.Amt = checkCostTotal
  2715. iteminfo.ClaaSumfee = check_claa_sunmfee
  2716. iteminfo.ClabAmt = check_clab_amt
  2717. iteminfo.OthAmt = check_other_amt
  2718. iteminfoStructs = append(iteminfoStructs, iteminfo)
  2719. }
  2720. if laboratoryCostTotal != 0 {
  2721. iteminfo.MedChrgitm = "04"
  2722. iteminfo.FulamtOwnpayAmt = laboratory_fulamt_ownpay_amt
  2723. iteminfo.Amt = laboratoryCostTotal
  2724. iteminfo.ClaaSumfee = laboratory_claa_sunmfee
  2725. iteminfo.ClabAmt = laboratory_clab_amt
  2726. iteminfo.OthAmt = laboratory_other_amt
  2727. iteminfoStructs = append(iteminfoStructs, iteminfo)
  2728. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  2729. }
  2730. if treatCostTotal != 0 {
  2731. iteminfo.MedChrgitm = "05"
  2732. iteminfo.FulamtOwnpayAmt = treat_fulamt_ownpay_amt
  2733. iteminfo.Amt = treatCostTotal
  2734. iteminfo.ClaaSumfee = treat_claa_sunmfee
  2735. iteminfo.ClabAmt = treat_clab_amt
  2736. iteminfo.OthAmt = treat_other_amt
  2737. iteminfoStructs = append(iteminfoStructs, iteminfo)
  2738. //(struct4101.IteminfoStruct, iteminfo)
  2739. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  2740. }
  2741. if operationCostTotal != 0 {
  2742. iteminfo.MedChrgitm = "06"
  2743. iteminfo.FulamtOwnpayAmt = bed_fulamt_ownpay_amt
  2744. iteminfo.Amt = operationCostTotal
  2745. iteminfo.ClaaSumfee = operation_claa_sunmfee
  2746. iteminfo.ClabAmt = operation_clab_amt
  2747. iteminfo.OthAmt = operation_other_amt
  2748. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  2749. iteminfoStructs = append(iteminfoStructs, iteminfo)
  2750. }
  2751. if nursingCostTotal != 0 {
  2752. iteminfo.MedChrgitm = "07"
  2753. iteminfo.FulamtOwnpayAmt = nursing_fulamt_ownpay_amt
  2754. iteminfo.Amt = nursingCostTotal
  2755. iteminfo.ClaaSumfee = nursing_claa_sunmfee
  2756. iteminfo.ClabAmt = nursing_clab_amt
  2757. iteminfo.OthAmt = nursing_other_amt
  2758. iteminfoStructs = append(iteminfoStructs, iteminfo)
  2759. }
  2760. if materialCostTotal != 0 {
  2761. iteminfo.MedChrgitm = "08"
  2762. iteminfo.FulamtOwnpayAmt = material_fulamt_ownpay_amt
  2763. iteminfo.Amt = materialCostTotal
  2764. iteminfo.ClaaSumfee = material_claa_sunmfee
  2765. iteminfo.ClabAmt = material_clab_amt
  2766. iteminfo.OthAmt = material_other_amt
  2767. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  2768. iteminfoStructs = append(iteminfoStructs, iteminfo)
  2769. }
  2770. if westernMedicineCostTotal != 0 {
  2771. iteminfo.MedChrgitm = "09"
  2772. iteminfo.FulamtOwnpayAmt = westernMedicine_fulamt_ownpay_amt
  2773. iteminfo.Amt = westernMedicineCostTotal
  2774. iteminfo.ClaaSumfee = westernMedicine_claa_sunmfee
  2775. iteminfo.ClabAmt = westernMedicine_clab_amt
  2776. iteminfo.OthAmt = westernMedicine_other_amt
  2777. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  2778. iteminfoStructs = append(iteminfoStructs, iteminfo)
  2779. }
  2780. if chineseMedicineCostTotal != 0 {
  2781. iteminfo.MedChrgitm = "10"
  2782. iteminfo.FulamtOwnpayAmt = chinese_medicine_fulamt_ownpay_amt
  2783. iteminfo.Amt = chineseMedicineCostTotal
  2784. iteminfo.ClaaSumfee = chinese_medicine_claa_sunmfee
  2785. iteminfo.ClabAmt = chinese_medicine_clab_amt
  2786. iteminfo.OthAmt = chinese_medicine_other_amt
  2787. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  2788. iteminfoStructs = append(iteminfoStructs, iteminfo)
  2789. }
  2790. if chineseTraditionalMedicineCostTotal != 0 {
  2791. iteminfo.MedChrgitm = "11"
  2792. iteminfo.FulamtOwnpayAmt = westernMedicine_fulamt_ownpay_amt
  2793. iteminfo.Amt = westernMedicineCostTotal
  2794. iteminfo.ClaaSumfee = westernMedicine_claa_sunmfee
  2795. iteminfo.ClabAmt = westernMedicine_clab_amt
  2796. iteminfo.OthAmt = westernMedicine_other_amt
  2797. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  2798. iteminfoStructs = append(iteminfoStructs, iteminfo)
  2799. }
  2800. if commonlyTreatmentCostTotal != 0 {
  2801. iteminfo.MedChrgitm = "12"
  2802. iteminfo.FulamtOwnpayAmt = commonly_treatment_fulamt_ownpay_amt
  2803. iteminfo.Amt = commonlyTreatmentCostTotal
  2804. iteminfo.ClaaSumfee = commonly_treatment_claa_sunmfee
  2805. iteminfo.ClabAmt = commonly_treatment_clab_amt
  2806. iteminfo.OthAmt = commonly_treatment_other_amt
  2807. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  2808. iteminfoStructs = append(iteminfoStructs, iteminfo)
  2809. }
  2810. if registerCostTotal != 0 {
  2811. iteminfo.MedChrgitm = "13"
  2812. iteminfo.FulamtOwnpayAmt = register_fulamt_ownpay_amt
  2813. iteminfo.Amt = registerCostTotal
  2814. iteminfo.ClaaSumfee = register_claa_sunmfee
  2815. iteminfo.ClabAmt = register_clab_amt
  2816. iteminfo.OthAmt = register_other_amt
  2817. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  2818. iteminfoStructs = append(iteminfoStructs, iteminfo)
  2819. }
  2820. if otherCostTotal != 0 {
  2821. iteminfo.MedChrgitm = "14"
  2822. iteminfo.FulamtOwnpayAmt = other_fulamt_ownpay_amt
  2823. iteminfo.Amt = otherCostTotal
  2824. iteminfo.ClaaSumfee = other_claa_sunmfee
  2825. iteminfo.ClabAmt = other_clab_amt
  2826. iteminfo.OthAmt = other_other_amt
  2827. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  2828. iteminfoStructs = append(iteminfoStructs, iteminfo)
  2829. }
  2830. struct4101.IteminfoStruct = iteminfoStructs
  2831. struct4101.Ntly = "中国"
  2832. struct4101.AdmCaty = "A03.06"
  2833. result := service.Gdyb4101(struct4101, miConfig.SecretKey, miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, c.GetAdminUserInfo().CurrentOrgId)
  2834. fmt.Println(result)
  2835. var dat map[string]interface{}
  2836. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  2837. fmt.Println(dat)
  2838. } else {
  2839. fmt.Println(err)
  2840. }
  2841. userJSONBytes, _ := json.Marshal(dat)
  2842. var res ResultSeventeen
  2843. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  2844. utils.ErrorLog("解析失败:%v", err)
  2845. //c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2846. adminUser := c.GetAdminUserInfo()
  2847. errlog := &models.HisOrderError{
  2848. UserOrgId: adminUser.CurrentOrgId,
  2849. Ctime: time.Now().Unix(),
  2850. Mtime: time.Now().Unix(),
  2851. ErrMsg: res.ErrMsg + "解析失败",
  2852. Status: 1,
  2853. PatientId: order_id,
  2854. Stage: 10106,
  2855. }
  2856. service.CreateErrMsgLog(errlog)
  2857. continue
  2858. }
  2859. if res.Infcode != 0 {
  2860. adminUser := c.GetAdminUserInfo()
  2861. errlog := &models.HisOrderError{
  2862. UserOrgId: adminUser.CurrentOrgId,
  2863. Ctime: time.Now().Unix(),
  2864. Mtime: time.Now().Unix(),
  2865. ErrMsg: res.ErrMsg,
  2866. Status: 1,
  2867. PatientId: order_id,
  2868. Stage: 10106,
  2869. }
  2870. service.CreateErrMsgLog(errlog)
  2871. continue
  2872. } else {
  2873. hisFundSettleListResult := &models.HisFundSettleListResult{
  2874. Number: res.Output.SetlListId,
  2875. Status: 1,
  2876. Ctime: time.Now().Unix(),
  2877. Mtime: time.Now().Unix(),
  2878. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  2879. IsUpload: 1,
  2880. OrderId: order_id,
  2881. }
  2882. service.CreateUploadRecord(hisFundSettleListResult)
  2883. continue
  2884. }
  2885. }
  2886. }
  2887. func (c *HisApiController) GetOrgInfo() {
  2888. miConfig, _ := service.FindMedicalInsuranceInfo(4)
  2889. service.Gdyb1201("", miConfig.OrgName, "1122", miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, 1, "")
  2890. }
  2891. func (c *HisApiController) GetHisPatientInfo() {
  2892. medical_insurance_card := c.GetString("medical_insurance_card")
  2893. id_card_type, _ := c.GetInt64("id_card_type")
  2894. id_card := c.GetString("id_card")
  2895. adminInfo := c.GetAdminUserInfo()
  2896. config, _ := service.GetMedicalInsuranceConfig(adminInfo.CurrentOrgId)
  2897. miConfig, _ := service.FindMedicalInsuranceInfo(adminInfo.CurrentOrgId)
  2898. appRole, _ := service.GetAppRole(adminInfo.CurrentOrgId)
  2899. IdCardNo := ""
  2900. if id_card_type == 1 {
  2901. IdCardNo = medical_insurance_card
  2902. } else if id_card_type == 2 {
  2903. IdCardNo = id_card
  2904. }
  2905. if config.IsOpen == 1 {
  2906. 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
  2907. resp, requestErr := http.Get(api)
  2908. if requestErr != nil {
  2909. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2910. return
  2911. }
  2912. defer resp.Body.Close()
  2913. body, ioErr := ioutil.ReadAll(resp.Body)
  2914. if ioErr != nil {
  2915. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  2916. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2917. return
  2918. }
  2919. var respJSON map[string]interface{}
  2920. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  2921. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  2922. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2923. return
  2924. }
  2925. userJSON := respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  2926. userJSONBytes, _ := json.Marshal(userJSON)
  2927. var res ResultTwo
  2928. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  2929. utils.ErrorLog("解析失败:%v", err)
  2930. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2931. return
  2932. }
  2933. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  2934. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  2935. infoStr := string(Iinfos)
  2936. idetinfoStr := string(Idetinfos)
  2937. if res.Infcode == 0 {
  2938. his := models.VMHisPatient{
  2939. Status: 1,
  2940. Ctime: time.Now().Unix(),
  2941. Mtime: time.Now().Unix(),
  2942. PsnNo: res.Output.Baseinfo.PsnNo,
  2943. PsnCertType: res.Output.Baseinfo.PsnCertType,
  2944. Certno: res.Output.Baseinfo.Certno,
  2945. PsnName: res.Output.Baseinfo.PsnName,
  2946. Gend: res.Output.Baseinfo.Gend,
  2947. Naty: res.Output.Baseinfo.Naty,
  2948. Brdy: res.Output.Baseinfo.Brdy,
  2949. Age: res.Output.Baseinfo.Age,
  2950. Iinfo: infoStr,
  2951. Idetinfo: idetinfoStr,
  2952. UserOrgId: adminInfo.CurrentOrgId,
  2953. IsReturn: 1,
  2954. IdCardType: id_card_type,
  2955. }
  2956. c.ServeSuccessJSON(map[string]interface{}{
  2957. "info": his,
  2958. })
  2959. } else {
  2960. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  2961. return
  2962. }
  2963. }
  2964. }
  2965. //func GetBasBaseInfo() (jsonStr string, err error) {
  2966. //
  2967. // handle := syscall.NewLazyDLL("SSCard.dll")
  2968. // add := handle.NewProc("ReadCardBas")
  2969. // str := make([]byte, 1024)
  2970. // str1 := make([]byte, 1024)
  2971. // ret, _, _ := add.Call((uintptr)(unsafe.Pointer(&str[0])), IntPtr(1024), (uintptr)(unsafe.Pointer(&str1[0])), IntPtr(1024))
  2972. // fmt.Println(ConvertToString(string(str), "gbk", "utf-8"))
  2973. //
  2974. // fmt.Println(ConvertToString(string(str1), "gbk", "utf-8"))
  2975. //
  2976. // fmt.Println("> Add(4,5)的结果为:", ret)
  2977. // handle.Release()
  2978. //
  2979. // return "", nil
  2980. //
  2981. //}
  2982. //func GetQRBaseInfo() (jsonStr string, err error) {
  2983. // handle := syscall.LoadDLL("SSCard.dll")
  2984. // ReadCardBas := handle.FindProc("GetQRBase")
  2985. //
  2986. // str := make([]byte, 256)
  2987. // str1 := make([]byte, 256)
  2988. // r, _, _ := ReadCardBas.Call((uintptr)(unsafe.Pointer(&str[0])), IntPtr(1024), (uintptr)(unsafe.Pointer(&str1[0])), IntPtr(1024))
  2989. //
  2990. // fmt.Println(string(str))
  2991. // fmt.Println(r)
  2992. // return string(str), nil
  2993. //}
  2994. //func CardInit() int {
  2995. // DllTestDef := syscall.MustLoadDLL("SSCard.dll")
  2996. // add := DllTestDef.MustFindProc("Init")
  2997. // ret, _, err := add.Call(StrPtr("http://igb.hsa.gdgov.cn/gdyb_inf/poc/api/card/initDll"), StrPtr("440200"))
  2998. // if err != nil {
  2999. // fmt.Println("SSCard的运算结果为:", ret)
  3000. // }
  3001. // result := int(ret)
  3002. // return result
  3003. //}
  3004. //func CardInit() int {
  3005. // ret, _, err := add.Call(StrPtr("http://igb.hsa.gdgov.cn/gdyb_inf/poc/api/card/initDll"), StrPtr("440200"))
  3006. // if err != nil {
  3007. // fmt.Println("SSCard的运算结果为:", ret)
  3008. // }
  3009. // fmt.Println(err)
  3010. // result := int(ret)
  3011. // return result
  3012. //}
  3013. func IntPtr(n int) uintptr {
  3014. return uintptr(n)
  3015. }
  3016. func StrPtr(s string) uintptr {
  3017. return uintptr(unsafe.Pointer(syscall.StringBytePtr(s)))
  3018. }
  3019. type Result2001 struct {
  3020. Cainfo interface{} `json:"cainfo"`
  3021. ErrMsg string `json:"err_msg"`
  3022. InfRefmsgid string `json:"inf_refmsgid"`
  3023. Infcode int64 `json:"infcode"`
  3024. Output struct {
  3025. Trtinfo struct {
  3026. PsnNo string `json:"psn_no"`
  3027. TrtChkType string `json:"trt_chk_type"`
  3028. FundPayType string `json:"fund_pay_type"`
  3029. TrtEnjymntFlag string `json:"trt_enjymnt_flag"`
  3030. Begndate string `json:"begndate"`
  3031. Enddate string `json:"enddate"`
  3032. TrtChkRslt string `json:"trt_chk_rslt"`
  3033. } `json:"trtinfo"`
  3034. } `json:"output"`
  3035. RefmsgTime string `json:"refmsg_time"`
  3036. RespondTime string `json:"respond_time"`
  3037. Signtype interface{} `json:"signtype"`
  3038. WarnMsg interface{} `json:"warn_msg"`
  3039. }
  3040. type Result2001Org10265 struct {
  3041. Cainfo interface{} `json:"cainfo"`
  3042. ErrMsg string `json:"err_msg"`
  3043. InfRefmsgid string `json:"inf_refmsgid"`
  3044. Infcode string `json:"infcode"`
  3045. Output struct {
  3046. Trtinfo struct {
  3047. PsnNo string `json:"psn_no"`
  3048. TrtChkType string `json:"trt_chk_type"`
  3049. FundPayType string `json:"fund_pay_type"`
  3050. TrtEnjymntFlag string `json:"trt_enjymnt_flag"`
  3051. Begndate string `json:"begndate"`
  3052. Enddate string `json:"enddate"`
  3053. TrtChkRslt string `json:"trt_chk_rslt"`
  3054. } `json:"trtinfo"`
  3055. } `json:"output"`
  3056. RefmsgTime string `json:"refmsg_time"`
  3057. RespondTime string `json:"respond_time"`
  3058. Signtype interface{} `json:"signtype"`
  3059. WarnMsg interface{} `json:"warn_msg"`
  3060. }
  3061. type ResultTwo struct {
  3062. ErrMsg string `json:"err_msg"`
  3063. InfRefmsgid string `json:"inf_refmsgid"`
  3064. Infcode int64 `json:"infcode"`
  3065. Output struct {
  3066. Baseinfo struct {
  3067. Age float64 `json:"age"`
  3068. Brdy string `json:"brdy"`
  3069. Certno string `json:"certno"`
  3070. Gend string `json:"gend"`
  3071. Naty string `json:"naty"`
  3072. PsnCertType string `json:"psn_cert_type"`
  3073. PsnName string `json:"psn_name"`
  3074. PsnNo string `json:"psn_no"`
  3075. } `json:"baseinfo"`
  3076. Idetinfo []interface{} `json:"idetinfo"`
  3077. Iinfo []struct {
  3078. Balc float64 `json:"balc"`
  3079. CvlservFlag string `json:"cvlserv_flag"`
  3080. EmpName string `json:"emp_name"`
  3081. InsuplcAdmdvs string `json:"insuplc_admdvs"`
  3082. Insutype string `json:"insutype"`
  3083. PausInsuDansuplcAdmdvs string `json:"paus_insu_dansuplc_admdvs"`
  3084. PausInsuDate string `json:"paus_insu_date"`
  3085. PsnInsuDate string `json:"psn_insu_date"`
  3086. PsnInsuStas string `json:"psn_insu_stas"`
  3087. PsnType string `json:"psn_type"`
  3088. } `json:"insuinfo"`
  3089. } `json:"output"`
  3090. RefmsgTime string `json:"refmsg_time"`
  3091. RespondTime string `json:"respond_time"`
  3092. Signtype interface{} `json:"signtype"`
  3093. WarnInfo interface{} `json:"warn_info"`
  3094. }
  3095. type ResultTwo10265 struct {
  3096. ErrMsg string `json:"err_msg"`
  3097. InfRefmsgid string `json:"inf_refmsgid"`
  3098. Infcode string `json:"infcode"`
  3099. Output struct {
  3100. Baseinfo struct {
  3101. Age float64 `json:"age"`
  3102. Brdy string `json:"brdy"`
  3103. Certno string `json:"certno"`
  3104. Gend string `json:"gend"`
  3105. Naty string `json:"naty"`
  3106. PsnCertType string `json:"psn_cert_type"`
  3107. PsnName string `json:"psn_name"`
  3108. PsnNo string `json:"psn_no"`
  3109. } `json:"baseinfo"`
  3110. Idetinfo []interface{} `json:"idetinfo"`
  3111. Iinfo []struct {
  3112. Balc float64 `json:"balc"`
  3113. CvlservFlag string `json:"cvlserv_flag"`
  3114. EmpName string `json:"emp_name"`
  3115. InsuplcAdmdvs string `json:"insuplc_admdvs"`
  3116. Insutype string `json:"insutype"`
  3117. PausInsuDansuplcAdmdvs string `json:"paus_insu_dansuplc_admdvs"`
  3118. PausInsuDate string `json:"paus_insu_date"`
  3119. PsnInsuDate string `json:"psn_insu_date"`
  3120. PsnInsuStas string `json:"psn_insu_stas"`
  3121. PsnType string `json:"psn_type"`
  3122. } `json:"insuinfo"`
  3123. } `json:"output"`
  3124. RefmsgTime string `json:"refmsg_time"`
  3125. RespondTime string `json:"respond_time"`
  3126. Signtype interface{} `json:"signtype"`
  3127. WarnInfo interface{} `json:"warn_info"`
  3128. }
  3129. type ResultThree struct {
  3130. Cainfo interface{} `json:"cainfo"`
  3131. ErrMsg string `json:"err_msg"`
  3132. InfRefmsgid string `json:"inf_refmsgid"`
  3133. Infcode int64 `json:"infcode"`
  3134. Output struct {
  3135. Data struct {
  3136. IptOtpNo string `json:"ipt_otp_no"`
  3137. MdtrtID string `json:"mdtrt_id"`
  3138. PsnNo string `json:"psn_no"`
  3139. } `json:"data"`
  3140. } `json:"output"`
  3141. RefmsgTime string `json:"refmsg_time"`
  3142. RespondTime string `json:"respond_time"`
  3143. Signtype interface{} `json:"signtype"`
  3144. WarnMsg interface{} `json:"warn_msg"`
  3145. }
  3146. type ResultThree10265 struct {
  3147. Cainfo interface{} `json:"cainfo"`
  3148. ErrMsg string `json:"err_msg"`
  3149. InfRefmsgid string `json:"inf_refmsgid"`
  3150. Infcode string `json:"infcode"`
  3151. Output struct {
  3152. Data struct {
  3153. IptOtpNo string `json:"ipt_otp_no"`
  3154. MdtrtID string `json:"mdtrt_id"`
  3155. PsnNo string `json:"psn_no"`
  3156. } `json:"data"`
  3157. } `json:"output"`
  3158. RefmsgTime string `json:"refmsg_time"`
  3159. RespondTime string `json:"respond_time"`
  3160. Signtype interface{} `json:"signtype"`
  3161. WarnMsg interface{} `json:"warn_msg"`
  3162. }
  3163. type ResultFour struct {
  3164. Cainfo string `json:"cainfo"`
  3165. ErrMsg string `json:"err_msg"`
  3166. InfRefmsgid string `json:"inf_refmsgid"`
  3167. Infcode int64 `json:"infcode"`
  3168. Output struct {
  3169. Result []struct {
  3170. BasMednFlag string `json:"bas_medn_flag"`
  3171. ChldMedcFlag string `json:"chld_medc_flag"`
  3172. ChrgitmLv string `json:"chrgitm_lv"`
  3173. Cnt float64 `json:"cnt"`
  3174. DetItemFeeSumamt float64 `json:"det_item_fee_sumamt"`
  3175. DrtReimFlag string `json:"drt_reim_flag"`
  3176. FeedetlSn string `json:"feedetl_sn"`
  3177. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  3178. HiNegoDrugFlag string `json:"hi_nego_drug_flag"`
  3179. InscpScpAmt float64 `json:"inscp_scp_amt"`
  3180. ListSpItemFlag string `json:"list_sp_item_flag"`
  3181. LmtUsedFlag string `json:"lmt_used_flag"`
  3182. MedChrgitmType string `json:"med_chrgitm_type"`
  3183. Memo string `json:"memo"`
  3184. OverlmtAmt float64 `json:"overlmt_amt"`
  3185. PreselfpayAmt float64 `json:"preselfpay_amt"`
  3186. Pric float64 `json:"pric"`
  3187. PricUplmtAmt float64 `json:"pric_uplmt_amt"`
  3188. SelfpayProp float64 `json:"selfpay_prop"`
  3189. } `json:"result"`
  3190. } `json:"output"`
  3191. RefmsgTime string `json:"refmsg_time"`
  3192. RespondTime string `json:"respond_time"`
  3193. Signtype string `json:"signtype"`
  3194. WarnMsg string `json:"warn_msg"`
  3195. }
  3196. type ResultFour10265 struct {
  3197. Cainfo string `json:"cainfo"`
  3198. ErrMsg string `json:"err_msg"`
  3199. InfRefmsgid string `json:"inf_refmsgid"`
  3200. Infcode string `json:"infcode"`
  3201. Output struct {
  3202. Result []struct {
  3203. BasMednFlag string `json:"bas_medn_flag"`
  3204. ChldMedcFlag string `json:"chld_medc_flag"`
  3205. ChrgitmLv string `json:"chrgitm_lv"`
  3206. Cnt float64 `json:"cnt"`
  3207. DetItemFeeSumamt float64 `json:"det_item_fee_sumamt"`
  3208. DrtReimFlag string `json:"drt_reim_flag"`
  3209. FeedetlSn string `json:"feedetl_sn"`
  3210. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  3211. HiNegoDrugFlag string `json:"hi_nego_drug_flag"`
  3212. InscpScpAmt float64 `json:"inscp_scp_amt"`
  3213. ListSpItemFlag string `json:"list_sp_item_flag"`
  3214. LmtUsedFlag string `json:"lmt_used_flag"`
  3215. MedChrgitmType string `json:"med_chrgitm_type"`
  3216. Memo string `json:"memo"`
  3217. OverlmtAmt float64 `json:"overlmt_amt"`
  3218. PreselfpayAmt float64 `json:"preselfpay_amt"`
  3219. Pric float64 `json:"pric"`
  3220. PricUplmtAmt float64 `json:"pric_uplmt_amt"`
  3221. SelfpayProp float64 `json:"selfpay_prop"`
  3222. } `json:"result"`
  3223. } `json:"output"`
  3224. RefmsgTime string `json:"refmsg_time"`
  3225. RespondTime string `json:"respond_time"`
  3226. Signtype string `json:"signtype"`
  3227. WarnMsg string `json:"warn_msg"`
  3228. }
  3229. type ResultFive struct {
  3230. Balc float64 `json:"balc"`
  3231. CvlservFlag string `json:"cvlserv_flag"`
  3232. EmpName string `json:"emp_name"`
  3233. InsuplcAdmdvs string `json:"insuplc_admdvs"`
  3234. Insutype string `json:"insutype"`
  3235. PausInsuDansuplcAdmdvs string `json:"paus_insu_dansuplc_admdvs"`
  3236. PausInsuDate string `json:"paus_insu_date"`
  3237. PsnInsuDate string `json:"psn_insu_date"`
  3238. PsnInsuStas string `json:"psn_insu_stas"`
  3239. PsnType string `json:"psn_type"`
  3240. }
  3241. type ResultSix struct {
  3242. Cainfo interface{} `json:"cainfo"`
  3243. ErrMsg string `json:"err_msg"`
  3244. InfRefmsgid string `json:"inf_refmsgid"`
  3245. Infcode int64 `json:"infcode"`
  3246. Output struct {
  3247. } `json:"output"`
  3248. RefmsgTime string `json:"refmsg_time"`
  3249. RespondTime string `json:"respond_time"`
  3250. Signtype interface{} `json:"signtype"`
  3251. WarnMsg interface{} `json:"warn_msg"`
  3252. }
  3253. type ResultSix10265 struct {
  3254. Cainfo interface{} `json:"cainfo"`
  3255. ErrMsg string `json:"err_msg"`
  3256. InfRefmsgid string `json:"inf_refmsgid"`
  3257. Infcode string `json:"infcode"`
  3258. Output struct {
  3259. } `json:"output"`
  3260. RefmsgTime string `json:"refmsg_time"`
  3261. RespondTime string `json:"respond_time"`
  3262. Signtype interface{} `json:"signtype"`
  3263. WarnMsg interface{} `json:"warn_msg"`
  3264. }
  3265. type ResultSeven struct {
  3266. Cainfo string `json:"cainfo"`
  3267. ErrMsg string `json:"err_msg"`
  3268. InfRefmsgid string `json:"inf_refmsgid"`
  3269. Infcode int64 `json:"infcode"`
  3270. Output struct {
  3271. Setldetail []interface{} `json:"setldetail"`
  3272. Setlinfo struct {
  3273. AcctMulaidPay float64 `json:"acct_mulaid_pay"`
  3274. AcctPay float64 `json:"acct_pay"`
  3275. ActPayDedc float64 `json:"act_pay_dedc"`
  3276. Age float64 `json:"age"`
  3277. Balc float64 `json:"balc"`
  3278. Brdy string `json:"brdy"`
  3279. Certno string `json:"certno"`
  3280. ClrOptins string `json:"clr_optins"`
  3281. ClrType string `json:"clr_type"`
  3282. ClrWay string `json:"clr_way"`
  3283. CvlservFlag string `json:"cvlserv_flag"`
  3284. CvlservPay float64 `json:"cvlserv_pay"`
  3285. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  3286. FundPaySumamt float64 `json:"fund_pay_sumamt"`
  3287. Gend string `json:"gend"`
  3288. HifesPay float64 `json:"hifes_pay"`
  3289. HifmiPay float64 `json:"hifmi_pay"`
  3290. HifpPay float64 `json:"hifp_pay"`
  3291. HospPartAmt float64 `json:"hosp_part_amt"`
  3292. InscpScpAmt float64 `json:"inscp_scp_amt"`
  3293. Insutype string `json:"insutype"`
  3294. MafPay float64 `json:"maf_pay"`
  3295. MdtrtCertType string `json:"mdtrt_cert_type"`
  3296. HifobPay float64 `json:"hifob_pay"`
  3297. MdtrtID string `json:"mdtrt_id"`
  3298. MedType string `json:"med_type"`
  3299. MedfeeSumamt float64 `json:"medfee_sumamt"`
  3300. MedinsSetlID string `json:"medins_setl_id"`
  3301. Naty string `json:"naty"`
  3302. OthPay float64 `json:"oth_pay"`
  3303. OverlmtSelfpay float64 `json:"overlmt_selfpay"`
  3304. PoolPropSelfpay float64 `json:"pool_prop_selfpay"`
  3305. PreselfpayAmt float64 `json:"preselfpay_amt"`
  3306. PsnCashPay float64 `json:"psn_cash_pay"`
  3307. PsnCertType string `json:"psn_cert_type"`
  3308. PsnName string `json:"psn_name"`
  3309. PsnNo string `json:"psn_no"`
  3310. PsnPartAmt float64 `json:"psn_part_amt"`
  3311. PsnType string `json:"psn_type"`
  3312. SetlID string `json:"setl_id"`
  3313. SetlTime string `json:"setl_time"`
  3314. } `json:"setlinfo"`
  3315. } `json:"output"`
  3316. RefmsgTime string `json:"refmsg_time"`
  3317. RespondTime string `json:"respond_time"`
  3318. Signtype interface{} `json:"signtype"`
  3319. WarnMsg interface{} `json:"warn_msg"`
  3320. }
  3321. type ResultSeven10265 struct {
  3322. Cainfo string `json:"cainfo"`
  3323. ErrMsg string `json:"err_msg"`
  3324. InfRefmsgid string `json:"inf_refmsgid"`
  3325. Infcode string `json:"infcode"`
  3326. Output struct {
  3327. Setldetail []interface{} `json:"setldetail"`
  3328. Setlinfo struct {
  3329. AcctMulaidPay float64 `json:"acct_mulaid_pay"`
  3330. AcctPay float64 `json:"acct_pay"`
  3331. ActPayDedc float64 `json:"act_pay_dedc"`
  3332. Age float64 `json:"age"`
  3333. Balc float64 `json:"balc"`
  3334. Brdy string `json:"brdy"`
  3335. Certno string `json:"certno"`
  3336. ClrOptins string `json:"clr_optins"`
  3337. ClrType string `json:"clr_type"`
  3338. ClrWay string `json:"clr_way"`
  3339. CvlservFlag string `json:"cvlserv_flag"`
  3340. CvlservPay float64 `json:"cvlserv_pay"`
  3341. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  3342. FundPaySumamt float64 `json:"fund_pay_sumamt"`
  3343. Gend string `json:"gend"`
  3344. HifesPay float64 `json:"hifes_pay"`
  3345. HifmiPay float64 `json:"hifmi_pay"`
  3346. HifpPay float64 `json:"hifp_pay"`
  3347. HospPartAmt float64 `json:"hosp_part_amt"`
  3348. InscpScpAmt float64 `json:"inscp_scp_amt"`
  3349. Insutype string `json:"insutype"`
  3350. MafPay float64 `json:"maf_pay"`
  3351. MdtrtCertType string `json:"mdtrt_cert_type"`
  3352. HifobPay float64 `json:"hifob_pay"`
  3353. MdtrtID string `json:"mdtrt_id"`
  3354. MedType string `json:"med_type"`
  3355. MedfeeSumamt float64 `json:"medfee_sumamt"`
  3356. MedinsSetlID string `json:"medins_setl_id"`
  3357. Naty string `json:"naty"`
  3358. OthPay float64 `json:"oth_pay"`
  3359. OverlmtSelfpay float64 `json:"overlmt_selfpay"`
  3360. PoolPropSelfpay float64 `json:"pool_prop_selfpay"`
  3361. PreselfpayAmt float64 `json:"preselfpay_amt"`
  3362. PsnCashPay float64 `json:"psn_cash_pay"`
  3363. PsnCertType string `json:"psn_cert_type"`
  3364. PsnName string `json:"psn_name"`
  3365. PsnNo string `json:"psn_no"`
  3366. PsnPartAmt float64 `json:"psn_part_amt"`
  3367. PsnType string `json:"psn_type"`
  3368. SetlID string `json:"setl_id"`
  3369. SetlTime string `json:"setl_time"`
  3370. } `json:"setlinfo"`
  3371. } `json:"output"`
  3372. RefmsgTime string `json:"refmsg_time"`
  3373. RespondTime string `json:"respond_time"`
  3374. Signtype interface{} `json:"signtype"`
  3375. WarnMsg interface{} `json:"warn_msg"`
  3376. }
  3377. type ResultEight struct {
  3378. Cainfo string `json:"cainfo"`
  3379. ErrMsg string `json:"err_msg"`
  3380. InfRefmsgid string `json:"inf_refmsgid"`
  3381. Infcode int64 `json:"infcode"`
  3382. Output struct {
  3383. Stmtinfo struct {
  3384. SetlOptins string `json:"setl_optins"`
  3385. StmtRslt string `json:"stmt_rslt"`
  3386. StmtRsltDscr string `json:"stmt_rslt_dscr"`
  3387. } `json:"stmtinfo"`
  3388. } `json:"output"`
  3389. RefmsgTime string `json:"refmsg_time"`
  3390. RespondTime string `json:"respond_time"`
  3391. Signtype interface{} `json:"signtype"`
  3392. WarnMsg interface{} `json:"warn_msg"`
  3393. }
  3394. type ResultEightFor10188 struct {
  3395. Cainfo string `json:"cainfo"`
  3396. ErrMsg string `json:"err_msg"`
  3397. InfRefmsgid string `json:"inf_refmsgid"`
  3398. Infcode string `json:"infcode"`
  3399. Output struct {
  3400. Stmtinfo struct {
  3401. SetlOptins string `json:"setl_optins"`
  3402. StmtRslt string `json:"stmt_rslt"`
  3403. StmtRsltDscr string `json:"stmt_rslt_dscr"`
  3404. } `json:"stmtinfo"`
  3405. } `json:"output"`
  3406. RefmsgTime string `json:"refmsg_time"`
  3407. RespondTime string `json:"respond_time"`
  3408. Signtype interface{} `json:"signtype"`
  3409. WarnMsg interface{} `json:"warn_msg"`
  3410. }
  3411. type ResultNine struct {
  3412. Cainfo string `json:"cainfo"`
  3413. ErrMsg string `json:"err_msg"`
  3414. InfRefmsgid string `json:"inf_refmsgid"`
  3415. Infcode int64 `json:"infcode"`
  3416. Output struct {
  3417. FileQuryNo string `json:"file_qury_no"`
  3418. } `json:"output"`
  3419. RefmsgTime string `json:"refmsg_time"`
  3420. RespondTime string `json:"respond_time"`
  3421. Signtype interface{} `json:"signtype"`
  3422. WarnMsg interface{} `json:"warn_msg"`
  3423. }
  3424. type ResultTen struct {
  3425. Cainfo string `json:"cainfo"`
  3426. ErrMsg string `json:"err_msg"`
  3427. InfRefmsgid string `json:"inf_refmsgid"`
  3428. Infcode int64 `json:"infcode"`
  3429. Output struct {
  3430. DldEndtime string `json:"dld_endtime"`
  3431. FileQuryNo string `json:"file_qury_no"`
  3432. Filename string `json:"filename"`
  3433. } `json:"output"`
  3434. RefmsgTime string `json:"refmsg_time"`
  3435. RespondTime string `json:"respond_time"`
  3436. Signtype interface{} `json:"signtype"`
  3437. WarnMsg interface{} `json:"warn_msg"`
  3438. }
  3439. //type Autogenerated struct {
  3440. // Output struct {
  3441. // Setlinfo struct {
  3442. // SetlTime string `json:"setl_time"`
  3443. // CvlservPay float64 `json:"cvlserv_pay"`
  3444. // Year string `json:"year"`
  3445. // MedType string `json:"med_type"`
  3446. // PsnPay float64 `json:"psn_pay"`
  3447. // OpterID string `json:"opter_id"`
  3448. // Begndate string `json:"begndate"`
  3449. // FlxempeFlag string `json:"flxempe_flag"`
  3450. // HifmiPay float64 `json:"hifmi_pay"`
  3451. // PsnNo string `json:"psn_no"`
  3452. // ActPayDedc float64 `json:"act_pay_dedc"`
  3453. // MedinsSetlID interface{} `json:"medins_setl_id"`
  3454. // AcctMulaidPay interface{} `json:"acct_mulaid_pay"`
  3455. // ClrWay string `json:"clr_way"`
  3456. // OthPay float64 `json:"oth_pay"`
  3457. // Gend string `json:"gend"`
  3458. // MdtrtID string `json:"mdtrt_id"`
  3459. // AcctPay float64 `json:"acct_pay"`
  3460. // InscpScpAmt float64 `json:"inscp_scp_amt"`
  3461. // Insutype string `json:"insutype"`
  3462. // Invono interface{} `json:"invono"`
  3463. // Enddate string `json:"enddate"`
  3464. // CashPayamt float64 `json:"cash_payamt"`
  3465. // PsnType string `json:"psn_type"`
  3466. // FixmedinsName string `json:"fixmedins_name"`
  3467. // HifpPay float64 `json:"hifp_pay"`
  3468. // NewFlag interface{} `json:"new_flag"`
  3469. // OverlmtSelfpay float64 `json:"overlmt_selfpay"`
  3470. // PreselfpayAmt float64 `json:"preselfpay_amt"`
  3471. // PayLoc string `json:"pay_loc"`
  3472. // ClrType string `json:"clr_type"`
  3473. // RefdSetlFlag string `json:"refd_setl_flag"`
  3474. // CvlservFlag string `json:"cvlserv_flag"`
  3475. // EmpName string `json:"emp_name"`
  3476. // Brdy string `json:"brdy"`
  3477. // Naty string `json:"naty"`
  3478. // Certno string `json:"certno"`
  3479. // DiseCode string `json:"dise_code"`
  3480. // FixmedinsCode string `json:"fixmedins_code"`
  3481. // DedcHospLv string `json:"dedc_hosp_lv"`
  3482. // OpterName string `json:"opter_name"`
  3483. // Balc float64 `json:"balc"`
  3484. // FixmedinsPoolarea string `json:"fixmedins_poolarea"`
  3485. // PsnCertType string `json:"psn_cert_type"`
  3486. // HifobPay float64 `json:"hifob_pay"`
  3487. // MedfeeSumamt float64 `json:"medfee_sumamt"`
  3488. // HifesPay float64 `json:"hifes_pay"`
  3489. // FundPaySumamt float64 `json:"fund_pay_sumamt"`
  3490. // OptTime string `json:"opt_time"`
  3491. // FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  3492. // SetlID string `json:"setl_id"`
  3493. // MafPay float64 `json:"maf_pay"`
  3494. // PsnName string `json:"psn_name"`
  3495. // InsuOptins interface{} `json:"insu_optins"`
  3496. // PrefFundPay interface{} `json:"pref_fund_pay"`
  3497. // ClrOptins string `json:"clr_optins"`
  3498. // PoolPropSelfpay float64 `json:"pool_prop_selfpay"`
  3499. // DiseName string `json:"dise_name"`
  3500. // LmtpricHospLv string `json:"lmtpric_hosp_lv"`
  3501. // Age float64 `json:"age"`
  3502. // DtrtCertType string `json:"dtrt_cert_type"`
  3503. // HospLv string `json:"hosp_lv"`
  3504. // } `json:"setlinfo"`
  3505. // Setldetail []struct {
  3506. // FundPayType string `json:"fund_pay_type"`
  3507. // FundPayamt float64 `json:"fund_payamt"`
  3508. // SetlProcInfo interface{} `json:"setl_proc_info"`
  3509. // CrtPaybLmtAmt interface{} `json:"crt_payb_lmt_amt"`
  3510. // InscpScpAmt interface{} `json:"inscp_scp_amt"`
  3511. // FundPayTypeName interface{} `json:"fund_pay_type_name"`
  3512. // PrefFundPay interface{} `json:"pref_fund_pay"`
  3513. // } `json:"setldetail"`
  3514. // } `json:"output"`
  3515. // Infcode int `json:"infcode"`
  3516. // WarnMsg interface{} `json:"warn_msg"`
  3517. // Cainfo interface{} `json:"cainfo"`
  3518. // ErrMsg interface{} `json:"err_msg"`
  3519. // RefmsgTime string `json:"refmsg_time"`
  3520. // Signtype interface{} `json:"signtype"`
  3521. // RespondTime string `json:"respond_time"`
  3522. // InfRefmsgid string `json:"inf_refmsgid"`
  3523. //}
  3524. type ResultEleven struct {
  3525. Cainfo string `json:"cainfo"`
  3526. ErrMsg string `json:"err_msg"`
  3527. InfRefmsgid string `json:"inf_refmsgid"`
  3528. Infcode int64 `json:"infcode"`
  3529. Output struct {
  3530. Setlinfo struct {
  3531. SetlTime string `json:"setl_time"`
  3532. CvlservPay float64 `json:"cvlserv_pay"`
  3533. Year string `json:"year"`
  3534. MedType string `json:"med_type"`
  3535. PsnPay float64 `json:"psn_pay"`
  3536. OpterID string `json:"opter_id"`
  3537. Begndate string `json:"begndate"`
  3538. FlxempeFlag string `json:"flxempe_flag"`
  3539. HifmiPay float64 `json:"hifmi_pay"`
  3540. PsnNo string `json:"psn_no"`
  3541. ActPayDedc float64 `json:"act_pay_dedc"`
  3542. MedinsSetlID interface{} `json:"medins_setl_id"`
  3543. AcctMulaidPay interface{} `json:"acct_mulaid_pay"`
  3544. ClrWay string `json:"clr_way"`
  3545. OthPay float64 `json:"oth_pay"`
  3546. Gend string `json:"gend"`
  3547. MdtrtID string `json:"mdtrt_id"`
  3548. AcctPay float64 `json:"acct_pay"`
  3549. InscpScpAmt float64 `json:"inscp_scp_amt"`
  3550. Insutype string `json:"insutype"`
  3551. Invono interface{} `json:"invono"`
  3552. Enddate string `json:"enddate"`
  3553. CashPayamt float64 `json:"cash_payamt"`
  3554. PsnType string `json:"psn_type"`
  3555. FixmedinsName string `json:"fixmedins_name"`
  3556. HifpPay float64 `json:"hifp_pay"`
  3557. NewFlag interface{} `json:"new_flag"`
  3558. OverlmtSelfpay float64 `json:"overlmt_selfpay"`
  3559. PreselfpayAmt float64 `json:"preselfpay_amt"`
  3560. PayLoc string `json:"pay_loc"`
  3561. ClrType string `json:"clr_type"`
  3562. RefdSetlFlag string `json:"refd_setl_flag"`
  3563. CvlservFlag string `json:"cvlserv_flag"`
  3564. EmpName string `json:"emp_name"`
  3565. Brdy string `json:"brdy"`
  3566. Naty string `json:"naty"`
  3567. Certno string `json:"certno"`
  3568. DiseCode string `json:"dise_code"`
  3569. FixmedinsCode string `json:"fixmedins_code"`
  3570. DedcHospLv string `json:"dedc_hosp_lv"`
  3571. OpterName string `json:"opter_name"`
  3572. Balc float64 `json:"balc"`
  3573. FixmedinsPoolarea string `json:"fixmedins_poolarea"`
  3574. PsnCertType string `json:"psn_cert_type"`
  3575. HifobPay float64 `json:"hifob_pay"`
  3576. MedfeeSumamt float64 `json:"medfee_sumamt"`
  3577. HifesPay float64 `json:"hifes_pay"`
  3578. FundPaySumamt float64 `json:"fund_pay_sumamt"`
  3579. OptTime string `json:"opt_time"`
  3580. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  3581. SetlID string `json:"setl_id"`
  3582. MafPay float64 `json:"maf_pay"`
  3583. PsnName string `json:"psn_name"`
  3584. InsuOptins interface{} `json:"insu_optins"`
  3585. PrefFundPay interface{} `json:"pref_fund_pay"`
  3586. ClrOptins string `json:"clr_optins"`
  3587. PoolPropSelfpay float64 `json:"pool_prop_selfpay"`
  3588. DiseName string `json:"dise_name"`
  3589. LmtpricHospLv string `json:"lmtpric_hosp_lv"`
  3590. Age float64 `json:"age"`
  3591. DtrtCertType string `json:"dtrt_cert_type"`
  3592. HospLv string `json:"hosp_lv"`
  3593. } `json:"setlinfo"`
  3594. } `json:"output"`
  3595. RefmsgTime string `json:"refmsg_time"`
  3596. RespondTime string `json:"respond_time"`
  3597. Signtype interface{} `json:"signtype"`
  3598. WarnMsg interface{} `json:"warn_msg"`
  3599. }
  3600. type ResultEleven10265 struct {
  3601. Cainfo string `json:"cainfo"`
  3602. ErrMsg string `json:"err_msg"`
  3603. InfRefmsgid string `json:"inf_refmsgid"`
  3604. Infcode string `json:"infcode"`
  3605. Output struct {
  3606. Setlinfo struct {
  3607. SetlTime string `json:"setl_time"`
  3608. CvlservPay float64 `json:"cvlserv_pay"`
  3609. Year string `json:"year"`
  3610. MedType string `json:"med_type"`
  3611. PsnPay float64 `json:"psn_pay"`
  3612. OpterID string `json:"opter_id"`
  3613. Begndate string `json:"begndate"`
  3614. FlxempeFlag string `json:"flxempe_flag"`
  3615. HifmiPay float64 `json:"hifmi_pay"`
  3616. PsnNo string `json:"psn_no"`
  3617. ActPayDedc float64 `json:"act_pay_dedc"`
  3618. MedinsSetlID interface{} `json:"medins_setl_id"`
  3619. AcctMulaidPay interface{} `json:"acct_mulaid_pay"`
  3620. ClrWay string `json:"clr_way"`
  3621. OthPay float64 `json:"oth_pay"`
  3622. Gend string `json:"gend"`
  3623. MdtrtID string `json:"mdtrt_id"`
  3624. AcctPay float64 `json:"acct_pay"`
  3625. InscpScpAmt float64 `json:"inscp_scp_amt"`
  3626. Insutype string `json:"insutype"`
  3627. Invono interface{} `json:"invono"`
  3628. Enddate string `json:"enddate"`
  3629. CashPayamt float64 `json:"cash_payamt"`
  3630. PsnType string `json:"psn_type"`
  3631. FixmedinsName string `json:"fixmedins_name"`
  3632. HifpPay float64 `json:"hifp_pay"`
  3633. NewFlag interface{} `json:"new_flag"`
  3634. OverlmtSelfpay float64 `json:"overlmt_selfpay"`
  3635. PreselfpayAmt float64 `json:"preselfpay_amt"`
  3636. PayLoc string `json:"pay_loc"`
  3637. ClrType string `json:"clr_type"`
  3638. RefdSetlFlag string `json:"refd_setl_flag"`
  3639. CvlservFlag string `json:"cvlserv_flag"`
  3640. EmpName string `json:"emp_name"`
  3641. Brdy string `json:"brdy"`
  3642. Naty string `json:"naty"`
  3643. Certno string `json:"certno"`
  3644. DiseCode string `json:"dise_code"`
  3645. FixmedinsCode string `json:"fixmedins_code"`
  3646. DedcHospLv string `json:"dedc_hosp_lv"`
  3647. OpterName string `json:"opter_name"`
  3648. Balc float64 `json:"balc"`
  3649. FixmedinsPoolarea string `json:"fixmedins_poolarea"`
  3650. PsnCertType string `json:"psn_cert_type"`
  3651. HifobPay float64 `json:"hifob_pay"`
  3652. MedfeeSumamt float64 `json:"medfee_sumamt"`
  3653. HifesPay float64 `json:"hifes_pay"`
  3654. FundPaySumamt float64 `json:"fund_pay_sumamt"`
  3655. OptTime string `json:"opt_time"`
  3656. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  3657. SetlID string `json:"setl_id"`
  3658. MafPay float64 `json:"maf_pay"`
  3659. PsnName string `json:"psn_name"`
  3660. InsuOptins interface{} `json:"insu_optins"`
  3661. PrefFundPay interface{} `json:"pref_fund_pay"`
  3662. ClrOptins string `json:"clr_optins"`
  3663. PoolPropSelfpay float64 `json:"pool_prop_selfpay"`
  3664. DiseName string `json:"dise_name"`
  3665. LmtpricHospLv string `json:"lmtpric_hosp_lv"`
  3666. Age float64 `json:"age"`
  3667. DtrtCertType string `json:"dtrt_cert_type"`
  3668. HospLv string `json:"hosp_lv"`
  3669. } `json:"setlinfo"`
  3670. } `json:"output"`
  3671. RefmsgTime string `json:"refmsg_time"`
  3672. RespondTime string `json:"respond_time"`
  3673. Signtype interface{} `json:"signtype"`
  3674. WarnMsg interface{} `json:"warn_msg"`
  3675. }
  3676. type ResultTwelve struct {
  3677. Cainfo string `json:"cainfo"`
  3678. ErrMsg string `json:"err_msg"`
  3679. InfRefmsgid string `json:"inf_refmsgid"`
  3680. Infcode int64 `json:"infcode"`
  3681. Output struct {
  3682. MdtrtId string `json:"mdtrt_id"`
  3683. ChrgBchno string `json:"chrg_bchno"`
  3684. PsnNo string `json:"psn_no"`
  3685. } `json:"output"`
  3686. RefmsgTime string `json:"refmsg_time"`
  3687. RespondTime string `json:"respond_time"`
  3688. Signtype interface{} `json:"signtype"`
  3689. WarnMsg interface{} `json:"warn_msg"`
  3690. }
  3691. type ResultThirteen struct {
  3692. ErrMsg string `json:"err_msg"`
  3693. InfRefmsgid string `json:"inf_refmsgid"`
  3694. Infcode int64 `json:"infcode"`
  3695. Output struct {
  3696. Result struct {
  3697. TrtDclaDetlSn string `json:"trt_dcla_detl_sn"`
  3698. } `json:"result"`
  3699. } `json:"output"`
  3700. RefmsgTime string `json:"refmsg_time"`
  3701. RespondTime string `json:"respond_time"`
  3702. Signtype interface{} `json:"signtype"`
  3703. WarnInfo interface{} `json:"warn_info"`
  3704. }
  3705. type ResultThirteen10265 struct {
  3706. ErrMsg string `json:"err_msg"`
  3707. InfRefmsgid string `json:"inf_refmsgid"`
  3708. Infcode string `json:"infcode"`
  3709. Output struct {
  3710. Result struct {
  3711. TrtDclaDetlSn string `json:"trt_dcla_detl_sn"`
  3712. } `json:"result"`
  3713. } `json:"output"`
  3714. RefmsgTime string `json:"refmsg_time"`
  3715. RespondTime string `json:"respond_time"`
  3716. Signtype interface{} `json:"signtype"`
  3717. WarnInfo interface{} `json:"warn_info"`
  3718. }
  3719. type ResultFourteen struct {
  3720. ErrMsg string `json:"err_msg"`
  3721. InfRefmsgid string `json:"inf_refmsgid"`
  3722. Infcode int64 `json:"infcode"`
  3723. Output struct {
  3724. } `json:"output"`
  3725. RefmsgTime string `json:"refmsg_time"`
  3726. RespondTime string `json:"respond_time"`
  3727. Signtype interface{} `json:"signtype"`
  3728. WarnInfo interface{} `json:"warn_info"`
  3729. }
  3730. type ResultFourteen10265 struct {
  3731. ErrMsg string `json:"err_msg"`
  3732. InfRefmsgid string `json:"inf_refmsgid"`
  3733. Infcode string `json:"infcode"`
  3734. Output struct {
  3735. } `json:"output"`
  3736. RefmsgTime string `json:"refmsg_time"`
  3737. RespondTime string `json:"respond_time"`
  3738. Signtype interface{} `json:"signtype"`
  3739. WarnInfo interface{} `json:"warn_info"`
  3740. }
  3741. type ResultSixteen struct {
  3742. Cainfo string `json:"cainfo"`
  3743. ErrMsg string `json:"err_msg"`
  3744. InfRefmsgid string `json:"inf_refmsgid"`
  3745. Infcode int64 `json:"infcode"`
  3746. Output struct {
  3747. Setldetail []interface{} `json:"setldetail"`
  3748. Setlinfo struct {
  3749. MdtrtID string `json:"mdtrt_id"`
  3750. SetlID string `json:"setl_id"`
  3751. ClrOptins string `json:"clr_optins"`
  3752. SetlTime string `json:"setl_time"`
  3753. MedfeeSumamt float64 `json:"medfee_sumamt"`
  3754. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  3755. OverlmtSelfpay float64 `json:"overlmt_selfpay"`
  3756. PreselfpayAmt float64 `json:"preselfpay_amt"`
  3757. InscpScpAmt float64 `json:"inscp_scp_amt"`
  3758. ActPayDedc float64 `json:"act_pay_dedc"`
  3759. HifpPay float64 `json:"hifp_pay"`
  3760. PoolPropSe float64 `json:"pool_prop_selfpay"`
  3761. Lfpay float64 `json:"selfpay"`
  3762. CvlservPay float64 `json:"cvlserv_pay"`
  3763. HifesPay float64 `json:"hifes_pay"`
  3764. HifmiPay float64 `json:"hifmi_pay"`
  3765. HifobPay float64 `json:"hifob_pay"`
  3766. MafPay float64 `json:"maf_pay"`
  3767. OthPay float64 `json:"oth_pay"`
  3768. FundPaySumamt float64 `json:"fund_pay_sumamt"`
  3769. PsnPartAmt float64 `json:"psn_part_amt"`
  3770. AcctPay float64 `json:"acct_pay"`
  3771. Balc float64 `json:"balc"`
  3772. AcctMulaidPay float64 `json:"acct_mulaid_pay"`
  3773. HospPartAmt float64 `json:"hosp_part_amt"`
  3774. MedinsSetlID string `json:"medins_setl_id"`
  3775. PdnCashPay string `json:"pdn_cash_pay"`
  3776. } `json:"setlinfo"`
  3777. } `json:"output"`
  3778. RefmsgTime string `json:"refmsg_time"`
  3779. RespondTime string `json:"respond_time"`
  3780. Signtype interface{} `json:"signtype"`
  3781. WarnMsg interface{} `json:"warn_msg"`
  3782. }
  3783. type ResultSixteen10265 struct {
  3784. Cainfo string `json:"cainfo"`
  3785. ErrMsg string `json:"err_msg"`
  3786. InfRefmsgid string `json:"inf_refmsgid"`
  3787. Infcode string `json:"infcode"`
  3788. Output struct {
  3789. Setldetail []interface{} `json:"setldetail"`
  3790. Setlinfo struct {
  3791. MdtrtID string `json:"mdtrt_id"`
  3792. SetlID string `json:"setl_id"`
  3793. ClrOptins string `json:"clr_optins"`
  3794. SetlTime string `json:"setl_time"`
  3795. MedfeeSumamt float64 `json:"medfee_sumamt"`
  3796. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  3797. OverlmtSelfpay float64 `json:"overlmt_selfpay"`
  3798. PreselfpayAmt float64 `json:"preselfpay_amt"`
  3799. InscpScpAmt float64 `json:"inscp_scp_amt"`
  3800. ActPayDedc float64 `json:"act_pay_dedc"`
  3801. HifpPay float64 `json:"hifp_pay"`
  3802. PoolPropSe float64 `json:"pool_prop_selfpay"`
  3803. Lfpay float64 `json:"selfpay"`
  3804. CvlservPay float64 `json:"cvlserv_pay"`
  3805. HifesPay float64 `json:"hifes_pay"`
  3806. HifmiPay float64 `json:"hifmi_pay"`
  3807. HifobPay float64 `json:"hifob_pay"`
  3808. MafPay float64 `json:"maf_pay"`
  3809. OthPay float64 `json:"oth_pay"`
  3810. FundPaySumamt float64 `json:"fund_pay_sumamt"`
  3811. PsnPartAmt float64 `json:"psn_part_amt"`
  3812. AcctPay float64 `json:"acct_pay"`
  3813. Balc float64 `json:"balc"`
  3814. AcctMulaidPay float64 `json:"acct_mulaid_pay"`
  3815. HospPartAmt float64 `json:"hosp_part_amt"`
  3816. MedinsSetlID string `json:"medins_setl_id"`
  3817. PdnCashPay string `json:"pdn_cash_pay"`
  3818. } `json:"setlinfo"`
  3819. } `json:"output"`
  3820. RefmsgTime string `json:"refmsg_time"`
  3821. RespondTime string `json:"respond_time"`
  3822. Signtype interface{} `json:"signtype"`
  3823. WarnMsg interface{} `json:"warn_msg"`
  3824. }
  3825. type ResultSeventeen struct {
  3826. ErrMsg string `json:"err_msg"`
  3827. InfRefmsgid string `json:"inf_refmsgid"`
  3828. Infcode int64 `json:"infcode"`
  3829. Output struct {
  3830. SetlListId string `json:"setl_list_id"`
  3831. } `json:"output"`
  3832. RefmsgTime string `json:"refmsg_time"`
  3833. RespondTime string `json:"respond_time"`
  3834. Signtype string `json:"signtype"`
  3835. WarnInfo string `json:"warn_info"`
  3836. }
  3837. type Result90991 struct {
  3838. ErrMsg string `json:"err_msg"`
  3839. InfRefmsgid string `json:"inf_refmsgid"`
  3840. Infcode int64 `json:"infcode"`
  3841. Output struct {
  3842. Result struct {
  3843. PsnNo string `json:"psn_no"`
  3844. CardStat string `json:"card_stat"`
  3845. Certno string `json:"certno"`
  3846. PsnName string `json:"psn_name"`
  3847. CheckStat string `json:"check_stat"`
  3848. } `json:"result"`
  3849. } `json:"output"`
  3850. RefmsgTime string `json:"refmsg_time"`
  3851. RespondTime string `json:"respond_time"`
  3852. Signtype interface{} `json:"signtype"`
  3853. WarnInfo interface{} `json:"warn_info"`
  3854. }
  3855. type Result90100 struct {
  3856. ErrMsg string `json:"err_msg"`
  3857. InfRefmsgid string `json:"inf_refmsgid"`
  3858. Infcode int64 `json:"infcode"`
  3859. Output struct {
  3860. PoolareaNo string `json:"poolarea_no"`
  3861. PoolareaNoName string `json:"poolarea_no_name"`
  3862. Insutype string `json:"insutype"`
  3863. InsutypeName string `json:"insutype_name"`
  3864. ClctType string `json:"clct_type"`
  3865. ClctTypeName string `json:"clct_type_name"`
  3866. ClctFlag string `json:"clct_flag"`
  3867. ClctFlagName string `json:"clct_flag_name"`
  3868. AccrymBegn string `json:"accrym_begn"`
  3869. AccrymEnd string `json:"accrym_end"`
  3870. ClctTime string `json:"clct_time"`
  3871. ClctstdCrtfRuleCodg string `json:"clctstd_crtf_rule_codg"`
  3872. } `json:"output"`
  3873. RefmsgTime string `json:"refmsg_time"`
  3874. RespondTime string `json:"respond_time"`
  3875. Signtype interface{} `json:"signtype"`
  3876. WarnInfo interface{} `json:"warn_info"`
  3877. }
  3878. type Custom struct {
  3879. DetItemFeeSumamt string
  3880. Cut string
  3881. FeedetlSn string
  3882. Price string
  3883. MedListCodg string
  3884. Type int64
  3885. AdviceId int64
  3886. ProjectId int64
  3887. ItemId int64
  3888. }
  3889. type Result5301 struct {
  3890. ErrMsg string `json:"err_msg"`
  3891. InfRefmsgid string `json:"inf_refmsgid"`
  3892. Infcode int64 `json:"infcode"`
  3893. Output struct {
  3894. Result []struct {
  3895. OpspDiseCode string `json:"opsp_dise_code"`
  3896. OpspDiseName string `json:"opsp_dise_name"`
  3897. Begndate string `json:"begndate"`
  3898. Enddate string `json:"enddate"`
  3899. } `json:"feedetail"`
  3900. } `json:"output"`
  3901. RefmsgTime string `json:"refmsg_time"`
  3902. RespondTime string `json:"respond_time"`
  3903. Signtype interface{} `json:"signtype"`
  3904. WarnInfo interface{} `json:"warn_info"`
  3905. }
  3906. type Result5301For10265 struct {
  3907. ErrMsg string `json:"err_msg"`
  3908. InfRefmsgid string `json:"inf_refmsgid"`
  3909. Infcode string `json:"infcode"`
  3910. Output struct {
  3911. Result []struct {
  3912. OpspDiseCode string `json:"opsp_dise_code"`
  3913. OpspDiseName string `json:"opsp_dise_name"`
  3914. Begndate string `json:"begndate"`
  3915. Enddate string `json:"enddate"`
  3916. } `json:"feedetail"`
  3917. } `json:"output"`
  3918. RefmsgTime string `json:"refmsg_time"`
  3919. RespondTime string `json:"respond_time"`
  3920. Signtype interface{} `json:"signtype"`
  3921. WarnInfo interface{} `json:"warn_info"`
  3922. }
  3923. //获取个人信息----挂号-----上传就诊信息
  3924. func (c *HisApiController) GetRegisterInfo() {
  3925. id, _ := c.GetInt64("id")
  3926. record_time := c.GetString("record_time")
  3927. settlementValue, _ := c.GetInt64("settlement_value")
  3928. medical_insurance_card := c.GetString("medical_insurance_card")
  3929. name := c.GetString("name")
  3930. id_card_type, _ := c.GetInt64("id_card_type")
  3931. certificates, _ := c.GetInt64("certificates")
  3932. medical_care, _ := c.GetInt64("medical_care")
  3933. birthday := c.GetString("birthday")
  3934. id_card := c.GetString("id_card")
  3935. register_type, _ := c.GetInt64("register")
  3936. doctor, _ := c.GetInt64("doctor")
  3937. department, _ := c.GetInt64("department")
  3938. gender, _ := c.GetInt64("sex")
  3939. registration_fee, _ := c.GetFloat("registration_fee")
  3940. medical_expenses, _ := c.GetFloat("medical_expenses")
  3941. social_type, _ := c.GetInt64("social_type")
  3942. med_type := c.GetString("social_type")
  3943. admin_user_id, _ := c.GetInt64("admin_user_id")
  3944. insuplc_admdvs := c.GetString("insuplc_admdvs")
  3945. timeLayout := "2006-01-02"
  3946. loc, _ := time.LoadLocation("Local")
  3947. birthdays, _ := time.ParseInLocation(timeLayout+" 15:04:05", birthday+" 00:00:00", loc)
  3948. birthUnix := birthdays.Unix()
  3949. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  3950. if err != nil {
  3951. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  3952. return
  3953. }
  3954. recordDateTime := theTime.Unix()
  3955. adminInfo := c.GetAdminUserInfo()
  3956. var patient service.Patients
  3957. if id == 0 {
  3958. patient, _ = service.GetPatientByIDCard(id_card, adminInfo.CurrentOrgId)
  3959. } else {
  3960. patient, _ = service.GetPatientByIDTwo(adminInfo.CurrentOrgId, id)
  3961. }
  3962. patientPrescription, _ := service.FindPatientPrescriptionInfo(adminInfo.CurrentOrgId, id, recordDateTime)
  3963. if patientPrescription.ID == 0 {
  3964. patientPrescription, _ = service.FindLastPatientPrescriptionInfo(adminInfo.CurrentOrgId, id, recordDateTime)
  3965. }
  3966. miConfig, _ := service.FindMedicalInsuranceInfo(adminInfo.CurrentOrgId)
  3967. if patient.ID == 0 {
  3968. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodePatientNoExist)
  3969. return
  3970. }
  3971. if len(patient.IdCardNo) == 0 {
  3972. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeIDCartNo)
  3973. return
  3974. }
  3975. config, _ := service.GetMedicalInsuranceConfig(adminInfo.CurrentOrgId)
  3976. roles, _ := service.GetAdminUserInfoByID(adminInfo.CurrentOrgId, admin_user_id)
  3977. doctor_info, _ := service.GetAdminUserInfoByID(adminInfo.CurrentOrgId, doctor)
  3978. //就诊结算未完成,不能进行二次挂号
  3979. his, _ := service.GetHisPatientInfoTwo(adminInfo.CurrentOrgId, patient.ID, recordDateTime)
  3980. if len(his) >= 1 {
  3981. order, _ := service.GetNewHisOrderTwo(adminInfo.CurrentOrgId, his[len(his)-1].Number, his[len(his)-1].PatientId, recordDateTime)
  3982. if len(his) >= 1 && order.ID == 0 {
  3983. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisPatientParamWrong)
  3984. return
  3985. }
  3986. }
  3987. //var register_log string
  3988. if config.IsOpen == 1 {
  3989. var res ResultTwo
  3990. var res10265 ResultTwo10265
  3991. var PsnNo string
  3992. var PsnCertType string
  3993. var Certno string
  3994. var PsnName string
  3995. var Gend string
  3996. var Naty string
  3997. var Brdy string
  3998. var Age float64
  3999. var infoStr string
  4000. var idetinfoStr string
  4001. var infocode int64
  4002. var verify_number string
  4003. fmt.Println(verify_number)
  4004. if miConfig.MdtrtareaAdmvs == "421300" {
  4005. psn_info, _ := service.GetPsnByPatientId(id)
  4006. PsnNo = psn_info.PsnNo
  4007. PsnCertType = psn_info.PsnCertType
  4008. Certno = psn_info.Certno
  4009. PsnName = psn_info.PsnName
  4010. Gend = psn_info.Gend
  4011. Naty = psn_info.Naty
  4012. Brdy = psn_info.Brdy
  4013. Age = psn_info.Age
  4014. infoStr = psn_info.Insuinfo
  4015. idetinfoStr = psn_info.Idetinfo
  4016. infocode = 0
  4017. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  4018. psn_info, _ := service.GetPsnByPatientId(id)
  4019. PsnNo = psn_info.PsnNo
  4020. PsnCertType = psn_info.PsnCertType
  4021. Certno = psn_info.Certno
  4022. PsnName = psn_info.PsnName
  4023. Gend = psn_info.Gend
  4024. Naty = psn_info.Naty
  4025. Brdy = psn_info.Brdy
  4026. Age = psn_info.Age
  4027. infoStr = psn_info.Insuinfo
  4028. idetinfoStr = psn_info.Idetinfo
  4029. infocode = 0
  4030. verify_number = psn_info.VerifyNumber
  4031. } else {
  4032. var result string
  4033. var requestLog string
  4034. if miConfig.UserOrgId == 10138 {
  4035. result, requestLog = service.Gdyb1101D(patient.IdCardNo, miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, id_card_type, "", strconv.FormatInt(certificates, 10), name, record_time)
  4036. } else {
  4037. result, requestLog = service.Gdyb1101(patient.IdCardNo, miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, id_card_type, "", strconv.FormatInt(certificates, 10), name)
  4038. }
  4039. saveLog(result, requestLog, "1101", "人员基本信息获取")
  4040. if miConfig.Code == "H15049901371" {
  4041. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  4042. utils.ErrorLog("解析失败:%v", err)
  4043. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4044. return
  4045. }
  4046. res.ErrMsg = res10265.ErrMsg
  4047. res.Output = res10265.Output
  4048. res.InfRefmsgid = res10265.InfRefmsgid
  4049. } else {
  4050. if err := json.Unmarshal([]byte(result), &res); err != nil {
  4051. utils.ErrorLog("解析失败:%v", err)
  4052. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4053. return
  4054. }
  4055. }
  4056. PsnNo = res.Output.Baseinfo.PsnNo
  4057. PsnCertType = res.Output.Baseinfo.PsnCertType
  4058. Certno = res.Output.Baseinfo.Certno
  4059. PsnName = res.Output.Baseinfo.PsnName
  4060. Gend = res.Output.Baseinfo.Gend
  4061. Naty = res.Output.Baseinfo.Naty
  4062. Brdy = res.Output.Baseinfo.Brdy
  4063. Age = res.Output.Baseinfo.Age
  4064. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  4065. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  4066. infoStr = string(Iinfos)
  4067. idetinfoStr = string(Idetinfos)
  4068. if miConfig.Code == "H15049901371" {
  4069. infocode, _ = strconv.ParseInt(res10265.Infcode, 10, 64)
  4070. } else {
  4071. infocode = res.Infcode
  4072. }
  4073. }
  4074. if infocode == 0 {
  4075. his := models.VMHisPatient{
  4076. Name: name,
  4077. Gender: gender,
  4078. Birthday: birthUnix,
  4079. MedicalTreatmentType: medical_care,
  4080. IdType: certificates,
  4081. IdCardNo: id_card,
  4082. BalanceAccountsType: settlementValue,
  4083. SocialType: social_type,
  4084. MedicalInsuranceNumber: medical_insurance_card,
  4085. RegisterType: register_type,
  4086. RegisterCost: registration_fee,
  4087. TreatmentCost: medical_expenses,
  4088. Status: 1,
  4089. Ctime: time.Now().Unix(),
  4090. Mtime: time.Now().Unix(),
  4091. PsnNo: PsnNo,
  4092. PsnCertType: PsnCertType,
  4093. Certno: Certno,
  4094. PsnName: PsnName,
  4095. Gend: Gend,
  4096. Naty: Naty,
  4097. Brdy: Brdy,
  4098. Age: Age,
  4099. Iinfo: infoStr,
  4100. Idetinfo: idetinfoStr,
  4101. PatientId: patient.ID,
  4102. RecordDate: theTime.Unix(),
  4103. UserOrgId: adminInfo.CurrentOrgId,
  4104. AdminUserId: admin_user_id,
  4105. IsReturn: 1,
  4106. IdCardType: id_card_type,
  4107. Doctor: doctor,
  4108. Departments: department,
  4109. }
  4110. timestamp := time.Now().Unix()
  4111. tempTime := time.Unix(timestamp, 0)
  4112. timeFormat := tempTime.Format("20060102150405")
  4113. chrgBchno := rand.Intn(100000) + 10000
  4114. ipt_otp_no := timeFormat + strconv.FormatInt(int64(chrgBchno), 10) + strconv.FormatInt(his.PatientId, 10)
  4115. //count, _ := service.FindHisRegisterRecord(theTime.Unix(), patient.ID, adminInfo.CurrentOrgId)
  4116. department, _ := service.GetDepartMentDetail(department)
  4117. doctor_id := strconv.FormatInt(patientPrescription.DoctorId, 10)
  4118. IdCardNo := ""
  4119. if id_card_type == 1 {
  4120. // IdCardNo = medical_insurance_card
  4121. IdCardNo = patient.IdCardNo
  4122. } else {
  4123. IdCardNo = patient.IdCardNo
  4124. }
  4125. var rf []*ResultFive
  4126. json.Unmarshal([]byte(his.Iinfo), &rf)
  4127. var insutypes []*ResultFive
  4128. var insutype string
  4129. var insuplc_admdvs_temp string
  4130. var is390 int = 0
  4131. var is310 int = 0
  4132. for _, item := range rf {
  4133. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  4134. insutypes = append(insutypes, item)
  4135. }
  4136. }
  4137. if len(insutypes) == 1 {
  4138. insutype = insutypes[0].Insutype
  4139. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  4140. } else {
  4141. for _, i := range insutypes {
  4142. if i.Insutype == "390" {
  4143. is390 = 1
  4144. }
  4145. if i.Insutype == "310" {
  4146. is310 = 1
  4147. }
  4148. }
  4149. }
  4150. if is390 == 1 {
  4151. insutype = "390"
  4152. }
  4153. if is310 == 1 {
  4154. insutype = "310"
  4155. }
  4156. if len(insutypes) == 0 {
  4157. insutype = "310"
  4158. }
  4159. if len(insutypes) == 2 {
  4160. insutype = med_type
  4161. }
  4162. if len(med_type) > 0 {
  4163. insutype = med_type
  4164. }
  4165. //for _, item := range rf {
  4166. // if item.Insutype == insutype {
  4167. // insuplc_admdvs = item.InsuplcAdmdvs
  4168. // }
  4169. //}
  4170. var infocode int64
  4171. var resThree ResultThree
  4172. var resThree10265 ResultThree10265
  4173. if len(insuplc_admdvs) == 0 {
  4174. insuplc_admdvs_temp = miConfig.InsuplcAdmdvs
  4175. } else {
  4176. insuplc_admdvs_temp = insuplc_admdvs
  4177. }
  4178. if miConfig.MdtrtareaAdmvs == "421300" {
  4179. api := "http://192.168.124.4:9532/" + "hbyb/2201?psn_no=" + PsnNo + "&insutype=" + insutype + "&cert_no=" + Certno + "&ipt_otp_no=" + ipt_otp_no +
  4180. "&org_name=" + miConfig.OrgName + "&doctor=" + doctor_info.UserName + "&fixmedins_code=" + miConfig.Code +
  4181. "&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_id + "&doctor_name=" + doctor_info.UserName
  4182. resp, requestErr := http.Get(api)
  4183. if requestErr != nil {
  4184. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4185. return
  4186. }
  4187. body, ioErr := ioutil.ReadAll(resp.Body)
  4188. if ioErr != nil {
  4189. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  4190. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4191. return
  4192. }
  4193. var respJSON map[string]interface{}
  4194. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  4195. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  4196. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4197. return
  4198. }
  4199. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  4200. result, _ := json.Marshal(respJSON)
  4201. if err := json.Unmarshal([]byte(result), &resThree); err != nil {
  4202. utils.ErrorLog("解析失败:%v", err)
  4203. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4204. return
  4205. }
  4206. infocode = resThree.Infcode
  4207. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  4208. psn_info, _ := service.GetPsnByPatientId(id)
  4209. psn_info.VerifyNumber = strings.Replace(psn_info.VerifyNumber, "+", "%2B", -1)
  4210. var cert_no string
  4211. if id_card_type == 3 {
  4212. psn_info.VerifyNumber = IdCardNo + "|" + psn_info.VerifyNumber
  4213. cert_no = IdCardNo
  4214. } else {
  4215. bas := strings.Split(psn_info.CardInfo, "|")
  4216. cert_no = bas[2]
  4217. }
  4218. var api string
  4219. if miConfig.MdtrtareaAdmvs == "320921" {
  4220. api = "http://192.168.3.111:9532/" + "jsyb/2201?psn_no=" + PsnNo + "&insutype=" + insutype + "&cert_no=" + cert_no + "&ipt_otp_no=" + ipt_otp_no +
  4221. "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&doctor_name=" + doctor_info.UserName + "&fixmedins_code=" + miConfig.Code +
  4222. "&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_id + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&verify_number=" + psn_info.VerifyNumber + "&cainfo=" + miConfig.Cainfo
  4223. } else {
  4224. api = "http://192.168.5.251:9532/" + "jsyb/2201?psn_no=" + PsnNo + "&insutype=" + insutype + "&cert_no=" + cert_no + "&ipt_otp_no=" + ipt_otp_no +
  4225. "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&doctor_name=" + doctor_info.UserName + "&fixmedins_code=" + miConfig.Code +
  4226. "&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_id + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&verify_number=" + psn_info.VerifyNumber + "&cainfo=" + miConfig.Cainfo
  4227. }
  4228. resp, requestErr := http.Get(api)
  4229. if requestErr != nil {
  4230. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4231. return
  4232. }
  4233. body, ioErr := ioutil.ReadAll(resp.Body)
  4234. if ioErr != nil {
  4235. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  4236. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4237. return
  4238. }
  4239. var respJSON map[string]interface{}
  4240. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  4241. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  4242. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4243. return
  4244. }
  4245. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  4246. result, _ := json.Marshal(respJSON)
  4247. if err := json.Unmarshal([]byte(result), &resThree10265); err != nil {
  4248. utils.ErrorLog("解析失败:%v", err)
  4249. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4250. return
  4251. }
  4252. resThree.ErrMsg = resThree10265.ErrMsg
  4253. resThree.Output = resThree10265.Output
  4254. resThree.InfRefmsgid = resThree10265.InfRefmsgid
  4255. infocode, _ = strconv.ParseInt(resThree10265.Infcode, 10, 64)
  4256. } else {
  4257. result, requestLog := service.Gdyb2201(res.Output.Baseinfo.PsnNo, insutype, IdCardNo, miConfig.OrgName, roles.UserName, ipt_otp_no, department.Name, miConfig.Code, department.Number, doctor_id, insuplc_admdvs_temp, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, id_card_type, doctor_info.UserName)
  4258. saveLog(result, requestLog, "2201", "挂号")
  4259. if miConfig.Code == "H15049901371" {
  4260. if err := json.Unmarshal([]byte(result), &resThree10265); err != nil {
  4261. utils.ErrorLog("解析失败:%v", err)
  4262. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4263. return
  4264. }
  4265. resThree.ErrMsg = resThree10265.ErrMsg
  4266. resThree.Output = resThree10265.Output
  4267. resThree.InfRefmsgid = resThree10265.InfRefmsgid
  4268. } else {
  4269. if err := json.Unmarshal([]byte(result), &resThree); err != nil {
  4270. utils.ErrorLog("解析失败:%v", err)
  4271. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4272. return
  4273. }
  4274. }
  4275. if miConfig.Code == "H15049901371" {
  4276. infocode, _ = strconv.ParseInt(resThree10265.Infcode, 10, 64)
  4277. } else {
  4278. infocode = resThree.Infcode
  4279. }
  4280. }
  4281. if infocode != 0 {
  4282. adminUser := c.GetAdminUserInfo()
  4283. errlog := &models.HisOrderError{
  4284. UserOrgId: adminUser.CurrentOrgId,
  4285. Ctime: time.Now().Unix(),
  4286. Mtime: time.Now().Unix(),
  4287. ErrMsg: resThree.ErrMsg,
  4288. Status: 1,
  4289. PatientId: id,
  4290. RecordTime: recordDateTime,
  4291. Stage: 2,
  4292. }
  4293. service.CreateErrMsgLog(errlog)
  4294. c.ServeSuccessJSON(map[string]interface{}{
  4295. "failed_code": -10,
  4296. "msg": resThree.ErrMsg,
  4297. })
  4298. return
  4299. }
  4300. his.Number = resThree.Output.Data.MdtrtID
  4301. his.PsnNo = resThree.Output.Data.PsnNo
  4302. his.IptOtpNo = resThree.Output.Data.IptOtpNo
  4303. his.IdCardNo = patient.IdCardNo
  4304. his.PhoneNumber = patient.Phone
  4305. his.UserOrgId = adminInfo.CurrentOrgId
  4306. his.Insutype = insutype
  4307. his.Ctime = time.Now().Unix()
  4308. his.Mtime = time.Now().Unix()
  4309. his.InsuplcAdmdvs = insuplc_admdvs_temp
  4310. his.Status = 1
  4311. service.UpdateHisPatientStatus(&his)
  4312. service.UpdateHisPrescriptionHisID(his.ID, patient.ID, recordDateTime, adminInfo.CurrentOrgId)
  4313. c.ServeSuccessJSON(map[string]interface{}{
  4314. "his_info": his,
  4315. })
  4316. } else {
  4317. adminUser := c.GetAdminUserInfo()
  4318. errlog := &models.HisOrderError{
  4319. UserOrgId: adminUser.CurrentOrgId,
  4320. Ctime: time.Now().Unix(),
  4321. Mtime: time.Now().Unix(),
  4322. ErrMsg: res.ErrMsg,
  4323. Status: 1,
  4324. PatientId: id,
  4325. RecordTime: recordDateTime,
  4326. Stage: 1,
  4327. }
  4328. service.CreateErrMsgLog(errlog)
  4329. c.ServeSuccessJSON(map[string]interface{}{
  4330. "failed_code": -10,
  4331. "msg": res.ErrMsg,
  4332. })
  4333. return
  4334. //c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeGdybOneException)
  4335. }
  4336. }
  4337. }
  4338. //上传明细----预结算----确认订单
  4339. func (c *HisApiController) GetUploadInfo() {
  4340. id, _ := c.GetInt64("id")
  4341. record_time := c.GetString("record_time")
  4342. his_patient_id, _ := c.GetInt64("his_patient_id")
  4343. order_id, _ := c.GetInt64("order_id")
  4344. pay_way, _ := c.GetInt64("pay_way")
  4345. pay_price, _ := c.GetFloat("pay_price")
  4346. pay_card_no := c.GetString("pay_card_no")
  4347. discount_price, _ := c.GetFloat("discount_price")
  4348. preferential_price, _ := c.GetFloat("preferential_price")
  4349. reality_price, _ := c.GetFloat("reality_price")
  4350. found_price, _ := c.GetFloat("found_price")
  4351. medical_insurance_price, _ := c.GetFloat("medical_insurance_price")
  4352. private_price, _ := c.GetFloat("private_price")
  4353. settle_accounts_type, _ := c.GetInt64("settle_accounts_type")
  4354. admin_user_id, _ := c.GetInt64("admin_user_id")
  4355. fapiao_code := c.GetString("fapiao_code")
  4356. fapiao_number := c.GetString("fapiao_number")
  4357. diagnosis_id := c.GetString("diagnosis")
  4358. sick_type, _ := c.GetInt64("sick_type")
  4359. reg_type, _ := c.GetInt64("p_type")
  4360. begin_time := c.GetString("begin_time")
  4361. id_str := c.GetString("ids")
  4362. ids_arr := strings.Split(id_str, ",")
  4363. timeLayout := "2006-01-02"
  4364. loc, _ := time.LoadLocation("Local")
  4365. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  4366. if err != nil {
  4367. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  4368. return
  4369. }
  4370. recordDateTime := theTime.Unix()
  4371. adminUser := c.GetAdminUserInfo()
  4372. var tempOrder models.HisOrder
  4373. tempOrder, _ = service.GetHisOrderByID(order_id)
  4374. var prescriptions []*models.HisPrescription
  4375. var start_time int64
  4376. var end_time int64
  4377. //if adminUser.CurrentOrgId == 10106{
  4378. // if len(fapiao_code) == 0{
  4379. // fapiao_code = "144072080589"
  4380. // }
  4381. // if len(fapiao_number) == 0{
  4382. // order, _ := service.GetLastHisOrder(adminUser.CurrentOrgId)
  4383. // if order.ID == 0{
  4384. // fapiao_number = "00001520"
  4385. // }else{
  4386. // //fapiao_code = "00001520"
  4387. // fpNumber, _ := strconv.Atoi(order.FaPiaoNumber)
  4388. // var zero string
  4389. // if fpNumber >= 1000{
  4390. // zero = "0000" + strconv.Itoa(fpNumber)
  4391. // }else if fpNumber >= 10000{
  4392. // zero = "000" + strconv.Itoa(fpNumber)
  4393. // } else if fpNumber >= 100000{
  4394. // zero = "00" + strconv.Itoa(fpNumber)
  4395. // } else if fpNumber >= 1000000{
  4396. // zero = "0" + strconv.Itoa(fpNumber)
  4397. // }else {
  4398. // zero = strconv.Itoa(fpNumber)
  4399. // }
  4400. // fapiao_number = zero
  4401. // }
  4402. // }
  4403. //}
  4404. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  4405. his, _ := service.GetNewHisPatientInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  4406. var patientPrescription models.HisPrescriptionInfo
  4407. patientPrescription, _ = service.FindHisPatientPrescriptionInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  4408. if patientPrescription.ID == 0 {
  4409. patientPrescription, _ = service.FindLastPatientPrescriptionInfo(adminUser.CurrentOrgId, id, recordDateTime)
  4410. }
  4411. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  4412. department, _ := service.GetDepartMentDetail(patientPrescription.Departments)
  4413. doctor_info, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, patientPrescription.DoctorId)
  4414. diagnosis_ids := strings.Split(diagnosis_id, ",")
  4415. var config []*models.HisXtDiagnoseConfig
  4416. for _, item := range diagnosis_ids {
  4417. id, _ := strconv.ParseInt(item, 10, 64)
  4418. diagnosisConfig, _ := service.FindDiagnoseById(id)
  4419. config = append(config, &diagnosisConfig)
  4420. }
  4421. sickConfig, _ := service.FindSickById(sick_type)
  4422. //if tempOrder.ID == 0 {
  4423. // tempOrder, _ = service.GetTodayHisOrder(adminUser.CurrentOrgId, id, recordDateTime, his.Number)
  4424. //}
  4425. if tempOrder.ID == 0 {
  4426. var result string
  4427. var requestLog string
  4428. var res2 ResultSix
  4429. var ressix10265 ResultSix10265
  4430. if miConfig.MdtrtareaAdmvs == "421300" {
  4431. data := make(map[string]interface{})
  4432. client := &http.Client{}
  4433. data["psn_no"] = his.PsnNo
  4434. data["mdtrt_id"] = his.Number
  4435. data["doctor"] = roles.UserName
  4436. data["department"] = department.Name
  4437. data["org_name"] = miConfig.OrgName
  4438. data["med_type"] = strconv.FormatInt(reg_type, 10)
  4439. data["doctor_id"] = strconv.FormatInt(doctor_info.AdminUserId, 10)
  4440. data["fixmedins_code"] = miConfig.Code
  4441. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  4442. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  4443. data["secret_key"] = miConfig.SecretKey
  4444. data["sick_code"] = sickConfig.CountryCode
  4445. data["sick_name"] = sickConfig.ClassName
  4446. data["dept"] = strconv.FormatInt(department.ID, 10)
  4447. data["config"] = config
  4448. data["begin_time"] = begin_time
  4449. bytesData, _ := json.Marshal(data)
  4450. req, _ := http.NewRequest("POST", "http://192.168.124.4:9532/"+"hbyb/2203", bytes.NewReader(bytesData))
  4451. resp, _ := client.Do(req)
  4452. defer resp.Body.Close()
  4453. body, ioErr := ioutil.ReadAll(resp.Body)
  4454. if ioErr != nil {
  4455. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  4456. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4457. return
  4458. }
  4459. var respJSON map[string]interface{}
  4460. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  4461. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  4462. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4463. return
  4464. }
  4465. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  4466. userJSONBytes, _ := json.Marshal(respJSON)
  4467. fmt.Println("log")
  4468. fmt.Println(string(userJSONBytes))
  4469. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  4470. utils.ErrorLog("解析失败:%v", err)
  4471. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4472. return
  4473. }
  4474. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  4475. //江苏地区国家医保医疗类别
  4476. //职工透析:医疗类别选特殊情况门诊9933
  4477. //居民血透门慢: 医疗类别选门诊慢病1402
  4478. //var med_type string
  4479. //if his.Insutype == "310" {
  4480. // if reg_type == 14 {
  4481. // med_type = "9933"
  4482. // } else if reg_type == 11 {
  4483. // med_type = "11"
  4484. //
  4485. // }
  4486. //} else if his.Insutype == "390" {
  4487. // if reg_type == 14 {
  4488. // med_type = "1402"
  4489. // } else if reg_type == 11 {
  4490. // med_type = "11"
  4491. // }
  4492. //}
  4493. data := make(map[string]interface{})
  4494. client := &http.Client{}
  4495. data["psn_no"] = his.PsnNo
  4496. data["mdtrt_id"] = his.Number
  4497. data["doctor"] = roles.UserName
  4498. data["department"] = department.Name
  4499. data["org_name"] = miConfig.OrgName
  4500. data["med_type"] = strconv.FormatInt(reg_type, 10)
  4501. data["doctor_id"] = strconv.FormatInt(doctor_info.AdminUserId, 10)
  4502. data["fixmedins_code"] = miConfig.Code
  4503. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  4504. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  4505. data["secret_key"] = miConfig.SecretKey
  4506. data["sick_code"] = sickConfig.CountryCode
  4507. data["sick_name"] = sickConfig.ClassName
  4508. data["url"] = miConfig.Url
  4509. data["ak"] = miConfig.AccessKey
  4510. data["begin_time"] = begin_time
  4511. data["cainfo"] = miConfig.Cainfo
  4512. data["dept"] = strconv.FormatInt(department.ID, 10)
  4513. data["config"] = config
  4514. bytesData, _ := json.Marshal(data)
  4515. var req *http.Request
  4516. if miConfig.MdtrtareaAdmvs == "320921" {
  4517. req, _ = http.NewRequest("POST", "http://192.168.3.111:9532/"+"jsyb/2203", bytes.NewReader(bytesData))
  4518. //api = "http://192.168.3.111:9532/" + "jsyb/readcard?" + "fixmedins_code=" + miConfig.Code + "&secret_key=" + miConfig.SecretKey + "&ak=" + miConfig.AccessKey + "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName +
  4519. // "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&cainfo=" + miConfig.Cainfo
  4520. } else {
  4521. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2203", bytes.NewReader(bytesData))
  4522. }
  4523. resp, _ := client.Do(req)
  4524. defer resp.Body.Close()
  4525. body, ioErr := ioutil.ReadAll(resp.Body)
  4526. if ioErr != nil {
  4527. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  4528. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4529. return
  4530. }
  4531. var respJSON map[string]interface{}
  4532. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  4533. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  4534. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4535. return
  4536. }
  4537. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  4538. userJSONBytes, _ := json.Marshal(respJSON)
  4539. fmt.Println("log")
  4540. fmt.Println(string(userJSONBytes))
  4541. if err := json.Unmarshal(userJSONBytes, &ressix10265); err != nil {
  4542. utils.ErrorLog("解析失败:%v", err)
  4543. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4544. return
  4545. }
  4546. res2.InfRefmsgid = ressix10265.InfRefmsgid
  4547. res2.Output = ressix10265.Output
  4548. res2.ErrMsg = ressix10265.ErrMsg
  4549. res2.Cainfo = ressix10265.Cainfo
  4550. res2.WarnMsg = ressix10265.WarnMsg
  4551. infocode, _ := strconv.ParseInt(ressix10265.Infcode, 10, 64)
  4552. res2.Infcode = infocode
  4553. } else {
  4554. if miConfig.MdtrtareaAdmvs == "440781" { //
  4555. 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)
  4556. } else {
  4557. if miConfig.Code == "H15049901371" {
  4558. //赤峰地区国家医保医疗类别
  4559. //职工透析:医疗类别选特殊情况门诊990502
  4560. //居民定额血透门慢: 医疗类别选门诊慢病140104
  4561. var med_type string
  4562. if his.Insutype == "390" {
  4563. if reg_type == 14 {
  4564. med_type = "9933"
  4565. } else if reg_type == 11 {
  4566. med_type = "11"
  4567. }
  4568. } else if his.Insutype == "310" {
  4569. if reg_type == 14 {
  4570. med_type = "990502"
  4571. } else if reg_type == 11 {
  4572. med_type = "11"
  4573. }
  4574. }
  4575. 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)
  4576. } else {
  4577. 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)
  4578. }
  4579. }
  4580. saveLog(result, requestLog, "2203", "上传就诊信息")
  4581. var respJSON2 map[string]interface{}
  4582. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  4583. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  4584. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4585. return
  4586. }
  4587. userJSONBytes2, _ := json.Marshal(respJSON2)
  4588. if miConfig.Code == "H15049901371" {
  4589. if err := json.Unmarshal(userJSONBytes2, &ressix10265); err != nil {
  4590. utils.ErrorLog("解析失败:%v", err)
  4591. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4592. return
  4593. }
  4594. res2.InfRefmsgid = ressix10265.InfRefmsgid
  4595. res2.Output = ressix10265.Output
  4596. res2.ErrMsg = ressix10265.ErrMsg
  4597. res2.Cainfo = ressix10265.Cainfo
  4598. res2.WarnMsg = ressix10265.WarnMsg
  4599. infocode, _ := strconv.ParseInt(ressix10265.Infcode, 10, 64)
  4600. res2.Infcode = infocode
  4601. } else {
  4602. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  4603. utils.ErrorLog("解析失败:%v", err)
  4604. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4605. return
  4606. }
  4607. }
  4608. }
  4609. if res2.Infcode != 0 {
  4610. adminUser := c.GetAdminUserInfo()
  4611. errlog := &models.HisOrderError{
  4612. UserOrgId: adminUser.CurrentOrgId,
  4613. Ctime: time.Now().Unix(),
  4614. Mtime: time.Now().Unix(),
  4615. ErrMsg: res2.ErrMsg,
  4616. Status: 1,
  4617. PatientId: id,
  4618. RecordTime: recordDateTime,
  4619. Stage: 3,
  4620. }
  4621. service.CreateErrMsgLog(errlog)
  4622. c.ServeSuccessJSON(map[string]interface{}{
  4623. "failed_code": -10,
  4624. "msg": res2.ErrMsg,
  4625. })
  4626. return
  4627. } else {
  4628. his.Diagnosis = diagnosis_id
  4629. his.SickType = sickConfig.ID
  4630. //var p_type int64
  4631. //if reg_type == 1111 || reg_type == 1112 {
  4632. // p_type = 11
  4633. //
  4634. //}
  4635. his.PType = fmt.Sprintf("%d", reg_type)
  4636. service.UpdateHisPatientThree(&his)
  4637. data := make(map[string]interface{})
  4638. if settle_accounts_type == 1 { //日结
  4639. if reg_type == 11 || reg_type == 1111 || reg_type == 1112 {
  4640. prescriptions, _ = service.GetPrescriptionByIds(ids_arr, adminUser.CurrentOrgId)
  4641. } else {
  4642. prescriptions, _ = service.GetNewHisPrescription(adminUser.CurrentOrgId, his_patient_id, recordDateTime, strconv.Itoa(int(reg_type)))
  4643. }
  4644. //prescriptions, _ = service.GetNewHisPrescriptionTwo(adminUser.CurrentOrgId, his_patient_id, recordDateTime, reg_type)
  4645. data["pre"] = prescriptions
  4646. } else { //月结
  4647. start_time_str := c.GetString("start_time")
  4648. end_time_str := c.GetString("end_time")
  4649. timeLayout := "2006-01-02"
  4650. loc, _ := time.LoadLocation("Local")
  4651. theStartTime, err := time.ParseInLocation(timeLayout+" 15:04:05", start_time_str+" 00:00:00", loc)
  4652. if err != nil {
  4653. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  4654. return
  4655. }
  4656. recordStartTime := theStartTime.Unix()
  4657. start_time = recordStartTime
  4658. theEndTime, err := time.ParseInLocation(timeLayout+" 15:04:05", end_time_str+" 00:00:00", loc)
  4659. if err != nil {
  4660. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  4661. return
  4662. }
  4663. recordEndTime := theEndTime.Unix()
  4664. end_time = recordEndTime
  4665. prescriptions, _ = service.GetMonthHisPrescriptionTwo(adminUser.CurrentOrgId, id, recordStartTime, recordEndTime, reg_type)
  4666. data["pre"] = prescriptions
  4667. }
  4668. timestamp := time.Now().Unix()
  4669. tempTime := time.Unix(timestamp, 0)
  4670. timeFormat := tempTime.Format("20060102150405")
  4671. chrgBchno := rand.Intn(100000) + 10000
  4672. chrg_bchno := timeFormat + strconv.FormatInt(int64(chrgBchno), 10) + strconv.FormatInt(his.PatientId, 10)
  4673. strconv.FormatInt(his.PatientId, 10)
  4674. client := &http.Client{}
  4675. data["psn_no"] = his.PsnNo
  4676. data["mdtrt_id"] = his.Number
  4677. data["chrg_bchno"] = chrg_bchno
  4678. data["org_name"] = miConfig.OrgName
  4679. data["doctor"] = roles.UserName
  4680. data["doctor_id"] = strconv.FormatInt(roles.AdminUserId, 10)
  4681. data["dept"] = strconv.FormatInt(patientPrescription.Departments, 10)
  4682. data["fixmedins_code"] = miConfig.Code
  4683. //if (department.ID == 0 && adminUser.CurrentOrgId == 9919) || (department.ID == 0 && adminUser.CurrentOrgId == 10106) {
  4684. // data["dept_code"] = "15"
  4685. //} else {
  4686. data["dept_code"] = department.Number
  4687. //}
  4688. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  4689. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  4690. data["secret_key"] = miConfig.SecretKey
  4691. data["balance_accounts_type"] = strconv.FormatInt(his.BalanceAccountsType, 10)
  4692. data["url"] = miConfig.Url
  4693. data["ak"] = miConfig.AccessKey
  4694. data["new_doctor_name"] = patientPrescription.Doctor
  4695. data["diag_code"] = sickConfig.CountryCode
  4696. data["cainfo"] = miConfig.Cainfo
  4697. var ids []int64
  4698. for _, item := range prescriptions {
  4699. ids = append(ids, item.ID)
  4700. }
  4701. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  4702. if config.IsOpen == 1 { //对接了医保,走医保流程
  4703. var res ResultFour
  4704. var resFour10265 ResultFour10265
  4705. if miConfig.MdtrtareaAdmvs == "421300" {
  4706. bytesData, _ := json.Marshal(data)
  4707. req, _ := http.NewRequest("POST", "http://192.168.124.4:9532/"+"hbyb/2204", bytes.NewReader(bytesData))
  4708. resp, _ := client.Do(req)
  4709. defer resp.Body.Close()
  4710. body, ioErr := ioutil.ReadAll(resp.Body)
  4711. if ioErr != nil {
  4712. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  4713. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4714. return
  4715. }
  4716. var respJSON map[string]interface{}
  4717. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  4718. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  4719. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4720. return
  4721. }
  4722. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  4723. userJSONBytes, _ := json.Marshal(respJSON)
  4724. fmt.Println("log")
  4725. fmt.Println(string(userJSONBytes))
  4726. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  4727. utils.ErrorLog("解析失败:%v", err)
  4728. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4729. return
  4730. }
  4731. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  4732. bytesData, _ := json.Marshal(data)
  4733. var req *http.Request
  4734. if miConfig.MdtrtareaAdmvs == "320921" {
  4735. req, _ = http.NewRequest("POST", "http://192.168.3.111:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  4736. } else {
  4737. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  4738. }
  4739. resp, _ := client.Do(req)
  4740. defer resp.Body.Close()
  4741. body, ioErr := ioutil.ReadAll(resp.Body)
  4742. if ioErr != nil {
  4743. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  4744. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4745. return
  4746. }
  4747. var respJSON map[string]interface{}
  4748. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  4749. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  4750. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4751. return
  4752. }
  4753. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  4754. userJSONBytes, _ := json.Marshal(respJSON)
  4755. fmt.Println("log")
  4756. fmt.Println(string(userJSONBytes))
  4757. if err := json.Unmarshal(userJSONBytes, &resFour10265); err != nil {
  4758. utils.ErrorLog("解析失败:%v", err)
  4759. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4760. return
  4761. }
  4762. res.InfRefmsgid = resFour10265.InfRefmsgid
  4763. res.Output = resFour10265.Output
  4764. res.ErrMsg = resFour10265.ErrMsg
  4765. res.Cainfo = resFour10265.Cainfo
  4766. res.WarnMsg = resFour10265.WarnMsg
  4767. infocode, _ := strconv.ParseInt(resFour10265.Infcode, 10, 64)
  4768. res.Infcode = infocode
  4769. } else {
  4770. if miConfig.Code == "H15049901371" {
  4771. 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)
  4772. var dat map[string]interface{}
  4773. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  4774. fmt.Println(dat)
  4775. } else {
  4776. fmt.Println(err)
  4777. }
  4778. saveLog(result, request_log, "2204", "上传费用明细")
  4779. userJSONBytes, _ := json.Marshal(dat)
  4780. if err := json.Unmarshal(userJSONBytes, &resFour10265); err != nil {
  4781. utils.ErrorLog("解析失败:%v", err)
  4782. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4783. return
  4784. }
  4785. res.InfRefmsgid = resFour10265.InfRefmsgid
  4786. res.Output = resFour10265.Output
  4787. res.ErrMsg = resFour10265.ErrMsg
  4788. res.Cainfo = resFour10265.Cainfo
  4789. res.WarnMsg = resFour10265.WarnMsg
  4790. infocode, _ := strconv.ParseInt(resFour10265.Infcode, 10, 64)
  4791. res.Infcode = infocode
  4792. } else {
  4793. 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)
  4794. var dat map[string]interface{}
  4795. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  4796. fmt.Println(dat)
  4797. } else {
  4798. fmt.Println(err)
  4799. }
  4800. saveLog(result, request_log, "2204", "上传费用明细")
  4801. userJSONBytes, _ := json.Marshal(dat)
  4802. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  4803. utils.ErrorLog("解析失败:%v", err)
  4804. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4805. return
  4806. }
  4807. }
  4808. }
  4809. if res.Infcode == 0 {
  4810. order := &models.HisOrder{
  4811. UserOrgId: adminUser.CurrentOrgId,
  4812. HisPatientId: his.ID,
  4813. PatientId: his.PatientId,
  4814. SettleAccountsDate: recordDateTime,
  4815. MdtrtId: his.Number,
  4816. PsnNo: his.PsnNo,
  4817. MedType: strconv.FormatInt(reg_type, 10),
  4818. Ctime: time.Now().Unix(),
  4819. Mtime: time.Now().Unix(),
  4820. Status: 1,
  4821. Number: chrg_bchno,
  4822. Infcode: res.Infcode,
  4823. WarnMsg: res.WarnMsg,
  4824. Cainfo: res.Cainfo,
  4825. ErrMsg: res.ErrMsg,
  4826. RespondTime: res.RefmsgTime,
  4827. InfRefmsgid: res.InfRefmsgid,
  4828. OrderStatus: 1,
  4829. PayWay: pay_way,
  4830. PayPrice: pay_price,
  4831. PayCardNo: pay_card_no,
  4832. DiscountPrice: discount_price,
  4833. PreferentialPrice: preferential_price,
  4834. RealityPrice: reality_price,
  4835. FoundPrice: found_price,
  4836. MedicalInsurancePrice: medical_insurance_price,
  4837. PrivatePrice: private_price,
  4838. IsMedicineInsurance: 1,
  4839. SettleType: settle_accounts_type,
  4840. SettleStartTime: start_time,
  4841. SettleEndTime: end_time,
  4842. Creator: roles.AdminUserId,
  4843. Modify: roles.AdminUserId,
  4844. FaPiaoNumber: fapiao_number,
  4845. FaPiaoCode: fapiao_code,
  4846. PType: 2,
  4847. Diagnosis: diagnosis_id,
  4848. }
  4849. err = service.CreateOrder(order)
  4850. if err != nil {
  4851. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCreatePreOrderException)
  4852. return
  4853. }
  4854. for _, item := range res.Output.Result {
  4855. temp := strings.Split(item.FeedetlSn, "-")
  4856. var advice_id int64 = 0
  4857. var project_id int64 = 0
  4858. var types int64 = 0
  4859. id, _ := strconv.ParseInt(temp[2], 10, 64)
  4860. types, _ = strconv.ParseInt(temp[1], 10, 64)
  4861. if temp[1] == "1" {
  4862. advice_id = id
  4863. project_id = 0
  4864. } else if temp[1] == "2" {
  4865. advice_id = 0
  4866. project_id = id
  4867. }
  4868. info := &models.HisOrderInfo{
  4869. OrderNumber: order.Number,
  4870. FeedetlSn: item.FeedetlSn,
  4871. UploadDate: time.Now().Unix(),
  4872. AdviceId: advice_id,
  4873. DetItemFeeSumamt: item.DetItemFeeSumamt,
  4874. Cnt: item.Cnt,
  4875. Pric: float64(item.Pric),
  4876. PatientId: his.PatientId,
  4877. PricUplmtAmt: item.PricUplmtAmt,
  4878. SelfpayProp: item.SelfpayProp,
  4879. FulamtOwnpayAmt: item.FulamtOwnpayAmt,
  4880. OverlmtAmt: item.OverlmtAmt,
  4881. PreselfpayAmt: item.PreselfpayAmt,
  4882. BasMednFlag: item.BasMednFlag,
  4883. MedChrgitmType: item.MedChrgitmType,
  4884. HiNegoDrugFlag: item.HiNegoDrugFlag,
  4885. Status: 1,
  4886. Memo: item.Memo,
  4887. Mtime: time.Now().Unix(),
  4888. InscpScpAmt: item.InscpScpAmt,
  4889. DrtReimFlag: item.DrtReimFlag,
  4890. Ctime: time.Now().Unix(),
  4891. ListSpItemFlag: item.ListSpItemFlag,
  4892. ChldMedcFlag: item.ChldMedcFlag,
  4893. LmtUsedFlag: item.LmtUsedFlag,
  4894. ChrgitmLv: item.ChrgitmLv,
  4895. UserOrgId: adminUser.CurrentOrgId,
  4896. HisPatientId: his.ID,
  4897. OrderId: order.ID,
  4898. ProjectId: project_id,
  4899. Type: types,
  4900. }
  4901. service.CreateOrderInfo(info)
  4902. }
  4903. service.UpDatePrescriptionNumber(adminUser.CurrentOrgId, ids, chrg_bchno)
  4904. service.UpDateHisPrescriptionInfoNumber(adminUser.CurrentOrgId, his_patient_id, chrg_bchno, recordDateTime)
  4905. var total float64
  4906. for _, item := range prescriptions {
  4907. if item.Type == 1 { //药品
  4908. for _, subItem := range item.HisDoctorAdviceInfo {
  4909. total = total + (subItem.Price * subItem.PrescribingNumber)
  4910. }
  4911. }
  4912. if item.Type == 2 { //项目
  4913. for _, subItem := range item.HisPrescriptionProject {
  4914. cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  4915. total = total + (subItem.Price * cnt)
  4916. }
  4917. }
  4918. }
  4919. for _, item := range prescriptions {
  4920. for _, subItem := range item.HisAdditionalCharge {
  4921. total = total + (subItem.Price * float64(subItem.Count))
  4922. }
  4923. }
  4924. var allTotal string
  4925. if adminUser.CurrentOrgId == 9919 {
  4926. allTotal = fmt.Sprintf("%.4f", total)
  4927. } else {
  4928. allTotal = fmt.Sprintf("%.4f", total)
  4929. }
  4930. if res.Infcode == 0 {
  4931. var rf []*ResultFive
  4932. json.Unmarshal([]byte(his.Iinfo), &rf)
  4933. chrg_bchno := chrg_bchno
  4934. cert_no := his.Certno
  4935. var insutypes []string
  4936. var insutype string
  4937. var is390 int = 0
  4938. var is310 int = 0
  4939. for _, item := range rf {
  4940. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  4941. insutypes = append(insutypes, item.Insutype)
  4942. }
  4943. }
  4944. if len(insutypes) == 1 {
  4945. insutype = insutypes[0]
  4946. } else {
  4947. for _, i := range insutypes {
  4948. if i == "390" {
  4949. is390 = 1
  4950. }
  4951. if i == "310" {
  4952. is310 = 1
  4953. }
  4954. }
  4955. }
  4956. if is390 == 1 {
  4957. insutype = "390"
  4958. }
  4959. if is310 == 1 {
  4960. insutype = "310"
  4961. }
  4962. if len(insutypes) == 0 {
  4963. insutype = "310"
  4964. }
  4965. if len(insutypes) == 2 {
  4966. insutype = strconv.FormatInt(his.SocialType, 10)
  4967. }
  4968. insutype = strconv.FormatInt(his.SocialType, 10)
  4969. //insutype = "390"
  4970. if his.IdCardType == 1 {
  4971. // cert_no = his.MedicalInsuranceNumber
  4972. cert_no = his.Certno
  4973. } else {
  4974. cert_no = his.Certno
  4975. }
  4976. var res ResultSeven
  4977. var resSeven10265 ResultSeven10265
  4978. var src_resquest string
  4979. var result2 string
  4980. var acct_used_flag string
  4981. fmt.Println("pay_way")
  4982. fmt.Println(pay_way)
  4983. fmt.Println("pay_way")
  4984. if pay_way == 4 {
  4985. acct_used_flag = "1"
  4986. } else {
  4987. acct_used_flag = "0"
  4988. }
  4989. if miConfig.MdtrtareaAdmvs == "421300" {
  4990. api := "http://192.168.124.4:9532/" + "hbyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  4991. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  4992. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  4993. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  4994. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  4995. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  4996. "&insutype=" + insutype + "&total=" + allTotal + "&med_type=" + strconv.FormatInt(reg_type, 10) + "&acct_used_flag=" + acct_used_flag
  4997. resp, requestErr := http.Get(api)
  4998. if requestErr != nil {
  4999. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5000. return
  5001. }
  5002. body, ioErr := ioutil.ReadAll(resp.Body)
  5003. if ioErr != nil {
  5004. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  5005. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5006. return
  5007. }
  5008. var respJSON map[string]interface{}
  5009. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  5010. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  5011. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5012. return
  5013. }
  5014. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  5015. result, _ := json.Marshal(respJSON)
  5016. if miConfig.Code == "H15049901371" {
  5017. if err := json.Unmarshal([]byte(result), &resSeven10265); err != nil {
  5018. utils.ErrorLog("解析失败:%v", err)
  5019. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5020. return
  5021. }
  5022. res.InfRefmsgid = resSeven10265.InfRefmsgid
  5023. res.Output = resSeven10265.Output
  5024. res.ErrMsg = resSeven10265.ErrMsg
  5025. res.Cainfo = resSeven10265.Cainfo
  5026. res.WarnMsg = resSeven10265.WarnMsg
  5027. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  5028. res.Infcode = infocode
  5029. } else {
  5030. if err := json.Unmarshal([]byte(result), &res); err != nil {
  5031. utils.ErrorLog("解析失败:%v", err)
  5032. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5033. return
  5034. }
  5035. }
  5036. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  5037. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  5038. psn_info.VerifyNumber = strings.Replace(psn_info.VerifyNumber, "+", "%2B", -1)
  5039. //psn_info, _ := service.GetPsnByPatientId(id)
  5040. bas := strings.Split(psn_info.CardInfo, "|")
  5041. if his.IdCardType == 1 {
  5042. cert_no = bas[2]
  5043. } else if his.IdCardType == 3 {
  5044. cert_no = his.Certno
  5045. psn_info.VerifyNumber = his.Certno + "|" + psn_info.VerifyNumber
  5046. } else {
  5047. cert_no = bas[1]
  5048. }
  5049. //江苏地区国家医保医疗类别
  5050. //职工透析:医疗类别选特殊情况门诊9933
  5051. //居民血透门慢: 医疗类别选门诊慢病1402
  5052. //var med_type string
  5053. //if his.Insutype == "310" {
  5054. // if reg_type == 14 {
  5055. // med_type = "9933"
  5056. // } else if reg_type == 11 {
  5057. // med_type = "11"
  5058. //
  5059. // }
  5060. //} else if his.Insutype == "390" {
  5061. // if reg_type == 14 {
  5062. // med_type = "1402"
  5063. // } else if reg_type == 11 {
  5064. // med_type = "11"
  5065. // }
  5066. //}
  5067. //psn_info.VerifyNumber = strings.Replace(psn_info.VerifyNumber, "+", "%2B", -1)
  5068. var api string
  5069. if miConfig.MdtrtareaAdmvs == "320921" {
  5070. api = "http://192.168.3.111:9532/" + "jsyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  5071. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  5072. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  5073. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  5074. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  5075. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  5076. "&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
  5077. //req, _ = http.NewRequest("POST", "http://192.168.3.111:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  5078. } else {
  5079. //req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  5080. api = "http://192.168.5.251:9532/" + "jsyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  5081. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  5082. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  5083. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  5084. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  5085. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  5086. "&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
  5087. }
  5088. resp, requestErr := http.Get(api)
  5089. if requestErr != nil {
  5090. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5091. return
  5092. }
  5093. body, ioErr := ioutil.ReadAll(resp.Body)
  5094. if ioErr != nil {
  5095. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  5096. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5097. return
  5098. }
  5099. var respJSON map[string]interface{}
  5100. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  5101. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  5102. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5103. return
  5104. }
  5105. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  5106. result, _ := json.Marshal(respJSON)
  5107. if err := json.Unmarshal([]byte(result), &resSeven10265); err != nil {
  5108. utils.ErrorLog("解析失败:%v", err)
  5109. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5110. return
  5111. }
  5112. res.InfRefmsgid = resSeven10265.InfRefmsgid
  5113. res.Output = resSeven10265.Output
  5114. res.ErrMsg = resSeven10265.ErrMsg
  5115. res.Cainfo = resSeven10265.Cainfo
  5116. res.WarnMsg = resSeven10265.WarnMsg
  5117. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  5118. res.Infcode = infocode
  5119. } else {
  5120. if miConfig.Code == "H15049901371" {
  5121. //赤峰地区国家医保医疗类别
  5122. //职工透析:医疗类别选特殊情况门诊990502
  5123. //居民定额血透门慢: 医疗类别选门诊慢病140104
  5124. var med_type string
  5125. if his.Insutype == "390" {
  5126. if reg_type == 14 {
  5127. med_type = "9933"
  5128. } else if reg_type == 11 {
  5129. med_type = "11"
  5130. }
  5131. } else if his.Insutype == "310" {
  5132. if reg_type == 14 {
  5133. med_type = "990502"
  5134. } else if reg_type == 11 {
  5135. med_type = "11"
  5136. }
  5137. }
  5138. 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)
  5139. } else {
  5140. 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)
  5141. }
  5142. //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)
  5143. var dat map[string]interface{}
  5144. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  5145. fmt.Println(dat)
  5146. } else {
  5147. fmt.Println(err)
  5148. }
  5149. saveLog(result2, src_resquest, "2207", "结算")
  5150. userJSONBytes, _ := json.Marshal(dat)
  5151. if miConfig.Code == "H15049901371" {
  5152. if err := json.Unmarshal(userJSONBytes, &resSeven10265); err != nil {
  5153. utils.ErrorLog("解析失败:%v", err)
  5154. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5155. return
  5156. }
  5157. res.InfRefmsgid = resSeven10265.InfRefmsgid
  5158. res.Output = resSeven10265.Output
  5159. res.ErrMsg = resSeven10265.ErrMsg
  5160. res.Cainfo = resSeven10265.Cainfo
  5161. res.WarnMsg = resSeven10265.WarnMsg
  5162. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  5163. res.Infcode = infocode
  5164. } else {
  5165. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  5166. utils.ErrorLog("解析失败:%v", err)
  5167. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5168. return
  5169. }
  5170. }
  5171. }
  5172. if res.Infcode != 0 {
  5173. errlog := &models.HisOrderError{
  5174. UserOrgId: adminUser.CurrentOrgId,
  5175. Ctime: time.Now().Unix(),
  5176. Mtime: time.Now().Unix(),
  5177. Number: chrg_bchno,
  5178. ErrMsg: res.ErrMsg,
  5179. Status: 1,
  5180. PatientId: id,
  5181. RecordTime: recordDateTime,
  5182. Stage: 6,
  5183. }
  5184. service.CreateErrMsgLog(errlog)
  5185. c.ServeSuccessJSON(map[string]interface{}{
  5186. "failed_code": -10,
  5187. "msg": res.ErrMsg,
  5188. })
  5189. return
  5190. } else {
  5191. order, _ := service.GetHisOrderTwo(adminUser.CurrentOrgId, chrg_bchno, id)
  5192. order.OrderStatus = 2
  5193. order.Status = 1
  5194. order.MdtrtId = res.Output.Setlinfo.MdtrtID
  5195. order.SetlId = res.Output.Setlinfo.SetlID
  5196. order.PsnNo = res.Output.Setlinfo.PsnNo
  5197. order.PsnName = res.Output.Setlinfo.PsnName
  5198. order.PsnCertType = res.Output.Setlinfo.PsnCertType
  5199. order.Certno = res.Output.Setlinfo.Certno
  5200. order.Gend = res.Output.Setlinfo.Gend
  5201. order.Naty = res.Output.Setlinfo.Naty
  5202. order.Age = res.Output.Setlinfo.Age
  5203. order.Insutype = res.Output.Setlinfo.Insutype
  5204. order.PsnType = res.Output.Setlinfo.PsnType
  5205. order.CvlservFlag = res.Output.Setlinfo.CvlservFlag
  5206. order.SetlTime = res.Output.Setlinfo.SetlTime
  5207. order.MdtrtCertType = res.Output.Setlinfo.MdtrtCertType
  5208. if res.Output.Setlinfo.MedType == "140101" {
  5209. order.MedType = "14"
  5210. } else {
  5211. order.MedType = res.Output.Setlinfo.MedType
  5212. }
  5213. if reg_type == 1112 {
  5214. order.MedType = "1112"
  5215. }
  5216. if reg_type == 1111 {
  5217. order.MedType = "1111"
  5218. }
  5219. order.MedfeeSumamt = res.Output.Setlinfo.MedfeeSumamt
  5220. order.FulamtOwnpayAmt = res.Output.Setlinfo.FulamtOwnpayAmt
  5221. order.OverlmtSelfPay = res.Output.Setlinfo.OverlmtSelfpay
  5222. order.PreselfpayAmt = res.Output.Setlinfo.PreselfpayAmt
  5223. order.InscpScpAmt = res.Output.Setlinfo.InscpScpAmt
  5224. order.ActPayDedc = res.Output.Setlinfo.ActPayDedc
  5225. order.HifpPay = res.Output.Setlinfo.HifpPay
  5226. order.CvlservPay = res.Output.Setlinfo.CvlservPay
  5227. order.PoolPropSelfpay = res.Output.Setlinfo.PoolPropSelfpay
  5228. order.HifesPay = res.Output.Setlinfo.HifesPay
  5229. order.HifobPay = res.Output.Setlinfo.HifobPay
  5230. order.MafPay = res.Output.Setlinfo.MafPay
  5231. order.HifmiPay = res.Output.Setlinfo.HifmiPay
  5232. order.OthPay = res.Output.Setlinfo.OthPay
  5233. order.FundPaySumamt = res.Output.Setlinfo.FundPaySumamt
  5234. order.PsnPartAmt = res.Output.Setlinfo.PsnPartAmt
  5235. order.AcctPay = res.Output.Setlinfo.AcctPay
  5236. order.PsnCashPay = res.Output.Setlinfo.PsnCashPay
  5237. order.HospPartAmt = res.Output.Setlinfo.HospPartAmt
  5238. order.Balc = res.Output.Setlinfo.Balc
  5239. order.AcctMulaidPay = res.Output.Setlinfo.AcctMulaidPay
  5240. order.MedinsSetlId = res.Output.Setlinfo.MedinsSetlID
  5241. order.ClrOptins = res.Output.Setlinfo.ClrOptins
  5242. order.ClrType = res.Output.Setlinfo.ClrType
  5243. order.ClrWay = res.Output.Setlinfo.ClrWay
  5244. order.Creator = order.Creator
  5245. order.Modify = roles.AdminUserId
  5246. order.RequestLog = src_resquest
  5247. setlDetail, _ := json.Marshal(res.Output.Setldetail)
  5248. detailStr := string(setlDetail)
  5249. order.SetlDetail = detailStr
  5250. err := service.UpdataOrderStatusTwo(chrg_bchno, adminUser.CurrentOrgId)
  5251. err = service.UpDateOrder(order)
  5252. if err == nil {
  5253. c.ServeSuccessJSON(map[string]interface{}{
  5254. "msg": "结算成功",
  5255. })
  5256. } else {
  5257. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeAmountAccountException)
  5258. return
  5259. }
  5260. }
  5261. } else {
  5262. adminUser := c.GetAdminUserInfo()
  5263. errlog := &models.HisOrderError{
  5264. UserOrgId: adminUser.CurrentOrgId,
  5265. Ctime: time.Now().Unix(),
  5266. Mtime: time.Now().Unix(),
  5267. ErrMsg: res.ErrMsg,
  5268. Status: 1,
  5269. PatientId: id,
  5270. RecordTime: recordDateTime,
  5271. Stage: 4,
  5272. }
  5273. service.CreateErrMsgLog(errlog)
  5274. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeRegisterRepeatException)
  5275. return
  5276. }
  5277. } else {
  5278. adminUser := c.GetAdminUserInfo()
  5279. errlog := &models.HisOrderError{
  5280. UserOrgId: adminUser.CurrentOrgId,
  5281. Ctime: time.Now().Unix(),
  5282. Mtime: time.Now().Unix(),
  5283. ErrMsg: res.ErrMsg,
  5284. Status: 1,
  5285. PatientId: id,
  5286. RecordTime: recordDateTime,
  5287. Stage: 4,
  5288. }
  5289. service.CreateErrMsgLog(errlog)
  5290. c.ServeSuccessJSON(map[string]interface{}{
  5291. "failed_code": -10,
  5292. "msg": res.ErrMsg,
  5293. })
  5294. return
  5295. //c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCalOrderException)
  5296. //return
  5297. }
  5298. }
  5299. }
  5300. } else if tempOrder.ID > 0 {
  5301. if tempOrder.IsPre == 1 {
  5302. allTotal := fmt.Sprintf("%.4f", tempOrder.MedfeeSumamt)
  5303. var rf []*ResultFive
  5304. json.Unmarshal([]byte(his.Iinfo), &rf)
  5305. chrg_bchno := tempOrder.Number
  5306. cert_no := his.Certno
  5307. var insutypes []string
  5308. var insutype string
  5309. var is390 int = 0
  5310. var is310 int = 0
  5311. for _, item := range rf {
  5312. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  5313. insutypes = append(insutypes, item.Insutype)
  5314. }
  5315. }
  5316. if len(insutypes) == 1 {
  5317. insutype = insutypes[0]
  5318. } else {
  5319. for _, i := range insutypes {
  5320. if i == "390" {
  5321. is390 = 1
  5322. }
  5323. if i == "310" {
  5324. is310 = 1
  5325. }
  5326. }
  5327. }
  5328. if is390 == 1 {
  5329. insutype = "390"
  5330. }
  5331. if is310 == 1 {
  5332. insutype = "310"
  5333. }
  5334. if len(insutypes) == 0 {
  5335. insutype = "310"
  5336. }
  5337. if len(insutypes) == 2 {
  5338. insutype = strconv.FormatInt(his.SocialType, 64)
  5339. }
  5340. //insutype = "390"
  5341. if his.IdCardType == 1 {
  5342. // cert_no = his.MedicalInsuranceNumber
  5343. cert_no = his.Certno
  5344. } else {
  5345. cert_no = his.Certno
  5346. }
  5347. var res ResultSeven
  5348. var resSeven10265 ResultSeven10265
  5349. var src_resquest string
  5350. var result2 string
  5351. var acct_used_flag string
  5352. fmt.Println("pay_way")
  5353. fmt.Println(pay_way)
  5354. fmt.Println("pay_way")
  5355. if pay_way == 4 {
  5356. acct_used_flag = "1"
  5357. } else {
  5358. acct_used_flag = "0"
  5359. }
  5360. if miConfig.MdtrtareaAdmvs == "421300" {
  5361. api := "http://192.168.124.4:9532/" + "hbyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  5362. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  5363. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  5364. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  5365. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  5366. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  5367. "&insutype=" + insutype + "&total=" + allTotal + "&med_type=" + strconv.FormatInt(reg_type, 10) + "&acct_used_flag=" + acct_used_flag
  5368. resp, requestErr := http.Get(api)
  5369. if requestErr != nil {
  5370. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5371. return
  5372. }
  5373. body, ioErr := ioutil.ReadAll(resp.Body)
  5374. if ioErr != nil {
  5375. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  5376. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5377. return
  5378. }
  5379. var respJSON map[string]interface{}
  5380. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  5381. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  5382. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5383. return
  5384. }
  5385. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  5386. result, _ := json.Marshal(respJSON)
  5387. fmt.Println("log")
  5388. fmt.Println(string(result))
  5389. if err := json.Unmarshal([]byte(result), &res); err != nil {
  5390. utils.ErrorLog("解析失败:%v", err)
  5391. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5392. return
  5393. }
  5394. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  5395. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  5396. psn_info.VerifyNumber = strings.Replace(psn_info.VerifyNumber, "+", "%2B", -1)
  5397. //psn_info, _ := service.GetPsnByPatientId(id)
  5398. bas := strings.Split(psn_info.CardInfo, "|")
  5399. if his.IdCardType == 1 {
  5400. cert_no = bas[2]
  5401. } else {
  5402. cert_no = bas[1]
  5403. }
  5404. //江苏地区国家医保医疗类别
  5405. //职工透析:医疗类别选特殊情况门诊9933
  5406. //居民血透门慢: 医疗类别选门诊慢病1402
  5407. //var med_type string
  5408. //if his.Insutype == "310" {
  5409. // if reg_type == 14 {
  5410. // med_type = "9933"
  5411. // } else if reg_type == 11 {
  5412. // med_type = "11"
  5413. //
  5414. // }
  5415. //} else if his.Insutype == "390" {
  5416. // if reg_type == 14 {
  5417. // med_type = "1402"
  5418. // } else if reg_type == 11 {
  5419. // med_type = "11"
  5420. // }
  5421. //}
  5422. var api string
  5423. if miConfig.MdtrtareaAdmvs == "320921" {
  5424. api = "http://192.168.3.111:9532/" + "jsyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  5425. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  5426. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  5427. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  5428. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  5429. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  5430. "&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
  5431. //req, _ = http.NewRequest("POST", "http://192.168.3.111:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  5432. } else {
  5433. //req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  5434. api = "http://192.168.5.251:9532/" + "jsyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  5435. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  5436. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  5437. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  5438. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  5439. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  5440. "&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
  5441. }
  5442. resp, requestErr := http.Get(api)
  5443. if requestErr != nil {
  5444. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5445. return
  5446. }
  5447. body, ioErr := ioutil.ReadAll(resp.Body)
  5448. if ioErr != nil {
  5449. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  5450. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5451. return
  5452. }
  5453. var respJSON map[string]interface{}
  5454. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  5455. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  5456. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5457. return
  5458. }
  5459. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  5460. result, _ := json.Marshal(respJSON)
  5461. fmt.Println("log")
  5462. fmt.Println(string(result))
  5463. if err := json.Unmarshal([]byte(result), &resSeven10265); err != nil {
  5464. utils.ErrorLog("解析失败:%v", err)
  5465. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5466. return
  5467. }
  5468. res.InfRefmsgid = resSeven10265.InfRefmsgid
  5469. res.Output = resSeven10265.Output
  5470. res.ErrMsg = resSeven10265.ErrMsg
  5471. res.Cainfo = resSeven10265.Cainfo
  5472. res.WarnMsg = resSeven10265.WarnMsg
  5473. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  5474. res.Infcode = infocode
  5475. } else {
  5476. var src_resquest string
  5477. if miConfig.Code == "H15049901371" {
  5478. //赤峰地区国家医保医疗类别
  5479. //职工透析:医疗类别选特殊情况门诊990502
  5480. //居民定额血透门慢: 医疗类别选门诊慢病140104
  5481. var med_type string
  5482. if his.Insutype == "390" {
  5483. if reg_type == 14 {
  5484. med_type = "9933"
  5485. } else if reg_type == 11 {
  5486. med_type = "11"
  5487. }
  5488. } else if his.Insutype == "310" {
  5489. if reg_type == 14 {
  5490. med_type = "990502"
  5491. } else if reg_type == 11 {
  5492. med_type = "11"
  5493. }
  5494. }
  5495. 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)
  5496. } else {
  5497. 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)
  5498. }
  5499. var dat map[string]interface{}
  5500. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  5501. fmt.Println(dat)
  5502. } else {
  5503. fmt.Println(err)
  5504. }
  5505. saveLog(result2, src_resquest, "2207", "结算")
  5506. userJSONBytes, _ := json.Marshal(dat)
  5507. if miConfig.Code == "H15049901371" {
  5508. if err := json.Unmarshal(userJSONBytes, &resSeven10265); err != nil {
  5509. utils.ErrorLog("解析失败:%v", err)
  5510. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5511. return
  5512. }
  5513. res.InfRefmsgid = resSeven10265.InfRefmsgid
  5514. res.Output = resSeven10265.Output
  5515. res.ErrMsg = resSeven10265.ErrMsg
  5516. res.Cainfo = resSeven10265.Cainfo
  5517. res.WarnMsg = resSeven10265.WarnMsg
  5518. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  5519. res.Infcode = infocode
  5520. } else {
  5521. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  5522. utils.ErrorLog("解析失败:%v", err)
  5523. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5524. return
  5525. }
  5526. }
  5527. }
  5528. if res.Infcode != 0 {
  5529. errlog := &models.HisOrderError{
  5530. UserOrgId: adminUser.CurrentOrgId,
  5531. Ctime: time.Now().Unix(),
  5532. Mtime: time.Now().Unix(),
  5533. Number: chrg_bchno,
  5534. ErrMsg: res.ErrMsg,
  5535. Status: 1,
  5536. PatientId: id,
  5537. RecordTime: recordDateTime,
  5538. Stage: 6,
  5539. }
  5540. service.CreateErrMsgLog(errlog)
  5541. c.ServeSuccessJSON(map[string]interface{}{
  5542. "failed_code": -10,
  5543. "msg": res.ErrMsg,
  5544. })
  5545. return
  5546. } else {
  5547. order, _ := service.GetHisOrderTwo(adminUser.CurrentOrgId, chrg_bchno, id)
  5548. order.OrderStatus = 2
  5549. order.MdtrtId = res.Output.Setlinfo.MdtrtID
  5550. order.SetlId = res.Output.Setlinfo.SetlID
  5551. order.PsnNo = res.Output.Setlinfo.PsnNo
  5552. order.PsnName = res.Output.Setlinfo.PsnName
  5553. order.PsnCertType = res.Output.Setlinfo.PsnCertType
  5554. order.Certno = res.Output.Setlinfo.Certno
  5555. order.Gend = res.Output.Setlinfo.Gend
  5556. order.Naty = res.Output.Setlinfo.Naty
  5557. order.Age = res.Output.Setlinfo.Age
  5558. order.Insutype = res.Output.Setlinfo.Insutype
  5559. order.PsnType = res.Output.Setlinfo.PsnType
  5560. order.CvlservFlag = res.Output.Setlinfo.CvlservFlag
  5561. order.SetlTime = res.Output.Setlinfo.SetlTime
  5562. order.MdtrtCertType = res.Output.Setlinfo.MdtrtCertType
  5563. //order.MedType = res.Output.Setlinfo.MedType
  5564. if reg_type == 1112 {
  5565. order.MedType = "1112"
  5566. }
  5567. if reg_type == 1111 {
  5568. order.MedType = "1111"
  5569. }
  5570. order.MedfeeSumamt = res.Output.Setlinfo.MedfeeSumamt
  5571. order.FulamtOwnpayAmt = res.Output.Setlinfo.FulamtOwnpayAmt
  5572. order.OverlmtSelfPay = res.Output.Setlinfo.OverlmtSelfpay
  5573. order.PreselfpayAmt = res.Output.Setlinfo.PreselfpayAmt
  5574. order.InscpScpAmt = res.Output.Setlinfo.InscpScpAmt
  5575. order.ActPayDedc = res.Output.Setlinfo.ActPayDedc
  5576. order.HifpPay = res.Output.Setlinfo.HifpPay
  5577. order.CvlservPay = res.Output.Setlinfo.CvlservPay
  5578. order.PoolPropSelfpay = res.Output.Setlinfo.PoolPropSelfpay
  5579. order.HifesPay = res.Output.Setlinfo.HifesPay
  5580. order.HifobPay = res.Output.Setlinfo.HifobPay
  5581. order.MafPay = res.Output.Setlinfo.MafPay
  5582. order.HifmiPay = res.Output.Setlinfo.HifmiPay
  5583. order.OthPay = res.Output.Setlinfo.OthPay
  5584. order.FundPaySumamt = res.Output.Setlinfo.FundPaySumamt
  5585. order.PsnPartAmt = res.Output.Setlinfo.PsnPartAmt
  5586. order.AcctPay = res.Output.Setlinfo.AcctPay
  5587. order.PsnCashPay = res.Output.Setlinfo.PsnCashPay
  5588. order.HospPartAmt = res.Output.Setlinfo.HospPartAmt
  5589. order.Balc = res.Output.Setlinfo.Balc
  5590. order.AcctMulaidPay = res.Output.Setlinfo.AcctMulaidPay
  5591. order.MedinsSetlId = res.Output.Setlinfo.MedinsSetlID
  5592. order.ClrOptins = res.Output.Setlinfo.ClrOptins
  5593. order.ClrWay = res.Output.Setlinfo.ClrWay
  5594. order.Creator = order.Creator
  5595. order.Modify = roles.AdminUserId
  5596. order.RequestLog = src_resquest
  5597. order.Diagnosis = diagnosis_id
  5598. setlDetail, _ := json.Marshal(res.Output.Setldetail)
  5599. detailStr := string(setlDetail)
  5600. order.SetlDetail = detailStr
  5601. err := service.UpdataOrderStatusTwo(chrg_bchno, adminUser.CurrentOrgId)
  5602. err = service.UpDateOrder(order)
  5603. if err == nil {
  5604. c.ServeSuccessJSON(map[string]interface{}{
  5605. "msg": "结算成功",
  5606. })
  5607. } else {
  5608. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeAmountAccountException)
  5609. return
  5610. }
  5611. }
  5612. }
  5613. }
  5614. }
  5615. //func (c *HisApiController) GetPreUploadInfo() {
  5616. // id, _ := c.GetInt64("id")
  5617. // record_time := c.GetString("record_time")
  5618. // settle_accounts_type, _ := c.GetInt64("settle_accounts_type")
  5619. // admin_user_id, _ := c.GetInt64("admin_user_id")
  5620. //
  5621. // timeLayout := "2006-01-02"
  5622. // loc, _ := time.LoadLocation("Local")
  5623. // theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  5624. // if err != nil {
  5625. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  5626. // return
  5627. // }
  5628. // recordDateTime := theTime.Unix()
  5629. // adminUser := c.GetAdminUserInfo()
  5630. //
  5631. // var prescriptions []*models.HisPrescription
  5632. //
  5633. // var start_time int64
  5634. // var end_time int64
  5635. //
  5636. // data := make(map[string]interface{})
  5637. // if settle_accounts_type == 1 { //日结
  5638. // prescriptions, _ = service.GetHisPrescription(adminUser.CurrentOrgId, id, recordDateTime)
  5639. // data["pre"] = prescriptions
  5640. //
  5641. // } else { //月结
  5642. // start_time_str := c.GetString("start_time")
  5643. // end_time_str := c.GetString("end_time")
  5644. // timeLayout := "2006-01-02"
  5645. // loc, _ := time.LoadLocation("Local")
  5646. // theStartTime, err := time.ParseInLocation(timeLayout+" 15:04:05", start_time_str+" 00:00:00", loc)
  5647. // if err != nil {
  5648. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  5649. // return
  5650. // }
  5651. // recordStartTime := theStartTime.Unix()
  5652. // start_time = recordStartTime
  5653. // theEndTime, err := time.ParseInLocation(timeLayout+" 15:04:05", end_time_str+" 00:00:00", loc)
  5654. // if err != nil {
  5655. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  5656. // return
  5657. // }
  5658. // recordEndTime := theEndTime.Unix()
  5659. // end_time = recordEndTime
  5660. // prescriptions, _ = service.GetMonthHisPrescription(adminUser.CurrentOrgId, id, recordStartTime, recordEndTime)
  5661. // data["pre"] = prescriptions
  5662. //
  5663. // }
  5664. //
  5665. // roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  5666. //
  5667. // his, _ := service.GetVMHisPatientInfo(adminUser.CurrentOrgId, id, recordDateTime)
  5668. // timestamp := time.Now().Unix()
  5669. // tempTime := time.Unix(timestamp, 0)
  5670. // timeFormat := tempTime.Format("20060102150405")
  5671. // chrgBchno := rand.Intn(100000) + 10000
  5672. // chrg_bchno := timeFormat + strconv.FormatInt(int64(chrgBchno), 10) + strconv.FormatInt(his.PatientId, 10)
  5673. // miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  5674. // patientPrescription, _ := service.FindPatientPrescriptionInfo(adminUser.CurrentOrgId, id, recordDateTime)
  5675. // department, _ := service.GetDepartMentDetail(patientPrescription.Departments)
  5676. // strconv.FormatInt(his.PatientId, 10)
  5677. // client := &http.Client{}
  5678. // data["psn_no"] = his.PsnNo
  5679. // data["mdtrt_id"] = his.Number
  5680. // data["chrg_bchno"] = chrg_bchno
  5681. // data["org_name"] = miConfig.OrgName
  5682. // data["doctor"] = roles.UserName
  5683. // data["doctor_id"] = strconv.FormatInt(roles.AdminUserId, 10)
  5684. // data["dept"] = strconv.FormatInt(patientPrescription.Departments, 10)
  5685. // data["fixmedins_code"] = miConfig.Code
  5686. // data["dept_code"] = department.Number
  5687. // data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  5688. // data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  5689. // data["secret_key"] = miConfig.SecretKey
  5690. // var ids []int64
  5691. //
  5692. // for _, item := range prescriptions {
  5693. // ids = append(ids, item.ID)
  5694. // }
  5695. // config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  5696. // if config.IsOpen == 1 { //对接了医保,走医保流程
  5697. // bytesData, _ := json.Marshal(data)
  5698. // req, _ := http.NewRequest("POST", "http://127.0.0.1:9532/"+"gdyb/five", bytes.NewReader(bytesData))
  5699. // resp, _ := client.Do(req)
  5700. // defer resp.Body.Close()
  5701. // body, ioErr := ioutil.ReadAll(resp.Body)
  5702. // if ioErr != nil {
  5703. // utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  5704. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5705. // return
  5706. // }
  5707. // var respJSON map[string]interface{}
  5708. // if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  5709. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  5710. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5711. // return
  5712. // }
  5713. //
  5714. // respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  5715. // userJSONBytes, _ := json.Marshal(respJSON)
  5716. // var res ResultFour
  5717. // if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  5718. // utils.ErrorLog("解析失败:%v", err)
  5719. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5720. // return
  5721. // }
  5722. //
  5723. // if res.Infcode == 0 {
  5724. // order := &models.HisOrder{
  5725. // UserOrgId: adminUser.CurrentOrgId,
  5726. // HisPatientId: his.ID,
  5727. // PatientId: his.PatientId,
  5728. // SettleAccountsDate: recordDateTime,
  5729. // Ctime: time.Now().Unix(),
  5730. // Mtime: time.Now().Unix(),
  5731. // Status: 1,
  5732. // Number: chrg_bchno,
  5733. // Infcode: res.Infcode,
  5734. // WarnMsg: res.WarnMsg,
  5735. // Cainfo: res.Cainfo,
  5736. // ErrMsg: res.ErrMsg,
  5737. // RespondTime: res.RefmsgTime,
  5738. // InfRefmsgid: res.InfRefmsgid,
  5739. // OrderStatus: 1,
  5740. // IsMedicineInsurance: 1,
  5741. // SettleType: settle_accounts_type,
  5742. // SettleStartTime: start_time,
  5743. // SettleEndTime: end_time,
  5744. // Creator: roles.ID,
  5745. // Modify: roles.ID,
  5746. // PType: 2,
  5747. // }
  5748. // err = service.CreateOrder(order)
  5749. // if err != nil {
  5750. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCreatePreOrderException)
  5751. // return
  5752. // }
  5753. //
  5754. // for _, item := range res.Output.Result {
  5755. // temp := strings.Split(item.FeedetlSn, "-")
  5756. // var advice_id int64 = 0
  5757. // var project_id int64 = 0
  5758. // var types int64 = 0
  5759. //
  5760. // id, _ := strconv.ParseInt(temp[2], 10, 64)
  5761. // types, _ = strconv.ParseInt(temp[1], 10, 64)
  5762. //
  5763. // if temp[1] == "1" {
  5764. // advice_id = id
  5765. // project_id = 0
  5766. // } else if temp[1] == "2" {
  5767. // advice_id = 0
  5768. // project_id = id
  5769. // }
  5770. //
  5771. // info := &models.HisOrderInfo{
  5772. // OrderNumber: order.Number,
  5773. // FeedetlSn: item.FeedetlSn,
  5774. // UploadDate: time.Now().Unix(),
  5775. // AdviceId: advice_id,
  5776. // DetItemFeeSumamt: item.DetItemFeeSumamt,
  5777. // Cnt: item.Cnt,
  5778. // Pric: float64(item.Pric),
  5779. // PatientId: his.PatientId,
  5780. // PricUplmtAmt: item.PricUplmtAmt,
  5781. // SelfpayProp: item.SelfpayProp,
  5782. // FulamtOwnpayAmt: item.FulamtOwnpayAmt,
  5783. // OverlmtAmt: item.OverlmtAmt,
  5784. // PreselfpayAmt: item.PreselfpayAmt,
  5785. // BasMednFlag: item.BasMednFlag,
  5786. // MedChrgitmType: item.MedChrgitmType,
  5787. // HiNegoDrugFlag: item.HiNegoDrugFlag,
  5788. // Status: 1,
  5789. // Memo: item.Memo,
  5790. // Mtime: time.Now().Unix(),
  5791. // InscpScpAmt: item.InscpScpAmt,
  5792. // DrtReimFlag: item.DrtReimFlag,
  5793. // Ctime: time.Now().Unix(),
  5794. // ListSpItemFlag: item.ListSpItemFlag,
  5795. // ChldMedcFlag: item.ChldMedcFlag,
  5796. // LmtUsedFlag: item.LmtUsedFlag,
  5797. // ChrgitmLv: item.ChrgitmLv,
  5798. // UserOrgId: adminUser.CurrentOrgId,
  5799. // HisPatientId: his.ID,
  5800. // OrderId: order.ID,
  5801. // ProjectId: project_id,
  5802. // Type: types,
  5803. // }
  5804. // service.CreateOrderInfo(info)
  5805. //
  5806. // }
  5807. // service.UpDatePrescriptionNumber(adminUser.CurrentOrgId, ids, chrg_bchno)
  5808. // service.UpDatePrescriptionInfoNumber(adminUser.CurrentOrgId, patientPrescription.PatientId, chrg_bchno, recordDateTime)
  5809. //
  5810. // var total float64
  5811. // for _, item := range prescriptions {
  5812. // if item.Type == 1 { //药品
  5813. // for _, subItem := range item.HisDoctorAdviceInfo {
  5814. // total = total + (subItem.Price * subItem.PrescribingNumber)
  5815. // }
  5816. // }
  5817. // if item.Type == 2 { //项目
  5818. // for _, subItem := range item.HisPrescriptionProject {
  5819. // total = total + (subItem.Price * float64(subItem.Count))
  5820. // }
  5821. // }
  5822. // }
  5823. //
  5824. // for _, item := range prescriptions {
  5825. // for _, subItem := range item.HisAdditionalCharge {
  5826. // total = total + (subItem.Price * float64(subItem.Count))
  5827. // }
  5828. // }
  5829. //
  5830. // allTotal := fmt.Sprintf("%.2f", total)
  5831. // if res.Infcode == 0 {
  5832. // var rf []*ResultFive
  5833. // json.Unmarshal([]byte(his.Iinfo), &rf)
  5834. // psn_no := his.PsnNo
  5835. // mdtrt_id := his.Number
  5836. // chrg_bchno := chrg_bchno
  5837. // cert_no := his.Certno
  5838. // insutype := rf[0].Insutype
  5839. //
  5840. // if his.IdCardType == 1 {
  5841. // cert_no = his.MedicalInsuranceNumber
  5842. //
  5843. // } else {
  5844. //
  5845. // cert_no = his.Certno
  5846. //
  5847. // }
  5848. //
  5849. // api := "http://127.0.0.1:9532/" + "gdyb/seven?cert_no=" + cert_no + "&insutype=" +
  5850. // insutype + "&psn_no=" + psn_no + "&chrg_bchno=" + chrg_bchno + "&mdtrt_id=" + mdtrt_id +
  5851. // "&total=" + allTotal + "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code + "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" +
  5852. // miConfig.SecretKey + "&med_type=" + strconv.FormatInt(patientPrescription.RegisterType, 10) + "&id_card_type=" + strconv.FormatInt(int64(his.IdCardType), 10)
  5853. // resp, requestErr := http.Get(api)
  5854. // if requestErr != nil {
  5855. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5856. // return
  5857. // }
  5858. // defer resp.Body.Close()
  5859. // body, ioErr := ioutil.ReadAll(resp.Body)
  5860. // if ioErr != nil {
  5861. // utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  5862. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5863. // return
  5864. // }
  5865. // var respJSON map[string]interface{}
  5866. // if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  5867. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  5868. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5869. // return
  5870. // }
  5871. // fmt.Println(respJSON)
  5872. // respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  5873. // userJSONBytes, _ := json.Marshal(respJSON)
  5874. // var res ResultSeven
  5875. // if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  5876. // utils.ErrorLog("解析失败:%v", err)
  5877. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5878. // return
  5879. // }
  5880. // if res.Infcode != 0 {
  5881. // errlog := &models.HisOrderError{
  5882. // UserOrgId: adminUser.CurrentOrgId,
  5883. // Ctime: time.Now().Unix(),
  5884. // Mtime: time.Now().Unix(),
  5885. // Number: chrg_bchno,
  5886. // ErrMsg: res.ErrMsg,
  5887. // Status: 1,
  5888. // PatientId: id,
  5889. // RecordTime: recordDateTime,
  5890. // Stage: 7,
  5891. // }
  5892. // service.CreateErrMsgLog(errlog)
  5893. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeRegisterRepeatException)
  5894. // return
  5895. // } else {
  5896. // order, _ := service.GetHisOrderTwo(adminUser.CurrentOrgId, chrg_bchno, id)
  5897. // order.OrderStatus = 1
  5898. // order.MdtrtId = res.Output.Setlinfo.MdtrtID
  5899. // order.SetlId = res.Output.Setlinfo.SetlID
  5900. // order.PsnNo = res.Output.Setlinfo.PsnNo
  5901. // order.PsnName = res.Output.Setlinfo.PsnName
  5902. // order.PsnCertType = res.Output.Setlinfo.PsnCertType
  5903. // order.Certno = res.Output.Setlinfo.Certno
  5904. // order.Gend = res.Output.Setlinfo.Gend
  5905. // order.Naty = res.Output.Setlinfo.Naty
  5906. // order.Age = res.Output.Setlinfo.Age
  5907. // order.Insutype = res.Output.Setlinfo.Insutype
  5908. // order.PsnType = res.Output.Setlinfo.PsnType
  5909. // order.CvlservFlag = res.Output.Setlinfo.CvlservFlag
  5910. // order.SetlTime = res.Output.Setlinfo.SetlTime
  5911. // order.MdtrtCertType = res.Output.Setlinfo.MdtrtCertType
  5912. // order.MedType = res.Output.Setlinfo.MedType
  5913. // order.MedfeeSumamt = res.Output.Setlinfo.MedfeeSumamt
  5914. // order.FulamtOwnpayAmt = res.Output.Setlinfo.FulamtOwnpayAmt
  5915. // order.OverlmtSelfPay = res.Output.Setlinfo.OverlmtSelfpay
  5916. // order.PreselfpayAmt = res.Output.Setlinfo.PreselfpayAmt
  5917. // order.InscpScpAmt = res.Output.Setlinfo.InscpScpAmt
  5918. // order.ActPayDedc = res.Output.Setlinfo.ActPayDedc
  5919. // order.HifpPay = res.Output.Setlinfo.HifpPay
  5920. // order.CvlservPay = res.Output.Setlinfo.CvlservPay
  5921. // order.PoolPropSelfpay = res.Output.Setlinfo.PoolPropSelfpay
  5922. // order.HifesPay = res.Output.Setlinfo.HifesPay
  5923. // order.HifobPay = res.Output.Setlinfo.HifobPay
  5924. // order.MafPay = res.Output.Setlinfo.MafPay
  5925. // order.OthPay = res.Output.Setlinfo.OthPay
  5926. // order.FundPaySumamt = res.Output.Setlinfo.FundPaySumamt
  5927. // order.PsnPartAmt = res.Output.Setlinfo.PsnPartAmt
  5928. // order.AcctPay = res.Output.Setlinfo.AcctPay
  5929. // order.PsnCashPay = res.Output.Setlinfo.PsnCashPay
  5930. // order.HospPartAmt = res.Output.Setlinfo.HospPartAmt
  5931. // order.Balc = res.Output.Setlinfo.Balc
  5932. // order.AcctMulaidPay = res.Output.Setlinfo.AcctMulaidPay
  5933. // order.MedinsSetlId = res.Output.Setlinfo.MedinsSetlID
  5934. // order.ClrOptins = res.Output.Setlinfo.ClrOptins
  5935. // order.ClrWay = res.Output.Setlinfo.ClrWay
  5936. // order.Creator = order.Creator
  5937. // order.Modify = roles.ID
  5938. // setlDetail, _ := json.Marshal(res.Output.Setldetail)
  5939. // detailStr := string(setlDetail)
  5940. // order.SetlDetail = detailStr
  5941. // //err := service.UpdataOrderStatusTwo(chrg_bchno, adminUser.CurrentOrgId)
  5942. // err = service.UpDateOrder(order)
  5943. // if err == nil {
  5944. // c.ServeSuccessJSON(map[string]interface{}{
  5945. // "msg": "预结算成功",
  5946. // })
  5947. // } else {
  5948. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeAmountAccountException)
  5949. // return
  5950. // }
  5951. // }
  5952. // } else {
  5953. // adminUser := c.GetAdminUserInfo()
  5954. // errlog := &models.HisOrderError{
  5955. // UserOrgId: adminUser.CurrentOrgId,
  5956. // Ctime: time.Now().Unix(),
  5957. // Mtime: time.Now().Unix(),
  5958. // ErrMsg: res.ErrMsg,
  5959. // Status: 1,
  5960. // PatientId: id,
  5961. // RecordTime: recordDateTime,
  5962. // Stage: 4,
  5963. // }
  5964. // service.CreateErrMsgLog(errlog)
  5965. //
  5966. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeRegisterRepeatException)
  5967. // return
  5968. // }
  5969. // } else {
  5970. // adminUser := c.GetAdminUserInfo()
  5971. // errlog := &models.HisOrderError{
  5972. // UserOrgId: adminUser.CurrentOrgId,
  5973. // Ctime: time.Now().Unix(),
  5974. // Mtime: time.Now().Unix(),
  5975. // ErrMsg: res.ErrMsg,
  5976. // Status: 1,
  5977. // PatientId: id,
  5978. // RecordTime: recordDateTime,
  5979. // Stage: 4,
  5980. // }
  5981. // service.CreateErrMsgLog(errlog)
  5982. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCalOrderException)
  5983. // return
  5984. // }
  5985. //
  5986. // } else {
  5987. // var total float64
  5988. // for _, item := range prescriptions {
  5989. // if item.Type == 1 { //药品
  5990. // for _, subItem := range item.HisDoctorAdviceInfo {
  5991. // total = total + (subItem.Price * subItem.PrescribingNumber)
  5992. // }
  5993. // }
  5994. // if item.Type == 2 { //项目
  5995. // for _, subItem := range item.HisPrescriptionProject {
  5996. // total = total + (subItem.Price * float64(subItem.Count))
  5997. // }
  5998. // }
  5999. //
  6000. // for _, subItem := range item.HisAdditionalCharge {
  6001. // total = total + (subItem.Price * float64(subItem.Count))
  6002. // }
  6003. // }
  6004. //
  6005. // allTotal := fmt.Sprintf("%.2f", total)
  6006. // totals, _ := strconv.ParseFloat(allTotal, 64)
  6007. // order := &models.HisOrder{
  6008. // UserOrgId: adminUser.CurrentOrgId,
  6009. // HisPatientId: his.ID,
  6010. // PatientId: id,
  6011. // SettleAccountsDate: recordDateTime,
  6012. // Ctime: time.Now().Unix(),
  6013. // Mtime: time.Now().Unix(),
  6014. // Status: 1,
  6015. // OrderStatus: 2,
  6016. // Number: chrg_bchno,
  6017. // MedfeeSumamt: totals,
  6018. // }
  6019. // err = service.CreateOrder(order)
  6020. // if err != nil {
  6021. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCreatePreOrderException)
  6022. // return
  6023. // }
  6024. //
  6025. // var customs []*Custom
  6026. // for _, item := range prescriptions {
  6027. //
  6028. // if item.Type == 1 { //药品
  6029. // for _, subItem := range item.HisDoctorAdviceInfo {
  6030. // cus := &Custom{
  6031. // AdviceId: subItem.ID,
  6032. // ProjectId: 0,
  6033. // DetItemFeeSumamt: fmt.Sprintf("%.2f", subItem.Price*subItem.PrescribingNumber),
  6034. // Cut: fmt.Sprintf("%.2f", subItem.PrescribingNumber),
  6035. // FeedetlSn: subItem.FeedetlSn,
  6036. // Price: fmt.Sprintf("%.2f", subItem.Price),
  6037. // MedListCodg: subItem.MedListCodg,
  6038. // Type: 1,
  6039. // }
  6040. // customs = append(customs, cus)
  6041. // }
  6042. // }
  6043. //
  6044. // if item.Type == 2 { //项目
  6045. // for _, subItem := range item.HisPrescriptionProject {
  6046. //
  6047. // cus := &Custom{
  6048. // AdviceId: 0,
  6049. // ProjectId: subItem.ID,
  6050. // DetItemFeeSumamt: fmt.Sprintf("%.2f", subItem.Price*float64(subItem.Count)),
  6051. // Cut: fmt.Sprintf("%.2f", float64(subItem.Count)),
  6052. // FeedetlSn: subItem.FeedetlSn,
  6053. // Price: fmt.Sprintf("%.2f", float64(subItem.Price)),
  6054. // MedListCodg: subItem.MedListCodg,
  6055. // Type: 2,
  6056. // }
  6057. //
  6058. // customs = append(customs, cus)
  6059. // }
  6060. // }
  6061. //
  6062. // for _, item := range item.HisAdditionalCharge {
  6063. // cus := &Custom{
  6064. // ItemId: item.ID,
  6065. // AdviceId: 0,
  6066. // ProjectId: 0,
  6067. // DetItemFeeSumamt: fmt.Sprintf("%.2f", item.Price),
  6068. // Cut: fmt.Sprintf("%.2f", float64(item.Count)),
  6069. // FeedetlSn: item.FeedetlSn,
  6070. // Price: fmt.Sprintf("%.2f", float64(item.Price)),
  6071. // MedListCodg: item.XtHisAddtionConfig.Code,
  6072. // Type: 3,
  6073. // }
  6074. //
  6075. // customs = append(customs, cus)
  6076. // }
  6077. //
  6078. // }
  6079. //
  6080. // for _, item := range customs {
  6081. // var advice_id int64 = 0
  6082. // var project_id int64 = 0
  6083. // var item_id int64 = 0
  6084. //
  6085. // var types int64 = 0
  6086. //
  6087. // if item.Type == 1 {
  6088. // advice_id = item.AdviceId
  6089. // project_id = 0
  6090. // item_id = 0
  6091. // } else if item.Type == 2 {
  6092. // advice_id = 0
  6093. // item_id = 0
  6094. //
  6095. // project_id = item.ProjectId
  6096. // } else if item.Type == 3 {
  6097. // advice_id = 0
  6098. // item_id = item.ItemId
  6099. // project_id = 0
  6100. // }
  6101. //
  6102. // detItemFeeSumamt, _ := strconv.ParseFloat(item.DetItemFeeSumamt, 32)
  6103. // cut, _ := strconv.ParseFloat(item.Cut, 32)
  6104. // pric, _ := strconv.ParseFloat(item.Price, 32)
  6105. //
  6106. // info := &models.HisOrderInfo{
  6107. // OrderNumber: order.Number,
  6108. // UploadDate: time.Now().Unix(),
  6109. // AdviceId: advice_id,
  6110. // DetItemFeeSumamt: detItemFeeSumamt,
  6111. // Cnt: cut,
  6112. // Pric: pric,
  6113. // PatientId: id,
  6114. // Status: 1,
  6115. // Mtime: time.Now().Unix(),
  6116. // Ctime: time.Now().Unix(),
  6117. // UserOrgId: adminUser.CurrentOrgId,
  6118. // HisPatientId: his.ID,
  6119. // OrderId: order.ID,
  6120. // ProjectId: project_id,
  6121. // Type: types,
  6122. // ItemId: item_id,
  6123. // }
  6124. // service.CreateOrderInfo(info)
  6125. // }
  6126. // //err := service.UpDateAddtionNumber(adminUser.CurrentOrgId, ids, chrg_bchno)
  6127. // err = service.UpDatePrescriptionNumber(adminUser.CurrentOrgId, ids, chrg_bchno)
  6128. // err = service.UpDatePrescriptionInfoNumber(adminUser.CurrentOrgId, id, chrg_bchno, recordDateTime)
  6129. // err = service.UpdataOrderStatusTwo(chrg_bchno, adminUser.CurrentOrgId)
  6130. // if err == nil {
  6131. // c.ServeSuccessJSON(map[string]interface{}{
  6132. // "msg": "结算成功",
  6133. // })
  6134. // } else {
  6135. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeAmountAccountException)
  6136. // return
  6137. // }
  6138. // }
  6139. //}
  6140. //上传明细-预结算-
  6141. func (c *HisApiController) GetPreUploadInfo() {
  6142. id, _ := c.GetInt64("id")
  6143. record_time := c.GetString("record_time")
  6144. his_patient_id, _ := c.GetInt64("his_patient_id")
  6145. settle_accounts_type, _ := c.GetInt64("settle_accounts_type")
  6146. admin_user_id, _ := c.GetInt64("admin_user_id")
  6147. diagnosis_id := c.GetString("diagnosis")
  6148. sick_type, _ := c.GetInt64("sick_type")
  6149. reg_type, _ := c.GetInt64("p_type")
  6150. begin_time := c.GetString("begin_time")
  6151. id_str := c.GetString("ids")
  6152. ids_arr := strings.Split(id_str, ",")
  6153. timeLayout := "2006-01-02"
  6154. loc, _ := time.LoadLocation("Local")
  6155. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  6156. if err != nil {
  6157. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  6158. return
  6159. }
  6160. recordDateTime := theTime.Unix()
  6161. adminUser := c.GetAdminUserInfo()
  6162. diagnosis_ids := strings.Split(diagnosis_id, ",")
  6163. var config []*models.HisXtDiagnoseConfig
  6164. for _, item := range diagnosis_ids {
  6165. id, _ := strconv.ParseInt(item, 10, 64)
  6166. diagnosisConfig, _ := service.FindDiagnoseById(id)
  6167. config = append(config, &diagnosisConfig)
  6168. }
  6169. //diagnosisConfig, _ := service.FindDiagnoseById(diagnosis_id)
  6170. sickConfig, _ := service.FindSickById(sick_type)
  6171. var prescriptions []*models.HisPrescription
  6172. var start_time int64
  6173. var end_time int64
  6174. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  6175. fmt.Println(his_patient_id)
  6176. his, _ := service.GetNewHisPatientInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  6177. timestamp := time.Now().Unix()
  6178. tempTime := time.Unix(timestamp, 0)
  6179. timeFormat := tempTime.Format("20060102150405")
  6180. chrgBchno := rand.Intn(100000) + 10000
  6181. chrg_bchno := timeFormat + strconv.FormatInt(int64(chrgBchno), 10) + strconv.FormatInt(his.PatientId, 10)
  6182. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  6183. var patientPrescription models.HisPrescriptionInfo
  6184. patientPrescription, _ = service.FindHisPatientPrescriptionInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  6185. if patientPrescription.ID == 0 {
  6186. patientPrescription, _ = service.FindLastPatientPrescriptionInfo(adminUser.CurrentOrgId, id, recordDateTime)
  6187. }
  6188. //miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  6189. department, _ := service.GetDepartMentDetail(patientPrescription.Departments)
  6190. doctor_info, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, patientPrescription.DoctorId)
  6191. strconv.FormatInt(his.PatientId, 10)
  6192. var res2 ResultSix
  6193. var resSix10265 ResultSix10265
  6194. var time_stamp string
  6195. if miConfig.MdtrtareaAdmvs == "421300" {
  6196. data := make(map[string]interface{})
  6197. client := &http.Client{}
  6198. data["psn_no"] = his.PsnNo
  6199. data["mdtrt_id"] = his.Number
  6200. data["doctor"] = roles.UserName
  6201. data["department"] = department.Name
  6202. data["org_name"] = miConfig.OrgName
  6203. data["med_type"] = strconv.FormatInt(reg_type, 10)
  6204. data["doctor_id"] = strconv.FormatInt(doctor_info.AdminUserId, 10)
  6205. data["fixmedins_code"] = miConfig.Code
  6206. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  6207. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  6208. data["secret_key"] = miConfig.SecretKey
  6209. data["sick_code"] = sickConfig.CountryCode
  6210. data["sick_name"] = sickConfig.ClassName
  6211. data["begin_time"] = begin_time
  6212. data["dept"] = strconv.FormatInt(department.ID, 10)
  6213. data["config"] = config
  6214. fmt.Println(data)
  6215. bytesData, _ := json.Marshal(data)
  6216. req, _ := http.NewRequest("POST", "http://192.168.124.4:9532/"+"hbyb/2203", bytes.NewReader(bytesData))
  6217. resp, _ := client.Do(req)
  6218. defer resp.Body.Close()
  6219. body, ioErr := ioutil.ReadAll(resp.Body)
  6220. if ioErr != nil {
  6221. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  6222. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6223. return
  6224. }
  6225. var respJSON map[string]interface{}
  6226. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  6227. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  6228. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6229. return
  6230. }
  6231. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  6232. userJSONBytes, _ := json.Marshal(respJSON)
  6233. fmt.Println("log")
  6234. fmt.Println(string(userJSONBytes))
  6235. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  6236. utils.ErrorLog("解析失败:%v", err)
  6237. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6238. return
  6239. }
  6240. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  6241. //江苏地区国家医保医疗类别
  6242. //职工透析:医疗类别选特殊情况门诊9933
  6243. //居民血透门慢: 医疗类别选门诊慢病1402
  6244. //var med_type string
  6245. //if his.Insutype == "310" {
  6246. // if reg_type == 14 {
  6247. // med_type = "9933"
  6248. // } else if reg_type == 11 {
  6249. // med_type = "11"
  6250. //
  6251. // }
  6252. //} else if his.Insutype == "390" {
  6253. // if reg_type == 14 {
  6254. // med_type = "1402"
  6255. // } else if reg_type == 11 {
  6256. // med_type = "11"
  6257. // }
  6258. //}
  6259. data := make(map[string]interface{})
  6260. client := &http.Client{}
  6261. data["psn_no"] = his.PsnNo
  6262. data["mdtrt_id"] = his.Number
  6263. data["doctor"] = roles.UserName
  6264. data["department"] = department.Name
  6265. data["org_name"] = miConfig.OrgName
  6266. data["med_type"] = strconv.FormatInt(reg_type, 10)
  6267. data["doctor_id"] = strconv.FormatInt(doctor_info.AdminUserId, 10)
  6268. data["fixmedins_code"] = miConfig.Code
  6269. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  6270. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  6271. data["secret_key"] = miConfig.SecretKey
  6272. data["sick_code"] = sickConfig.CountryCode
  6273. data["sick_name"] = sickConfig.ClassName
  6274. data["begin_time"] = begin_time
  6275. data["dept"] = strconv.FormatInt(department.ID, 10)
  6276. data["config"] = config
  6277. data["url"] = miConfig.Url
  6278. data["ak"] = miConfig.AccessKey
  6279. data["cainfo"] = miConfig.Cainfo
  6280. bytesData, _ := json.Marshal(data)
  6281. var req *http.Request
  6282. if miConfig.MdtrtareaAdmvs == "320921" {
  6283. req, _ = http.NewRequest("POST", "http://192.168.3.111:9532/"+"jsyb/2203", bytes.NewReader(bytesData))
  6284. //api = "http://192.168.3.111:9532/" + "jsyb/readcard?" + "fixmedins_code=" + miConfig.Code + "&secret_key=" + miConfig.SecretKey + "&ak=" + miConfig.AccessKey + "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName +
  6285. // "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&cainfo=" + miConfig.Cainfo
  6286. } else {
  6287. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2203", bytes.NewReader(bytesData))
  6288. }
  6289. resp, _ := client.Do(req)
  6290. defer resp.Body.Close()
  6291. body, ioErr := ioutil.ReadAll(resp.Body)
  6292. if ioErr != nil {
  6293. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  6294. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6295. return
  6296. }
  6297. var respJSON map[string]interface{}
  6298. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  6299. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  6300. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6301. return
  6302. }
  6303. time_stamp = strconv.FormatInt(int64(respJSON["data"].(map[string]interface{})["time_stamp"].(float64)), 10)
  6304. //fmt.Println(respJSON["data"].(map[string]interface{})["time_stamp"].(string))
  6305. //time_stamp = respJSON["data"].(map[string]interface{})["time_stamp"].(string)
  6306. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  6307. userJSONBytes, _ := json.Marshal(respJSON)
  6308. fmt.Println("log")
  6309. fmt.Println(string(userJSONBytes))
  6310. if err := json.Unmarshal(userJSONBytes, &resSix10265); err != nil {
  6311. utils.ErrorLog("解析失败:%v", err)
  6312. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6313. return
  6314. }
  6315. res2.InfRefmsgid = resSix10265.InfRefmsgid
  6316. res2.Output = resSix10265.Output
  6317. res2.ErrMsg = resSix10265.ErrMsg
  6318. res2.Cainfo = resSix10265.Cainfo
  6319. res2.WarnMsg = resSix10265.WarnMsg
  6320. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  6321. res2.Infcode = infocode
  6322. } else {
  6323. var result string
  6324. var requestLog string
  6325. if miConfig.MdtrtareaAdmvs == "440781" { //
  6326. 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)
  6327. } else {
  6328. if miConfig.Code == "H15049901371" {
  6329. //赤峰地区国家医保医疗类别
  6330. //职工透析:医疗类别选特殊情况门诊990502
  6331. //居民定额血透门慢: 医疗类别选门诊慢病140104
  6332. var med_type string
  6333. if his.Insutype == "390" {
  6334. if reg_type == 14 {
  6335. med_type = "9933"
  6336. } else if reg_type == 11 {
  6337. med_type = "11"
  6338. }
  6339. } else if his.Insutype == "310" {
  6340. if reg_type == 14 {
  6341. med_type = "990502"
  6342. } else if reg_type == 11 {
  6343. med_type = "11"
  6344. }
  6345. }
  6346. 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)
  6347. } else {
  6348. 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)
  6349. }
  6350. saveLog(result, requestLog, "2203", "上传就诊信息")
  6351. var respJSON2 map[string]interface{}
  6352. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  6353. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  6354. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6355. return
  6356. }
  6357. userJSONBytes2, _ := json.Marshal(respJSON2)
  6358. if miConfig.Code == "H15049901371" {
  6359. if err := json.Unmarshal(userJSONBytes2, &resSix10265); err != nil {
  6360. utils.ErrorLog("解析失败:%v", err)
  6361. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6362. return
  6363. }
  6364. res2.InfRefmsgid = resSix10265.InfRefmsgid
  6365. res2.Output = resSix10265.Output
  6366. res2.ErrMsg = resSix10265.ErrMsg
  6367. res2.Cainfo = resSix10265.Cainfo
  6368. res2.WarnMsg = resSix10265.WarnMsg
  6369. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  6370. res2.Infcode = infocode
  6371. } else {
  6372. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  6373. utils.ErrorLog("解析失败:%v", err)
  6374. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6375. return
  6376. }
  6377. }
  6378. }
  6379. }
  6380. if res2.Infcode != 0 {
  6381. adminUser := c.GetAdminUserInfo()
  6382. errlog := &models.HisOrderError{
  6383. UserOrgId: adminUser.CurrentOrgId,
  6384. Ctime: time.Now().Unix(),
  6385. Mtime: time.Now().Unix(),
  6386. ErrMsg: res2.ErrMsg,
  6387. Status: 1,
  6388. PatientId: id,
  6389. RecordTime: recordDateTime,
  6390. Stage: 3,
  6391. }
  6392. service.CreateErrMsgLog(errlog)
  6393. c.ServeSuccessJSON(map[string]interface{}{
  6394. "failed_code": -10,
  6395. "msg": res2.ErrMsg,
  6396. })
  6397. return
  6398. } else {
  6399. his.Diagnosis = diagnosis_id
  6400. his.SickType = sickConfig.ID
  6401. his.PType = fmt.Sprintf("%d", reg_type)
  6402. service.UpdateHisPatientThree(&his)
  6403. data := make(map[string]interface{})
  6404. if settle_accounts_type == 1 { //日结
  6405. if reg_type == 11 || reg_type == 1111 || reg_type == 1112 {
  6406. prescriptions, _ = service.GetPrescriptionByIds(ids_arr, adminUser.CurrentOrgId)
  6407. } else {
  6408. prescriptions, _ = service.GetNewHisPrescription(adminUser.CurrentOrgId, his_patient_id, recordDateTime, strconv.Itoa(int(reg_type)))
  6409. }
  6410. data["pre"] = prescriptions
  6411. } else { //月结
  6412. start_time_str := c.GetString("start_time")
  6413. end_time_str := c.GetString("end_time")
  6414. timeLayout := "2006-01-02"
  6415. loc, _ := time.LoadLocation("Local")
  6416. theStartTime, err := time.ParseInLocation(timeLayout+" 15:04:05", start_time_str+" 00:00:00", loc)
  6417. if err != nil {
  6418. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  6419. return
  6420. }
  6421. recordStartTime := theStartTime.Unix()
  6422. start_time = recordStartTime
  6423. theEndTime, err := time.ParseInLocation(timeLayout+" 15:04:05", end_time_str+" 00:00:00", loc)
  6424. if err != nil {
  6425. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  6426. return
  6427. }
  6428. recordEndTime := theEndTime.Unix()
  6429. end_time = recordEndTime
  6430. prescriptions, _ = service.GetMonthHisPrescriptionTwo(adminUser.CurrentOrgId, id, recordStartTime, recordEndTime, reg_type)
  6431. data["pre"] = prescriptions
  6432. }
  6433. client := &http.Client{}
  6434. data["psn_no"] = his.PsnNo
  6435. data["mdtrt_id"] = his.Number
  6436. data["chrg_bchno"] = chrg_bchno
  6437. data["org_name"] = miConfig.OrgName
  6438. data["doctor"] = roles.UserName
  6439. data["doctor_id"] = strconv.FormatInt(roles.AdminUserId, 10)
  6440. data["dept"] = strconv.FormatInt(patientPrescription.Departments, 10)
  6441. data["fixmedins_code"] = miConfig.Code
  6442. data["balance_accounts_type"] = strconv.FormatInt(his.BalanceAccountsType, 10)
  6443. if (department.ID == 0 && adminUser.CurrentOrgId == 9919) || (department.ID == 0 && adminUser.CurrentOrgId == 10106) {
  6444. data["dept_code"] = "15"
  6445. } else {
  6446. data["dept_code"] = department.Number
  6447. }
  6448. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  6449. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  6450. data["secret_key"] = miConfig.SecretKey
  6451. data["url"] = miConfig.Url
  6452. data["ak"] = miConfig.AccessKey
  6453. data["new_doctor_name"] = patientPrescription.Doctor
  6454. data["diag_code"] = sickConfig.CountryCode
  6455. data["time_stamp"] = time_stamp
  6456. data["cainfo"] = miConfig.Cainfo
  6457. var ids []int64
  6458. for _, item := range prescriptions {
  6459. ids = append(ids, item.ID)
  6460. }
  6461. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  6462. if config.IsOpen == 1 { //对接了医保,走医保流程
  6463. var res ResultFour
  6464. var resFour10265 ResultFour10265
  6465. if miConfig.MdtrtareaAdmvs == "421300" {
  6466. bytesData, _ := json.Marshal(data)
  6467. req, _ := http.NewRequest("POST", "http://192.168.124.4:9532/"+"hbyb/2204", bytes.NewReader(bytesData))
  6468. resp, _ := client.Do(req)
  6469. defer resp.Body.Close()
  6470. body, ioErr := ioutil.ReadAll(resp.Body)
  6471. if ioErr != nil {
  6472. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  6473. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6474. return
  6475. }
  6476. var respJSON map[string]interface{}
  6477. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  6478. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  6479. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6480. return
  6481. }
  6482. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  6483. userJSONBytes, _ := json.Marshal(respJSON)
  6484. fmt.Println("log")
  6485. fmt.Println(string(userJSONBytes))
  6486. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  6487. utils.ErrorLog("解析失败:%v", err)
  6488. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6489. return
  6490. }
  6491. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  6492. bytesData, _ := json.Marshal(data)
  6493. var req *http.Request
  6494. if miConfig.MdtrtareaAdmvs == "320921" {
  6495. req, _ = http.NewRequest("POST", "http://192.168.3.111:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  6496. } else {
  6497. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  6498. }
  6499. resp, _ := client.Do(req)
  6500. defer resp.Body.Close()
  6501. body, ioErr := ioutil.ReadAll(resp.Body)
  6502. if ioErr != nil {
  6503. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  6504. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6505. return
  6506. }
  6507. var respJSON map[string]interface{}
  6508. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  6509. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  6510. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6511. return
  6512. }
  6513. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  6514. userJSONBytes, _ := json.Marshal(respJSON)
  6515. fmt.Println("log")
  6516. fmt.Println(string(userJSONBytes))
  6517. if err := json.Unmarshal(userJSONBytes, &resFour10265); err != nil {
  6518. utils.ErrorLog("解析失败:%v", err)
  6519. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6520. return
  6521. }
  6522. res.InfRefmsgid = resFour10265.InfRefmsgid
  6523. res.Output = resFour10265.Output
  6524. res.ErrMsg = resFour10265.ErrMsg
  6525. res.Cainfo = resFour10265.Cainfo
  6526. res.WarnMsg = resFour10265.WarnMsg
  6527. infocode, _ := strconv.ParseInt(resFour10265.Infcode, 10, 64)
  6528. res.Infcode = infocode
  6529. } else {
  6530. if miConfig.Code == "H15049901371" {
  6531. 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)
  6532. var dat map[string]interface{}
  6533. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  6534. fmt.Println(dat)
  6535. } else {
  6536. fmt.Println(err)
  6537. }
  6538. saveLog(result, request_log, "2204", "上传费用明细")
  6539. userJSONBytes, _ := json.Marshal(dat)
  6540. if err := json.Unmarshal(userJSONBytes, &resFour10265); err != nil {
  6541. utils.ErrorLog("解析失败:%v", err)
  6542. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6543. return
  6544. }
  6545. res.InfRefmsgid = resFour10265.InfRefmsgid
  6546. res.Output = resFour10265.Output
  6547. res.ErrMsg = resFour10265.ErrMsg
  6548. res.Cainfo = resFour10265.Cainfo
  6549. res.WarnMsg = resFour10265.WarnMsg
  6550. infocode, _ := strconv.ParseInt(resFour10265.Infcode, 10, 64)
  6551. res.Infcode = infocode
  6552. } else {
  6553. 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), miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, data["balance_accounts_type"].(string), patientPrescription.DoctorId, sickConfig.CountryCode)
  6554. var dat map[string]interface{}
  6555. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  6556. fmt.Println(dat)
  6557. } else {
  6558. fmt.Println(err)
  6559. }
  6560. saveLog(result, request_log, "2204", "上传费用明细")
  6561. userJSONBytes, _ := json.Marshal(dat)
  6562. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  6563. utils.ErrorLog("解析失败:%v", err)
  6564. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6565. return
  6566. }
  6567. }
  6568. }
  6569. if res.Infcode == 0 {
  6570. order := &models.HisOrder{
  6571. UserOrgId: adminUser.CurrentOrgId,
  6572. HisPatientId: his.ID,
  6573. PatientId: his.PatientId,
  6574. SettleAccountsDate: recordDateTime,
  6575. Ctime: time.Now().Unix(),
  6576. Mtime: time.Now().Unix(),
  6577. MdtrtId: his.Number,
  6578. PsnNo: his.PsnNo,
  6579. MedType: strconv.FormatInt(reg_type, 10),
  6580. Status: 1,
  6581. Number: chrg_bchno,
  6582. Infcode: res.Infcode,
  6583. WarnMsg: res.WarnMsg,
  6584. Cainfo: res.Cainfo,
  6585. ErrMsg: res.ErrMsg,
  6586. RespondTime: res.RefmsgTime,
  6587. InfRefmsgid: res.InfRefmsgid,
  6588. OrderStatus: 1,
  6589. IsMedicineInsurance: 1,
  6590. SettleType: settle_accounts_type,
  6591. SettleStartTime: start_time,
  6592. SettleEndTime: end_time,
  6593. Creator: roles.AdminUserId,
  6594. Modify: roles.AdminUserId,
  6595. PType: 2,
  6596. Diagnosis: diagnosis_id,
  6597. }
  6598. err = service.CreateOrder(order)
  6599. if err != nil {
  6600. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCreatePreOrderException)
  6601. return
  6602. }
  6603. for _, item := range res.Output.Result {
  6604. temp := strings.Split(item.FeedetlSn, "-")
  6605. var advice_id int64 = 0
  6606. var project_id int64 = 0
  6607. var types int64 = 0
  6608. id, _ := strconv.ParseInt(temp[2], 10, 64)
  6609. types, _ = strconv.ParseInt(temp[1], 10, 64)
  6610. if temp[1] == "1" {
  6611. advice_id = id
  6612. project_id = 0
  6613. } else if temp[1] == "2" {
  6614. advice_id = 0
  6615. project_id = id
  6616. }
  6617. info := &models.HisOrderInfo{
  6618. OrderNumber: order.Number,
  6619. FeedetlSn: item.FeedetlSn,
  6620. UploadDate: time.Now().Unix(),
  6621. AdviceId: advice_id,
  6622. DetItemFeeSumamt: item.DetItemFeeSumamt,
  6623. Cnt: item.Cnt,
  6624. Pric: float64(item.Pric),
  6625. PatientId: his.PatientId,
  6626. PricUplmtAmt: item.PricUplmtAmt,
  6627. SelfpayProp: item.SelfpayProp,
  6628. FulamtOwnpayAmt: item.FulamtOwnpayAmt,
  6629. OverlmtAmt: item.OverlmtAmt,
  6630. PreselfpayAmt: item.PreselfpayAmt,
  6631. BasMednFlag: item.BasMednFlag,
  6632. MedChrgitmType: item.MedChrgitmType,
  6633. HiNegoDrugFlag: item.HiNegoDrugFlag,
  6634. Status: 1,
  6635. Memo: item.Memo,
  6636. Mtime: time.Now().Unix(),
  6637. InscpScpAmt: item.InscpScpAmt,
  6638. DrtReimFlag: item.DrtReimFlag,
  6639. Ctime: time.Now().Unix(),
  6640. ListSpItemFlag: item.ListSpItemFlag,
  6641. ChldMedcFlag: item.ChldMedcFlag,
  6642. LmtUsedFlag: item.LmtUsedFlag,
  6643. ChrgitmLv: item.ChrgitmLv,
  6644. UserOrgId: adminUser.CurrentOrgId,
  6645. HisPatientId: his.ID,
  6646. OrderId: order.ID,
  6647. ProjectId: project_id,
  6648. Type: types,
  6649. }
  6650. service.CreateOrderInfo(info)
  6651. }
  6652. service.UpDatePrescriptionNumber(adminUser.CurrentOrgId, ids, chrg_bchno)
  6653. service.UpDateHisPrescriptionInfoNumber(adminUser.CurrentOrgId, his_patient_id, chrg_bchno, recordDateTime)
  6654. var total float64
  6655. for _, item := range prescriptions {
  6656. if item.Type == 1 { //药品
  6657. for _, subItem := range item.HisDoctorAdviceInfo {
  6658. total = total + (subItem.Price * subItem.PrescribingNumber)
  6659. }
  6660. }
  6661. if item.Type == 2 { //项目
  6662. for _, subItem := range item.HisPrescriptionProject {
  6663. cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  6664. total = total + (subItem.Price * cnt)
  6665. }
  6666. }
  6667. }
  6668. for _, item := range prescriptions {
  6669. for _, subItem := range item.HisAdditionalCharge {
  6670. total = total + (subItem.Price * float64(subItem.Count))
  6671. }
  6672. }
  6673. allTotal := fmt.Sprintf("%.4f", total)
  6674. if res.Infcode == 0 {
  6675. var rf []*ResultFive
  6676. json.Unmarshal([]byte(his.Iinfo), &rf)
  6677. chrg_bchno := chrg_bchno
  6678. cert_no := his.Certno
  6679. var insutypes []string
  6680. var insutype string
  6681. var is390 int = 0
  6682. var is310 int = 0
  6683. for _, item := range rf {
  6684. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  6685. insutypes = append(insutypes, item.Insutype)
  6686. }
  6687. }
  6688. if len(insutypes) == 1 {
  6689. insutype = insutypes[0]
  6690. } else {
  6691. for _, i := range insutypes {
  6692. if i == "390" {
  6693. is390 = 1
  6694. }
  6695. if i == "310" {
  6696. is310 = 1
  6697. }
  6698. }
  6699. }
  6700. if is390 == 1 {
  6701. insutype = "390"
  6702. }
  6703. if is310 == 1 {
  6704. insutype = "310"
  6705. }
  6706. if len(insutypes) == 0 {
  6707. insutype = "310"
  6708. }
  6709. if len(insutypes) == 2 {
  6710. insutype = strconv.FormatInt(his.SocialType, 64)
  6711. }
  6712. //insutype = "390"
  6713. if his.IdCardType == 1 {
  6714. cert_no = his.MedicalInsuranceNumber
  6715. } else {
  6716. cert_no = his.Certno
  6717. }
  6718. var res ResultSeven
  6719. var resSeven10265 ResultSeven10265
  6720. if miConfig.MdtrtareaAdmvs == "421300" {
  6721. api := "http://192.168.124.4:9532/" + "hbyb/2206?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  6722. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  6723. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  6724. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  6725. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  6726. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  6727. "&insutype=" + insutype + "&total=" + allTotal + "&med_type=" + strconv.FormatInt(reg_type, 10)
  6728. resp, requestErr := http.Get(api)
  6729. if requestErr != nil {
  6730. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6731. return
  6732. }
  6733. body, ioErr := ioutil.ReadAll(resp.Body)
  6734. if ioErr != nil {
  6735. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  6736. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6737. return
  6738. }
  6739. var respJSON map[string]interface{}
  6740. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  6741. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  6742. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6743. return
  6744. }
  6745. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  6746. result, _ := json.Marshal(respJSON)
  6747. fmt.Println("log")
  6748. fmt.Println(string(result))
  6749. if err := json.Unmarshal([]byte(result), &res); err != nil {
  6750. utils.ErrorLog("解析失败:%v", err)
  6751. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6752. return
  6753. }
  6754. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  6755. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  6756. psn_info.VerifyNumber = strings.Replace(psn_info.VerifyNumber, "+", "%2B", -1)
  6757. bas := strings.Split(psn_info.CardInfo, "|")
  6758. if his.IdCardType == 1 {
  6759. cert_no = bas[2]
  6760. } else {
  6761. cert_no = bas[1]
  6762. }
  6763. //江苏地区国家医保医疗类别
  6764. //职工透析:医疗类别选特殊情况门诊9933
  6765. //居民血透门慢: 医疗类别选门诊慢病1402
  6766. //var med_type string
  6767. //if his.Insutype == "310" {
  6768. // if reg_type == 14 {
  6769. // med_type = "9933"
  6770. // } else if reg_type == 11 {
  6771. // med_type = "11"
  6772. //
  6773. // }
  6774. //} else if his.Insutype == "390" {
  6775. // if reg_type == 14 {
  6776. // med_type = "1402"
  6777. // } else if reg_type == 11 {
  6778. // med_type = "11"
  6779. // }
  6780. //}
  6781. var api string
  6782. if miConfig.MdtrtareaAdmvs == "320921" {
  6783. api = "http://192.168.3.111:9532/" + "jsyb/2206?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  6784. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  6785. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  6786. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  6787. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  6788. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  6789. "&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
  6790. //req, _ = http.NewRequest("POST", "http://192.168.3.111:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  6791. } else {
  6792. //req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  6793. api = "http://192.168.5.251:9532/" + "jsyb/2206?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  6794. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  6795. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  6796. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  6797. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  6798. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  6799. "&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
  6800. }
  6801. resp, requestErr := http.Get(api)
  6802. if requestErr != nil {
  6803. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6804. return
  6805. }
  6806. body, ioErr := ioutil.ReadAll(resp.Body)
  6807. if ioErr != nil {
  6808. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  6809. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6810. return
  6811. }
  6812. var respJSON map[string]interface{}
  6813. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  6814. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  6815. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6816. return
  6817. }
  6818. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  6819. result, _ := json.Marshal(respJSON)
  6820. fmt.Println("log")
  6821. fmt.Println(string(result))
  6822. if err := json.Unmarshal([]byte(result), &resSeven10265); err != nil {
  6823. utils.ErrorLog("解析失败:%v", err)
  6824. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6825. return
  6826. }
  6827. res.InfRefmsgid = resSeven10265.InfRefmsgid
  6828. res.Output = resSeven10265.Output
  6829. res.ErrMsg = resSeven10265.ErrMsg
  6830. res.Cainfo = resSeven10265.Cainfo
  6831. res.WarnMsg = resSeven10265.WarnMsg
  6832. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  6833. res.Infcode = infocode
  6834. } else {
  6835. var result string
  6836. var request_log string
  6837. if miConfig.Code == "H15049901371" {
  6838. //赤峰地区国家医保医疗类别
  6839. //职工透析:医疗类别选特殊情况门诊990502
  6840. //居民定额血透门慢: 医疗类别选门诊慢病140104
  6841. var med_type string
  6842. if his.Insutype == "390" {
  6843. if reg_type == 14 {
  6844. med_type = "9933"
  6845. } else if reg_type == 11 {
  6846. med_type = "11"
  6847. }
  6848. } else if his.Insutype == "310" {
  6849. if reg_type == 14 {
  6850. med_type = "990502"
  6851. } else if reg_type == 11 {
  6852. med_type = "11"
  6853. }
  6854. }
  6855. 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, med_type, his.IdCardType, 0, 0, 0, 0, his.IdType)
  6856. } else {
  6857. 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)
  6858. }
  6859. var dat map[string]interface{}
  6860. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  6861. fmt.Println(dat)
  6862. } else {
  6863. fmt.Println(err)
  6864. }
  6865. saveLog(result, request_log, "2206", "预结算")
  6866. //userJSONBytes, _ := json.Marshal(dat)
  6867. //
  6868. //if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  6869. // utils.ErrorLog("解析失败:%v", err)
  6870. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6871. // return
  6872. //}
  6873. userJSONBytes, _ := json.Marshal(dat)
  6874. if miConfig.Code == "H15049901371" {
  6875. if err := json.Unmarshal(userJSONBytes, &resSeven10265); err != nil {
  6876. utils.ErrorLog("解析失败:%v", err)
  6877. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6878. return
  6879. }
  6880. res.InfRefmsgid = resSeven10265.InfRefmsgid
  6881. res.Output = resSeven10265.Output
  6882. res.ErrMsg = resSeven10265.ErrMsg
  6883. res.Cainfo = resSeven10265.Cainfo
  6884. res.WarnMsg = resSeven10265.WarnMsg
  6885. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  6886. res.Infcode = infocode
  6887. } else {
  6888. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  6889. utils.ErrorLog("解析失败:%v", err)
  6890. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6891. return
  6892. }
  6893. }
  6894. }
  6895. if res.Infcode != 0 {
  6896. errlog := &models.HisOrderError{
  6897. UserOrgId: adminUser.CurrentOrgId,
  6898. Ctime: time.Now().Unix(),
  6899. Mtime: time.Now().Unix(),
  6900. Number: chrg_bchno,
  6901. ErrMsg: res.ErrMsg,
  6902. Status: 1,
  6903. PatientId: id,
  6904. RecordTime: recordDateTime,
  6905. Stage: 20,
  6906. }
  6907. service.CreateErrMsgLog(errlog)
  6908. c.ServeSuccessJSON(map[string]interface{}{
  6909. "failed_code": -10,
  6910. "msg": res.ErrMsg,
  6911. })
  6912. return
  6913. } else {
  6914. order, _ := service.GetHisOrderTwo(adminUser.CurrentOrgId, chrg_bchno, id)
  6915. order.OrderStatus = 1
  6916. order.IsPre = 1
  6917. order.Status = 1
  6918. order.MdtrtId = res.Output.Setlinfo.MdtrtID
  6919. order.SetlId = res.Output.Setlinfo.SetlID
  6920. order.PsnNo = res.Output.Setlinfo.PsnNo
  6921. order.PsnName = res.Output.Setlinfo.PsnName
  6922. order.PsnCertType = res.Output.Setlinfo.PsnCertType
  6923. order.Certno = res.Output.Setlinfo.Certno
  6924. order.Gend = res.Output.Setlinfo.Gend
  6925. order.Naty = res.Output.Setlinfo.Naty
  6926. order.Age = res.Output.Setlinfo.Age
  6927. order.Insutype = res.Output.Setlinfo.Insutype
  6928. order.PsnType = res.Output.Setlinfo.PsnType
  6929. order.CvlservFlag = res.Output.Setlinfo.CvlservFlag
  6930. order.SetlTime = res.Output.Setlinfo.SetlTime
  6931. order.MdtrtCertType = res.Output.Setlinfo.MdtrtCertType
  6932. if res.Output.Setlinfo.MedType == "140101" {
  6933. order.MedType = "14"
  6934. } else {
  6935. order.MedType = res.Output.Setlinfo.MedType
  6936. }
  6937. if reg_type == 1112 {
  6938. order.MedType = "1112"
  6939. }
  6940. if reg_type == 1111 {
  6941. order.MedType = "1111"
  6942. }
  6943. order.MedfeeSumamt = res.Output.Setlinfo.MedfeeSumamt
  6944. order.FulamtOwnpayAmt = res.Output.Setlinfo.FulamtOwnpayAmt
  6945. order.OverlmtSelfPay = res.Output.Setlinfo.OverlmtSelfpay
  6946. order.PreselfpayAmt = res.Output.Setlinfo.PreselfpayAmt
  6947. order.InscpScpAmt = res.Output.Setlinfo.InscpScpAmt
  6948. order.ActPayDedc = res.Output.Setlinfo.ActPayDedc
  6949. order.HifpPay = res.Output.Setlinfo.HifpPay
  6950. order.CvlservPay = res.Output.Setlinfo.CvlservPay
  6951. order.PoolPropSelfpay = res.Output.Setlinfo.PoolPropSelfpay
  6952. order.HifesPay = res.Output.Setlinfo.HifesPay
  6953. order.HifobPay = res.Output.Setlinfo.HifobPay
  6954. order.MafPay = res.Output.Setlinfo.MafPay
  6955. order.HifmiPay = res.Output.Setlinfo.HifmiPay
  6956. order.OthPay = res.Output.Setlinfo.OthPay
  6957. order.FundPaySumamt = res.Output.Setlinfo.FundPaySumamt
  6958. order.PsnPartAmt = res.Output.Setlinfo.PsnPartAmt
  6959. order.AcctPay = res.Output.Setlinfo.AcctPay
  6960. order.PsnCashPay = res.Output.Setlinfo.PsnCashPay
  6961. order.HospPartAmt = res.Output.Setlinfo.HospPartAmt
  6962. order.Balc = res.Output.Setlinfo.Balc
  6963. order.AcctMulaidPay = res.Output.Setlinfo.AcctMulaidPay
  6964. order.MedinsSetlId = res.Output.Setlinfo.MedinsSetlID
  6965. order.ClrOptins = res.Output.Setlinfo.ClrOptins
  6966. order.ClrWay = res.Output.Setlinfo.ClrWay
  6967. order.Creator = order.Creator
  6968. order.Modify = roles.AdminUserId
  6969. setlDetail, _ := json.Marshal(res.Output.Setldetail)
  6970. detailStr := string(setlDetail)
  6971. order.SetlDetail = detailStr
  6972. //err := service.UpdataOrderStatusTwo(chrg_bchno, adminUser.CurrentOrgId)
  6973. err = service.UpDateOrder(order)
  6974. if err == nil {
  6975. c.ServeSuccessJSON(map[string]interface{}{
  6976. "msg": "预结算成功",
  6977. })
  6978. } else {
  6979. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeAmountAccountException)
  6980. return
  6981. }
  6982. }
  6983. } else {
  6984. adminUser := c.GetAdminUserInfo()
  6985. errlog := &models.HisOrderError{
  6986. UserOrgId: adminUser.CurrentOrgId,
  6987. Ctime: time.Now().Unix(),
  6988. Mtime: time.Now().Unix(),
  6989. ErrMsg: res.ErrMsg,
  6990. Status: 1,
  6991. PatientId: id,
  6992. RecordTime: recordDateTime,
  6993. Stage: 4,
  6994. }
  6995. service.CreateErrMsgLog(errlog)
  6996. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeRegisterRepeatException)
  6997. return
  6998. }
  6999. } else {
  7000. adminUser := c.GetAdminUserInfo()
  7001. errlog := &models.HisOrderError{
  7002. UserOrgId: adminUser.CurrentOrgId,
  7003. Ctime: time.Now().Unix(),
  7004. Mtime: time.Now().Unix(),
  7005. ErrMsg: res.ErrMsg,
  7006. Status: 1,
  7007. PatientId: id,
  7008. RecordTime: recordDateTime,
  7009. Stage: 4,
  7010. }
  7011. service.CreateErrMsgLog(errlog)
  7012. c.ServeSuccessJSON(map[string]interface{}{
  7013. "failed_code": -10,
  7014. "msg": res.ErrMsg,
  7015. })
  7016. return
  7017. }
  7018. }
  7019. }
  7020. }
  7021. //func (c *HisApiController) GetSettleInfo() {
  7022. // id, _ := c.GetInt64("id")
  7023. // order_id, _ := c.GetInt64("order_id")
  7024. //
  7025. // record_time := c.GetString("record_time")
  7026. // pay_way, _ := c.GetInt64("pay_way")
  7027. // pay_price, _ := c.GetFloat("pay_price")
  7028. // pay_card_no := c.GetString("pay_card_no")
  7029. // discount_price, _ := c.GetFloat("discount_price")
  7030. // preferential_price, _ := c.GetFloat("preferential_price")
  7031. // reality_price, _ := c.GetFloat("reality_price")
  7032. // found_price, _ := c.GetFloat("found_price")
  7033. // medical_insurance_price, _ := c.GetFloat("medical_insurance_price")
  7034. // private_price, _ := c.GetFloat("private_price")
  7035. // settle_accounts_type, _ := c.GetInt64("settle_accounts_type")
  7036. // admin_user_id, _ := c.GetInt64("admin_user_id")
  7037. //
  7038. // timeLayout := "2006-01-02"
  7039. // loc, _ := time.LoadLocation("Local")
  7040. // theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  7041. // if err != nil {
  7042. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  7043. // return
  7044. // }
  7045. // recordDateTime := theTime.Unix()
  7046. // adminUser := c.GetAdminUserInfo()
  7047. //
  7048. // var prescriptions []*models.HisPrescription
  7049. //
  7050. // data := make(map[string]interface{})
  7051. // if settle_accounts_type == 1 { //日结
  7052. // prescriptions, _ = service.GetHisPrescription(adminUser.CurrentOrgId, id, recordDateTime)
  7053. // data["pre"] = prescriptions
  7054. //
  7055. // } else { //月结
  7056. // start_time_str := c.GetString("start_time")
  7057. // end_time_str := c.GetString("end_time")
  7058. // timeLayout := "2006-01-02"
  7059. // loc, _ := time.LoadLocation("Local")
  7060. // theStartTime, err := time.ParseInLocation(timeLayout+" 15:04:05", start_time_str+" 00:00:00", loc)
  7061. // if err != nil {
  7062. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  7063. // return
  7064. // }
  7065. // recordStartTime := theStartTime.Unix()
  7066. // theEndTime, err := time.ParseInLocation(timeLayout+" 15:04:05", end_time_str+" 00:00:00", loc)
  7067. // if err != nil {
  7068. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  7069. // return
  7070. // }
  7071. // recordEndTime := theEndTime.Unix()
  7072. // prescriptions, _ = service.GetMonthHisPrescription(adminUser.CurrentOrgId, id, recordStartTime, recordEndTime)
  7073. // data["pre"] = prescriptions
  7074. //
  7075. // }
  7076. //
  7077. // roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  7078. //
  7079. // his, _ := service.GetVMHisPatientInfo(adminUser.CurrentOrgId, id, recordDateTime)
  7080. // miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  7081. // patientPrescription, _ := service.FindPatientPrescriptionInfo(adminUser.CurrentOrgId, id, recordDateTime)
  7082. // strconv.FormatInt(his.PatientId, 10)
  7083. //
  7084. // order_src, _ := service.GetHisOrderByID(order_id)
  7085. //
  7086. // config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  7087. // if config.IsOpen == 1 { //对接了医保,走医保流程
  7088. //
  7089. // var total float64
  7090. // for _, item := range prescriptions {
  7091. // if item.Type == 1 { //药品
  7092. // for _, subItem := range item.HisDoctorAdviceInfo {
  7093. // total = total + (subItem.Price * subItem.PrescribingNumber)
  7094. // }
  7095. // }
  7096. // if item.Type == 2 { //项目
  7097. // for _, subItem := range item.HisPrescriptionProject {
  7098. // total = total + (subItem.Price * float64(subItem.Count))
  7099. // }
  7100. // }
  7101. // }
  7102. //
  7103. // for _, item := range prescriptions {
  7104. // for _, subItem := range item.HisAdditionalCharge {
  7105. // total = total + (subItem.Price * float64(subItem.Count))
  7106. // }
  7107. // }
  7108. //
  7109. // allTotal := fmt.Sprintf("%.2f", total)
  7110. // var rf []*ResultFive
  7111. // json.Unmarshal([]byte(his.Iinfo), &rf)
  7112. // psn_no := order_src.PsnNo
  7113. // mdtrt_id := order_src.MdtrtId
  7114. // chrg_bchno := order_src.Number
  7115. // cert_no := order_src.Certno
  7116. // insutype := rf[0].Insutype
  7117. //
  7118. // if his.IdCardType == 1 {
  7119. // cert_no = his.MedicalInsuranceNumber
  7120. // } else {
  7121. // cert_no = his.Certno
  7122. // }
  7123. //
  7124. // result, src_resquest := service.Gdyb2207(his.PsnNo, his.Number, chrg_bchno, cert_no, insutype, strconv.FormatFloat(total, 'E', -1, 64) ,miConfig.OrgName,roles.UserName,miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, strconv.FormatInt(patientPrescription.RegisterType, 10),his.IdCardType, order_src.FulamtOwnpayAmt,order_src.OverlmtSelfPay,order_src.PreselfpayAmt,order_src.InscpScpAmt)
  7125. // var dat map[string]interface{}
  7126. // if err := json.Unmarshal([]byte(result), &dat); err == nil {
  7127. // fmt.Println(dat)
  7128. // } else {
  7129. // fmt.Println(err)
  7130. // }
  7131. //
  7132. // userJSONBytes, _ := json.Marshal(dat)
  7133. //
  7134. //
  7135. //
  7136. // var res ResultSeven
  7137. // if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  7138. // utils.ErrorLog("解析失败:%v", err)
  7139. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7140. // return
  7141. // }
  7142. // if res.Infcode == -1 {
  7143. // errlog := &models.HisOrderError{
  7144. // UserOrgId: adminUser.CurrentOrgId,
  7145. // Ctime: time.Now().Unix(),
  7146. // Mtime: time.Now().Unix(),
  7147. // Number: chrg_bchno,
  7148. // ErrMsg: res.ErrMsg,
  7149. // Status: 1,
  7150. // PatientId: id,
  7151. // RecordTime: recordDateTime,
  7152. // Stage: 6,
  7153. // }
  7154. // service.CreateErrMsgLog(errlog)
  7155. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeRegisterRepeatException)
  7156. // return
  7157. // } else {
  7158. // order_src.OrderStatus = 2
  7159. // order_src.PayWay = pay_way
  7160. // order_src.PayPrice = pay_price
  7161. // order_src.PayCardNo = pay_card_no
  7162. // order_src.DiscountPrice = discount_price
  7163. // order_src.PreferentialPrice = preferential_price
  7164. // order_src.RealityPrice = reality_price
  7165. // order_src.FoundPrice = found_price
  7166. // order_src.MedicalInsurancePrice = medical_insurance_price
  7167. // order_src.PrivatePrice = private_price
  7168. // order_src.MdtrtId = res.Output.Setlinfo.MdtrtID
  7169. // order_src.SetlId = res.Output.Setlinfo.SetlID
  7170. // order_src.PsnNo = res.Output.Setlinfo.PsnNo
  7171. // order_src.PsnName = res.Output.Setlinfo.PsnName
  7172. // order_src.PsnCertType = res.Output.Setlinfo.PsnCertType
  7173. // order_src.Certno = res.Output.Setlinfo.Certno
  7174. // order_src.Gend = res.Output.Setlinfo.Gend
  7175. // order_src.Naty = res.Output.Setlinfo.Naty
  7176. // order_src.Age = res.Output.Setlinfo.Age
  7177. // order_src.Insutype = res.Output.Setlinfo.Insutype
  7178. // order_src.PsnType = res.Output.Setlinfo.PsnType
  7179. // order_src.CvlservFlag = res.Output.Setlinfo.CvlservFlag
  7180. // order_src.SetlTime = res.Output.Setlinfo.SetlTime
  7181. // order_src.MdtrtCertType = res.Output.Setlinfo.MdtrtCertType
  7182. // order_src.MedType = res.Output.Setlinfo.MedType
  7183. // order_src.MedfeeSumamt = res.Output.Setlinfo.MedfeeSumamt
  7184. // order_src.FulamtOwnpayAmt = res.Output.Setlinfo.FulamtOwnpayAmt
  7185. // order_src.OverlmtSelfPay = res.Output.Setlinfo.OverlmtSelfpay
  7186. // order_src.PreselfpayAmt = res.Output.Setlinfo.PreselfpayAmt
  7187. // order_src.InscpScpAmt = res.Output.Setlinfo.InscpScpAmt
  7188. // order_src.ActPayDedc = res.Output.Setlinfo.ActPayDedc
  7189. // order_src.HifpPay = res.Output.Setlinfo.HifpPay
  7190. // order_src.CvlservPay = res.Output.Setlinfo.CvlservPay
  7191. // order_src.PoolPropSelfpay = res.Output.Setlinfo.PoolPropSelfpay
  7192. // order_src.HifesPay = res.Output.Setlinfo.HifesPay
  7193. // order_src.HifobPay = res.Output.Setlinfo.HifobPay
  7194. // order_src.MafPay = res.Output.Setlinfo.MafPay
  7195. // order_src.OthPay = res.Output.Setlinfo.OthPay
  7196. // order_src.FundPaySumamt = res.Output.Setlinfo.FundPaySumamt
  7197. // order_src.PsnPartAmt = res.Output.Setlinfo.PsnPartAmt
  7198. // order_src.AcctPay = res.Output.Setlinfo.AcctPay
  7199. // order_src.PsnCashPay = res.Output.Setlinfo.PsnCashPay
  7200. // order_src.HospPartAmt = res.Output.Setlinfo.HospPartAmt
  7201. // order_src.Balc = res.Output.Setlinfo.Balc
  7202. // order_src.AcctMulaidPay = res.Output.Setlinfo.AcctMulaidPay
  7203. // order_src.MedinsSetlId = res.Output.Setlinfo.MedinsSetlID
  7204. // order_src.ClrOptins = res.Output.Setlinfo.ClrOptins
  7205. // order_src.ClrWay = res.Output.Setlinfo.ClrWay
  7206. // order_src.Creator = order_src.Creator
  7207. // order_src.Modify = roles.ID
  7208. // order_src.RequestLog = src_resquest
  7209. // setlDetail, _ := json.Marshal(res.Output.Setldetail)
  7210. // detailStr := string(setlDetail)
  7211. // order_src.SetlDetail = detailStr
  7212. // err = service.UpdataOrderStatusTwo(chrg_bchno, adminUser.CurrentOrgId)
  7213. // err = service.UpDateOrder(order_src)
  7214. //
  7215. // if err == nil {
  7216. // c.ServeSuccessJSON(map[string]interface{}{
  7217. // "msg": "结算成功",
  7218. // })
  7219. // } else {
  7220. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeAmountAccountException)
  7221. // return
  7222. // }
  7223. // }
  7224. // }
  7225. //}
  7226. //退款
  7227. func (c *HisApiController) Refund() {
  7228. order_id, _ := c.GetInt64("order_id")
  7229. admin_user_id, _ := c.GetInt64("admin_user_id")
  7230. adminUser := c.GetAdminUserInfo()
  7231. var order models.HisOrder
  7232. order, _ = service.GetHisOrderByID(order_id)
  7233. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  7234. if order.ID == 0 {
  7235. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  7236. return
  7237. }
  7238. his, _ := service.GetHisPatientByNumber(order.MdtrtId)
  7239. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  7240. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  7241. if config.IsOpen == 1 { //对接了医保,走医保流程
  7242. var res ResultSixteen
  7243. var resSixteen10265 ResultSixteen10265
  7244. var src_resquest string
  7245. var result string
  7246. if miConfig.MdtrtareaAdmvs == "421300" {
  7247. api3 := "http://192.168.124.4:9532/" + "hbyb/2208?psn_no=" + order.PsnNo +
  7248. "&mdtrt_id=" + order.MdtrtId + "&setl_id=" + order.SetlId + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  7249. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  7250. resp3, requestErr3 := http.Get(api3)
  7251. if requestErr3 != nil {
  7252. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7253. return
  7254. }
  7255. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  7256. if ioErr3 != nil {
  7257. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  7258. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7259. return
  7260. }
  7261. var respJSON3 map[string]interface{}
  7262. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  7263. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  7264. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7265. return
  7266. }
  7267. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  7268. userJSONBytes3, _ := json.Marshal(respJSON3)
  7269. fmt.Println("log")
  7270. fmt.Println(string(userJSONBytes3))
  7271. if err := json.Unmarshal(userJSONBytes3, &res); err != nil {
  7272. utils.ErrorLog("解析失败:%v", err)
  7273. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7274. return
  7275. }
  7276. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  7277. var api3 string
  7278. if miConfig.MdtrtareaAdmvs == "320921" {
  7279. api3 = "http://192.168.3.111:9532/" + "jsyb/2208?psn_no=" + order.PsnNo +
  7280. "&mdtrt_id=" + order.MdtrtId + "&setl_id=" + order.SetlId + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  7281. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  7282. //req, _ = http.NewRequest("POST", "http://192.168.3.111:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  7283. } else {
  7284. //req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  7285. api3 = "http://192.168.5.251:9532/" + "jsyb/2208?psn_no=" + order.PsnNo +
  7286. "&mdtrt_id=" + order.MdtrtId + "&setl_id=" + order.SetlId + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  7287. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  7288. }
  7289. resp3, requestErr3 := http.Get(api3)
  7290. if requestErr3 != nil {
  7291. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7292. return
  7293. }
  7294. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  7295. if ioErr3 != nil {
  7296. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  7297. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7298. return
  7299. }
  7300. var respJSON3 map[string]interface{}
  7301. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  7302. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  7303. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7304. return
  7305. }
  7306. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  7307. userJSONBytes3, _ := json.Marshal(respJSON3)
  7308. if err := json.Unmarshal(userJSONBytes3, &resSixteen10265); err != nil {
  7309. utils.ErrorLog("解析失败:%v", err)
  7310. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7311. return
  7312. }
  7313. res.InfRefmsgid = resSixteen10265.InfRefmsgid
  7314. res.Output = resSixteen10265.Output
  7315. res.ErrMsg = resSixteen10265.ErrMsg
  7316. res.Cainfo = resSixteen10265.Cainfo
  7317. res.WarnMsg = resSixteen10265.WarnMsg
  7318. infocode, _ := strconv.ParseInt(resSixteen10265.Infcode, 10, 64)
  7319. res.Infcode = infocode
  7320. } else {
  7321. if miConfig.Code == "H15049901371" {
  7322. result, src_resquest = service.Gdyb2208(order.PsnNo, order.MdtrtId, order.SetlId, miConfig.OrgName, roles.UserName, miConfig.SecretKey, miConfig.Code, his.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs)
  7323. var dat map[string]interface{}
  7324. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  7325. fmt.Println(dat)
  7326. } else {
  7327. fmt.Println(err)
  7328. }
  7329. saveLog(result, src_resquest, "2208", "退费")
  7330. userJSONBytes, _ := json.Marshal(dat)
  7331. if err := json.Unmarshal(userJSONBytes, &resSixteen10265); err != nil {
  7332. utils.ErrorLog("解析失败:%v", err)
  7333. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7334. return
  7335. }
  7336. res.InfRefmsgid = resSixteen10265.InfRefmsgid
  7337. res.Output = resSixteen10265.Output
  7338. res.ErrMsg = resSixteen10265.ErrMsg
  7339. res.Cainfo = resSixteen10265.Cainfo
  7340. res.WarnMsg = resSixteen10265.WarnMsg
  7341. infocode, _ := strconv.ParseInt(resSixteen10265.Infcode, 10, 64)
  7342. res.Infcode = infocode
  7343. } else {
  7344. result, src_resquest = service.Gdyb2208(order.PsnNo, order.MdtrtId, order.SetlId, miConfig.OrgName, roles.UserName, miConfig.SecretKey, miConfig.Code, his.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs)
  7345. var dat map[string]interface{}
  7346. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  7347. fmt.Println(dat)
  7348. } else {
  7349. fmt.Println(err)
  7350. }
  7351. saveLog(result, src_resquest, "2208", "退费")
  7352. userJSONBytes, _ := json.Marshal(dat)
  7353. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  7354. utils.ErrorLog("解析失败:%v", err)
  7355. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7356. return
  7357. }
  7358. }
  7359. }
  7360. if res.Infcode == 0 {
  7361. var res2 ResultSix
  7362. var resSix10265 ResultSix10265
  7363. if miConfig.MdtrtareaAdmvs == "421300" {
  7364. api3 := "http://192.168.124.4:9532/" + "hbyb/2205?psn_no=" + order.PsnNo +
  7365. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  7366. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  7367. resp3, requestErr3 := http.Get(api3)
  7368. if requestErr3 != nil {
  7369. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7370. return
  7371. }
  7372. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  7373. if ioErr3 != nil {
  7374. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  7375. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7376. return
  7377. }
  7378. var respJSON3 map[string]interface{}
  7379. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  7380. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  7381. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7382. return
  7383. }
  7384. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  7385. userJSONBytes3, _ := json.Marshal(respJSON3)
  7386. fmt.Println("log")
  7387. fmt.Println(string(userJSONBytes3))
  7388. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  7389. utils.ErrorLog("解析失败:%v", err)
  7390. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7391. return
  7392. }
  7393. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  7394. var api3 string
  7395. if miConfig.MdtrtareaAdmvs == "320921" {
  7396. api3 = "http://192.168.3.111:9532/" + "jsyb/2205?psn_no=" + order.PsnNo +
  7397. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  7398. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  7399. //req, _ = http.NewRequest("POST", "http://192.168.3.111:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  7400. } else {
  7401. //req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  7402. api3 = "http://192.168.5.251:9532/" + "jsyb/2205?psn_no=" + order.PsnNo +
  7403. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  7404. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  7405. }
  7406. resp3, requestErr3 := http.Get(api3)
  7407. if requestErr3 != nil {
  7408. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7409. return
  7410. }
  7411. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  7412. if ioErr3 != nil {
  7413. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  7414. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7415. return
  7416. }
  7417. var respJSON3 map[string]interface{}
  7418. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  7419. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  7420. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7421. return
  7422. }
  7423. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  7424. userJSONBytes3, _ := json.Marshal(respJSON3)
  7425. fmt.Println("log")
  7426. fmt.Println(string(userJSONBytes3))
  7427. if err := json.Unmarshal(userJSONBytes3, &resSix10265); err != nil {
  7428. utils.ErrorLog("解析失败:%v", err)
  7429. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7430. return
  7431. }
  7432. res2.InfRefmsgid = resSix10265.InfRefmsgid
  7433. res2.Output = resSix10265.Output
  7434. res2.ErrMsg = resSix10265.ErrMsg
  7435. res2.Cainfo = resSix10265.Cainfo
  7436. res2.WarnMsg = resSix10265.WarnMsg
  7437. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  7438. res2.Infcode = infocode
  7439. } else {
  7440. if miConfig.Code == "H15049901371" {
  7441. result2, src_request := service.Gdyb2205(order.PsnNo, order.MdtrtId, order.Number, miConfig.OrgName, roles.UserName, his.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, miConfig.Code)
  7442. var dat map[string]interface{}
  7443. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  7444. fmt.Println(dat)
  7445. } else {
  7446. fmt.Println(err)
  7447. }
  7448. saveLog(result2, src_request, "2205", "撤销明细")
  7449. userJSONBytes, _ := json.Marshal(dat)
  7450. if err := json.Unmarshal(userJSONBytes, &resSix10265); err != nil {
  7451. utils.ErrorLog("解析失败:%v", err)
  7452. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7453. return
  7454. }
  7455. res2.InfRefmsgid = resSix10265.InfRefmsgid
  7456. res2.Output = resSix10265.Output
  7457. res2.ErrMsg = resSix10265.ErrMsg
  7458. res2.Cainfo = resSix10265.Cainfo
  7459. res2.WarnMsg = resSix10265.WarnMsg
  7460. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  7461. res2.Infcode = infocode
  7462. } else {
  7463. result2, src_request := service.Gdyb2205(order.PsnNo, order.MdtrtId, order.Number, miConfig.OrgName, roles.UserName, his.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, miConfig.Code)
  7464. var dat map[string]interface{}
  7465. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  7466. fmt.Println(dat)
  7467. } else {
  7468. fmt.Println(err)
  7469. }
  7470. saveLog(result2, src_request, "2205", "撤销明细")
  7471. userJSONBytes, _ := json.Marshal(dat)
  7472. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  7473. utils.ErrorLog("解析失败:%v", err)
  7474. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7475. return
  7476. }
  7477. }
  7478. }
  7479. if res2.Infcode == 0 {
  7480. err := service.UpdataOrderStatus(order_id, order.Number, adminUser.CurrentOrgId, src_resquest, result)
  7481. if err == nil {
  7482. c.ServeSuccessJSON(map[string]interface{}{
  7483. "msg": "退费成功",
  7484. })
  7485. } else {
  7486. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7487. return
  7488. }
  7489. } else {
  7490. c.ServeSuccessJSON(map[string]interface{}{
  7491. "code": -10,
  7492. "msg": res2.ErrMsg,
  7493. })
  7494. }
  7495. } else {
  7496. c.ServeSuccessJSON(map[string]interface{}{
  7497. "code": -10,
  7498. "msg": res.ErrMsg,
  7499. })
  7500. }
  7501. }
  7502. }
  7503. func (c *HisApiController) RefundNumber() {
  7504. record_time := c.GetString("record_time")
  7505. //patient_id, _ := c.GetInt64("patient_id")
  7506. admin_user_id, _ := c.GetInt64("admin_user_id")
  7507. his_patient_id, _ := c.GetInt64("id")
  7508. timeLayout := "2006-01-02"
  7509. loc, _ := time.LoadLocation("Local")
  7510. adminUser := c.GetAdminUserInfo()
  7511. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  7512. fmt.Println(err)
  7513. if err != nil {
  7514. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  7515. return
  7516. }
  7517. recordDateTime := theTime.Unix()
  7518. //his, _ := service.GetVMHisPatientInfo(adminUser.CurrentOrgId, patient_id, recordDateTime)
  7519. his, _ := service.GetHisPatientRecord(adminUser.CurrentOrgId, his_patient_id)
  7520. //patientPrescription, _ := service.FindPatientPrescriptionInfo(adminUser.CurrentOrgId, patient_id, recordDateTime)
  7521. //order, _ := service.GetHisOrderByID(order_id)
  7522. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  7523. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  7524. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  7525. count, _ := service.GetOrderCountByNumber(adminUser.CurrentOrgId, his.PatientId, recordDateTime, his.Number)
  7526. if count > 0 {
  7527. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeOrderParamWrong)
  7528. return
  7529. }
  7530. if config.IsOpen == 1 { //对接了医保,走医保流程
  7531. var res2 ResultSix
  7532. var resSix10265 ResultSix10265
  7533. if miConfig.MdtrtareaAdmvs == "421300" {
  7534. api3 := "http://192.168.124.4:9532/" + "hbyb/2202?psn_no=" + his.PsnNo +
  7535. "&mdtrt_id=" + his.Number + "&ipt_otp_no=" + his.IptOtpNo + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  7536. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  7537. resp3, requestErr3 := http.Get(api3)
  7538. if requestErr3 != nil {
  7539. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7540. return
  7541. }
  7542. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  7543. if ioErr3 != nil {
  7544. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  7545. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7546. return
  7547. }
  7548. var respJSON3 map[string]interface{}
  7549. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  7550. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  7551. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7552. return
  7553. }
  7554. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  7555. userJSONBytes3, _ := json.Marshal(respJSON3)
  7556. fmt.Println("log")
  7557. fmt.Println(string(userJSONBytes3))
  7558. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  7559. utils.ErrorLog("解析失败:%v", err)
  7560. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7561. return
  7562. }
  7563. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  7564. var api3 string
  7565. if miConfig.MdtrtareaAdmvs == "320921" {
  7566. api3 = "http://192.168.3.111:9532/" + "jsyb/2202?psn_no=" + his.PsnNo +
  7567. "&mdtrt_id=" + his.Number + "&ipt_otp_no=" + his.IptOtpNo + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  7568. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  7569. //req, _ = http.NewRequest("POST", "http://192.168.3.111:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  7570. } else {
  7571. //req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  7572. api3 = "http://192.168.5.251:9532/" + "jsyb/2202?psn_no=" + his.PsnNo +
  7573. "&mdtrt_id=" + his.Number + "&ipt_otp_no=" + his.IptOtpNo + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  7574. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  7575. }
  7576. resp3, requestErr3 := http.Get(api3)
  7577. if requestErr3 != nil {
  7578. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7579. return
  7580. }
  7581. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  7582. if ioErr3 != nil {
  7583. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  7584. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7585. return
  7586. }
  7587. var respJSON3 map[string]interface{}
  7588. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  7589. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  7590. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7591. return
  7592. }
  7593. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  7594. userJSONBytes3, _ := json.Marshal(respJSON3)
  7595. if err := json.Unmarshal(userJSONBytes3, &resSix10265); err != nil {
  7596. utils.ErrorLog("解析失败:%v", err)
  7597. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7598. return
  7599. }
  7600. res2.InfRefmsgid = resSix10265.InfRefmsgid
  7601. res2.Output = resSix10265.Output
  7602. res2.ErrMsg = resSix10265.ErrMsg
  7603. res2.Cainfo = resSix10265.Cainfo
  7604. res2.WarnMsg = resSix10265.WarnMsg
  7605. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  7606. res2.Infcode = infocode
  7607. } else {
  7608. var api3 string
  7609. if miConfig.Code == "H15049901371" {
  7610. api3 = "http://127.0.0.1:9532/" + "gdyb/three?psn_no=" + his.PsnNo +
  7611. "&mdtrt_id=" + his.Number + "&ipt_otp_no=" + his.IptOtpNo + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  7612. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  7613. } else {
  7614. api3 = "http://127.0.0.1:9532/" + "gdyb/three?psn_no=" + his.PsnNo +
  7615. "&mdtrt_id=" + his.Number + "&ipt_otp_no=" + his.IptOtpNo + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  7616. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  7617. }
  7618. resp3, requestErr3 := http.Get(api3)
  7619. if requestErr3 != nil {
  7620. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7621. return
  7622. }
  7623. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  7624. if ioErr3 != nil {
  7625. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  7626. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7627. return
  7628. }
  7629. var respJSON3 map[string]interface{}
  7630. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  7631. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  7632. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7633. return
  7634. }
  7635. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  7636. userJSONBytes3, _ := json.Marshal(respJSON3)
  7637. if miConfig.Code == "H15049901371" {
  7638. if err := json.Unmarshal(userJSONBytes3, &resSix10265); err != nil {
  7639. utils.ErrorLog("解析失败:%v", err)
  7640. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7641. return
  7642. }
  7643. res2.InfRefmsgid = resSix10265.InfRefmsgid
  7644. res2.Output = resSix10265.Output
  7645. res2.ErrMsg = resSix10265.ErrMsg
  7646. res2.Cainfo = resSix10265.Cainfo
  7647. res2.WarnMsg = resSix10265.WarnMsg
  7648. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  7649. res2.Infcode = infocode
  7650. } else {
  7651. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  7652. utils.ErrorLog("解析失败:%v", err)
  7653. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7654. return
  7655. }
  7656. }
  7657. }
  7658. if res2.Infcode == 0 {
  7659. if err == nil {
  7660. c.ServeSuccessJSON(map[string]interface{}{
  7661. "msg": "退号成功",
  7662. })
  7663. service.UpdataRegStatusTwo(his_patient_id, recordDateTime, adminUser.CurrentOrgId)
  7664. } else {
  7665. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7666. return
  7667. }
  7668. } else {
  7669. c.ServeSuccessJSON(map[string]interface{}{
  7670. "code": -10,
  7671. "msg": res2.ErrMsg,
  7672. })
  7673. }
  7674. } else {
  7675. //err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId)
  7676. //if err == nil {
  7677. // c.ServeSuccessJSON(map[string]interface{}{
  7678. // "msg": "退费成功",
  7679. // })
  7680. //} else {
  7681. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7682. // return
  7683. //}
  7684. }
  7685. }
  7686. func (c *HisApiController) RefundDetail() {
  7687. order_id, _ := c.GetInt64("order_id")
  7688. //admin_user_id, _ := c.GetInt64("admin_user_id")
  7689. //his_patient_id, _ := c.GetInt64("his_patient_id")
  7690. number := c.GetString("number")
  7691. record_time := c.GetString("record_time")
  7692. patient_id, _ := c.GetInt64("patient_id")
  7693. //med_type, _ := c.GetInt64("med_type")
  7694. timeLayout := "2006-01-02"
  7695. loc, _ := time.LoadLocation("Local")
  7696. adminUser := c.GetAdminUserInfo()
  7697. //roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  7698. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  7699. fmt.Println(err)
  7700. if err != nil {
  7701. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  7702. return
  7703. }
  7704. recordDateTime := theTime.Unix()
  7705. //his, _ := service.GetNewVMHisPatientInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  7706. patientPrescription, _ := service.FindPatientPrescriptionInfo(adminUser.CurrentOrgId, patient_id, recordDateTime)
  7707. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  7708. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  7709. var order models.HisOrder
  7710. order, _ = service.GetHisOrderByID(order_id)
  7711. his, _ := service.GetHisPatientByNumber(order.MdtrtId)
  7712. if config.IsOpen == 1 { //对接了医保,走医保流程
  7713. var res2 ResultSix
  7714. if miConfig.MdtrtareaAdmvs == "421300" {
  7715. api3 := "http://192.168.124.4:9532/" + "hbyb/2205?psn_no=" + order.PsnNo +
  7716. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + patientPrescription.Doctor + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  7717. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  7718. resp3, requestErr3 := http.Get(api3)
  7719. if requestErr3 != nil {
  7720. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7721. return
  7722. }
  7723. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  7724. if ioErr3 != nil {
  7725. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  7726. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7727. return
  7728. }
  7729. var respJSON3 map[string]interface{}
  7730. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  7731. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  7732. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7733. return
  7734. }
  7735. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  7736. userJSONBytes3, _ := json.Marshal(respJSON3)
  7737. fmt.Println("log")
  7738. fmt.Println(string(userJSONBytes3))
  7739. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  7740. utils.ErrorLog("解析失败:%v", err)
  7741. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7742. return
  7743. }
  7744. err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId, "", "")
  7745. if err == nil {
  7746. c.ServeSuccessJSON(map[string]interface{}{
  7747. "msg": "撤销明细成功",
  7748. })
  7749. return
  7750. } else {
  7751. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7752. return
  7753. }
  7754. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  7755. var resSix10265 ResultSix10265
  7756. var api3 string
  7757. if miConfig.MdtrtareaAdmvs == "320921" {
  7758. api3 = "http://192.168.3.111:9532/" + "jsyb/2205?psn_no=" + order.PsnNo +
  7759. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + patientPrescription.Doctor + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  7760. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  7761. //req, _ = http.NewRequest("POST", "http://192.168.3.111:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  7762. } else {
  7763. //req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  7764. api3 = "http://192.168.5.251:9532/" + "jsyb/2205?psn_no=" + order.PsnNo +
  7765. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + patientPrescription.Doctor + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  7766. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  7767. }
  7768. resp3, requestErr3 := http.Get(api3)
  7769. if requestErr3 != nil {
  7770. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7771. return
  7772. }
  7773. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  7774. if ioErr3 != nil {
  7775. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  7776. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7777. return
  7778. }
  7779. var respJSON3 map[string]interface{}
  7780. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  7781. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  7782. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7783. return
  7784. }
  7785. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  7786. userJSONBytes3, _ := json.Marshal(respJSON3)
  7787. fmt.Println("log")
  7788. fmt.Println(string(userJSONBytes3))
  7789. if err := json.Unmarshal(userJSONBytes3, &resSix10265); err != nil {
  7790. utils.ErrorLog("解析失败:%v", err)
  7791. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7792. return
  7793. }
  7794. res2.InfRefmsgid = resSix10265.InfRefmsgid
  7795. res2.Output = resSix10265.Output
  7796. res2.ErrMsg = resSix10265.ErrMsg
  7797. res2.Cainfo = resSix10265.Cainfo
  7798. res2.WarnMsg = resSix10265.WarnMsg
  7799. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  7800. res2.Infcode = infocode
  7801. err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId, "", "")
  7802. if err == nil {
  7803. c.ServeSuccessJSON(map[string]interface{}{
  7804. "msg": "撤销明细成功",
  7805. })
  7806. return
  7807. } else {
  7808. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7809. return
  7810. }
  7811. } else {
  7812. api2 := "http://127.0.0.1:9532/" + "gdyb/six?psn_no=" + his.PsnNo +
  7813. "&mdtrt_id=" + his.Number + "&chrg_bchno=" + order.Number + "&doctor=" + patientPrescription.Doctor + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  7814. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  7815. resp2, requestErr2 := http.Get(api2)
  7816. if requestErr2 != nil {
  7817. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7818. return
  7819. }
  7820. body2, ioErr2 := ioutil.ReadAll(resp2.Body)
  7821. if ioErr2 != nil {
  7822. utils.ErrorLog("接口返回数据读取失败: %v", ioErr2)
  7823. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7824. return
  7825. }
  7826. var respJSON2 map[string]interface{}
  7827. if err := json.Unmarshal([]byte(string(body2)), &respJSON2); err != nil {
  7828. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  7829. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7830. return
  7831. }
  7832. err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId, "", "")
  7833. if err == nil {
  7834. c.ServeSuccessJSON(map[string]interface{}{
  7835. "msg": "撤销明细成功",
  7836. })
  7837. return
  7838. } else {
  7839. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7840. return
  7841. }
  7842. }
  7843. } else {
  7844. err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId, "", "")
  7845. if err == nil {
  7846. c.ServeSuccessJSON(map[string]interface{}{
  7847. "msg": "退费成功",
  7848. })
  7849. } else {
  7850. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7851. return
  7852. }
  7853. }
  7854. }
  7855. //对账
  7856. func (c *HisApiController) GetCheckAccount() {
  7857. start_time := c.GetString("start_time")
  7858. end_time := c.GetString("end_time")
  7859. insutype := c.GetString("insutype")
  7860. clr_type := c.GetString("clr_type")
  7861. clr_org := c.GetString("clr_optins")
  7862. admin_user_id, _ := c.GetInt64("admin_user_id")
  7863. adminUser := c.GetAdminUserInfo()
  7864. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  7865. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  7866. if len(clr_org) == 0 {
  7867. clr_org = miConfig.MdtrtareaAdmvs
  7868. }
  7869. timeLayout := "2006-01-02"
  7870. loc, _ := time.LoadLocation("Local")
  7871. startime, _ := time.ParseInLocation(timeLayout+" 15:04:05", start_time+" 00:00:00", loc)
  7872. endtime, _ := time.ParseInLocation(timeLayout+" 15:04:05", end_time+" 23:59:59", loc)
  7873. orders, _ := service.GetOrderByTime(startime.Unix(), endtime.Unix(), adminUser.CurrentOrgId, insutype, clr_org, clr_type)
  7874. fixmedins_setl_cnt := int64(len(orders))
  7875. var medfee_sumamt float64
  7876. var acct_pay float64
  7877. var fund_pay_sumamt float64
  7878. for _, item := range orders {
  7879. medfee_sumamt = medfee_sumamt + item.MedfeeSumamt
  7880. acct_pay = acct_pay + item.AcctPay
  7881. fund_pay_sumamt = fund_pay_sumamt + item.FundPaySumamt
  7882. }
  7883. var user_name string
  7884. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  7885. if role.ID == 0 {
  7886. user_name = "xxx"
  7887. } else {
  7888. user_name = role.UserName
  7889. }
  7890. var res ResultEight
  7891. var res10188 ResultEightFor10188
  7892. if config.IsOpen == 1 {
  7893. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  7894. api := "http://192.168.3.111:9532/" + "jsyb/3201?" +
  7895. "insutype=" + insutype +
  7896. "&clr_type=" + "11" +
  7897. "&setl_optins=" + clr_org +
  7898. "&stmt_begndate=" + start_time +
  7899. "&stm_enddate=" + end_time +
  7900. "&medfee_sumamt=" + fmt.Sprintf("%.4f", medfee_sumamt) +
  7901. "&fund_pay_sumamt=" + fmt.Sprintf("%.4f", fund_pay_sumamt) +
  7902. "&acct_pay=" + fmt.Sprintf("%.4f", acct_pay) +
  7903. "&fixmedins_setl_cnt=" + strconv.FormatInt(fixmedins_setl_cnt, 10) +
  7904. "&fixmedins_code=" + miConfig.Code +
  7905. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs +
  7906. "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  7907. "&secret_key=" + miConfig.SecretKey +
  7908. "&org_name=" + miConfig.OrgName +
  7909. "&doctor=" + user_name +
  7910. "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  7911. fmt.Println(api)
  7912. resp, requestErr := http.Get(api)
  7913. if requestErr != nil {
  7914. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7915. return
  7916. }
  7917. body, ioErr := ioutil.ReadAll(resp.Body)
  7918. fmt.Println(body)
  7919. if ioErr != nil {
  7920. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  7921. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7922. return
  7923. }
  7924. var respJSON map[string]interface{}
  7925. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  7926. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  7927. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7928. return
  7929. }
  7930. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  7931. userJSONBytes, _ := json.Marshal(respJSON)
  7932. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  7933. utils.ErrorLog("解析失败:%v", err)
  7934. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7935. return
  7936. }
  7937. res.InfRefmsgid = res10188.InfRefmsgid
  7938. res.Output = res10188.Output
  7939. res.ErrMsg = res10188.ErrMsg
  7940. res.Cainfo = res10188.Cainfo
  7941. res.WarnMsg = res10188.WarnMsg
  7942. infocode, _ := strconv.ParseInt(res10188.Infcode, 10, 64)
  7943. res.Infcode = infocode
  7944. } else {
  7945. api := "http://127.0.0.1:9532/" + "gdyb/ten?" +
  7946. "insutype=" + insutype +
  7947. "&clr_type=" + clr_type +
  7948. "&setl_optins=" + clr_org +
  7949. "&stmt_begndate=" + start_time +
  7950. "&stm_enddate=" + end_time +
  7951. "&medfee_sumamt=" + fmt.Sprintf("%.4f", medfee_sumamt) +
  7952. "&fund_pay_sumamt=" + fmt.Sprintf("%.4f", fund_pay_sumamt) +
  7953. "&acct_pay=" + fmt.Sprintf("%.4f", acct_pay) +
  7954. "&fixmedins_setl_cnt=" + strconv.FormatInt(fixmedins_setl_cnt, 10) +
  7955. "&fixmedins_code=" + miConfig.Code +
  7956. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs +
  7957. "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  7958. "&secret_key=" + miConfig.SecretKey +
  7959. "&org_name=" + miConfig.OrgName +
  7960. "&doctor=" + user_name
  7961. fmt.Println(api)
  7962. resp, requestErr := http.Get(api)
  7963. if requestErr != nil {
  7964. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7965. return
  7966. }
  7967. body, ioErr := ioutil.ReadAll(resp.Body)
  7968. fmt.Println(body)
  7969. if ioErr != nil {
  7970. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  7971. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7972. return
  7973. }
  7974. var respJSON map[string]interface{}
  7975. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  7976. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  7977. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7978. return
  7979. }
  7980. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  7981. userJSONBytes, _ := json.Marshal(respJSON)
  7982. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  7983. utils.ErrorLog("解析失败:%v", err)
  7984. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7985. return
  7986. }
  7987. }
  7988. if res.Infcode == 0 {
  7989. if res.Output.Stmtinfo.StmtRslt == "0" {
  7990. micc := &models.MedicalInsuranceCostCompare{
  7991. StartTime: startime.Unix(),
  7992. EndTime: endtime.Unix(),
  7993. Insutype: insutype,
  7994. CheckType: 1,
  7995. Num: fixmedins_setl_cnt,
  7996. Mtime: time.Now().Unix(),
  7997. Status: 1,
  7998. UserOrgId: adminUser.CurrentOrgId,
  7999. CostTotal: medfee_sumamt,
  8000. FuncTotal: fund_pay_sumamt,
  8001. PsnPay: acct_pay,
  8002. Creator: admin_user_id,
  8003. Ctime: time.Now().Unix(),
  8004. ClrType: clr_type,
  8005. }
  8006. err := service.CreateMedicalInsuranceCostCompareRecord(micc)
  8007. if err == nil {
  8008. c.ServeSuccessJSON(map[string]interface{}{
  8009. "stmt_rslt": res.Output.Stmtinfo.StmtRslt,
  8010. "stmt_rslt_dscr": res.Output.Stmtinfo.StmtRsltDscr,
  8011. })
  8012. } else {
  8013. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8014. }
  8015. } else {
  8016. c.ServeSuccessJSON(map[string]interface{}{
  8017. "stmt_rslt": res.Output.Stmtinfo.StmtRslt,
  8018. "stmt_rslt_dscr": res.Output.Stmtinfo.StmtRsltDscr,
  8019. })
  8020. }
  8021. } else {
  8022. c.ServeSuccessJSON(map[string]interface{}{
  8023. "code": -10,
  8024. "msg": res.ErrMsg,
  8025. })
  8026. }
  8027. }
  8028. }
  8029. func (c *HisApiController) Check310() {
  8030. adminUser := c.GetAdminUserInfo()
  8031. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  8032. var user_name string
  8033. user_name = "高慧裕"
  8034. api := "http://127.0.0.1:9532/" + "gdyb/ten?" +
  8035. "insutype=" + "310" +
  8036. "&clr_type=" + "" +
  8037. "&setl_optins=" + "441202" +
  8038. "&stmt_begndate=" + "2022-03-01" +
  8039. "&stm_enddate=" + "2022-03-31" +
  8040. "&medfee_sumamt=" + "194930.12" +
  8041. "&fund_pay_sumamt=" + "188741.46" +
  8042. "&acct_pay=" + "0" +
  8043. "&fixmedins_setl_cnt=" + "452" +
  8044. "&fixmedins_code=" + miConfig.Code +
  8045. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs +
  8046. "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  8047. "&secret_key=" + miConfig.SecretKey +
  8048. "&org_name=" + miConfig.OrgName +
  8049. "&doctor=" + user_name
  8050. fmt.Println(api)
  8051. resp, requestErr := http.Get(api)
  8052. if requestErr != nil {
  8053. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8054. return
  8055. }
  8056. body, ioErr := ioutil.ReadAll(resp.Body)
  8057. fmt.Println(body)
  8058. if ioErr != nil {
  8059. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  8060. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8061. return
  8062. }
  8063. var respJSON map[string]interface{}
  8064. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  8065. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  8066. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8067. return
  8068. }
  8069. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  8070. userJSONBytes, _ := json.Marshal(respJSON)
  8071. var res ResultEight
  8072. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  8073. utils.ErrorLog("解析失败:%v", err)
  8074. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8075. return
  8076. }
  8077. }
  8078. func (c *HisApiController) Check390() {
  8079. adminUser := c.GetAdminUserInfo()
  8080. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  8081. var user_name string
  8082. user_name = "高慧裕"
  8083. api := "http://127.0.0.1:9532/" + "gdyb/ten?" +
  8084. "insutype=" + "390" +
  8085. "&clr_type=" + "" +
  8086. "&setl_optins=" + "441202" +
  8087. "&stmt_begndate=" + "2022-03-01" +
  8088. "&stm_enddate=" + "2022-03-31" +
  8089. "&medfee_sumamt=" + "1068448.89" +
  8090. "&fund_pay_sumamt=" + "1014677.62" +
  8091. "&acct_pay=" + "0" +
  8092. "&fixmedins_setl_cnt=" + "1950" +
  8093. "&fixmedins_code=" + miConfig.Code +
  8094. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs +
  8095. "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  8096. "&secret_key=" + miConfig.SecretKey +
  8097. "&org_name=" + miConfig.OrgName +
  8098. "&doctor=" + user_name
  8099. fmt.Println(api)
  8100. resp, requestErr := http.Get(api)
  8101. if requestErr != nil {
  8102. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8103. return
  8104. }
  8105. body, ioErr := ioutil.ReadAll(resp.Body)
  8106. fmt.Println(body)
  8107. if ioErr != nil {
  8108. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  8109. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8110. return
  8111. }
  8112. var respJSON map[string]interface{}
  8113. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  8114. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  8115. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8116. return
  8117. }
  8118. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  8119. userJSONBytes, _ := json.Marshal(respJSON)
  8120. var res ResultEight
  8121. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  8122. utils.ErrorLog("解析失败:%v", err)
  8123. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8124. return
  8125. }
  8126. }
  8127. //对账明细
  8128. func (c *HisApiController) GetCheckDetailAccount() {
  8129. start_time := c.GetString("start_time")
  8130. end_time := c.GetString("end_time")
  8131. admin_user_id, _ := c.GetInt64("admin_user_id")
  8132. adminUser := c.GetAdminUserInfo()
  8133. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  8134. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  8135. timeLayout := "2006-01-02"
  8136. loc, _ := time.LoadLocation("Local")
  8137. startime, _ := time.ParseInLocation(timeLayout+" 15:04:05", start_time+" 00:00:00", loc)
  8138. endtime, _ := time.ParseInLocation(timeLayout+" 15:04:05", end_time+" 23:59:59", loc)
  8139. orders, _ := service.GetOrderByTimeTwo(startime.Unix(), endtime.Unix(), adminUser.CurrentOrgId)
  8140. Mkdir(miConfig.OrgName)
  8141. file := strconv.FormatInt(adminUser.CurrentOrgId, 10) + strconv.FormatInt(time.Now().Unix(), 10)
  8142. file_name := file + ".txt"
  8143. zip_name := file + ".zip"
  8144. zip_path := miConfig.OrgName + "/" + zip_name
  8145. file_path := miConfig.OrgName + "/" + file_name
  8146. decimal.DivisionPrecision = 2
  8147. var medfee_sumamt float64
  8148. var psn_cash_pay float64
  8149. var fund_pay_sumamt float64
  8150. fixmedins_setl_cnt := int64(len(orders))
  8151. for _, item := range orders {
  8152. medfee_sumamt = medfee_sumamt + item.MedfeeSumamt
  8153. psn_cash_pay = psn_cash_pay + item.PsnCashPay
  8154. fund_pay_sumamt = fund_pay_sumamt + item.FundPaySumamt
  8155. }
  8156. f, err := os.Create(miConfig.OrgName + "/" + file_name)
  8157. defer f.Close()
  8158. if err != nil {
  8159. fmt.Println(err.Error())
  8160. } else {
  8161. for _, item := range orders {
  8162. var refd_setl_flag string
  8163. if item.OrderStatus == 2 {
  8164. refd_setl_flag = "0"
  8165. var str string
  8166. str = item.SetlId + " " +
  8167. item.MdtrtId + " " +
  8168. item.PsnNo + " " +
  8169. fmt.Sprintf("%.4f", item.MedfeeSumamt) + " " +
  8170. fmt.Sprintf("%.4f", item.FundPaySumamt) + " " +
  8171. fmt.Sprintf("%.4f", item.AcctPay) + " " + refd_setl_flag + "\r\n"
  8172. _, err = f.Write([]byte(str))
  8173. }
  8174. if item.OrderStatus == 3 {
  8175. var str string
  8176. str = item.SetlId + " " +
  8177. item.MdtrtId + " " +
  8178. item.PsnNo + " " +
  8179. fmt.Sprintf("%.4f", item.MedfeeSumamt) + " " +
  8180. fmt.Sprintf("%.4f", item.FundPaySumamt) + " " +
  8181. fmt.Sprintf("%.4f", item.AcctPay) + " " + "1" + "\r\n"
  8182. _, err = f.Write([]byte(str))
  8183. var str2 string
  8184. str2 = item.SetlId + " " +
  8185. item.MdtrtId + " " +
  8186. item.PsnNo + " " +
  8187. fmt.Sprintf("%.4f", 0-item.MedfeeSumamt) + " " +
  8188. fmt.Sprintf("%.4f", 0-item.FundPaySumamt) + " " +
  8189. fmt.Sprintf("%.4f", 0-item.AcctPay) + " " + "1" + "\r\n"
  8190. _, err = f.Write([]byte(str2))
  8191. }
  8192. }
  8193. }
  8194. Zip(file_path, zip_path)
  8195. fmt.Println(ReadFile(zip_path))
  8196. fmt.Println(string(ReadFile(zip_path)))
  8197. if config.IsOpen == 1 {
  8198. var user_name string
  8199. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  8200. if role.ID == 0 {
  8201. user_name = "管理员"
  8202. } else {
  8203. user_name = role.UserName
  8204. }
  8205. baseParams := models.BaseParams{
  8206. SecretKey: miConfig.SecretKey,
  8207. FixmedinsCode: miConfig.Code,
  8208. InsuplcAdmdvs: miConfig.InsuplcAdmdvs,
  8209. MdtrtareaAdmvs: miConfig.MdtrtareaAdmvs,
  8210. OrgName: miConfig.OrgName,
  8211. Doctor: user_name,
  8212. }
  8213. result := service.Gdyb9101(baseParams, zip_name, ReadFile(zip_path))
  8214. var dat map[string]interface{}
  8215. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  8216. fmt.Println(dat)
  8217. } else {
  8218. fmt.Println(err)
  8219. }
  8220. userJSONBytes, _ := json.Marshal(dat)
  8221. var res ResultNine
  8222. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  8223. utils.ErrorLog("解析失败:%v", err)
  8224. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8225. return
  8226. }
  8227. if res.Infcode == 0 {
  8228. fileNo := res.Output.FileQuryNo
  8229. api := "http://127.0.0.1:9532/" + "gdyb/twelve?" +
  8230. "file_qury_no=" + fileNo +
  8231. "&setl_optins=" + "定点医保中心" +
  8232. "&stmt_begndate=" + start_time +
  8233. "&stm_enddate=" + end_time +
  8234. "&medfee_sumamt=" + fmt.Sprintf("%.4f", medfee_sumamt) +
  8235. "&fund_pay_sumamt=" + fmt.Sprintf("%.4f", fund_pay_sumamt) +
  8236. "&cash_payamt=" + fmt.Sprintf("%.4f", psn_cash_pay) +
  8237. "&fixmedins_setl_cnt=" + strconv.FormatInt(fixmedins_setl_cnt, 10) +
  8238. "&fixmedins_code=" + miConfig.Code +
  8239. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs +
  8240. "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  8241. "&secret_key=" + miConfig.SecretKey +
  8242. "&org_name=" + miConfig.OrgName +
  8243. "&doctor=" + user_name
  8244. resp, requestErr := http.Get(api)
  8245. if requestErr != nil {
  8246. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8247. return
  8248. }
  8249. body, ioErr := ioutil.ReadAll(resp.Body)
  8250. if ioErr != nil {
  8251. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  8252. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8253. return
  8254. }
  8255. var respJSON map[string]interface{}
  8256. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  8257. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  8258. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8259. return
  8260. }
  8261. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  8262. userJSONBytes, _ := json.Marshal(respJSON)
  8263. var res ResultTen
  8264. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  8265. utils.ErrorLog("解析失败:%v", err)
  8266. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8267. return
  8268. }
  8269. if res.Infcode == 0 {
  8270. service.Gdyb9102(baseParams, zip_name, fileNo)
  8271. micc := &models.MedicalInsuranceCostCompare{
  8272. StartTime: startime.Unix(),
  8273. EndTime: endtime.Unix(),
  8274. Insutype: "0",
  8275. CheckType: 2,
  8276. Num: fixmedins_setl_cnt,
  8277. Mtime: time.Now().Unix(),
  8278. Status: 1,
  8279. UserOrgId: adminUser.CurrentOrgId,
  8280. CostTotal: medfee_sumamt,
  8281. FuncTotal: fund_pay_sumamt,
  8282. PsnPay: psn_cash_pay,
  8283. Creator: admin_user_id,
  8284. Ctime: time.Now().Unix(),
  8285. }
  8286. service.CreateMedicalInsuranceCostCompareRecord(micc)
  8287. c.ServeSuccessJSON(map[string]interface{}{
  8288. "msg": "明细对账成功",
  8289. })
  8290. }
  8291. } else {
  8292. }
  8293. }
  8294. }
  8295. type CustomOrderInfo struct {
  8296. Name string
  8297. Spec string
  8298. Unit string
  8299. Count float64
  8300. Price float64
  8301. Total float64
  8302. }
  8303. func (c *HisApiController) GetSettleAccounts() {
  8304. //id, _ := c.GetInt64("id")
  8305. //record_time := c.GetString("record_time")
  8306. order_id, _ := c.GetInt64("order_id")
  8307. admin_user_id, _ := c.GetInt64("admin_user_id")
  8308. //timeLayout := "2006-01-02"
  8309. //loc, _ := time.LoadLocation("Local")
  8310. //
  8311. //theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  8312. //if err != nil {
  8313. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  8314. // return
  8315. //}
  8316. //recordDateTime := theTime.Unix()
  8317. adminUser := c.GetAdminUserInfo()
  8318. order, _ := service.GetHisOrderByID(order_id)
  8319. his, _ := service.GetHisPatientByNumber(order.MdtrtId)
  8320. orderInfos, _ := service.GetHisOrderInfoByNumber(order.Number)
  8321. orderInfos_two, _ := service.GetHisOrderInfoByNumberTwo(order.Number)
  8322. orderInfos = append(orderInfos, orderInfos_two...)
  8323. his_hospital, _ := service.GetInHospitalRecordByNumber(order.MdtrtId)
  8324. //diagnosisConfig, _ := service.FindDiagnoseById(his.Diagnosis)
  8325. var diagnosis_ids []string
  8326. if his.ID > 0 {
  8327. diagnosis_ids = strings.Split(his.Diagnosis, ",")
  8328. } else {
  8329. diagnosis_ids = strings.Split(his_hospital.Diagnosis, ",")
  8330. }
  8331. patient, _ := service.GetPatientByIDTwo(adminUser.CurrentOrgId, order.PatientId)
  8332. var dia_config []*models.HisXtDiagnoseConfig
  8333. var name string
  8334. for _, item := range diagnosis_ids {
  8335. id, _ := strconv.ParseInt(item, 10, 64)
  8336. diagnosisConfig, _ := service.FindDiagnoseById(id)
  8337. dia_config = append(dia_config, &diagnosisConfig)
  8338. if len(name) == 0 {
  8339. name = diagnosisConfig.ClassName
  8340. } else {
  8341. name = name + "," + diagnosisConfig.ClassName
  8342. }
  8343. }
  8344. var bedCostTotal float64 = 0 //床位总费
  8345. var bedCostSelfTotal float64 = 0 //床位自费
  8346. var bedCostPartSelfTotal float64 = 0 //床位部分项目自费
  8347. var operationCostTotal float64 = 0 //手术费
  8348. var operationCostSelfTotal float64 = 0 //手术费
  8349. var operationCostPartSelfTotal float64 = 0 //手术费
  8350. var otherCostTotal float64 = 0 //其他费用
  8351. var otherCostSelfTotal float64 = 0 //其他费用
  8352. var otherCostPartSelfTotal float64 = 0 //其他费用
  8353. var materialCostTotal float64 = 0 //材料费
  8354. var materialCostSelfTotal float64 = 0 //材料费
  8355. var materialCostPartSelfTotal float64 = 0 //材料费
  8356. var westernMedicineCostTotal float64 = 0 //西药费
  8357. var westernMedicineCostSelfTotal float64 = 0 //西药费
  8358. var westernMedicineCostPartSelfTotal float64 = 0 //西药费
  8359. var chineseTraditionalMedicineCostTotal float64 = 0 //中成药
  8360. var chineseTraditionalMedicineCostSelfTotal float64 = 0 //中成药
  8361. var chineseTraditionalMedicineCostPartSelfTotal float64 = 0 //中成药
  8362. var checkCostTotal float64 = 0 //检查费
  8363. var checkCostSelfTotal float64 = 0 //检查费
  8364. var checkCostPartSelfTotal float64 = 0 //检查费
  8365. var laboratoryCostTotal float64 = 0 //化验费
  8366. var laboratoryCostSelfTotal float64 = 0 //化验费
  8367. var laboratoryCostPartSelfTotal float64 = 0 //化验费
  8368. var treatCostTotal float64 = 0 //治疗费用
  8369. var treatCostSelfTotal float64 = 0 //治疗费用
  8370. var treatCostPartSelfTotal float64 = 0 //治疗费用
  8371. decimal.DivisionPrecision = 2
  8372. for _, item := range orderInfos {
  8373. if item.MedChrgitmType == "01" { //床位费
  8374. bedCostTotal, _ = decimal.NewFromFloat(bedCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  8375. bedCostSelfTotal, _ = decimal.NewFromFloat(bedCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  8376. bedCostPartSelfTotal, _ = decimal.NewFromFloat(bedCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  8377. }
  8378. if c.GetAdminUserInfo().CurrentOrgId == 10188 || c.GetAdminUserInfo().CurrentOrgId == 10217 {
  8379. if item.MedChrgitmType == "03" { //检查费
  8380. laboratoryCostTotal, _ = decimal.NewFromFloat(laboratoryCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  8381. laboratoryCostSelfTotal, _ = decimal.NewFromFloat(laboratoryCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  8382. laboratoryCostPartSelfTotal, _ = decimal.NewFromFloat(laboratoryCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  8383. }
  8384. } else {
  8385. if item.MedChrgitmType == "03" { //检查费
  8386. checkCostTotal, _ = decimal.NewFromFloat(checkCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  8387. checkCostSelfTotal, _ = decimal.NewFromFloat(checkCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  8388. checkCostPartSelfTotal, _ = decimal.NewFromFloat(checkCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  8389. }
  8390. }
  8391. if item.MedChrgitmType == "04" { //化验费
  8392. laboratoryCostTotal, _ = decimal.NewFromFloat(laboratoryCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  8393. laboratoryCostSelfTotal, _ = decimal.NewFromFloat(laboratoryCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  8394. laboratoryCostPartSelfTotal, _ = decimal.NewFromFloat(laboratoryCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  8395. }
  8396. if item.MedChrgitmType == "05" || item.MedChrgitmType == "1402" || item.MedChrgitmType == "1403" { //治疗费
  8397. treatCostTotal, _ = decimal.NewFromFloat(treatCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  8398. treatCostSelfTotal, _ = decimal.NewFromFloat(treatCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  8399. treatCostPartSelfTotal, _ = decimal.NewFromFloat(treatCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  8400. }
  8401. if item.MedChrgitmType == "06" { //手术费
  8402. operationCostTotal, _ = decimal.NewFromFloat(operationCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  8403. operationCostSelfTotal, _ = decimal.NewFromFloat(operationCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  8404. operationCostPartSelfTotal, _ = decimal.NewFromFloat(operationCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  8405. }
  8406. if item.MedChrgitmType == "08" { //材料费
  8407. materialCostTotal, _ = decimal.NewFromFloat(materialCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  8408. materialCostSelfTotal, _ = decimal.NewFromFloat(materialCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  8409. materialCostPartSelfTotal, _ = decimal.NewFromFloat(materialCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  8410. }
  8411. if item.MedChrgitmType == "09" { //西药费
  8412. westernMedicineCostTotal, _ = decimal.NewFromFloat(westernMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  8413. westernMedicineCostSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  8414. westernMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  8415. }
  8416. if item.MedChrgitmType == "11" { //中成费
  8417. chineseTraditionalMedicineCostTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  8418. chineseTraditionalMedicineCostSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  8419. chineseTraditionalMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  8420. }
  8421. if item.MedChrgitmType == "14" || item.MedChrgitmType == "0" || item.MedChrgitmType == "12" || item.MedChrgitmType == "02" { //其他费
  8422. otherCostTotal, _ = decimal.NewFromFloat(otherCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  8423. otherCostSelfTotal, _ = decimal.NewFromFloat(otherCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  8424. otherCostPartSelfTotal, _ = decimal.NewFromFloat(otherCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  8425. }
  8426. }
  8427. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  8428. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  8429. var user_name string
  8430. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  8431. if role.ID == 0 {
  8432. user_name = "管理员"
  8433. } else {
  8434. user_name = role.UserName
  8435. }
  8436. baseParams := models.BaseParams{
  8437. SecretKey: miConfig.SecretKey,
  8438. FixmedinsCode: miConfig.Code,
  8439. InsuplcAdmdvs: miConfig.InsuplcAdmdvs,
  8440. MdtrtareaAdmvs: miConfig.MdtrtareaAdmvs,
  8441. OrgName: miConfig.OrgName,
  8442. Doctor: user_name,
  8443. }
  8444. businessParams := models.BusinessParams{
  8445. PsnNo: order.PsnNo,
  8446. MdtrtId: order.MdtrtId,
  8447. SetlId: order.SetlId,
  8448. }
  8449. var res ResultEleven
  8450. var resEleven10265 ResultEleven10265
  8451. if config.IsOpen == 1 {
  8452. if miConfig.MdtrtareaAdmvs == "421300" {
  8453. api := "http://192.168.124.4:9532/" + "hbyb/5203?psn_no=" + businessParams.PsnNo + "&mdtrt_id=" + businessParams.MdtrtId + "&setl_id=" + businessParams.SetlId +
  8454. "&org_name=" + miConfig.OrgName + "&doctor=" + baseParams.Doctor + "&fixmedins_code=" + miConfig.Code +
  8455. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  8456. resp, requestErr := http.Get(api)
  8457. if requestErr != nil {
  8458. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8459. return
  8460. }
  8461. body, ioErr := ioutil.ReadAll(resp.Body)
  8462. if ioErr != nil {
  8463. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  8464. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8465. return
  8466. }
  8467. var respJSON map[string]interface{}
  8468. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  8469. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  8470. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8471. return
  8472. }
  8473. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  8474. result, _ := json.Marshal(respJSON)
  8475. fmt.Println("log")
  8476. fmt.Println(string(result))
  8477. if err := json.Unmarshal([]byte(result), &res); err != nil {
  8478. utils.ErrorLog("解析失败:%v", err)
  8479. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8480. return
  8481. }
  8482. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  8483. var api string
  8484. if miConfig.MdtrtareaAdmvs == "320921" {
  8485. api = "http://192.168.3.111:9532/" + "jsyb/5203?psn_no=" + businessParams.PsnNo + "&mdtrt_id=" + businessParams.MdtrtId + "&setl_id=" + businessParams.SetlId +
  8486. "&org_name=" + miConfig.OrgName + "&doctor=" + baseParams.Doctor + "&fixmedins_code=" + miConfig.Code +
  8487. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  8488. //req, _ = http.NewRequest("POST", "http://192.168.3.111:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  8489. } else {
  8490. //req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  8491. api = "http://192.168.5.251:9532/" + "jsyb/5203?psn_no=" + businessParams.PsnNo + "&mdtrt_id=" + businessParams.MdtrtId + "&setl_id=" + businessParams.SetlId +
  8492. "&org_name=" + miConfig.OrgName + "&doctor=" + baseParams.Doctor + "&fixmedins_code=" + miConfig.Code +
  8493. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  8494. }
  8495. resp, requestErr := http.Get(api)
  8496. if requestErr != nil {
  8497. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8498. return
  8499. }
  8500. body, ioErr := ioutil.ReadAll(resp.Body)
  8501. if ioErr != nil {
  8502. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  8503. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8504. return
  8505. }
  8506. var respJSON map[string]interface{}
  8507. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  8508. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  8509. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8510. return
  8511. }
  8512. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  8513. result, _ := json.Marshal(respJSON)
  8514. fmt.Println("log")
  8515. fmt.Println(string(result))
  8516. if err := json.Unmarshal([]byte(result), &resEleven10265); err != nil {
  8517. utils.ErrorLog("解析失败:%v", err)
  8518. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8519. return
  8520. }
  8521. res.InfRefmsgid = resEleven10265.InfRefmsgid
  8522. res.Output = resEleven10265.Output
  8523. res.ErrMsg = resEleven10265.ErrMsg
  8524. res.Cainfo = resEleven10265.Cainfo
  8525. res.WarnMsg = resEleven10265.WarnMsg
  8526. infocode, _ := strconv.ParseInt(resEleven10265.Infcode, 10, 64)
  8527. res.Infcode = infocode
  8528. } else {
  8529. //result2 := service.Gdyb1101()
  8530. //result2 := service.Gdyb5204(baseParams, businessParams)
  8531. //saveLog(result2, "", "5204", "查询")
  8532. result := service.Gdyb5203(baseParams, businessParams)
  8533. var dat map[string]interface{}
  8534. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  8535. fmt.Println(dat)
  8536. } else {
  8537. fmt.Println(err)
  8538. }
  8539. userJSONBytes, _ := json.Marshal(dat)
  8540. if miConfig.Code == "H15049901371" {
  8541. if err := json.Unmarshal(userJSONBytes, &resEleven10265); err != nil {
  8542. utils.ErrorLog("解析失败:%v", err)
  8543. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8544. return
  8545. }
  8546. res.InfRefmsgid = resEleven10265.InfRefmsgid
  8547. res.Output = resEleven10265.Output
  8548. res.ErrMsg = resEleven10265.ErrMsg
  8549. res.Cainfo = resEleven10265.Cainfo
  8550. res.WarnMsg = resEleven10265.WarnMsg
  8551. infocode, _ := strconv.ParseInt(resEleven10265.Infcode, 10, 64)
  8552. res.Infcode = infocode
  8553. } else {
  8554. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  8555. utils.ErrorLog("解析失败:%v", err)
  8556. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8557. return
  8558. }
  8559. }
  8560. }
  8561. printor_admin, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  8562. charge_admin, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, order.Creator)
  8563. patientPrescription, _ := service.FindPatientPrescriptionInfo(adminUser.CurrentOrgId, order.PatientId, order.SettleAccountsDate)
  8564. adminRole_two, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, patientPrescription.DoctorId)
  8565. doctor_info, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, his_hospital.Doctor)
  8566. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  8567. var doctor_name string
  8568. if roles.ID == 0 {
  8569. doctor_name = "管理员"
  8570. } else {
  8571. doctor_name = roles.UserName
  8572. }
  8573. yiliao_leibie := ""
  8574. switch order.MedType {
  8575. case "11":
  8576. yiliao_leibie = "普通门诊"
  8577. break
  8578. case "12":
  8579. yiliao_leibie = "门诊挂号"
  8580. break
  8581. case "13":
  8582. yiliao_leibie = "急诊"
  8583. break
  8584. case "14":
  8585. yiliao_leibie = "门诊特殊病"
  8586. break
  8587. case "15":
  8588. yiliao_leibie = "门诊统筹"
  8589. break
  8590. case "16":
  8591. yiliao_leibie = "门诊慢性病"
  8592. break
  8593. case "21":
  8594. yiliao_leibie = "普通住院"
  8595. break
  8596. }
  8597. departments, _ := service.GetDepartMentDetail(patientPrescription.Departments)
  8598. if res.Infcode == 0 {
  8599. c.ServeSuccessJSON(map[string]interface{}{
  8600. "diagnosis": name,
  8601. "order_infos": orderInfos,
  8602. "number": order.MdtrtId,
  8603. "date": order.SettleAccountsDate,
  8604. "charge_admin": charge_admin,
  8605. "printor_admin": printor_admin,
  8606. "info": res.Output.Setlinfo,
  8607. "order": order,
  8608. "bedCostTotal": bedCostTotal,
  8609. "bedCostSelfTotal": bedCostSelfTotal,
  8610. "bedCostPartSelfTotal": bedCostPartSelfTotal,
  8611. "operationCostTotal": operationCostTotal,
  8612. "operationCostSelfTotal": operationCostSelfTotal,
  8613. "operationCostPartSelfTotal": operationCostPartSelfTotal,
  8614. "otherCostTotal": otherCostTotal,
  8615. "otherCostSelfTotal": otherCostSelfTotal,
  8616. "otherCostPartSelfTotal": otherCostPartSelfTotal,
  8617. "materialCostTotal": materialCostTotal,
  8618. "materialCostSelfTotal": materialCostSelfTotal,
  8619. "materialCostPartSelfTotal": materialCostPartSelfTotal,
  8620. "westernMedicineCostTotal": westernMedicineCostTotal,
  8621. "westernMedicineCostSelfTotal": westernMedicineCostSelfTotal,
  8622. "westernMedicineCostPartSelfTotal": westernMedicineCostPartSelfTotal,
  8623. "chineseTraditionalMedicineCostTotal": chineseTraditionalMedicineCostTotal,
  8624. "chineseTraditionalMedicineCostSelfTotal": chineseTraditionalMedicineCostSelfTotal,
  8625. "chineseTraditionalMedicineCostPartSelfTotal": chineseTraditionalMedicineCostPartSelfTotal,
  8626. "checkCostTotal": checkCostTotal,
  8627. "checkCostSelfTotal": checkCostSelfTotal,
  8628. "checkCostPartSelfTotal": checkCostPartSelfTotal,
  8629. "laboratoryCostTotal": laboratoryCostTotal,
  8630. "laboratoryCostSelfTotal": laboratoryCostSelfTotal,
  8631. "laboratoryCostPartSelfTotal": laboratoryCostPartSelfTotal,
  8632. "treatCostTotal": treatCostTotal,
  8633. "treatCostSelfTotal": treatCostSelfTotal,
  8634. "treatCostPartSelfTotal": treatCostPartSelfTotal,
  8635. "doctor_info": doctor_info,
  8636. "doctor_code": adminRole_two.DoctorCode,
  8637. "doctor_name": doctor_name,
  8638. "health_card_no": order.PsnNo,
  8639. "department": departments.Name,
  8640. "yiliao_leibie": yiliao_leibie,
  8641. "after_money": order.AccountPrice,
  8642. "patient": patient,
  8643. "org_name": miConfig.OrgName,
  8644. "org_code": miConfig.Code,
  8645. "order_number": order.Number,
  8646. "his_hospital": his_hospital,
  8647. "his": his,
  8648. "dia_config": dia_config,
  8649. //"check_order_info": cus_slice,
  8650. })
  8651. }
  8652. }
  8653. }
  8654. func (c *HisApiController) CheckTreatment() {
  8655. patient_id, _ := c.GetInt64("patient_id")
  8656. id_card_no := c.GetString("id_card_no")
  8657. insutype := c.GetString("insutype")
  8658. med_type := c.GetString("med_type")
  8659. admin_user_id, _ := c.GetInt64("admin_user_id")
  8660. adminUser := c.GetAdminUserInfo()
  8661. patient, _ := service.GetPatientByID(adminUser.CurrentOrgId, patient_id)
  8662. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  8663. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  8664. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  8665. if miConfig.MdtrtareaAdmvs == "421300" {
  8666. var res ResultTwo
  8667. api := "http://192.168.124.4:9532/" + "hbyb/1101?cert_no=" + "" +
  8668. "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  8669. "&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)
  8670. resp, requestErr := http.Get(api)
  8671. if requestErr != nil {
  8672. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8673. return
  8674. }
  8675. body, ioErr := ioutil.ReadAll(resp.Body)
  8676. if ioErr != nil {
  8677. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  8678. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8679. return
  8680. }
  8681. var respJSON map[string]interface{}
  8682. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  8683. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  8684. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8685. return
  8686. }
  8687. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  8688. result, _ := json.Marshal(respJSON)
  8689. if err := json.Unmarshal([]byte(result), &res); err != nil {
  8690. utils.ErrorLog("解析失败:%v", err)
  8691. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8692. return
  8693. }
  8694. if res.Infcode == 0 {
  8695. api := "http://192.168.124.4:9532/" + "hbyb/2001?cert_no=" + "" +
  8696. "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  8697. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&psn_no=" + res.Output.Baseinfo.PsnNo + "&insutype=" + insutype + "&med_type=" + med_type
  8698. resp, requestErr := http.Get(api)
  8699. if requestErr != nil {
  8700. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8701. return
  8702. }
  8703. body, ioErr := ioutil.ReadAll(resp.Body)
  8704. if ioErr != nil {
  8705. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  8706. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8707. return
  8708. }
  8709. var respJSON map[string]interface{}
  8710. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  8711. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  8712. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8713. return
  8714. }
  8715. var res Result2001
  8716. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  8717. result2, _ := json.Marshal(respJSON)
  8718. if err := json.Unmarshal([]byte(result2), &res); err != nil {
  8719. utils.ErrorLog("解析失败:%v", err)
  8720. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8721. return
  8722. }
  8723. if res.Infcode == 0 {
  8724. c.ServeSuccessJSON(map[string]interface{}{
  8725. "msg": res.Output.Trtinfo,
  8726. })
  8727. }
  8728. } else {
  8729. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  8730. return
  8731. }
  8732. } else {
  8733. result := service.Gdyb1101A(id_card_no, miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, patient.Name)
  8734. var dat map[string]interface{}
  8735. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  8736. fmt.Println(dat)
  8737. } else {
  8738. fmt.Println(err)
  8739. }
  8740. userJSONBytes, _ := json.Marshal(dat)
  8741. var res ResultTwo
  8742. var res10265 ResultTwo10265
  8743. if miConfig.Code == "H15049901371" {
  8744. if err := json.Unmarshal(userJSONBytes, &res10265); err != nil {
  8745. utils.ErrorLog("解析失败:%v", err)
  8746. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8747. return
  8748. }
  8749. res.ErrMsg = res10265.ErrMsg
  8750. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  8751. res.Infcode = infocode
  8752. res.Output = res10265.Output
  8753. res.InfRefmsgid = res10265.InfRefmsgid
  8754. } else {
  8755. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  8756. utils.ErrorLog("解析失败:%v", err)
  8757. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8758. return
  8759. }
  8760. }
  8761. var user_name string
  8762. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, adminUser.AdminUser.Id)
  8763. if role.ID == 0 {
  8764. user_name = "xxx"
  8765. } else {
  8766. user_name = role.UserName
  8767. }
  8768. baseParams := models.BaseParams{
  8769. SecretKey: miConfig.SecretKey,
  8770. FixmedinsCode: miConfig.Code,
  8771. InsuplcAdmdvs: miConfig.InsuplcAdmdvs,
  8772. MdtrtareaAdmvs: miConfig.MdtrtareaAdmvs,
  8773. OrgName: miConfig.OrgName,
  8774. Doctor: user_name,
  8775. }
  8776. if config.IsOpen == 1 {
  8777. if miConfig.Code == "H15049901371" {
  8778. if med_type == "14" {
  8779. if insutype == "390" {
  8780. med_type = "9933"
  8781. } else if insutype == "310" {
  8782. med_type = "990502"
  8783. }
  8784. } else if med_type == "11" {
  8785. med_type = "11"
  8786. }
  8787. }
  8788. result := service.Gdyb2001(baseParams, res.Output.Baseinfo.PsnNo, insutype, med_type)
  8789. var dat map[string]interface{}
  8790. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  8791. fmt.Println(dat)
  8792. } else {
  8793. fmt.Println(err)
  8794. }
  8795. var res Result2001
  8796. var res10265 Result2001Org10265
  8797. if miConfig.Code == "H15049901371" {
  8798. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  8799. utils.ErrorLog("解析失败:%v", err)
  8800. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8801. return
  8802. }
  8803. res.ErrMsg = res10265.ErrMsg
  8804. res.Output = res10265.Output
  8805. res.InfRefmsgid = res10265.InfRefmsgid
  8806. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  8807. res.Infcode = infocode
  8808. } else {
  8809. if err := json.Unmarshal([]byte(result), &res); err != nil {
  8810. utils.ErrorLog("解析失败:%v", err)
  8811. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8812. return
  8813. }
  8814. }
  8815. if res.Infcode == 0 {
  8816. c.ServeSuccessJSON(map[string]interface{}{
  8817. "msg": res.Output.Trtinfo,
  8818. })
  8819. }
  8820. }
  8821. }
  8822. }
  8823. //func (c *HisApiController) PutRecord() {
  8824. // id, _ := c.GetInt64("id")
  8825. // record_time := c.GetString("record_time")
  8826. // timeLayout := "2006-01-02"
  8827. // loc, _ := time.LoadLocation("Local")
  8828. // theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  8829. // if err != nil {
  8830. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  8831. // return
  8832. // }
  8833. // recordDateTime := theTime.Unix()
  8834. //
  8835. // adminInfo := c.GetAdminUserInfo()
  8836. // patient, _ := service.GetPatientByID(adminInfo.CurrentOrgId, id)
  8837. // patientPrescription, _ := service.FindPatientPrescriptionInfo(adminInfo.CurrentOrgId, id, recordDateTime)
  8838. //
  8839. // miConfig, _ := service.FindMedicalInsuranceInfo(adminInfo.CurrentOrgId)
  8840. //
  8841. // fmt.Println(miConfig.SecretKey)
  8842. //
  8843. // if patient == nil {
  8844. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodePatientNoExist)
  8845. // return
  8846. // }
  8847. // if len(patient.IdCardNo) == 0 {
  8848. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeIDCartNo)
  8849. // return
  8850. // }
  8851. // config, _ := service.GetMedicalInsuranceConfig(adminInfo.CurrentOrgId)
  8852. // if config.IsOpen == 1 {
  8853. // 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
  8854. // resp, requestErr := http.Get(api)
  8855. // if requestErr != nil {
  8856. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8857. // return
  8858. // }
  8859. // defer resp.Body.Close()
  8860. // body, ioErr := ioutil.ReadAll(resp.Body)
  8861. // if ioErr != nil {
  8862. // utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  8863. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8864. // return
  8865. // }
  8866. // var respJSON map[string]interface{}
  8867. //
  8868. // if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  8869. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  8870. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8871. // return
  8872. // }
  8873. //
  8874. // userJSON := respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  8875. // userJSONBytes, _ := json.Marshal(userJSON)
  8876. // var res ResultTwo
  8877. // if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  8878. // utils.ErrorLog("解析失败:%v", err)
  8879. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8880. // return
  8881. // }
  8882. // Iinfos, _ := json.Marshal(res.Output.Iinfo)
  8883. // Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  8884. // infoStr := string(Iinfos)
  8885. // idetinfoStr := string(Idetinfos)
  8886. //
  8887. // if res.Infcode == 0 {
  8888. // his := models.VMHisPatient{
  8889. // Status: 1,
  8890. // Ctime: time.Now().Unix(),
  8891. // Mtime: time.Now().Unix(),
  8892. // PsnNo: res.Output.Baseinfo.PsnNo,
  8893. // PsnCertType: res.Output.Baseinfo.PsnCertType,
  8894. // Certno: res.Output.Baseinfo.Certno,
  8895. // PsnName: res.Output.Baseinfo.PsnName,
  8896. // Gend: res.Output.Baseinfo.Gend,
  8897. // Naty: res.Output.Baseinfo.Naty,
  8898. // Brdy: res.Output.Baseinfo.Brdy,
  8899. // Age: res.Output.Baseinfo.Age,
  8900. // Iinfo: infoStr,
  8901. // Idetinfo: idetinfoStr,
  8902. // PatientId: patient.ID,
  8903. // RecordDate: theTime.Unix(),
  8904. // UserOrgId: adminInfo.CurrentOrgId,
  8905. // AdminUserId: adminInfo.AdminUser.Id,
  8906. // IsReturn: 1,
  8907. // }
  8908. //
  8909. // //doctor_id := strconv.FormatInt(patientPrescription.DoctorId, 10)
  8910. // //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")
  8911. // //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")
  8912. //
  8913. // //var dat map[string]interface{}
  8914. // //if err := json.Unmarshal([]byte(result), &dat); err == nil {
  8915. // // fmt.Println(dat)
  8916. // //} else {
  8917. // // fmt.Println(err)
  8918. // //}
  8919. //
  8920. // var dat2 map[string]interface{}
  8921. // if err := json.Unmarshal([]byte(result2), &dat2); err == nil {
  8922. // fmt.Println(dat2)
  8923. // } else {
  8924. // fmt.Println(err)
  8925. // }
  8926. //
  8927. // } else {
  8928. // adminUser := c.GetAdminUserInfo()
  8929. // errlog := &models.HisOrderError{
  8930. // UserOrgId: adminUser.CurrentOrgId,
  8931. // Ctime: time.Now().Unix(),
  8932. // Mtime: time.Now().Unix(),
  8933. // ErrMsg: res.ErrMsg,
  8934. // Status: 1,
  8935. // PatientId: id,
  8936. // RecordTime: recordDateTime,
  8937. // Stage: 1,
  8938. // }
  8939. // service.CreateErrMsgLog(errlog)
  8940. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeGdybOneException)
  8941. // return
  8942. // }
  8943. // }
  8944. //
  8945. //}
  8946. //func (c *HisApiController) GetUploadDiag() {
  8947. // id, _ := c.GetInt64("id")
  8948. // record_time := c.GetString("record_time")
  8949. //
  8950. // diagnosis_id, _ := c.GetInt64("diagnosis")
  8951. // sick_type, _ := c.GetInt64("sick_type")
  8952. // reg_type, _ := c.GetInt64("reg_type")
  8953. //
  8954. // timeLayout := "2006-01-02"
  8955. // loc, _ := time.LoadLocation("Local")
  8956. // theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  8957. // if err != nil {
  8958. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  8959. // return
  8960. // }
  8961. //
  8962. // var patientPrescription models.HisPrescriptionInfo
  8963. // recordDateTime := theTime.Unix()
  8964. // adminInfo := c.GetAdminUserInfo()
  8965. // patientPrescription, _ = service.FindPatientPrescriptionInfo(adminInfo.CurrentOrgId, id, recordDateTime)
  8966. //
  8967. // if patientPrescription.ID == 0 {
  8968. // patientPrescription, _ = service.FindLastPatientPrescriptionInfo(adminInfo.CurrentOrgId, id, recordDateTime)
  8969. // }
  8970. //
  8971. // miConfig, _ := service.FindMedicalInsuranceInfo(adminInfo.CurrentOrgId)
  8972. // diagnosisConfig, _ := service.FindDiagnoseById(diagnosis_id)
  8973. // his, _ := service.GetVMHisPatientInfo(adminInfo.CurrentOrgId, id, recordDateTime)
  8974. // sickConfig, _ := service.FindSickById(sick_type)
  8975. // department, _ := service.GetDepartMentDetail(patientPrescription.Departments)
  8976. //
  8977. // api2 := "http://127.0.0.1:9532/" + "gdyb/four?psn_no=" + his.PsnNo +
  8978. // "&mdtrt_id=" + his.Number + "&doctor=" + patientPrescription.Doctor + "&department=" + department.Name +
  8979. // "&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 +
  8980. // "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&sick_code=" + sickConfig.ContentCode + "&sick_name=" + sickConfig.ClassName
  8981. // resp2, requestErr2 := http.Get(api2)
  8982. // if requestErr2 != nil {
  8983. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8984. // return
  8985. // }
  8986. // body2, ioErr2 := ioutil.ReadAll(resp2.Body)
  8987. // if ioErr2 != nil {
  8988. // utils.ErrorLog("接口返回数据读取失败: %v", ioErr2)
  8989. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8990. // return
  8991. // }
  8992. // var respJSON2 map[string]interface{}
  8993. // if err := json.Unmarshal([]byte(string(body2)), &respJSON2); err != nil {
  8994. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  8995. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8996. // return
  8997. // }
  8998. // respJSON2 = respJSON2["data"].(map[string]interface{})["pre"].(map[string]interface{})
  8999. // userJSONBytes2, _ := json.Marshal(respJSON2)
  9000. //
  9001. // var res2 ResultSix
  9002. // if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  9003. // utils.ErrorLog("解析失败:%v", err)
  9004. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9005. // return
  9006. // }
  9007. // if res2.Infcode != 0 {
  9008. // adminUser := c.GetAdminUserInfo()
  9009. // errlog := &models.HisOrderError{
  9010. // UserOrgId: adminUser.CurrentOrgId,
  9011. // Ctime: time.Now().Unix(),
  9012. // Mtime: time.Now().Unix(),
  9013. // ErrMsg: res2.ErrMsg,
  9014. // Status: 1,
  9015. // PatientId: id,
  9016. // RecordTime: recordDateTime,
  9017. // Stage: 3,
  9018. // }
  9019. // service.CreateErrMsgLog(errlog)
  9020. //
  9021. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeRegisterThreeException)
  9022. // return
  9023. // }
  9024. //
  9025. // c.ServeSuccessJSON(map[string]interface{}{
  9026. // "msg": "上传成功",
  9027. // })
  9028. //
  9029. //}
  9030. type QueryResult struct {
  9031. ID int64
  9032. Name string
  9033. Code string
  9034. List_type_code string
  9035. }
  9036. func (c *HisApiController) GetCheckCode() {
  9037. ids_str := c.GetString("ids")
  9038. record_type, _ := c.GetInt64("record_type") //1.药品 2.耗材 3.项目
  9039. ids_arr := strings.Split(ids_str, ",")
  9040. var queryResult []QueryResult
  9041. ids := make([]int64, 0)
  9042. for _, item := range ids_arr {
  9043. id, _ := strconv.ParseInt(item, 10, 64)
  9044. ids = append(ids, id)
  9045. }
  9046. if record_type == 1 {
  9047. drugs, _ := service.GetBatchDrugList(ids)
  9048. for _, item := range drugs {
  9049. result := QueryResult{
  9050. ID: item.ID,
  9051. Name: item.DrugName,
  9052. Code: item.MedicalInsuranceNumber,
  9053. List_type_code: "101",
  9054. }
  9055. queryResult = append(queryResult, result)
  9056. }
  9057. } else if record_type == 2 {
  9058. goods, _ := service.GetBatchGoodInformationList(ids)
  9059. for _, item := range goods {
  9060. result := QueryResult{
  9061. ID: item.ID,
  9062. Name: item.GoodName,
  9063. Code: item.MedicalInsuranceNumber,
  9064. List_type_code: "301",
  9065. }
  9066. queryResult = append(queryResult, result)
  9067. }
  9068. } else if record_type == 3 {
  9069. projects, _ := service.GetBathchMyPorjecgList(ids)
  9070. for _, item := range projects {
  9071. result := QueryResult{
  9072. ID: item.ID,
  9073. Name: item.ProjectName,
  9074. Code: item.MedicalCode,
  9075. List_type_code: "201",
  9076. }
  9077. queryResult = append(queryResult, result)
  9078. }
  9079. }
  9080. admin_user_id, _ := c.GetInt64("admin_user_id")
  9081. adminUser := c.GetAdminUserInfo()
  9082. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  9083. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  9084. var user_name string
  9085. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  9086. if role.ID == 0 {
  9087. user_name = "xxx"
  9088. } else {
  9089. user_name = role.UserName
  9090. }
  9091. baseParams := &models.BaseParams{
  9092. SecretKey: miConfig.SecretKey,
  9093. FixmedinsCode: miConfig.Code,
  9094. InsuplcAdmdvs: miConfig.InsuplcAdmdvs,
  9095. MdtrtareaAdmvs: miConfig.MdtrtareaAdmvs,
  9096. OrgName: miConfig.OrgName,
  9097. Doctor: user_name,
  9098. }
  9099. if config.IsOpen == 1 {
  9100. for _, item := range queryResult {
  9101. var result string
  9102. if record_type == 1 {
  9103. result = service.Gdyb3301(baseParams, item.Name, item.Code, item.List_type_code, "2021-04-26", "", item.List_type_code)
  9104. } else if record_type == 2 {
  9105. result = service.Gdyb3301(baseParams, item.Name, item.Code, item.List_type_code, "2021-04-26", "", item.List_type_code)
  9106. } else if record_type == 3 {
  9107. result = service.Gdyb3301(baseParams, item.Name, item.Code, item.List_type_code, "2021-04-26", "", item.List_type_code)
  9108. }
  9109. var dat map[string]interface{}
  9110. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  9111. fmt.Println(dat)
  9112. } else {
  9113. fmt.Println(err)
  9114. }
  9115. userJSONBytes, _ := json.Marshal(dat)
  9116. var res ResultSix
  9117. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  9118. utils.ErrorLog("解析失败:%v", err)
  9119. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9120. return
  9121. }
  9122. if res.Infcode == 0 {
  9123. if record_type == 1 {
  9124. service.UpdateBaseDrugById(item.ID)
  9125. } else if record_type == 2 {
  9126. service.UpdateGoodInformaitonByDetail(item.ID)
  9127. } else if record_type == 3 {
  9128. service.UpdateProjectById(item.ID)
  9129. }
  9130. c.ServeSuccessJSON(map[string]interface{}{
  9131. "failed_code": 0,
  9132. "msg": "目录对照成功",
  9133. })
  9134. } else {
  9135. c.ServeSuccessJSON(map[string]interface{}{
  9136. "failed_code": -10,
  9137. "msg": res.ErrMsg,
  9138. })
  9139. }
  9140. }
  9141. }
  9142. }
  9143. func (c *HisApiController) UnCheckCode() {
  9144. ids_str := c.GetString("ids")
  9145. record_type, _ := c.GetInt64("record_type") //1.药品 2.耗材 3.项目
  9146. admin_user_id, _ := c.GetInt64("admin_user_id")
  9147. ids_arr := strings.Split(ids_str, ",")
  9148. var queryResult []QueryResult
  9149. ids := make([]int64, 0)
  9150. for _, item := range ids_arr {
  9151. id, _ := strconv.ParseInt(item, 10, 64)
  9152. ids = append(ids, id)
  9153. }
  9154. if record_type == 1 {
  9155. drugs, _ := service.GetBatchDrugList(ids)
  9156. for _, item := range drugs {
  9157. result := QueryResult{
  9158. ID: item.ID,
  9159. Name: item.DrugName,
  9160. Code: item.MedicalInsuranceNumber,
  9161. List_type_code: "101",
  9162. }
  9163. queryResult = append(queryResult, result)
  9164. }
  9165. } else if record_type == 2 {
  9166. goods, _ := service.GetBatchGoodInformationList(ids)
  9167. for _, item := range goods {
  9168. result := QueryResult{
  9169. ID: item.ID,
  9170. Name: item.GoodName,
  9171. Code: item.MedicalInsuranceNumber,
  9172. List_type_code: "301",
  9173. }
  9174. queryResult = append(queryResult, result)
  9175. }
  9176. } else if record_type == 3 {
  9177. projects, _ := service.GetBathchMyPorjecgList(ids)
  9178. for _, item := range projects {
  9179. result := QueryResult{
  9180. ID: item.ID,
  9181. Name: item.ProjectName,
  9182. Code: item.MedicalCode,
  9183. List_type_code: "201",
  9184. }
  9185. queryResult = append(queryResult, result)
  9186. }
  9187. }
  9188. adminUser := c.GetAdminUserInfo()
  9189. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  9190. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  9191. var user_name string
  9192. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  9193. if role.ID == 0 {
  9194. user_name = "xxx"
  9195. } else {
  9196. user_name = role.UserName
  9197. }
  9198. baseParams := &models.BaseParams{
  9199. SecretKey: miConfig.SecretKey,
  9200. FixmedinsCode: miConfig.Code,
  9201. InsuplcAdmdvs: miConfig.InsuplcAdmdvs,
  9202. MdtrtareaAdmvs: miConfig.MdtrtareaAdmvs,
  9203. OrgName: miConfig.OrgName,
  9204. Doctor: user_name,
  9205. }
  9206. if config.IsOpen == 1 {
  9207. for _, item := range queryResult {
  9208. var result string
  9209. if record_type == 1 {
  9210. result = service.Gdyb3302(baseParams, item.Name, item.Code, item.List_type_code)
  9211. } else if record_type == 2 {
  9212. result = service.Gdyb3302(baseParams, item.Name, item.Code, item.List_type_code)
  9213. } else if record_type == 3 {
  9214. result = service.Gdyb3302(baseParams, item.Name, item.Code, item.List_type_code)
  9215. }
  9216. var dat2 map[string]interface{}
  9217. if err := json.Unmarshal([]byte(result), &dat2); err == nil {
  9218. fmt.Println(dat2)
  9219. } else {
  9220. fmt.Println(err)
  9221. }
  9222. userJSONBytes, _ := json.Marshal(dat2)
  9223. var res ResultSix
  9224. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  9225. utils.ErrorLog("解析失败:%v", err)
  9226. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9227. return
  9228. }
  9229. if res.Infcode == 0 {
  9230. if record_type == 1 {
  9231. service.UpdateDrugByIdDetail(item.ID)
  9232. } else if record_type == 2 {
  9233. service.UpdateGoodInfoById(item.ID)
  9234. } else if record_type == 3 {
  9235. service.UpdateMyProjectById(item.ID)
  9236. }
  9237. c.ServeSuccessJSON(map[string]interface{}{
  9238. "failed_code": 0,
  9239. "msg": "撤销目录对照成功",
  9240. })
  9241. } else {
  9242. c.ServeSuccessJSON(map[string]interface{}{
  9243. "failed_code": -10,
  9244. "msg": res.ErrMsg,
  9245. })
  9246. }
  9247. }
  9248. }
  9249. }
  9250. func (c *HisApiController) GetPatientInfo() {
  9251. id_card_no := c.GetString("id_card_no")
  9252. admin_user_id, _ := c.GetInt64("admin_user_id")
  9253. patient, _ := service.GetPatientByIDCard(id_card_no, c.GetAdminUserInfo().CurrentOrgId)
  9254. if patient.ID == 0 {
  9255. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodePatientNoExist)
  9256. return
  9257. }
  9258. role, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  9259. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  9260. config, _ := service.GetMedicalInsuranceConfig(c.GetAdminUserInfo().CurrentOrgId)
  9261. if config.IsOpen == 1 {
  9262. result := service.Gdyb1101A(id_card_no, miConfig.OrgName, role.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, patient.Name)
  9263. var dat map[string]interface{}
  9264. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  9265. fmt.Println(dat)
  9266. } else {
  9267. fmt.Println(err)
  9268. }
  9269. userJSONBytes, _ := json.Marshal(dat)
  9270. var res ResultTwo
  9271. var res10265 ResultTwo10265
  9272. if miConfig.Code == "H15049901371" {
  9273. if err := json.Unmarshal(userJSONBytes, &res10265); err != nil {
  9274. utils.ErrorLog("解析失败:%v", err)
  9275. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9276. return
  9277. }
  9278. res.ErrMsg = res10265.ErrMsg
  9279. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  9280. res.Infcode = infocode
  9281. res.Output = res10265.Output
  9282. res.InfRefmsgid = res10265.InfRefmsgid
  9283. } else {
  9284. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  9285. utils.ErrorLog("解析失败:%v", err)
  9286. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9287. return
  9288. }
  9289. }
  9290. //if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  9291. // utils.ErrorLog("解析失败:%v", err)
  9292. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9293. // return
  9294. //}
  9295. if res.Infcode != 0 {
  9296. c.ServeSuccessJSON(map[string]interface{}{
  9297. "failed_code": -10,
  9298. "msg": res.ErrMsg,
  9299. })
  9300. } else {
  9301. c.ServeSuccessJSON(map[string]interface{}{
  9302. "failed_code": 0,
  9303. "info": res,
  9304. })
  9305. }
  9306. }
  9307. }
  9308. func (c *HisApiController) PsnPutOnRecord() {
  9309. record_type, _ := c.GetInt64("type")
  9310. patient_id, _ := c.GetInt64("patient_id")
  9311. admin_user_id, _ := c.GetInt64("admin_user_id")
  9312. start_time := c.GetString("start_time")
  9313. end_time := c.GetString("end_time")
  9314. adminUser := c.GetAdminUserInfo()
  9315. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  9316. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  9317. var patients []*models.Patients
  9318. if record_type == 1 { //全部备案
  9319. patient, _ := service.GetAllPatient(adminUser.CurrentOrgId)
  9320. patients = append(patients, patient...)
  9321. } else { //单个备案
  9322. patient, _ := service.GetPatientByID(adminUser.CurrentOrgId, patient_id)
  9323. patients = append(patients, patient)
  9324. }
  9325. var user_name string
  9326. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  9327. if role.ID == 0 {
  9328. user_name = "xxx"
  9329. } else {
  9330. user_name = role.UserName
  9331. }
  9332. if config.IsOpen == 1 {
  9333. for _, item := range patients {
  9334. 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
  9335. resp, requestErr := http.Get(api)
  9336. if requestErr != nil {
  9337. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9338. return
  9339. }
  9340. defer resp.Body.Close()
  9341. body, ioErr := ioutil.ReadAll(resp.Body)
  9342. if ioErr != nil {
  9343. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  9344. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9345. return
  9346. }
  9347. var respJSON map[string]interface{}
  9348. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  9349. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  9350. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9351. return
  9352. }
  9353. userJSON := respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  9354. userJSONBytes, _ := json.Marshal(userJSON)
  9355. var res ResultTwo
  9356. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  9357. utils.ErrorLog("解析失败:%v", err)
  9358. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9359. return
  9360. }
  9361. if res.Infcode == 0 {
  9362. result := service.Gdyb2505(res.Output.Baseinfo.PsnNo, user_name, miConfig.OrgName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, start_time, end_time)
  9363. var dat map[string]interface{}
  9364. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  9365. fmt.Println(dat)
  9366. } else {
  9367. fmt.Println(err)
  9368. }
  9369. userJSONBytes, _ := json.Marshal(dat)
  9370. var res2 ResultThirteen
  9371. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  9372. utils.ErrorLog("解析失败:%v", err)
  9373. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9374. return
  9375. }
  9376. if res2.Infcode == 0 {
  9377. psnResult := &models.GdybPsnRecord{
  9378. UserOrgId: adminUser.CurrentOrgId,
  9379. PatientId: item.ID,
  9380. PsnNo: res.Output.Baseinfo.PsnNo,
  9381. Ctime: time.Now().Unix(),
  9382. Mtime: time.Now().Unix(),
  9383. Status: 1,
  9384. IsCancel: 1,
  9385. TrtDclaDetlSn: res2.Output.Result.TrtDclaDetlSn,
  9386. }
  9387. service.CreatePsnRecord(psnResult)
  9388. } else {
  9389. c.ServeSuccessJSON(map[string]interface{}{
  9390. "failed_code": -10,
  9391. "msg": res2.ErrMsg,
  9392. })
  9393. return
  9394. }
  9395. }
  9396. }
  9397. }
  9398. }
  9399. func (c *HisApiController) PsnUnPutOnRecord() {
  9400. id, _ := c.GetInt64("id")
  9401. //record_type, _ := c.GetInt64("type")
  9402. admin_user_id, _ := c.GetInt64("admin_user_id")
  9403. adminUser := c.GetAdminUserInfo()
  9404. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  9405. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  9406. var user_name string
  9407. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  9408. if role.ID == 0 {
  9409. user_name = "xxx"
  9410. } else {
  9411. user_name = role.UserName
  9412. }
  9413. psn_record, _ := service.GetPsnRecordById(id)
  9414. if psn_record.ID == 0 {
  9415. c.ServeFailJSONWithSGJErrorCode(enums.ErrorPsnRecordNoExistWrong)
  9416. return
  9417. }
  9418. if config.IsOpen == 1 {
  9419. result := service.Gdyb2506(psn_record.PsnNo, user_name, miConfig.OrgName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, psn_record.TrtDclaDetlSn)
  9420. var dat map[string]interface{}
  9421. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  9422. fmt.Println(dat)
  9423. } else {
  9424. fmt.Println(err)
  9425. }
  9426. userJSONBytes, _ := json.Marshal(dat)
  9427. var res ResultFourteen
  9428. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  9429. utils.ErrorLog("解析失败:%v", err)
  9430. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9431. return
  9432. }
  9433. if res.Infcode == 0 {
  9434. psn_record.IsCancel = 2
  9435. service.CreatePsnRecord(&psn_record)
  9436. } else {
  9437. c.ServeSuccessJSON(map[string]interface{}{
  9438. "failed_code": -10,
  9439. "msg": res.ErrMsg,
  9440. })
  9441. return
  9442. }
  9443. }
  9444. }
  9445. func (c *HisApiController) PsnPutNCDSOnRecord() {
  9446. patient_id, _ := c.GetInt64("patient_id")
  9447. insutype_two := c.GetString("insutype")
  9448. psn_no := c.GetString("psn_no")
  9449. doctor_id, _ := c.GetInt64("doctor_id")
  9450. sick_id, _ := c.GetInt64("sick_id")
  9451. department_id, _ := c.GetInt64("department_id")
  9452. start_time := c.GetString("start_time")
  9453. end_time := c.GetString("end_time")
  9454. check_time := c.GetString("check_time")
  9455. adminUser := c.GetAdminUserInfo()
  9456. patient, _ := service.GetPatientByID(adminUser.CurrentOrgId, patient_id)
  9457. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  9458. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  9459. sick, _ := service.FindSickById(sick_id)
  9460. doctor, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, doctor_id)
  9461. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, doctor_id)
  9462. var res ResultTwo
  9463. var res10265 ResultTwo10265
  9464. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  9465. psn_info, _ := service.GetPsnByPatientId(patient.ID)
  9466. api := "http://192.168.3.111:9532/" + "hbyb/1101?cert_no=" + "" +
  9467. "&org_name=" + miConfig.OrgName + "&doctor=" + role.UserName + "&fixmedins_code=" + miConfig.Code +
  9468. "&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
  9469. resp, requestErr := http.Get(api)
  9470. if requestErr != nil {
  9471. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9472. return
  9473. }
  9474. body, ioErr := ioutil.ReadAll(resp.Body)
  9475. if ioErr != nil {
  9476. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  9477. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9478. return
  9479. }
  9480. var respJSON map[string]interface{}
  9481. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  9482. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  9483. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9484. return
  9485. }
  9486. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  9487. result, _ := json.Marshal(respJSON)
  9488. fmt.Println("log")
  9489. fmt.Println(string(result))
  9490. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  9491. utils.ErrorLog("解析失败:%v", err)
  9492. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9493. return
  9494. }
  9495. res.ErrMsg = res10265.ErrMsg
  9496. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  9497. res.Infcode = infocode
  9498. res.Output = res10265.Output
  9499. res.InfRefmsgid = res10265.InfRefmsgid
  9500. } else {
  9501. result, _ := service.Gdyb1101(patient.IdCardNo, miConfig.OrgName, role.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, 2, "", "0", patient.Name)
  9502. if miConfig.Code == "H15049901371" {
  9503. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  9504. utils.ErrorLog("解析失败:%v", err)
  9505. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9506. return
  9507. }
  9508. res.ErrMsg = res10265.ErrMsg
  9509. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  9510. res.Infcode = infocode
  9511. res.Output = res10265.Output
  9512. res.InfRefmsgid = res10265.InfRefmsgid
  9513. } else {
  9514. if err := json.Unmarshal([]byte(result), &res); err != nil {
  9515. utils.ErrorLog("解析失败:%v", err)
  9516. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9517. return
  9518. }
  9519. }
  9520. }
  9521. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  9522. infoStr := string(Iinfos)
  9523. var rf []*ResultFive
  9524. json.Unmarshal([]byte(infoStr), &rf)
  9525. var insuplc_admdvs string
  9526. var insutype string
  9527. var is390 int = 0
  9528. var is310 int = 0
  9529. var insutypes []*ResultFive
  9530. for _, item := range rf {
  9531. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  9532. insutypes = append(insutypes, item)
  9533. }
  9534. }
  9535. if len(insutypes) == 1 {
  9536. insutype = insutypes[0].Insutype
  9537. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  9538. } else {
  9539. for _, i := range insutypes {
  9540. if i.Insutype == "390" {
  9541. is390 = 1
  9542. }
  9543. if i.Insutype == "310" {
  9544. is310 = 1
  9545. }
  9546. }
  9547. }
  9548. if is390 == 1 {
  9549. insutype = "390"
  9550. }
  9551. if is310 == 1 {
  9552. insutype = "310"
  9553. }
  9554. if len(insutypes) == 2 {
  9555. insutype = insutype_two
  9556. }
  9557. if len(insutypes) == 0 {
  9558. insutype = "310"
  9559. }
  9560. insutype = insutype_two
  9561. fmt.Println(insutype)
  9562. for _, item := range rf {
  9563. fmt.Println(item.Insutype)
  9564. fmt.Println(insutype)
  9565. if item.Insutype == insutype {
  9566. fmt.Println(item.Insutype)
  9567. fmt.Println(insutype)
  9568. insuplc_admdvs = item.InsuplcAdmdvs
  9569. }
  9570. }
  9571. fmt.Println(insuplc_admdvs)
  9572. var res2 ResultThirteen
  9573. var res10265_2 ResultThirteen10265
  9574. if config.IsOpen == 1 {
  9575. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  9576. } else {
  9577. result := service.Gdyb2503(psn_no, insutype, miConfig.OrgName, doctor.UserName, miConfig.Code, strconv.FormatInt(doctor.ID, 10), insuplc_admdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, sick.ClassName, sick.ContentCode, start_time, end_time, check_time)
  9578. var dat map[string]interface{}
  9579. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  9580. fmt.Println(dat)
  9581. } else {
  9582. fmt.Println(err)
  9583. }
  9584. userJSONBytes, _ := json.Marshal(dat)
  9585. if miConfig.Code == "H15049901371" {
  9586. if err := json.Unmarshal(userJSONBytes, &res10265_2); err != nil {
  9587. utils.ErrorLog("解析失败:%v", err)
  9588. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9589. return
  9590. }
  9591. res2.ErrMsg = res10265_2.ErrMsg
  9592. infocode, _ := strconv.ParseInt(res10265_2.Infcode, 10, 64)
  9593. res2.Infcode = infocode
  9594. res2.Output = res10265_2.Output
  9595. res2.InfRefmsgid = res10265_2.InfRefmsgid
  9596. } else {
  9597. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  9598. utils.ErrorLog("解析失败:%v", err)
  9599. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9600. return
  9601. }
  9602. }
  9603. }
  9604. if res2.Infcode == 0 {
  9605. psnResult := &models.GdybPsnNcdsRecord{
  9606. UserOrgId: adminUser.CurrentOrgId,
  9607. PatientId: patient.ID,
  9608. PsnNo: psn_no,
  9609. DoctorId: doctor.AdminUserId,
  9610. DepartmentId: department_id,
  9611. SickType: sick_id,
  9612. Insutype: insutype,
  9613. Ctime: time.Now().Unix(),
  9614. Mtime: time.Now().Unix(),
  9615. Status: 1,
  9616. IsCancel: 1,
  9617. TrtDclaDetlSn: res2.Output.Result.TrtDclaDetlSn,
  9618. }
  9619. service.CreatePsnNCDSRecord(psnResult)
  9620. c.ServeSuccessJSON(map[string]interface{}{
  9621. "failed_code": 0,
  9622. "msg": "备案成功",
  9623. "result": psnResult,
  9624. })
  9625. } else {
  9626. c.ServeSuccessJSON(map[string]interface{}{
  9627. "failed_code": -10,
  9628. "msg": res2.ErrMsg,
  9629. })
  9630. return
  9631. }
  9632. }
  9633. }
  9634. func (c *HisApiController) PsnPutUnNCDSOnRecord() {
  9635. id, _ := c.GetInt64("id")
  9636. admin_user_id, _ := c.GetInt64("admin_user_id")
  9637. adminUser := c.GetAdminUserInfo()
  9638. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  9639. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  9640. //config, _ := service.Ge(adminUser.CurrentOrgId)
  9641. patient, _ := service.GetPatientByID(c.GetAdminUserInfo().CurrentOrgId, id)
  9642. //role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  9643. //var user_name string
  9644. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  9645. //if role.ID == 0 {
  9646. // user_name = "xxx"
  9647. //} else {
  9648. // user_name = role.UserName
  9649. //}
  9650. psn_record, _ := service.GetPsnNCDSRecordById(id)
  9651. if psn_record.ID == 0 {
  9652. c.ServeFailJSONWithSGJErrorCode(enums.ErrorPsnRecordNoExistWrong)
  9653. return
  9654. }
  9655. result, _ := service.Gdyb1101(patient.IdCardNo, miConfig.OrgName, role.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, 2, "", "0", patient.Name)
  9656. var res ResultTwo
  9657. var res10265 ResultTwo10265
  9658. if miConfig.Code == "H15049901371" {
  9659. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  9660. utils.ErrorLog("解析失败:%v", err)
  9661. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9662. return
  9663. }
  9664. res.ErrMsg = res10265.ErrMsg
  9665. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  9666. res.Infcode = infocode
  9667. res.Output = res10265.Output
  9668. res.InfRefmsgid = res10265.InfRefmsgid
  9669. } else {
  9670. if err := json.Unmarshal([]byte(result), &res); err != nil {
  9671. utils.ErrorLog("解析失败:%v", err)
  9672. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9673. return
  9674. }
  9675. }
  9676. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  9677. infoStr := string(Iinfos)
  9678. var rf []*ResultFive
  9679. json.Unmarshal([]byte(infoStr), &rf)
  9680. var insuplc_admdvs string
  9681. var insutype string
  9682. var is390 int = 0
  9683. var is310 int = 0
  9684. var insutypes []*ResultFive
  9685. for _, item := range rf {
  9686. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  9687. insutypes = append(insutypes, item)
  9688. }
  9689. }
  9690. if len(insutypes) == 1 {
  9691. insutype = insutypes[0].Insutype
  9692. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  9693. } else {
  9694. for _, i := range insutypes {
  9695. if i.Insutype == "390" {
  9696. is390 = 1
  9697. }
  9698. if i.Insutype == "310" {
  9699. is310 = 1
  9700. }
  9701. }
  9702. }
  9703. if is390 == 1 {
  9704. insutype = "390"
  9705. }
  9706. if is310 == 1 {
  9707. insutype = "310"
  9708. }
  9709. if len(insutypes) == 0 {
  9710. insutype = "310"
  9711. }
  9712. insutype = psn_record.Insutype
  9713. for _, item := range rf {
  9714. if item.Insutype == insutype {
  9715. insuplc_admdvs = item.InsuplcAdmdvs
  9716. }
  9717. }
  9718. if config.IsOpen == 1 {
  9719. result := service.Gdyb2504(psn_record.PsnNo, miConfig.OrgName, role.UserName, miConfig.Code, insuplc_admdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, psn_record.TrtDclaDetlSn)
  9720. var dat map[string]interface{}
  9721. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  9722. fmt.Println(dat)
  9723. } else {
  9724. fmt.Println(err)
  9725. }
  9726. userJSONBytes, _ := json.Marshal(dat)
  9727. var res ResultFourteen
  9728. var res10265 ResultFourteen10265
  9729. if miConfig.Code == "H15049901371" {
  9730. if err := json.Unmarshal(userJSONBytes, &res10265); err != nil {
  9731. utils.ErrorLog("解析失败:%v", err)
  9732. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9733. return
  9734. }
  9735. res.ErrMsg = res10265.ErrMsg
  9736. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  9737. res.Infcode = infocode
  9738. res.Output = res10265.Output
  9739. res.InfRefmsgid = res10265.InfRefmsgid
  9740. } else {
  9741. if err := json.Unmarshal([]byte(result), &res); err != nil {
  9742. utils.ErrorLog("解析失败:%v", err)
  9743. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9744. return
  9745. }
  9746. }
  9747. //if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  9748. // utils.ErrorLog("解析失败:%v", err)
  9749. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9750. // return
  9751. //}
  9752. if res.Infcode == 0 {
  9753. psn_record.IsCancel = 2
  9754. service.CreatePsnNCDSRecord(&psn_record)
  9755. c.ServeSuccessJSON(map[string]interface{}{
  9756. "failed_code": 0,
  9757. "msg": "撤销备案成功",
  9758. })
  9759. } else {
  9760. c.ServeSuccessJSON(map[string]interface{}{
  9761. "failed_code": -10,
  9762. "msg": res.ErrMsg,
  9763. })
  9764. return
  9765. }
  9766. }
  9767. }
  9768. func (c *HisApiController) TestTest() {
  9769. patient, _ := service.GetHisPatientInfo(4, 456, 1619712000)
  9770. fmt.Println(patient.Iinfo)
  9771. }
  9772. type CustomData struct {
  9773. MsgId string
  9774. PsnNo string
  9775. Info string
  9776. }
  9777. func (c *HisApiController) ReversalData() {
  9778. var customData []*CustomData
  9779. custom := &CustomData{
  9780. MsgId: "H44022900158202103301714472004",
  9781. PsnNo: "44020000001101329945",
  9782. Info: "2207",
  9783. }
  9784. customData = append(customData, custom)
  9785. custom1 := &CustomData{
  9786. MsgId: "H4402290015820210330172057803",
  9787. PsnNo: "44020000001101161813",
  9788. Info: "2207",
  9789. }
  9790. customData = append(customData, custom1)
  9791. custom2 := &CustomData{
  9792. MsgId: "H44022900158202103301705198813",
  9793. PsnNo: "44190000133097375417",
  9794. Info: "2207",
  9795. }
  9796. customData = append(customData, custom2)
  9797. custom3 := &CustomData{
  9798. MsgId: "H44022900158202103301715524756",
  9799. PsnNo: "44020000001100187221",
  9800. Info: "2207",
  9801. }
  9802. customData = append(customData, custom3)
  9803. custom4 := &CustomData{
  9804. MsgId: "H44022900158202103301730376224",
  9805. PsnNo: "44020000001101959155",
  9806. Info: "2207",
  9807. }
  9808. customData = append(customData, custom4)
  9809. custom5 := &CustomData{
  9810. MsgId: "H44022900158202103301748008725",
  9811. PsnNo: "44020000001104246641",
  9812. Info: "2207",
  9813. }
  9814. customData = append(customData, custom5)
  9815. custom6 := &CustomData{
  9816. MsgId: "H44022900158202103301718096755",
  9817. PsnNo: "44020000001102211860",
  9818. Info: "2207",
  9819. }
  9820. customData = append(customData, custom6)
  9821. custom7 := &CustomData{
  9822. MsgId: "H44022900158202103301736551640",
  9823. PsnNo: "44020000001102687718",
  9824. Info: "2207",
  9825. }
  9826. customData = append(customData, custom7)
  9827. custom8 := &CustomData{
  9828. MsgId: "H44022900158202103301743097676",
  9829. PsnNo: "44020000001102127785",
  9830. Info: "2207",
  9831. }
  9832. customData = append(customData, custom8)
  9833. custom9 := &CustomData{
  9834. MsgId: "H44022900158202103301712304203",
  9835. PsnNo: "44020000001101518097",
  9836. Info: "2207",
  9837. }
  9838. customData = append(customData, custom9)
  9839. custom10 := &CustomData{
  9840. MsgId: "H44022900158202103301738448785",
  9841. PsnNo: "44020000001100500813",
  9842. Info: "2207",
  9843. }
  9844. customData = append(customData, custom10)
  9845. custom11 := &CustomData{
  9846. MsgId: "H44022900158202103301732455843",
  9847. PsnNo: "44020000001102690557",
  9848. Info: "2207",
  9849. }
  9850. customData = append(customData, custom11)
  9851. custom12 := &CustomData{
  9852. MsgId: "H44022900158202103301745421708",
  9853. PsnNo: "44020000001102211928",
  9854. Info: "2207",
  9855. }
  9856. customData = append(customData, custom12)
  9857. custom1212 := &CustomData{
  9858. MsgId: "H440229001582021033017351627",
  9859. PsnNo: "44020000001102481733",
  9860. Info: "2207",
  9861. }
  9862. customData = append(customData, custom1212)
  9863. custom13 := &CustomData{
  9864. MsgId: "H44022900158202103301740327951",
  9865. PsnNo: "44020000001103174866",
  9866. Info: "2207",
  9867. }
  9868. customData = append(customData, custom13)
  9869. custom14 := &CustomData{
  9870. MsgId: "H4402290015820210330174922668",
  9871. PsnNo: "44020000001102927272",
  9872. Info: "2207",
  9873. }
  9874. customData = append(customData, custom14)
  9875. custom15 := &CustomData{
  9876. MsgId: "H44022900158202103301752362273",
  9877. PsnNo: "44020000001102942890",
  9878. Info: "2207",
  9879. }
  9880. customData = append(customData, custom15)
  9881. custom16 := &CustomData{
  9882. MsgId: "H44022900158202103301751082917",
  9883. PsnNo: "44020000001101662162",
  9884. Info: "2207",
  9885. }
  9886. customData = append(customData, custom16)
  9887. custom17 := &CustomData{
  9888. MsgId: "H44022900158202103301754147728",
  9889. PsnNo: "44020000000229014511",
  9890. Info: "2207",
  9891. }
  9892. customData = append(customData, custom17)
  9893. adminUser := c.GetAdminUserInfo()
  9894. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  9895. for _, item := range customData {
  9896. result := service.Gdyb2601(item.PsnNo, item.MsgId, item.Info, miConfig.OrgName, "张俊杰", miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey)
  9897. fmt.Println(result)
  9898. }
  9899. }
  9900. func (c *HisApiController) GetAllopatry() {
  9901. year := c.GetString("year")
  9902. month := c.GetString("month")
  9903. admin_user_id, _ := c.GetInt64("admin_user_id")
  9904. adminUser := c.GetAdminUserInfo()
  9905. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  9906. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  9907. result, _ := service.Gdyb9001(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, 1669)
  9908. var dat map[string]interface{}
  9909. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  9910. fmt.Println(dat)
  9911. } else {
  9912. fmt.Println(err)
  9913. }
  9914. userJSONBytes, _ := json.Marshal(dat)
  9915. var res models.Result9001
  9916. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  9917. utils.ErrorLog("解析失败:%v", err)
  9918. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9919. return
  9920. }
  9921. result2, _ := service.Gdyb3260(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, year, month, res.Output.Signinoutb.SignNo)
  9922. var dat2 map[string]interface{}
  9923. if err := json.Unmarshal([]byte(result2), &dat2); err == nil {
  9924. fmt.Println(dat)
  9925. } else {
  9926. fmt.Println(err)
  9927. }
  9928. userJSONBytes2, _ := json.Marshal(dat2)
  9929. var res2 models.Result3260
  9930. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  9931. utils.ErrorLog("解析失败:%v", err)
  9932. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9933. return
  9934. }
  9935. if res2.Infcode == 0 {
  9936. c.ServeSuccessJSON(map[string]interface{}{
  9937. "list": res2.Output.Data,
  9938. })
  9939. return
  9940. } else {
  9941. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9942. return
  9943. }
  9944. }
  9945. func (c *HisApiController) ComfirmAllopatry() {
  9946. year := c.GetString("year")
  9947. month := c.GetString("month")
  9948. admin_user_id, _ := c.GetInt64("admin_user_id")
  9949. adminUser := c.GetAdminUserInfo()
  9950. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  9951. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  9952. result, _ := service.Gdyb9001(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, 1669)
  9953. var dat map[string]interface{}
  9954. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  9955. fmt.Println(dat)
  9956. } else {
  9957. fmt.Println(err)
  9958. }
  9959. userJSONBytes, _ := json.Marshal(dat)
  9960. var res models.Result9001
  9961. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  9962. utils.ErrorLog("解析失败:%v", err)
  9963. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9964. return
  9965. }
  9966. result2, _ := service.Gdyb3260(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, year, month, res.Output.Signinoutb.SignNo)
  9967. var dat2 map[string]interface{}
  9968. if err := json.Unmarshal([]byte(result2), &dat2); err == nil {
  9969. fmt.Println(dat)
  9970. } else {
  9971. fmt.Println(err)
  9972. }
  9973. userJSONBytes2, _ := json.Marshal(dat2)
  9974. var res2 models.Result3260
  9975. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  9976. utils.ErrorLog("解析失败:%v", err)
  9977. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9978. return
  9979. }
  9980. if res2.Infcode == 0 {
  9981. result, _, msgId := service.Gdyb3261(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, year, month, res2)
  9982. var dat map[string]interface{}
  9983. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  9984. fmt.Println(dat)
  9985. } else {
  9986. fmt.Println(err)
  9987. }
  9988. userJSONBytes, _ := json.Marshal(dat)
  9989. var res3 models.Result3261
  9990. if err := json.Unmarshal(userJSONBytes, &res3); err != nil {
  9991. utils.ErrorLog("解析失败:%v", err)
  9992. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9993. return
  9994. }
  9995. if res3.Infcode == 0 {
  9996. record := &models.HisYidiClearRecord{
  9997. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  9998. Ctime: time.Now().Unix(),
  9999. Mtime: time.Now().Unix(),
  10000. Status: 1,
  10001. MsgId: msgId,
  10002. }
  10003. service.SaveClearRecord(record)
  10004. c.ServeSuccessJSON(map[string]interface{}{
  10005. "msg": "提取成功",
  10006. })
  10007. }
  10008. }
  10009. }
  10010. func (c *HisApiController) RefundAllopatry() {
  10011. year := c.GetString("year")
  10012. month := c.GetString("month")
  10013. id, _ := c.GetInt64("id")
  10014. admin_user_id, _ := c.GetInt64("admin_user_id")
  10015. adminUser := c.GetAdminUserInfo()
  10016. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  10017. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  10018. record, _ := service.GetClearRecordById(id)
  10019. result, _ := service.Gdyb3262(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, year, month, record.MsgId)
  10020. var dat map[string]interface{}
  10021. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  10022. fmt.Println(dat)
  10023. } else {
  10024. fmt.Println(err)
  10025. }
  10026. userJSONBytes, _ := json.Marshal(dat)
  10027. var empty ResultFourteen
  10028. if err := json.Unmarshal(userJSONBytes, &empty); err != nil {
  10029. utils.ErrorLog("解析失败:%v", err)
  10030. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10031. return
  10032. }
  10033. if empty.Infcode == 0 {
  10034. c.ServeSuccessJSON(map[string]interface{}{
  10035. "msg": "撤销成功",
  10036. })
  10037. return
  10038. }
  10039. }
  10040. func (c *HisApiController) ReversalOtherData() {
  10041. var customData []*CustomData
  10042. custom := &CustomData{
  10043. MsgId: "H44022900158202103301714472004",
  10044. PsnNo: "44020000001101329945",
  10045. Info: "2208",
  10046. }
  10047. customData = append(customData, custom)
  10048. custom1 := &CustomData{
  10049. MsgId: "H4402290015820210330172057803",
  10050. PsnNo: "44020000001101161813",
  10051. Info: "2208",
  10052. }
  10053. customData = append(customData, custom1)
  10054. custom2 := &CustomData{
  10055. MsgId: "H44022900158202103301705198813",
  10056. PsnNo: "44190000133097375417",
  10057. Info: "2208",
  10058. }
  10059. customData = append(customData, custom2)
  10060. custom3 := &CustomData{
  10061. MsgId: "H44022900158202103301715524756",
  10062. PsnNo: "44020000001100187221",
  10063. Info: "2208",
  10064. }
  10065. customData = append(customData, custom3)
  10066. custom4 := &CustomData{
  10067. MsgId: "H44022900158202103301730376224",
  10068. PsnNo: "44020000001101959155",
  10069. Info: "2208",
  10070. }
  10071. customData = append(customData, custom4)
  10072. custom5 := &CustomData{
  10073. MsgId: "H44022900158202103301748008725",
  10074. PsnNo: "44020000001104246641",
  10075. Info: "2208",
  10076. }
  10077. customData = append(customData, custom5)
  10078. custom6 := &CustomData{
  10079. MsgId: "H44022900158202103301718096755",
  10080. PsnNo: "44020000001102211860",
  10081. Info: "2208",
  10082. }
  10083. customData = append(customData, custom6)
  10084. custom7 := &CustomData{
  10085. MsgId: "H44022900158202103301736551640",
  10086. PsnNo: "44020000001102687718",
  10087. Info: "2208",
  10088. }
  10089. customData = append(customData, custom7)
  10090. custom8 := &CustomData{
  10091. MsgId: "H44022900158202103301743097676",
  10092. PsnNo: "44020000001102127785",
  10093. Info: "2208",
  10094. }
  10095. customData = append(customData, custom8)
  10096. custom9 := &CustomData{
  10097. MsgId: "H44022900158202103301712304203",
  10098. PsnNo: "44020000001101518097",
  10099. Info: "2208",
  10100. }
  10101. customData = append(customData, custom9)
  10102. custom10 := &CustomData{
  10103. MsgId: "H44022900158202103301738448785",
  10104. PsnNo: "44020000001100500813",
  10105. Info: "2208",
  10106. }
  10107. customData = append(customData, custom10)
  10108. custom11 := &CustomData{
  10109. MsgId: "H44022900158202103301732455843",
  10110. PsnNo: "44020000001102690557",
  10111. Info: "2208",
  10112. }
  10113. customData = append(customData, custom11)
  10114. custom12 := &CustomData{
  10115. MsgId: "H44022900158202103301745421708",
  10116. PsnNo: "44020000001102211928",
  10117. Info: "2208",
  10118. }
  10119. customData = append(customData, custom12)
  10120. custom1212 := &CustomData{
  10121. MsgId: "H440229001582021033017351627",
  10122. PsnNo: "44020000001102481733",
  10123. Info: "2208",
  10124. }
  10125. customData = append(customData, custom1212)
  10126. custom13 := &CustomData{
  10127. MsgId: "H44022900158202103301740327951",
  10128. PsnNo: "44020000001103174866",
  10129. Info: "2208",
  10130. }
  10131. customData = append(customData, custom13)
  10132. custom14 := &CustomData{
  10133. MsgId: "H4402290015820210330174922668",
  10134. PsnNo: "44020000001102927272",
  10135. Info: "2208",
  10136. }
  10137. customData = append(customData, custom14)
  10138. custom15 := &CustomData{
  10139. MsgId: "H44022900158202103301752362273",
  10140. PsnNo: "44020000001102942890",
  10141. Info: "2208",
  10142. }
  10143. customData = append(customData, custom15)
  10144. custom16 := &CustomData{
  10145. MsgId: "H44022900158202103301751082917",
  10146. PsnNo: "44020000001101662162",
  10147. Info: "2208",
  10148. }
  10149. customData = append(customData, custom16)
  10150. custom17 := &CustomData{
  10151. MsgId: "H44022900158202103301754147728",
  10152. PsnNo: "44020000000229014511",
  10153. Info: "2208",
  10154. }
  10155. customData = append(customData, custom17)
  10156. adminUser := c.GetAdminUserInfo()
  10157. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  10158. for _, item := range customData {
  10159. result := service.Gdyb2601(item.PsnNo, item.MsgId, item.Info, miConfig.OrgName, "张俊杰", miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey)
  10160. fmt.Println(result)
  10161. }
  10162. }
  10163. func PathExists(path string) (bool, error) {
  10164. _, err := os.Stat(path)
  10165. if err == nil {
  10166. return true, nil
  10167. }
  10168. if os.IsNotExist(err) {
  10169. return false, nil
  10170. }
  10171. return false, err
  10172. }
  10173. //创建文件夹
  10174. func Mkdir(dir string) {
  10175. // 创建文件夹
  10176. exist, err := PathExists(dir)
  10177. if err != nil {
  10178. fmt.Println(err.Error())
  10179. } else {
  10180. if exist {
  10181. fmt.Println(dir + "文件夹已存在!")
  10182. } else {
  10183. // 文件夹名称,权限
  10184. err := os.Mkdir(dir, os.ModePerm)
  10185. if err != nil {
  10186. fmt.Println(dir+"文件夹创建失败:", err.Error())
  10187. } else {
  10188. fmt.Println(dir + "文件夹创建成功!")
  10189. }
  10190. }
  10191. }
  10192. }
  10193. //压缩文件
  10194. func Zip(srcFile string, destZip string) error {
  10195. zipfile, err := os.Create(destZip)
  10196. if err != nil {
  10197. return err
  10198. }
  10199. defer zipfile.Close()
  10200. archive := zip.NewWriter(zipfile)
  10201. defer archive.Close()
  10202. filepath.Walk(srcFile, func(path string, info os.FileInfo, err error) error {
  10203. if err != nil {
  10204. return err
  10205. }
  10206. header, err := zip.FileInfoHeader(info)
  10207. if err != nil {
  10208. return err
  10209. }
  10210. header.Name = strings.TrimPrefix(path, filepath.Dir(srcFile)+"/")
  10211. // header.Name = path
  10212. if info.IsDir() {
  10213. header.Name += "/"
  10214. } else {
  10215. header.Method = zip.Deflate
  10216. }
  10217. writer, err := archive.CreateHeader(header)
  10218. if err != nil {
  10219. return err
  10220. }
  10221. if !info.IsDir() {
  10222. file, err := os.Open(path)
  10223. if err != nil {
  10224. return err
  10225. }
  10226. defer file.Close()
  10227. _, err = io.Copy(writer, file)
  10228. }
  10229. return err
  10230. })
  10231. return err
  10232. }
  10233. func ReadFile(filePath string) []byte {
  10234. f, err := os.Open(filePath)
  10235. if err != nil {
  10236. fmt.Println("read file fail", err)
  10237. return nil
  10238. }
  10239. defer f.Close()
  10240. fd, err := ioutil.ReadAll(f)
  10241. if err != nil {
  10242. fmt.Println("read to fd fail", err)
  10243. return nil
  10244. }
  10245. return fd
  10246. }
  10247. func saveLog(result string, request string, infno string, desc string) {
  10248. org_id, _ := beego.AppConfig.Int64("org_id")
  10249. miConfig, _ := service.FindMedicalInsuranceInfo(org_id)
  10250. dir := miConfig.OrgName + "日志"
  10251. utils.Mkdir(dir)
  10252. month := time.Unix(1557042972, 0).Format("1")
  10253. year := time.Now().Format("2006")
  10254. month = time.Now().Format("01")
  10255. day := time.Now().Format("02")
  10256. hour := time.Now().Format("15")
  10257. min := time.Now().Format("04")
  10258. sec := time.Now().Format("05")
  10259. result_time := year + "-" + month + "-" + day + " " + hour + ":" + min + ":" + sec
  10260. file := strconv.FormatInt(org_id, 10) + "_" + year + month + day + "_log"
  10261. file_name := file + ".txt"
  10262. file_path := miConfig.OrgName + "日志" + "/" + file_name
  10263. exist, _ := utils.PathExists(file_path)
  10264. if exist { //存在
  10265. fmt.Println("存在")
  10266. f, err := os.OpenFile(file_path, os.O_WRONLY, 0644)
  10267. if err != nil {
  10268. fmt.Println("read fail")
  10269. }
  10270. content := "\r\n" + "\r\n" + "\r\n" + result_time + " " + "【 " + desc + infno + "入参" + " 】:" + "\r\n" + request + "\r\n" + result_time + " " + "【 " + desc + infno + "出参" + " 】:" + "\r\n" + result
  10271. n, _ := f.Seek(0, 2)
  10272. _, err = f.WriteAt([]byte(content), n)
  10273. } else { //不存在
  10274. fmt.Println("文件不存在,创建文件")
  10275. f, err := os.Create(miConfig.OrgName + "日志" + "/" + file_name)
  10276. defer f.Close()
  10277. if err != nil {
  10278. } else {
  10279. _, err = f.Write([]byte("记录日志"))
  10280. }
  10281. }
  10282. }
  10283. type Charset string
  10284. const (
  10285. UTF8 = Charset("UTF-8")
  10286. GB18030 = Charset("GB18030")
  10287. )
  10288. func ConvertToString(src string, srcCode string, tagCode string) string {
  10289. srcCoder := mahonia.NewDecoder(srcCode)
  10290. srcResult := srcCoder.ConvertString(src)
  10291. tagCoder := mahonia.NewDecoder(tagCode)
  10292. _, cdata, _ := tagCoder.Translate([]byte(srcResult), true)
  10293. result := string(cdata)
  10294. return result
  10295. }