his_api_controller.go 454KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504250525062507250825092510251125122513251425152516251725182519252025212522252325242525252625272528252925302531253225332534253525362537253825392540254125422543254425452546254725482549255025512552255325542555255625572558255925602561256225632564256525662567256825692570257125722573257425752576257725782579258025812582258325842585258625872588258925902591259225932594259525962597259825992600260126022603260426052606260726082609261026112612261326142615261626172618261926202621262226232624262526262627262826292630263126322633263426352636263726382639264026412642264326442645264626472648264926502651265226532654265526562657265826592660266126622663266426652666266726682669267026712672267326742675267626772678267926802681268226832684268526862687268826892690269126922693269426952696269726982699270027012702270327042705270627072708270927102711271227132714271527162717271827192720272127222723272427252726272727282729273027312732273327342735273627372738273927402741274227432744274527462747274827492750275127522753275427552756275727582759276027612762276327642765276627672768276927702771277227732774277527762777277827792780278127822783278427852786278727882789279027912792279327942795279627972798279928002801280228032804280528062807280828092810281128122813281428152816281728182819282028212822282328242825282628272828282928302831283228332834283528362837283828392840284128422843284428452846284728482849285028512852285328542855285628572858285928602861286228632864286528662867286828692870287128722873287428752876287728782879288028812882288328842885288628872888288928902891289228932894289528962897289828992900290129022903290429052906290729082909291029112912291329142915291629172918291929202921292229232924292529262927292829292930293129322933293429352936293729382939294029412942294329442945294629472948294929502951295229532954295529562957295829592960296129622963296429652966296729682969297029712972297329742975297629772978297929802981298229832984298529862987298829892990299129922993299429952996299729982999300030013002300330043005300630073008300930103011301230133014301530163017301830193020302130223023302430253026302730283029303030313032303330343035303630373038303930403041304230433044304530463047304830493050305130523053305430553056305730583059306030613062306330643065306630673068306930703071307230733074307530763077307830793080308130823083308430853086308730883089309030913092309330943095309630973098309931003101310231033104310531063107310831093110311131123113311431153116311731183119312031213122312331243125312631273128312931303131313231333134313531363137313831393140314131423143314431453146314731483149315031513152315331543155315631573158315931603161316231633164316531663167316831693170317131723173317431753176317731783179318031813182318331843185318631873188318931903191319231933194319531963197319831993200320132023203320432053206320732083209321032113212321332143215321632173218321932203221322232233224322532263227322832293230323132323233323432353236323732383239324032413242324332443245324632473248324932503251325232533254325532563257325832593260326132623263326432653266326732683269327032713272327332743275327632773278327932803281328232833284328532863287328832893290329132923293329432953296329732983299330033013302330333043305330633073308330933103311331233133314331533163317331833193320332133223323332433253326332733283329333033313332333333343335333633373338333933403341334233433344334533463347334833493350335133523353335433553356335733583359336033613362336333643365336633673368336933703371337233733374337533763377337833793380338133823383338433853386338733883389339033913392339333943395339633973398339934003401340234033404340534063407340834093410341134123413341434153416341734183419342034213422342334243425342634273428342934303431343234333434343534363437343834393440344134423443344434453446344734483449345034513452345334543455345634573458345934603461346234633464346534663467346834693470347134723473347434753476347734783479348034813482348334843485348634873488348934903491349234933494349534963497349834993500350135023503350435053506350735083509351035113512351335143515351635173518351935203521352235233524352535263527352835293530353135323533353435353536353735383539354035413542354335443545354635473548354935503551355235533554355535563557355835593560356135623563356435653566356735683569357035713572357335743575357635773578357935803581358235833584358535863587358835893590359135923593359435953596359735983599360036013602360336043605360636073608360936103611361236133614361536163617361836193620362136223623362436253626362736283629363036313632363336343635363636373638363936403641364236433644364536463647364836493650365136523653365436553656365736583659366036613662366336643665366636673668366936703671367236733674367536763677367836793680368136823683368436853686368736883689369036913692369336943695369636973698369937003701370237033704370537063707370837093710371137123713371437153716371737183719372037213722372337243725372637273728372937303731373237333734373537363737373837393740374137423743374437453746374737483749375037513752375337543755375637573758375937603761376237633764376537663767376837693770377137723773377437753776377737783779378037813782378337843785378637873788378937903791379237933794379537963797379837993800380138023803380438053806380738083809381038113812381338143815381638173818381938203821382238233824382538263827382838293830383138323833383438353836383738383839384038413842384338443845384638473848384938503851385238533854385538563857385838593860386138623863386438653866386738683869387038713872387338743875387638773878387938803881388238833884388538863887388838893890389138923893389438953896389738983899390039013902390339043905390639073908390939103911391239133914391539163917391839193920392139223923392439253926392739283929393039313932393339343935393639373938393939403941394239433944394539463947394839493950395139523953395439553956395739583959396039613962396339643965396639673968396939703971397239733974397539763977397839793980398139823983398439853986398739883989399039913992399339943995399639973998399940004001400240034004400540064007400840094010401140124013401440154016401740184019402040214022402340244025402640274028402940304031403240334034403540364037403840394040404140424043404440454046404740484049405040514052405340544055405640574058405940604061406240634064406540664067406840694070407140724073407440754076407740784079408040814082408340844085408640874088408940904091409240934094409540964097409840994100410141024103410441054106410741084109411041114112411341144115411641174118411941204121412241234124412541264127412841294130413141324133413441354136413741384139414041414142414341444145414641474148414941504151415241534154415541564157415841594160416141624163416441654166416741684169417041714172417341744175417641774178417941804181418241834184418541864187418841894190419141924193419441954196419741984199420042014202420342044205420642074208420942104211421242134214421542164217421842194220422142224223422442254226422742284229423042314232423342344235423642374238423942404241424242434244424542464247424842494250425142524253425442554256425742584259426042614262426342644265426642674268426942704271427242734274427542764277427842794280428142824283428442854286428742884289429042914292429342944295429642974298429943004301430243034304430543064307430843094310431143124313431443154316431743184319432043214322432343244325432643274328432943304331433243334334433543364337433843394340434143424343434443454346434743484349435043514352435343544355435643574358435943604361436243634364436543664367436843694370437143724373437443754376437743784379438043814382438343844385438643874388438943904391439243934394439543964397439843994400440144024403440444054406440744084409441044114412441344144415441644174418441944204421442244234424442544264427442844294430443144324433443444354436443744384439444044414442444344444445444644474448444944504451445244534454445544564457445844594460446144624463446444654466446744684469447044714472447344744475447644774478447944804481448244834484448544864487448844894490449144924493449444954496449744984499450045014502450345044505450645074508450945104511451245134514451545164517451845194520452145224523452445254526452745284529453045314532453345344535453645374538453945404541454245434544454545464547454845494550455145524553455445554556455745584559456045614562456345644565456645674568456945704571457245734574457545764577457845794580458145824583458445854586458745884589459045914592459345944595459645974598459946004601460246034604460546064607460846094610461146124613461446154616461746184619462046214622462346244625462646274628462946304631463246334634463546364637463846394640464146424643464446454646464746484649465046514652465346544655465646574658465946604661466246634664466546664667466846694670467146724673467446754676467746784679468046814682468346844685468646874688468946904691469246934694469546964697469846994700470147024703470447054706470747084709471047114712471347144715471647174718471947204721472247234724472547264727472847294730473147324733473447354736473747384739474047414742474347444745474647474748474947504751475247534754475547564757475847594760476147624763476447654766476747684769477047714772477347744775477647774778477947804781478247834784478547864787478847894790479147924793479447954796479747984799480048014802480348044805480648074808480948104811481248134814481548164817481848194820482148224823482448254826482748284829483048314832483348344835483648374838483948404841484248434844484548464847484848494850485148524853485448554856485748584859486048614862486348644865486648674868486948704871487248734874487548764877487848794880488148824883488448854886488748884889489048914892489348944895489648974898489949004901490249034904490549064907490849094910491149124913491449154916491749184919492049214922492349244925492649274928492949304931493249334934493549364937493849394940494149424943494449454946494749484949495049514952495349544955495649574958495949604961496249634964496549664967496849694970497149724973497449754976497749784979498049814982498349844985498649874988498949904991499249934994499549964997499849995000500150025003500450055006500750085009501050115012501350145015501650175018501950205021502250235024502550265027502850295030503150325033503450355036503750385039504050415042504350445045504650475048504950505051505250535054505550565057505850595060506150625063506450655066506750685069507050715072507350745075507650775078507950805081508250835084508550865087508850895090509150925093509450955096509750985099510051015102510351045105510651075108510951105111511251135114511551165117511851195120512151225123512451255126512751285129513051315132513351345135513651375138513951405141514251435144514551465147514851495150515151525153515451555156515751585159516051615162516351645165516651675168516951705171517251735174517551765177517851795180518151825183518451855186518751885189519051915192519351945195519651975198519952005201520252035204520552065207520852095210521152125213521452155216521752185219522052215222522352245225522652275228522952305231523252335234523552365237523852395240524152425243524452455246524752485249525052515252525352545255525652575258525952605261526252635264526552665267526852695270527152725273527452755276527752785279528052815282528352845285528652875288528952905291529252935294529552965297529852995300530153025303530453055306530753085309531053115312531353145315531653175318531953205321532253235324532553265327532853295330533153325333533453355336533753385339534053415342534353445345534653475348534953505351535253535354535553565357535853595360536153625363536453655366536753685369537053715372537353745375537653775378537953805381538253835384538553865387538853895390539153925393539453955396539753985399540054015402540354045405540654075408540954105411541254135414541554165417541854195420542154225423542454255426542754285429543054315432543354345435543654375438543954405441544254435444544554465447544854495450545154525453545454555456545754585459546054615462546354645465546654675468546954705471547254735474547554765477547854795480548154825483548454855486548754885489549054915492549354945495549654975498549955005501550255035504550555065507550855095510551155125513551455155516551755185519552055215522552355245525552655275528552955305531553255335534553555365537553855395540554155425543554455455546554755485549555055515552555355545555555655575558555955605561556255635564556555665567556855695570557155725573557455755576557755785579558055815582558355845585558655875588558955905591559255935594559555965597559855995600560156025603560456055606560756085609561056115612561356145615561656175618561956205621562256235624562556265627562856295630563156325633563456355636563756385639564056415642564356445645564656475648564956505651565256535654565556565657565856595660566156625663566456655666566756685669567056715672567356745675567656775678567956805681568256835684568556865687568856895690569156925693569456955696569756985699570057015702570357045705570657075708570957105711571257135714571557165717571857195720572157225723572457255726572757285729573057315732573357345735573657375738573957405741574257435744574557465747574857495750575157525753575457555756575757585759576057615762576357645765576657675768576957705771577257735774577557765777577857795780578157825783578457855786578757885789579057915792579357945795579657975798579958005801580258035804580558065807580858095810581158125813581458155816581758185819582058215822582358245825582658275828582958305831583258335834583558365837583858395840584158425843584458455846584758485849585058515852585358545855585658575858585958605861586258635864586558665867586858695870587158725873587458755876587758785879588058815882588358845885588658875888588958905891589258935894589558965897589858995900590159025903590459055906590759085909591059115912591359145915591659175918591959205921592259235924592559265927592859295930593159325933593459355936593759385939594059415942594359445945594659475948594959505951595259535954595559565957595859595960596159625963596459655966596759685969597059715972597359745975597659775978597959805981598259835984598559865987598859895990599159925993599459955996599759985999600060016002600360046005600660076008600960106011601260136014601560166017601860196020602160226023602460256026602760286029603060316032603360346035603660376038603960406041604260436044604560466047604860496050605160526053605460556056605760586059606060616062606360646065606660676068606960706071607260736074607560766077607860796080608160826083608460856086608760886089609060916092609360946095609660976098609961006101610261036104610561066107610861096110611161126113611461156116611761186119612061216122612361246125612661276128612961306131613261336134613561366137613861396140614161426143614461456146614761486149615061516152615361546155615661576158615961606161616261636164616561666167616861696170617161726173617461756176617761786179618061816182618361846185618661876188618961906191619261936194619561966197619861996200620162026203620462056206620762086209621062116212621362146215621662176218621962206221622262236224622562266227622862296230623162326233623462356236623762386239624062416242624362446245624662476248624962506251625262536254625562566257625862596260626162626263626462656266626762686269627062716272627362746275627662776278627962806281628262836284628562866287628862896290629162926293629462956296629762986299630063016302630363046305630663076308630963106311631263136314631563166317631863196320632163226323632463256326632763286329633063316332633363346335633663376338633963406341634263436344634563466347634863496350635163526353635463556356635763586359636063616362636363646365636663676368636963706371637263736374637563766377637863796380638163826383638463856386638763886389639063916392639363946395639663976398639964006401640264036404640564066407640864096410641164126413641464156416641764186419642064216422642364246425642664276428642964306431643264336434643564366437643864396440644164426443644464456446644764486449645064516452645364546455645664576458645964606461646264636464646564666467646864696470647164726473647464756476647764786479648064816482648364846485648664876488648964906491649264936494649564966497649864996500650165026503650465056506650765086509651065116512651365146515651665176518651965206521652265236524652565266527652865296530653165326533653465356536653765386539654065416542654365446545654665476548654965506551655265536554655565566557655865596560656165626563656465656566656765686569657065716572657365746575657665776578657965806581658265836584658565866587658865896590659165926593659465956596659765986599660066016602660366046605660666076608660966106611661266136614661566166617661866196620662166226623662466256626662766286629663066316632663366346635663666376638663966406641664266436644664566466647664866496650665166526653665466556656665766586659666066616662666366646665666666676668666966706671667266736674667566766677667866796680668166826683668466856686668766886689669066916692669366946695669666976698669967006701670267036704670567066707670867096710671167126713671467156716671767186719672067216722672367246725672667276728672967306731673267336734673567366737673867396740674167426743674467456746674767486749675067516752675367546755675667576758675967606761676267636764676567666767676867696770677167726773677467756776677767786779678067816782678367846785678667876788678967906791679267936794679567966797679867996800680168026803680468056806680768086809681068116812681368146815681668176818681968206821682268236824682568266827682868296830683168326833683468356836683768386839684068416842684368446845684668476848684968506851685268536854685568566857685868596860686168626863686468656866686768686869687068716872687368746875687668776878687968806881688268836884688568866887688868896890689168926893689468956896689768986899690069016902690369046905690669076908690969106911691269136914691569166917691869196920692169226923692469256926692769286929693069316932693369346935693669376938693969406941694269436944694569466947694869496950695169526953695469556956695769586959696069616962696369646965696669676968696969706971697269736974697569766977697869796980698169826983698469856986698769886989699069916992699369946995699669976998699970007001700270037004700570067007700870097010701170127013701470157016701770187019702070217022702370247025702670277028702970307031703270337034703570367037703870397040704170427043704470457046704770487049705070517052705370547055705670577058705970607061706270637064706570667067706870697070707170727073707470757076707770787079708070817082708370847085708670877088708970907091709270937094709570967097709870997100710171027103710471057106710771087109711071117112711371147115711671177118711971207121712271237124712571267127712871297130713171327133713471357136713771387139714071417142714371447145714671477148714971507151715271537154715571567157715871597160716171627163716471657166716771687169717071717172717371747175717671777178717971807181718271837184718571867187718871897190719171927193719471957196719771987199720072017202720372047205720672077208720972107211721272137214721572167217721872197220722172227223722472257226722772287229723072317232723372347235723672377238723972407241724272437244724572467247724872497250725172527253725472557256725772587259726072617262726372647265726672677268726972707271727272737274727572767277727872797280728172827283728472857286728772887289729072917292729372947295729672977298729973007301730273037304730573067307730873097310731173127313731473157316731773187319732073217322732373247325732673277328732973307331733273337334733573367337733873397340734173427343734473457346734773487349735073517352735373547355735673577358735973607361736273637364736573667367736873697370737173727373737473757376737773787379738073817382738373847385738673877388738973907391739273937394739573967397739873997400740174027403740474057406740774087409741074117412741374147415741674177418741974207421742274237424742574267427742874297430743174327433743474357436743774387439744074417442744374447445744674477448744974507451745274537454745574567457745874597460746174627463746474657466746774687469747074717472747374747475747674777478747974807481748274837484748574867487748874897490749174927493749474957496749774987499750075017502750375047505750675077508750975107511751275137514751575167517751875197520752175227523752475257526752775287529753075317532753375347535753675377538753975407541754275437544754575467547754875497550755175527553755475557556755775587559756075617562756375647565756675677568756975707571757275737574757575767577757875797580758175827583758475857586758775887589759075917592759375947595759675977598759976007601760276037604760576067607760876097610761176127613761476157616761776187619762076217622762376247625762676277628762976307631763276337634763576367637763876397640764176427643764476457646764776487649765076517652765376547655765676577658765976607661766276637664766576667667766876697670767176727673767476757676767776787679768076817682768376847685768676877688768976907691769276937694769576967697769876997700770177027703770477057706770777087709771077117712771377147715771677177718771977207721772277237724772577267727772877297730773177327733773477357736773777387739774077417742774377447745774677477748774977507751775277537754775577567757775877597760776177627763776477657766776777687769777077717772777377747775777677777778777977807781778277837784778577867787778877897790779177927793779477957796779777987799780078017802780378047805780678077808780978107811781278137814781578167817781878197820782178227823782478257826782778287829783078317832783378347835783678377838783978407841784278437844784578467847784878497850785178527853785478557856785778587859786078617862786378647865786678677868786978707871787278737874787578767877787878797880788178827883788478857886788778887889789078917892789378947895789678977898789979007901790279037904790579067907790879097910791179127913791479157916791779187919792079217922792379247925792679277928792979307931793279337934793579367937793879397940794179427943794479457946794779487949795079517952795379547955795679577958795979607961796279637964796579667967796879697970797179727973797479757976797779787979798079817982798379847985798679877988798979907991799279937994799579967997799879998000800180028003800480058006800780088009801080118012801380148015801680178018801980208021802280238024802580268027802880298030803180328033803480358036803780388039804080418042804380448045804680478048804980508051805280538054805580568057805880598060806180628063806480658066806780688069807080718072807380748075807680778078807980808081808280838084808580868087808880898090809180928093809480958096809780988099810081018102810381048105810681078108810981108111811281138114811581168117811881198120812181228123812481258126812781288129813081318132813381348135813681378138813981408141814281438144814581468147814881498150815181528153815481558156815781588159816081618162816381648165816681678168816981708171817281738174817581768177817881798180818181828183818481858186818781888189819081918192819381948195819681978198819982008201820282038204820582068207820882098210821182128213821482158216821782188219822082218222822382248225822682278228822982308231823282338234823582368237823882398240824182428243824482458246824782488249825082518252825382548255825682578258825982608261826282638264826582668267826882698270827182728273827482758276827782788279828082818282828382848285828682878288828982908291829282938294829582968297829882998300830183028303830483058306830783088309831083118312831383148315831683178318831983208321832283238324832583268327832883298330833183328333833483358336833783388339834083418342834383448345834683478348834983508351835283538354835583568357835883598360836183628363836483658366836783688369837083718372837383748375837683778378837983808381838283838384838583868387838883898390839183928393839483958396839783988399840084018402840384048405840684078408840984108411841284138414841584168417841884198420842184228423842484258426842784288429843084318432843384348435843684378438843984408441844284438444844584468447844884498450845184528453845484558456845784588459846084618462846384648465846684678468846984708471847284738474847584768477847884798480848184828483848484858486848784888489849084918492849384948495849684978498849985008501850285038504850585068507850885098510851185128513851485158516851785188519852085218522852385248525852685278528852985308531853285338534853585368537853885398540854185428543854485458546854785488549855085518552855385548555855685578558855985608561856285638564856585668567856885698570857185728573857485758576857785788579858085818582858385848585858685878588858985908591859285938594859585968597859885998600860186028603860486058606860786088609861086118612861386148615861686178618861986208621862286238624862586268627862886298630863186328633863486358636863786388639864086418642864386448645864686478648864986508651865286538654865586568657865886598660866186628663866486658666866786688669867086718672867386748675867686778678867986808681868286838684868586868687868886898690869186928693869486958696869786988699870087018702870387048705870687078708870987108711871287138714871587168717871887198720872187228723872487258726872787288729873087318732873387348735873687378738873987408741874287438744874587468747874887498750875187528753875487558756875787588759876087618762876387648765876687678768876987708771877287738774877587768777877887798780878187828783878487858786878787888789879087918792879387948795879687978798879988008801880288038804880588068807880888098810881188128813881488158816881788188819882088218822882388248825882688278828882988308831883288338834883588368837883888398840884188428843884488458846884788488849885088518852885388548855885688578858885988608861886288638864886588668867886888698870887188728873887488758876887788788879888088818882888388848885888688878888888988908891889288938894889588968897889888998900890189028903890489058906890789088909891089118912891389148915891689178918891989208921892289238924892589268927892889298930893189328933893489358936893789388939894089418942894389448945894689478948894989508951895289538954895589568957895889598960896189628963896489658966896789688969897089718972897389748975897689778978897989808981898289838984898589868987898889898990899189928993899489958996899789988999900090019002900390049005900690079008900990109011901290139014901590169017901890199020902190229023902490259026902790289029903090319032903390349035903690379038903990409041904290439044904590469047904890499050905190529053905490559056905790589059906090619062906390649065906690679068906990709071907290739074907590769077907890799080908190829083908490859086908790889089909090919092909390949095909690979098909991009101910291039104910591069107910891099110911191129113911491159116911791189119912091219122912391249125912691279128912991309131913291339134913591369137913891399140914191429143914491459146914791489149915091519152915391549155915691579158915991609161916291639164916591669167916891699170917191729173917491759176917791789179918091819182918391849185918691879188918991909191919291939194919591969197919891999200920192029203920492059206920792089209921092119212921392149215921692179218921992209221922292239224922592269227922892299230923192329233923492359236923792389239924092419242924392449245924692479248924992509251925292539254925592569257925892599260926192629263926492659266926792689269927092719272927392749275927692779278927992809281928292839284928592869287928892899290929192929293929492959296929792989299930093019302930393049305930693079308930993109311931293139314931593169317931893199320932193229323932493259326932793289329933093319332933393349335933693379338933993409341934293439344934593469347934893499350935193529353935493559356935793589359936093619362936393649365936693679368936993709371937293739374937593769377937893799380938193829383938493859386938793889389939093919392939393949395939693979398939994009401940294039404940594069407940894099410941194129413941494159416941794189419942094219422942394249425942694279428942994309431943294339434943594369437943894399440944194429443944494459446944794489449945094519452945394549455945694579458945994609461946294639464946594669467946894699470947194729473947494759476947794789479948094819482948394849485948694879488948994909491949294939494949594969497949894999500950195029503950495059506950795089509951095119512951395149515951695179518951995209521952295239524952595269527952895299530953195329533953495359536953795389539954095419542954395449545954695479548954995509551955295539554955595569557955895599560956195629563956495659566956795689569957095719572957395749575957695779578957995809581958295839584958595869587958895899590959195929593959495959596959795989599960096019602960396049605960696079608960996109611961296139614961596169617961896199620962196229623962496259626962796289629963096319632963396349635963696379638963996409641964296439644964596469647964896499650965196529653965496559656965796589659966096619662966396649665966696679668966996709671967296739674967596769677967896799680968196829683968496859686968796889689969096919692969396949695969696979698969997009701970297039704970597069707970897099710971197129713971497159716971797189719972097219722972397249725972697279728972997309731973297339734973597369737973897399740974197429743974497459746974797489749975097519752975397549755975697579758975997609761976297639764976597669767976897699770977197729773977497759776977797789779978097819782978397849785978697879788978997909791979297939794979597969797979897999800980198029803980498059806980798089809981098119812981398149815981698179818981998209821982298239824982598269827982898299830983198329833983498359836983798389839984098419842984398449845984698479848984998509851985298539854985598569857985898599860986198629863986498659866986798689869987098719872987398749875987698779878987998809881988298839884988598869887988898899890989198929893989498959896989798989899990099019902990399049905990699079908990999109911991299139914991599169917991899199920992199229923992499259926992799289929993099319932993399349935993699379938993999409941994299439944994599469947994899499950995199529953995499559956995799589959996099619962996399649965996699679968996999709971997299739974997599769977997899799980998199829983998499859986998799889989999099919992999399949995999699979998999910000100011000210003100041000510006100071000810009100101001110012100131001410015100161001710018100191002010021100221002310024100251002610027100281002910030100311003210033100341003510036100371003810039100401004110042100431004410045100461004710048100491005010051100521005310054100551005610057100581005910060100611006210063100641006510066100671006810069100701007110072100731007410075100761007710078100791008010081100821008310084100851008610087100881008910090100911009210093100941009510096100971009810099101001010110102101031010410105101061010710108101091011010111101121011310114101151011610117101181011910120101211012210123101241012510126101271012810129101301013110132101331013410135101361013710138101391014010141101421014310144101451014610147101481014910150101511015210153101541015510156101571015810159101601016110162101631016410165101661016710168101691017010171101721017310174101751017610177101781017910180101811018210183101841018510186101871018810189101901019110192101931019410195101961019710198101991020010201102021020310204102051020610207102081020910210102111021210213102141021510216102171021810219102201022110222102231022410225102261022710228102291023010231102321023310234102351023610237102381023910240102411024210243102441024510246102471024810249102501025110252102531025410255102561025710258102591026010261102621026310264102651026610267102681026910270102711027210273102741027510276102771027810279102801028110282102831028410285102861028710288102891029010291102921029310294102951029610297102981029910300103011030210303103041030510306103071030810309103101031110312103131031410315103161031710318103191032010321103221032310324103251032610327103281032910330103311033210333103341033510336103371033810339103401034110342103431034410345103461034710348103491035010351103521035310354103551035610357103581035910360103611036210363103641036510366103671036810369103701037110372103731037410375103761037710378103791038010381103821038310384103851038610387103881038910390103911039210393103941039510396103971039810399104001040110402104031040410405104061040710408104091041010411104121041310414104151041610417104181041910420104211042210423104241042510426104271042810429104301043110432104331043410435104361043710438104391044010441104421044310444104451044610447104481044910450104511045210453104541045510456104571045810459104601046110462104631046410465104661046710468104691047010471104721047310474104751047610477104781047910480104811048210483104841048510486104871048810489104901049110492104931049410495104961049710498104991050010501105021050310504105051050610507105081050910510105111051210513105141051510516105171051810519105201052110522105231052410525105261052710528105291053010531105321053310534105351053610537105381053910540105411054210543105441054510546105471054810549105501055110552105531055410555105561055710558105591056010561105621056310564105651056610567105681056910570105711057210573105741057510576105771057810579105801058110582105831058410585105861058710588105891059010591105921059310594105951059610597105981059910600106011060210603106041060510606106071060810609106101061110612106131061410615106161061710618106191062010621106221062310624106251062610627106281062910630106311063210633106341063510636106371063810639106401064110642106431064410645106461064710648106491065010651106521065310654106551065610657106581065910660106611066210663106641066510666106671066810669106701067110672106731067410675106761067710678106791068010681106821068310684106851068610687106881068910690106911069210693106941069510696106971069810699107001070110702107031070410705107061070710708107091071010711107121071310714107151071610717107181071910720107211072210723107241072510726107271072810729107301073110732107331073410735107361073710738107391074010741107421074310744107451074610747107481074910750107511075210753107541075510756107571075810759107601076110762107631076410765107661076710768107691077010771107721077310774107751077610777107781077910780107811078210783107841078510786107871078810789107901079110792107931079410795107961079710798107991080010801108021080310804108051080610807108081080910810108111081210813108141081510816108171081810819108201082110822108231082410825108261082710828108291083010831108321083310834108351083610837108381083910840108411084210843108441084510846108471084810849108501085110852108531085410855108561085710858108591086010861108621086310864108651086610867108681086910870108711087210873108741087510876108771087810879108801088110882108831088410885108861088710888108891089010891108921089310894108951089610897108981089910900109011090210903109041090510906109071090810909109101091110912109131091410915109161091710918109191092010921109221092310924109251092610927109281092910930109311093210933109341093510936109371093810939109401094110942109431094410945109461094710948109491095010951109521095310954109551095610957109581095910960109611096210963109641096510966109671096810969109701097110972109731097410975109761097710978109791098010981109821098310984109851098610987109881098910990109911099210993109941099510996109971099810999110001100111002110031100411005110061100711008110091101011011110121101311014110151101611017110181101911020110211102211023110241102511026110271102811029110301103111032110331103411035110361103711038110391104011041110421104311044110451104611047110481104911050110511105211053110541105511056110571105811059110601106111062110631106411065110661106711068110691107011071110721107311074110751107611077110781107911080110811108211083110841108511086110871108811089110901109111092110931109411095110961109711098110991110011101111021110311104111051110611107111081110911110111111111211113111141111511116111171111811119111201112111122111231112411125111261112711128111291113011131111321113311134111351113611137111381113911140111411114211143111441114511146111471114811149111501115111152111531115411155111561115711158111591116011161111621116311164111651116611167111681116911170111711117211173111741117511176111771117811179111801118111182111831118411185111861118711188111891119011191111921119311194111951119611197111981119911200112011120211203112041120511206112071120811209112101121111212112131121411215112161121711218112191122011221112221122311224112251122611227112281122911230112311123211233112341123511236112371123811239112401124111242112431124411245112461124711248112491125011251112521125311254112551125611257112581125911260112611126211263112641126511266112671126811269112701127111272112731127411275112761127711278112791128011281112821128311284112851128611287112881128911290112911129211293112941129511296112971129811299113001130111302113031130411305113061130711308113091131011311113121131311314113151131611317113181131911320113211132211323113241132511326113271132811329113301133111332113331133411335113361133711338113391134011341113421134311344113451134611347113481134911350113511135211353113541135511356113571135811359113601136111362113631136411365113661136711368113691137011371113721137311374113751137611377113781137911380113811138211383113841138511386113871138811389113901139111392113931139411395113961139711398113991140011401114021140311404114051140611407114081140911410114111141211413114141141511416114171141811419114201142111422114231142411425114261142711428114291143011431114321143311434114351143611437114381143911440114411144211443114441144511446114471144811449114501145111452114531145411455114561145711458114591146011461114621146311464114651146611467114681146911470114711147211473114741147511476114771147811479114801148111482114831148411485114861148711488114891149011491114921149311494114951149611497114981149911500115011150211503115041150511506115071150811509115101151111512115131151411515115161151711518115191152011521115221152311524115251152611527115281152911530115311153211533115341153511536115371153811539115401154111542115431154411545115461154711548115491155011551115521155311554115551155611557115581155911560115611156211563115641156511566115671156811569115701157111572115731157411575115761157711578115791158011581115821158311584115851158611587115881158911590115911159211593115941159511596115971159811599116001160111602116031160411605116061160711608116091161011611116121161311614116151161611617116181161911620116211162211623116241162511626116271162811629116301163111632116331163411635116361163711638116391164011641116421164311644116451164611647116481164911650116511165211653116541165511656116571165811659116601166111662116631166411665116661166711668116691167011671116721167311674116751167611677116781167911680116811168211683116841168511686116871168811689116901169111692116931169411695116961169711698116991170011701117021170311704117051170611707117081170911710117111171211713117141171511716117171171811719117201172111722117231172411725117261172711728117291173011731117321173311734117351173611737117381173911740117411174211743117441174511746117471174811749117501175111752117531175411755117561175711758117591176011761117621176311764117651176611767117681176911770117711177211773117741177511776117771177811779117801178111782117831178411785117861178711788117891179011791117921179311794117951179611797117981179911800118011180211803118041180511806118071180811809118101181111812118131181411815118161181711818118191182011821118221182311824118251182611827118281182911830118311183211833118341183511836118371183811839118401184111842118431184411845118461184711848118491185011851118521185311854118551185611857118581185911860118611186211863118641186511866118671186811869118701187111872118731187411875118761187711878118791188011881118821188311884118851188611887118881188911890118911189211893118941189511896118971189811899119001190111902119031190411905119061190711908119091191011911119121191311914119151191611917119181191911920119211192211923119241192511926119271192811929119301193111932119331193411935119361193711938119391194011941119421194311944119451194611947119481194911950119511195211953119541195511956119571195811959119601196111962119631196411965119661196711968119691197011971119721197311974119751197611977119781197911980119811198211983119841198511986119871198811989119901199111992119931199411995119961199711998119991200012001120021200312004120051200612007120081200912010120111201212013120141201512016120171201812019120201202112022120231202412025120261202712028120291203012031120321203312034120351203612037120381203912040120411204212043120441204512046120471204812049120501205112052120531205412055120561205712058120591206012061120621206312064120651206612067120681206912070120711207212073120741207512076120771207812079120801208112082120831208412085120861208712088120891209012091120921209312094120951209612097120981209912100121011210212103121041210512106121071210812109121101211112112121131211412115121161211712118121191212012121121221212312124121251212612127121281212912130121311213212133121341213512136121371213812139121401214112142121431214412145121461214712148121491215012151121521215312154121551215612157121581215912160121611216212163121641216512166121671216812169121701217112172121731217412175121761217712178121791218012181121821218312184121851218612187121881218912190121911219212193121941219512196121971219812199122001220112202122031220412205122061220712208122091221012211122121221312214122151221612217122181221912220122211222212223122241222512226122271222812229122301223112232122331223412235122361223712238122391224012241122421224312244122451224612247122481224912250122511225212253122541225512256122571225812259122601226112262122631226412265122661226712268122691227012271122721227312274122751227612277122781227912280122811228212283122841228512286122871228812289122901229112292122931229412295122961229712298122991230012301123021230312304123051230612307123081230912310123111231212313123141231512316123171231812319123201232112322123231232412325123261232712328123291233012331123321233312334123351233612337123381233912340123411234212343123441234512346123471234812349123501235112352123531235412355123561235712358123591236012361123621236312364123651236612367123681236912370123711237212373123741237512376123771237812379123801238112382
  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. "regexp"
  23. "strconv"
  24. "strings"
  25. "syscall"
  26. "time"
  27. "unsafe"
  28. )
  29. type HisApiController struct {
  30. controllers.BaseAuthAPIController
  31. }
  32. func HisManagerApiRegistRouters() {
  33. //挂号
  34. beego.Router("/api/register/get", &HisApiController{}, "get:GetRegisterInfo")
  35. //上传就诊信息-上传明细-结算
  36. beego.Router("/api/upload/get", &HisApiController{}, "get:GetUploadInfo")
  37. //查询
  38. beego.Router("/api/settle/query", &HisApiController{}, "get:GetSettleAccounts")
  39. //对总账
  40. beego.Router("/api/checkaccount/get", &HisApiController{}, "get:GetCheckAccount")
  41. //对明细
  42. beego.Router("/api/checkdetailaccount/get", &HisApiController{}, "get:GetCheckDetailAccount")
  43. //退费,退明细
  44. beego.Router("/api/refund/post", &HisApiController{}, "get:Refund")
  45. //退号
  46. beego.Router("/api/refundnumber/post", &HisApiController{}, "get:RefundNumber")
  47. //退明细
  48. beego.Router("/api/refunddetail/post", &HisApiController{}, "get:RefundDetail")
  49. //上传就诊信息-上传明细-预结算
  50. beego.Router("/api/presettle/get", &HisApiController{}, "get:GetPreUploadInfo")
  51. beego.Router("/api/treatment/check", &HisApiController{}, "get:CheckTreatment")
  52. beego.Router("/api/org/info", &HisApiController{}, "get:GetOrgInfo")
  53. beego.Router("/api/readcard", &HisApiController{}, "get:ReadCard")
  54. beego.Router("/api/310", &HisApiController{}, "get:Check310")
  55. beego.Router("/api/390", &HisApiController{}, "get:Check390")
  56. beego.Router("/api/patient/info", &HisApiController{}, "get:GetPatientInfo")
  57. beego.Router("/api/checkcode/get", &HisApiController{}, "get:GetCheckCode")
  58. beego.Router("/api/uncheckcode/get", &HisApiController{}, "get:UnCheckCode")
  59. beego.Router("/api/psn/putonrecord", &HisApiController{}, "get:PsnPutOnRecord")
  60. beego.Router("/api/psn/unputonrecord", &HisApiController{}, "get:PsnUnPutOnRecord")
  61. beego.Router("/api/psn/ncds/putonrecord", &HisApiController{}, "get:PsnPutNCDSOnRecord")
  62. beego.Router("/api/psn/ncds/unputonrecord", &HisApiController{}, "get:PsnPutUnNCDSOnRecord")
  63. beego.Router("/api/reversal", &HisApiController{}, "get:ReversalData")
  64. beego.Router("/api/reversal/other", &HisApiController{}, "get:ReversalOtherData")
  65. beego.Router("/api/settlelist/get", &HisApiController{}, "get:GetSettleList")
  66. beego.Router("/api/settlelisthosptial/get", &HisApiController{}, "get:GetSettleListHospital")
  67. beego.Router("/api/pwd/check", &HisApiController{}, "get:CheckCardPWD")
  68. beego.Router("/api/insutype/check", &HisApiController{}, "get:CheckInsutype")
  69. beego.Router("/api/batchsettlelist/get", &HisApiController{}, "get:GetBatchSettleList")
  70. beego.Router("/api/psn/info", &HisApiController{}, "get:GetPsnNcdsInfo")
  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. beego.Router("/90990", &HisApiController{}, "get:CheckCardPWDTwo")
  76. beego.Router("/9001", &HisApiController{}, "get:Get9001")
  77. beego.Router("/api/readelecard", &HisApiController{}, "get:ReadEleCard")
  78. }
  79. func (c *HisApiController) Get9001() {
  80. adminUser := c.GetAdminUserInfo()
  81. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  82. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, 185)
  83. if miConfig.MdtrtareaAdmvs == "350500" {
  84. fmt.Println("350500")
  85. service.GetFjAuthorizationInfo(miConfig.Code)
  86. } else {
  87. result, _ := service.Gdyb9001(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, 1669)
  88. var dat map[string]interface{}
  89. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  90. fmt.Println(dat)
  91. } else {
  92. fmt.Println(err)
  93. }
  94. userJSONBytes, _ := json.Marshal(dat)
  95. var res models.Result9001
  96. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  97. utils.ErrorLog("解析失败:%v", err)
  98. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  99. return
  100. }
  101. }
  102. }
  103. func (c *HisApiController) Check3101() {
  104. patient_id, _ := c.GetInt64("patient_id")
  105. his_patient_id, _ := c.GetInt64("his_patient_id")
  106. admin_user_id, _ := c.GetInt64("admin_user_id")
  107. adminUser := c.GetAdminUserInfo()
  108. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  109. his, _ := service.GetNewHisPatientInfoFour(c.GetAdminUserInfo().CurrentOrgId, his_patient_id)
  110. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  111. record_time := c.GetString("record_time")
  112. trig_scen := c.GetString("trig_scen")
  113. timeLayout := "2006-01-02"
  114. loc, _ := time.LoadLocation("Local")
  115. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  116. if err != nil {
  117. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  118. return
  119. }
  120. recordDateTime := theTime.Unix()
  121. var patientPrescription models.HisPrescriptionInfo
  122. patientPrescription, _ = service.FindHisPatientPrescriptionInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  123. if patientPrescription.ID == 0 {
  124. patientPrescription, _ = service.FindLastPatientPrescriptionInfo(adminUser.CurrentOrgId, patient_id, recordDateTime)
  125. }
  126. department, _ := service.GetDepartMentDetail(patientPrescription.Departments)
  127. doctor_info, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, patientPrescription.DoctorId)
  128. //
  129. diagnosis_ids := strings.Split(patientPrescription.Diagnosis, ",")
  130. prescriptions, _ := service.GetNewHisPrescriptionTen(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  131. var pp models.PublicParams
  132. pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  133. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  134. pp.FixmedinsName = miConfig.OrgName
  135. pp.FixmedinsCode = miConfig.Code
  136. pp.RequestUrl = miConfig.Url
  137. pp.Cainfo = miConfig.Cainfo
  138. pp.SecretKey = miConfig.SecretKey
  139. pp.AccessKey = miConfig.AccessKey
  140. pp.OpterName = roles.UserName
  141. var config []*models.HisXtDiagnoseConfig
  142. for _, item := range diagnosis_ids {
  143. id, _ := strconv.ParseInt(item, 10, 64)
  144. diagnosisConfig, _ := service.FindDiagnoseById(id)
  145. config = append(config, &diagnosisConfig)
  146. }
  147. var pd models.PatientDtos
  148. pd.PatnID = his.PsnNo
  149. pd.PatnName = his.Name
  150. pd.Gend = his.Gend
  151. pd.Brdy = his.Brdy
  152. pd.Poolarea = his.InsuplcAdmdvs
  153. pd.CurrMdtrtID = his.Number
  154. var fed models.FsiEncounterDtos
  155. fed.MdtrtID = his.Number
  156. fed.MedinsID = miConfig.Code
  157. fed.MedinsName = miConfig.OrgName
  158. fed.MedinsAdmdvs = miConfig.MdtrtareaAdmvs
  159. fed.MedMdtrtType = "1"
  160. fed.MedinsType = "1"
  161. fed.MedinsLv = "11"
  162. tm := time.Unix(his.RecordDate, 0)
  163. s_tm := tm.Format("2006-01-02 15:04:05")
  164. fed.AdmDate = s_tm
  165. fed.DscgDate = s_tm
  166. fed.DscgMainDiseCodg = config[0].CountryCode
  167. fed.DscgMainDiseName = config[0].CountryContentName
  168. //诊断信息
  169. var fdds []*models.FsiDiagnoseDtos
  170. for index, item := range config {
  171. if index == 0 {
  172. var fdd models.FsiDiagnoseDtos
  173. fdd.DiseID = strconv.FormatInt(item.ID, 10)
  174. fdd.InoutDiseType = "1"
  175. fdd.MaindiseFlag = "1"
  176. fdd.DiseDate = s_tm
  177. fdd.DiasSrtNo = "1"
  178. fdd.DiseName = item.CountryContentName
  179. fdd.DiseCodg = item.CountryCode
  180. fdds = append(fdds, &fdd)
  181. } else {
  182. var fdd models.FsiDiagnoseDtos
  183. fdd.DiseID = strconv.FormatInt(item.ID, 10)
  184. fdd.InoutDiseType = "1"
  185. fdd.MaindiseFlag = "1"
  186. fdd.DiseDate = s_tm
  187. fdd.DiasSrtNo = strconv.FormatInt(int64(index), 10)
  188. fdd.DiseName = item.CountryContentName
  189. fdd.DiseCodg = item.CountryCode
  190. fdds = append(fdds, &fdd)
  191. }
  192. }
  193. fed.DrCodg = strconv.FormatInt(doctor_info.ID, 10)
  194. fed.AdmDeptCodg = strconv.FormatInt(department.ID, 10)
  195. fed.AdmDeptName = department.Name
  196. fed.DscgDeptCodg = strconv.FormatInt(department.ID, 10)
  197. fed.DscgDeptName = department.Name
  198. fed.MedMdtrtType = "1"
  199. fed.MedType = "11"
  200. //if his.Insutype == "390" {
  201. // fed.MedType = "1402"
  202. //} else {
  203. // fed.MedType = "9933"
  204. //}
  205. var orders []*models.FsiOrderDtos
  206. if trig_scen == "2" {
  207. //处方医嘱信息
  208. for _, item := range prescriptions {
  209. for _, subItem := range item.HisDoctorAdviceInfo {
  210. var order models.FsiOrderDtos
  211. order.RxID = strconv.FormatInt(item.ID, 10)
  212. order.Rxno = strconv.FormatInt(item.ID, 10)
  213. order.LongDrordFlag = "0"
  214. order.HilistType = "1"
  215. order.ChrgType = "1"
  216. order.DrordBhvr = "-"
  217. order.HilistCode = subItem.BaseDrugLib.MedicalInsuranceNumber
  218. order.HosplistName = subItem.BaseDrugLib.DrugName
  219. order.HilistLv = "1"
  220. order.HilistPric = fmt.Sprintf("%.2f", subItem.Price)
  221. order.HosplistCode = subItem.BaseDrugLib.MedicalInsuranceNumber
  222. order.HosplistName = subItem.BaseDrugLib.DrugName
  223. order.Cnt = fmt.Sprintf("%.2f", subItem.PrescribingNumber)
  224. order.Pric = fmt.Sprintf("%.2f", subItem.Price)
  225. order.Sumamt = fmt.Sprintf("%.2f", (subItem.PrescribingNumber * subItem.Price))
  226. order.OwnpayAmt = ""
  227. order.SelfpayAmt = ""
  228. order.Spec = ""
  229. order.SpecUnt = ""
  230. order.DrordBegnDate = s_tm
  231. order.DrordStopDate = ""
  232. order.DrordDrCodg = "1"
  233. order.DrordDeptName = department.Name
  234. order.DrordDrCodg = "1"
  235. order.DrordDrName = doctor_info.UserName
  236. order.DrordDrProfttl = ""
  237. order.CurrDrordFlag = "1"
  238. orders = append(orders, &order)
  239. }
  240. for _, subItem := range item.HisPrescriptionProject {
  241. if subItem.Type == 2 {
  242. var order models.FsiOrderDtos
  243. order.RxID = strconv.FormatInt(item.ID, 10)
  244. order.Rxno = strconv.FormatInt(item.ID, 10)
  245. order.LongDrordFlag = "0"
  246. order.HilistType = "1"
  247. order.ChrgType = "1"
  248. order.DrordBhvr = "-"
  249. order.HilistCode = subItem.HisProject.MedicalCode
  250. order.HosplistName = subItem.HisProject.ProjectName
  251. order.HilistLv = "1"
  252. order.HilistPric = fmt.Sprintf("%.2f", subItem.Price)
  253. order.HosplistCode = subItem.HisProject.MedicalCode
  254. order.HosplistName = subItem.HisProject.ProjectName
  255. order.Cnt = subItem.Count
  256. cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  257. order.Pric = fmt.Sprintf("%.2f", subItem.Price)
  258. order.Sumamt = fmt.Sprintf("%.2f", subItem.Price*cnt)
  259. order.OwnpayAmt = ""
  260. order.SelfpayAmt = ""
  261. order.Spec = ""
  262. order.SpecUnt = ""
  263. order.DrordBegnDate = s_tm
  264. order.DrordStopDate = ""
  265. order.DrordDrCodg = "1"
  266. order.DrordDeptName = department.Name
  267. order.DrordDrCodg = "1"
  268. order.DrordDrName = doctor_info.UserName
  269. order.DrordDrProfttl = ""
  270. order.CurrDrordFlag = "1"
  271. orders = append(orders, &order)
  272. }
  273. if subItem.Type == 3 {
  274. var order models.FsiOrderDtos
  275. order.RxID = strconv.FormatInt(item.ID, 10)
  276. order.Rxno = strconv.FormatInt(item.ID, 10)
  277. order.LongDrordFlag = "0"
  278. order.HilistType = "1"
  279. order.ChrgType = "1"
  280. order.DrordBhvr = "-"
  281. order.HilistCode = subItem.GoodInfo.MedicalInsuranceNumber
  282. order.HosplistName = subItem.GoodInfo.GoodName
  283. order.HilistLv = "1"
  284. order.HilistPric = fmt.Sprintf("%.2f", subItem.Price)
  285. order.HosplistCode = subItem.GoodInfo.MedicalInsuranceNumber
  286. order.HosplistName = subItem.GoodInfo.GoodName
  287. order.Cnt = subItem.Count
  288. cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  289. order.Pric = fmt.Sprintf("%.2f", subItem.Price)
  290. order.Sumamt = fmt.Sprintf("%.2f", subItem.Price*cnt)
  291. order.OwnpayAmt = ""
  292. order.SelfpayAmt = ""
  293. order.Spec = ""
  294. order.SpecUnt = ""
  295. order.DrordBegnDate = s_tm
  296. order.DrordStopDate = ""
  297. order.DrordDrCodg = "1"
  298. order.DrordDeptName = department.Name
  299. order.DrordDrCodg = "1"
  300. order.DrordDrName = doctor_info.UserName
  301. order.DrordDrProfttl = ""
  302. order.CurrDrordFlag = "1"
  303. orders = append(orders, &order)
  304. }
  305. }
  306. }
  307. //处方医嘱信息
  308. }
  309. fed.MatnStas = "0"
  310. fed.MedfeeSumamt = "0"
  311. fed.OwnpayAmt = "0"
  312. fed.SelfpayAmt = "0"
  313. fed.AcctPayamt = "0"
  314. fed.MaAmt = "0"
  315. fed.HifpPayamt = "0"
  316. fed.SetlTotlnum = "1"
  317. fed.Insutype = his.Insutype
  318. fed.ReimFlag = "0"
  319. fed.OutSetlFlag = "0"
  320. var fopd []*models.FsiOperationDtosData
  321. data := make(map[string]interface{})
  322. data["fed"] = fed
  323. data["fdd"] = fdds
  324. data["fod"] = orders
  325. data["pd"] = pd
  326. data["pp"] = pp
  327. data["fopd"] = fopd
  328. data["trig_scen"] = trig_scen
  329. fmt.Println(data)
  330. fmt.Println(fed)
  331. fmt.Println(fdds)
  332. fmt.Println(orders)
  333. fmt.Println(pd)
  334. fmt.Println(pp)
  335. fmt.Println(fopd)
  336. client := &http.Client{}
  337. bytesData, _ := json.Marshal(data)
  338. var req *http.Request
  339. if miConfig.MdtrtareaAdmvs == "320921" {
  340. req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/3101", bytes.NewReader(bytesData))
  341. } else {
  342. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3101", bytes.NewReader(bytesData))
  343. }
  344. resp, _ := client.Do(req)
  345. defer resp.Body.Close()
  346. body, ioErr := ioutil.ReadAll(resp.Body)
  347. if ioErr != nil {
  348. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  349. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  350. return
  351. }
  352. var respJSON map[string]interface{}
  353. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  354. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  355. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  356. return
  357. }
  358. //手术操作集合
  359. //手术操作集合
  360. }
  361. func (c *HisApiController) Check3102() {
  362. patient_id, _ := c.GetInt64("patient_id")
  363. order_id, _ := c.GetInt64("order_id")
  364. his_patient_id, _ := c.GetInt64("his_patient_id")
  365. admin_user_id, _ := c.GetInt64("admin_user_id")
  366. trig_scen := c.GetString("trig_scen")
  367. adminUser := c.GetAdminUserInfo()
  368. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  369. his, _ := service.GetNewHisPatientInfoFour(c.GetAdminUserInfo().CurrentOrgId, his_patient_id)
  370. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  371. record_time := c.GetString("record_time")
  372. order, _ := service.GetHisOrderByID(order_id)
  373. timeLayout := "2006-01-02"
  374. loc, _ := time.LoadLocation("Local")
  375. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  376. if err != nil {
  377. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  378. return
  379. }
  380. recordDateTime := theTime.Unix()
  381. var patientPrescription models.HisPrescriptionInfo
  382. patientPrescription, _ = service.FindHisPatientPrescriptionInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  383. if patientPrescription.ID == 0 {
  384. patientPrescription, _ = service.FindLastPatientPrescriptionInfo(adminUser.CurrentOrgId, patient_id, recordDateTime)
  385. }
  386. department, _ := service.GetDepartMentDetail(patientPrescription.Departments)
  387. doctor_info, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, patientPrescription.DoctorId)
  388. //
  389. diagnosis_ids := strings.Split(his.Diagnosis, ",")
  390. prescriptions, _ := service.GetNewHisPrescriptionTen(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  391. var pp models.PublicParams
  392. pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  393. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  394. pp.FixmedinsName = miConfig.OrgName
  395. pp.FixmedinsCode = miConfig.Code
  396. pp.RequestUrl = miConfig.Url
  397. pp.Cainfo = miConfig.Cainfo
  398. pp.SecretKey = miConfig.SecretKey
  399. pp.AccessKey = miConfig.AccessKey
  400. pp.OpterName = roles.UserName
  401. var config []*models.HisXtDiagnoseConfig
  402. for _, item := range diagnosis_ids {
  403. id, _ := strconv.ParseInt(item, 10, 64)
  404. diagnosisConfig, _ := service.FindDiagnoseById(id)
  405. config = append(config, &diagnosisConfig)
  406. }
  407. var pd models.PatientDtos
  408. pd.PatnID = his.PsnNo
  409. pd.PatnName = his.Name
  410. pd.Gend = his.Gend
  411. pd.Brdy = his.Brdy
  412. pd.Poolarea = his.InsuplcAdmdvs
  413. pd.CurrMdtrtID = his.Number
  414. var fed models.FsiEncounterDtos
  415. fed.MdtrtID = his.Number
  416. fed.MedinsID = miConfig.Code
  417. fed.MedinsName = miConfig.OrgName
  418. fed.MedinsAdmdvs = miConfig.MdtrtareaAdmvs
  419. fed.MedMdtrtType = "1"
  420. fed.MedinsType = "1"
  421. fed.MedinsLv = "11"
  422. tm := time.Unix(his.RecordDate, 0)
  423. s_tm := tm.Format("2006-01-02 15:04:05")
  424. fed.AdmDate = s_tm
  425. fed.DscgDate = s_tm
  426. fed.DscgMainDiseCodg = config[0].CountryCode
  427. fed.DscgMainDiseName = config[0].CountryContentName
  428. //诊断信息
  429. var fdds []*models.FsiDiagnoseDtos
  430. for index, item := range config {
  431. if index == 0 {
  432. var fdd models.FsiDiagnoseDtos
  433. fdd.DiseID = strconv.FormatInt(item.ID, 10)
  434. fdd.InoutDiseType = "1"
  435. fdd.MaindiseFlag = "1"
  436. fdd.DiseDate = s_tm
  437. fdd.DiasSrtNo = "1"
  438. fdd.DiseName = item.CountryContentName
  439. fdd.DiseCodg = item.CountryCode
  440. fdds = append(fdds, &fdd)
  441. } else {
  442. var fdd models.FsiDiagnoseDtos
  443. fdd.DiseID = strconv.FormatInt(item.ID, 10)
  444. fdd.InoutDiseType = "1"
  445. fdd.MaindiseFlag = "1"
  446. fdd.DiseDate = s_tm
  447. fdd.DiasSrtNo = strconv.FormatInt(int64(index), 10)
  448. fdd.DiseName = item.CountryContentName
  449. fdd.DiseCodg = item.CountryCode
  450. fdds = append(fdds, &fdd)
  451. }
  452. }
  453. fed.DrCodg = strconv.FormatInt(doctor_info.ID, 10)
  454. fed.AdmDeptCodg = strconv.FormatInt(department.ID, 10)
  455. fed.AdmDeptName = department.Name
  456. fed.DscgDeptCodg = strconv.FormatInt(department.ID, 10)
  457. fed.DscgDeptName = department.Name
  458. fed.MedType = order.MedType
  459. //处方医嘱信息
  460. var orders []*models.FsiOrderDtos
  461. //for _, item := range prescriptions {
  462. // for _, subItem := range item.HisDoctorAdviceInfo {
  463. // var order models.FsiOrderDtos
  464. // order.RxID = strconv.FormatInt(item.ID, 10)
  465. // order.Rxno = strconv.FormatInt(item.ID, 10)
  466. // order.LongDrordFlag = "0"
  467. // order.HilistType = "1"
  468. // order.ChrgType = "1"
  469. // order.DrordBhvr = "-"
  470. // order.HilistCode = subItem.BaseDrugLib.MedicalInsuranceNumber
  471. // order.HosplistName = subItem.BaseDrugLib.DrugName
  472. // order.HilistLv = "1"
  473. // order.HilistPric = strconv.FormatFloat(subItem.Price, 'E', -1, 64)
  474. // order.HosplistCode = subItem.BaseDrugLib.MedicalInsuranceNumber
  475. // order.HosplistName = subItem.BaseDrugLib.DrugName
  476. // order.Cnt = strconv.FormatFloat(subItem.PrescribingNumber, 'E', -1, 64)
  477. // order.Pric = strconv.FormatFloat(subItem.Price, 'E', -1, 64)
  478. // order.Sumamt = strconv.FormatFloat((subItem.Price * subItem.PrescribingNumber), 'E', -1, 64)
  479. // order.OwnpayAmt = ""
  480. // order.SelfpayAmt = ""
  481. // order.Spec = ""
  482. // order.SpecUnt = ""
  483. // order.DrordBegnDate = s_tm
  484. // order.DrordStopDate = ""
  485. // order.DrordDrCodg = "1"
  486. // order.DrordDeptName = department.Name
  487. // order.DrordDrCodg = "1"
  488. // order.DrordDrName = doctor_info.UserName
  489. // order.DrordDrProfttl = ""
  490. // order.CurrDrordFlag = "1"
  491. // orders = append(orders, &order)
  492. // }
  493. // for _, subItem := range item.HisPrescriptionProject {
  494. // if subItem.Type == 2 {
  495. // var order models.FsiOrderDtos
  496. // order.RxID = strconv.FormatInt(item.ID, 10)
  497. // order.Rxno = strconv.FormatInt(item.ID, 10)
  498. // order.LongDrordFlag = "0"
  499. // order.HilistType = "1"
  500. // order.ChrgType = "1"
  501. // order.DrordBhvr = "-"
  502. // order.HilistCode = subItem.HisProject.MedicalCode
  503. // order.HosplistName = subItem.HisProject.ProjectName
  504. // order.HilistLv = "1"
  505. // order.HilistPric = strconv.FormatFloat(subItem.Price, 'E', -1, 64)
  506. // order.HosplistCode = subItem.HisProject.MedicalCode
  507. // order.HosplistName = subItem.HisProject.ProjectName
  508. // order.Cnt = subItem.Count
  509. // cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  510. //
  511. // order.Pric = strconv.FormatFloat(subItem.Price, 'E', -1, 64)
  512. // order.Sumamt = strconv.FormatFloat((subItem.Price * cnt), 'E', -1, 64)
  513. // order.OwnpayAmt = ""
  514. // order.SelfpayAmt = ""
  515. // order.Spec = ""
  516. // order.SpecUnt = ""
  517. // order.DrordBegnDate = s_tm
  518. // order.DrordStopDate = ""
  519. // order.DrordDrCodg = "1"
  520. // order.DrordDeptName = department.Name
  521. // order.DrordDrCodg = "1"
  522. // order.DrordDrName = doctor_info.UserName
  523. // order.DrordDrProfttl = ""
  524. // order.CurrDrordFlag = "1"
  525. // orders = append(orders, &order)
  526. //
  527. // }
  528. // if subItem.Type == 3 {
  529. //
  530. // var order models.FsiOrderDtos
  531. // order.RxID = strconv.FormatInt(item.ID, 10)
  532. // order.Rxno = strconv.FormatInt(item.ID, 10)
  533. // order.LongDrordFlag = "0"
  534. // order.HilistType = "1"
  535. // order.ChrgType = "1"
  536. // order.DrordBhvr = "-"
  537. // order.HilistCode = subItem.GoodInfo.MedicalInsuranceNumber
  538. // order.HosplistName = subItem.GoodInfo.GoodName
  539. // order.HilistLv = "1"
  540. // order.HilistPric = strconv.FormatFloat(subItem.Price, 'E', -1, 64)
  541. // order.HosplistCode = subItem.GoodInfo.MedicalInsuranceNumber
  542. // order.HosplistName = subItem.GoodInfo.GoodName
  543. // order.Cnt = subItem.Count
  544. // cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  545. // order.Pric = strconv.FormatFloat(subItem.Price, 'E', -1, 64)
  546. // order.Sumamt = strconv.FormatFloat((subItem.Price * cnt), 'E', -1, 64)
  547. // order.OwnpayAmt = ""
  548. // order.SelfpayAmt = ""
  549. // order.Spec = ""
  550. // order.SpecUnt = ""
  551. // order.DrordBegnDate = s_tm
  552. // order.DrordStopDate = ""
  553. // order.DrordDrCodg = "1"
  554. // order.DrordDeptName = department.Name
  555. // order.DrordDrCodg = "1"
  556. // order.DrordDrName = doctor_info.UserName
  557. // order.DrordDrProfttl = ""
  558. // order.CurrDrordFlag = "1"
  559. // orders = append(orders, &order)
  560. //
  561. // }
  562. // }
  563. //}
  564. for _, item := range prescriptions {
  565. for _, subItem := range item.HisDoctorAdviceInfo {
  566. var order models.FsiOrderDtos
  567. order.RxID = strconv.FormatInt(item.ID, 10)
  568. order.Rxno = strconv.FormatInt(item.ID, 10)
  569. order.LongDrordFlag = "0"
  570. order.HilistType = "1"
  571. order.ChrgType = "1"
  572. order.DrordBhvr = "-"
  573. order.HilistCode = subItem.BaseDrugLib.MedicalInsuranceNumber
  574. order.HosplistName = subItem.BaseDrugLib.DrugName
  575. order.HilistLv = "1"
  576. order.HilistPric = fmt.Sprintf("%.2f", subItem.Price)
  577. order.HosplistCode = subItem.BaseDrugLib.MedicalInsuranceNumber
  578. order.HosplistName = subItem.BaseDrugLib.DrugName
  579. order.Cnt = fmt.Sprintf("%.2f", subItem.PrescribingNumber)
  580. order.Pric = fmt.Sprintf("%.2f", subItem.Price)
  581. order.Sumamt = fmt.Sprintf("%.2f", (subItem.PrescribingNumber * subItem.Price))
  582. order.OwnpayAmt = ""
  583. order.SelfpayAmt = ""
  584. order.Spec = ""
  585. order.SpecUnt = ""
  586. order.DrordBegnDate = s_tm
  587. order.DrordStopDate = ""
  588. order.DrordDrCodg = "1"
  589. order.DrordDeptName = department.Name
  590. order.DrordDrCodg = "1"
  591. order.DrordDrName = doctor_info.UserName
  592. order.DrordDrProfttl = ""
  593. order.CurrDrordFlag = "1"
  594. orders = append(orders, &order)
  595. }
  596. for _, subItem := range item.HisPrescriptionProject {
  597. if subItem.Type == 2 {
  598. var order models.FsiOrderDtos
  599. order.RxID = strconv.FormatInt(item.ID, 10)
  600. order.Rxno = strconv.FormatInt(item.ID, 10)
  601. order.LongDrordFlag = "0"
  602. order.HilistType = "1"
  603. order.ChrgType = "1"
  604. order.DrordBhvr = "-"
  605. order.HilistCode = subItem.HisProject.MedicalCode
  606. order.HosplistName = subItem.HisProject.ProjectName
  607. order.HilistLv = "1"
  608. order.HilistPric = fmt.Sprintf("%.2f", subItem.Price)
  609. order.HosplistCode = subItem.HisProject.MedicalCode
  610. order.HosplistName = subItem.HisProject.ProjectName
  611. order.Cnt = subItem.Count
  612. cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  613. order.Pric = fmt.Sprintf("%.2f", subItem.Price)
  614. order.Sumamt = fmt.Sprintf("%.2f", subItem.Price*cnt)
  615. order.OwnpayAmt = ""
  616. order.SelfpayAmt = ""
  617. order.Spec = ""
  618. order.SpecUnt = ""
  619. order.DrordBegnDate = s_tm
  620. order.DrordStopDate = ""
  621. order.DrordDrCodg = "1"
  622. order.DrordDeptName = department.Name
  623. order.DrordDrCodg = "1"
  624. order.DrordDrName = doctor_info.UserName
  625. order.DrordDrProfttl = ""
  626. order.CurrDrordFlag = "1"
  627. orders = append(orders, &order)
  628. }
  629. if subItem.Type == 3 {
  630. var order models.FsiOrderDtos
  631. order.RxID = strconv.FormatInt(item.ID, 10)
  632. order.Rxno = strconv.FormatInt(item.ID, 10)
  633. order.LongDrordFlag = "0"
  634. order.HilistType = "1"
  635. order.ChrgType = "1"
  636. order.DrordBhvr = "-"
  637. order.HilistCode = subItem.GoodInfo.MedicalInsuranceNumber
  638. order.HosplistName = subItem.GoodInfo.GoodName
  639. order.HilistLv = "1"
  640. order.HilistPric = fmt.Sprintf("%.2f", subItem.Price)
  641. order.HosplistCode = subItem.GoodInfo.MedicalInsuranceNumber
  642. order.HosplistName = subItem.GoodInfo.GoodName
  643. order.Cnt = subItem.Count
  644. cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  645. order.Pric = fmt.Sprintf("%.2f", subItem.Price)
  646. order.Sumamt = fmt.Sprintf("%.2f", subItem.Price*cnt)
  647. order.OwnpayAmt = ""
  648. order.SelfpayAmt = ""
  649. order.Spec = ""
  650. order.SpecUnt = ""
  651. order.DrordBegnDate = s_tm
  652. order.DrordStopDate = ""
  653. order.DrordDrCodg = "1"
  654. order.DrordDeptName = department.Name
  655. order.DrordDrCodg = "1"
  656. order.DrordDrName = doctor_info.UserName
  657. order.DrordDrProfttl = ""
  658. order.CurrDrordFlag = "1"
  659. orders = append(orders, &order)
  660. }
  661. }
  662. }
  663. //处方医嘱信息
  664. fed.MatnStas = "0"
  665. fed.MedfeeSumamt = fmt.Sprintf("%.2f", order.MedfeeSumamt)
  666. fed.OwnpayAmt = fmt.Sprintf("%.2f", order.FulamtOwnpayAmt)
  667. fed.SelfpayAmt = fmt.Sprintf("%.2f", order.PreselfpayAmt)
  668. fed.AcctPayamt = fmt.Sprintf("%.2f", order.AcctPay)
  669. fed.MaAmt = fmt.Sprintf("%.2f", order.MafPay)
  670. fed.HifpPayamt = fmt.Sprintf("%.2f", order.HifpPay)
  671. fed.SetlTotlnum = "1"
  672. fed.Insutype = his.Insutype
  673. fed.ReimFlag = "0"
  674. fed.OutSetlFlag = "0"
  675. var fopd []*models.FsiOperationDtosData
  676. data := make(map[string]interface{})
  677. data["fed"] = fed
  678. data["fdd"] = fdds
  679. data["fod"] = orders
  680. data["pd"] = pd
  681. data["pp"] = pp
  682. data["fopd"] = fopd
  683. data["trig_scen"] = trig_scen
  684. client := &http.Client{}
  685. bytesData, _ := json.Marshal(data)
  686. var req *http.Request
  687. if miConfig.MdtrtareaAdmvs == "320921" {
  688. req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/3102", bytes.NewReader(bytesData))
  689. } else {
  690. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3102", bytes.NewReader(bytesData))
  691. }
  692. resp, _ := client.Do(req)
  693. defer resp.Body.Close()
  694. body, ioErr := ioutil.ReadAll(resp.Body)
  695. if ioErr != nil {
  696. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  697. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  698. return
  699. }
  700. var respJSON map[string]interface{}
  701. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  702. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  703. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  704. return
  705. }
  706. //手术操作集合
  707. //手术操作集合
  708. }
  709. func (c *HisApiController) Check() {
  710. psn_no := c.GetString("psn_no")
  711. in := c.GetString("in")
  712. mt := c.GetString("mt")
  713. baseParams := models.BaseParams{
  714. SecretKey: "MSDBYGxXm1Mtyi3PtOUB7n1ktcxwyW57",
  715. FixmedinsCode: "H15049901371",
  716. InsuplcAdmdvs: "150499",
  717. MdtrtareaAdmvs: "150499",
  718. OrgName: "赤峰费森血液透析中心",
  719. Doctor: "1111",
  720. }
  721. service.Gdyb2001(baseParams, psn_no, in, mt)
  722. }
  723. func (c *HisApiController) GetPsnNcdsInfo() {
  724. admin_user_id, _ := c.GetInt64("admin_user_id")
  725. patient_id, _ := c.GetInt64("patient_id")
  726. id, _ := c.GetInt64("id")
  727. adminUser := c.GetAdminUserInfo()
  728. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  729. //config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  730. //patient, _ := service.GetPatientByID(c.GetAdminUserInfo().CurrentOrgId, id)
  731. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  732. psn_record, _ := service.GetPsnNCDSRecordById(id)
  733. //
  734. //if psn_record.ID == 0 {
  735. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorPsnRecordNoExistWrong)
  736. // return
  737. //}
  738. var res Result5301
  739. var res10265 Result5301For10265
  740. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  741. psn_info, _ := service.GetPsnByPatientId(patient_id)
  742. var api string
  743. if miConfig.MdtrtareaAdmvs == "320921" {
  744. api = "http://192.168.2.110:9532/" + "jsyb/5301?" + "fixmedins_code=" + miConfig.Code + "&secret_key=" + miConfig.SecretKey + "&ak=" + miConfig.AccessKey + "&org_name=" + miConfig.OrgName + "&doctor=" + role.UserName +
  745. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&psn_no=" + psn_info.PsnNo + "&cainfo=" + miConfig.Cainfo
  746. } else {
  747. 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 +
  748. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&psn_no=" + psn_info.PsnNo + "&cainfo=" + miConfig.Cainfo
  749. }
  750. resp, requestErr := http.Get(api)
  751. if requestErr != nil {
  752. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  753. return
  754. }
  755. body, ioErr := ioutil.ReadAll(resp.Body)
  756. if ioErr != nil {
  757. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  758. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  759. return
  760. }
  761. var respJSON map[string]interface{}
  762. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  763. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  764. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  765. return
  766. }
  767. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  768. result, _ := json.Marshal(respJSON)
  769. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  770. utils.ErrorLog("解析失败:%v", err)
  771. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  772. return
  773. }
  774. res.ErrMsg = res10265.ErrMsg
  775. res.Output = res10265.Output
  776. res.InfRefmsgid = res10265.InfRefmsgid
  777. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  778. res.Infcode = infocode
  779. } else {
  780. result := service.Gdyb5301(psn_record.PsnNo, miConfig.OrgName, role.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey)
  781. var dat map[string]interface{}
  782. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  783. fmt.Println(dat)
  784. } else {
  785. fmt.Println(err)
  786. }
  787. userJSONBytes, _ := json.Marshal(dat)
  788. if miConfig.Code == "H15049901371" {
  789. if err := json.Unmarshal(userJSONBytes, &res10265); err != nil {
  790. utils.ErrorLog("解析失败:%v", err)
  791. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  792. return
  793. }
  794. res.InfRefmsgid = res10265.InfRefmsgid
  795. res.Output = res10265.Output
  796. res.ErrMsg = res10265.ErrMsg
  797. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  798. res.Infcode = infocode
  799. } else {
  800. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  801. utils.ErrorLog("解析失败:%v", err)
  802. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  803. return
  804. }
  805. }
  806. }
  807. if res.Infcode == 0 {
  808. c.ServeSuccessJSON(map[string]interface{}{
  809. "result": res.Output.Result,
  810. })
  811. }
  812. }
  813. func (c *HisApiController) CheckInsutype() {
  814. his_patient_id, _ := c.GetInt64("his_patient_id")
  815. admin_user_id, _ := c.GetInt64("admin_user_id")
  816. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  817. his, _ := service.GetNewHisPatientInfoFour(c.GetAdminUserInfo().CurrentOrgId, his_patient_id)
  818. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  819. result := service.Gdyb90100(his.PsnNo, miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey)
  820. var dat map[string]interface{}
  821. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  822. fmt.Println(dat)
  823. } else {
  824. fmt.Println(err)
  825. }
  826. userJSONBytes, _ := json.Marshal(dat)
  827. var res Result90100
  828. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  829. utils.ErrorLog("解析失败:%v", err)
  830. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  831. return
  832. }
  833. if res.Infcode != 0 {
  834. c.ServeSuccessJSON(map[string]interface{}{
  835. "failed_code": -10,
  836. "msg": res.ErrMsg,
  837. })
  838. return
  839. } else {
  840. fmt.Println(res)
  841. }
  842. }
  843. func (c *HisApiController) CheckCardPWD() {
  844. card_pwd := c.GetString("card_pwd")
  845. his_patient_id, _ := c.GetInt64("his_patient_id")
  846. admin_user_id, _ := c.GetInt64("admin_user_id")
  847. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  848. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  849. his, _ := service.GetNewHisPatientInfoFour(c.GetAdminUserInfo().CurrentOrgId, his_patient_id)
  850. psn, _ := service.GetPsnByPatientId(his.PatientId)
  851. bas := strings.Split(psn.CardInfo, "|")
  852. basNumber := bas[2]
  853. result := service.Gdyb90991(his.PsnNo, miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, card_pwd, basNumber)
  854. var dat map[string]interface{}
  855. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  856. fmt.Println(dat)
  857. } else {
  858. fmt.Println(err)
  859. }
  860. userJSONBytes, _ := json.Marshal(dat)
  861. var res Result90991
  862. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  863. utils.ErrorLog("解析失败:%v", err)
  864. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  865. return
  866. }
  867. if res.Infcode != 0 {
  868. c.ServeSuccessJSON(map[string]interface{}{
  869. "failed_code": -10,
  870. "msg": res.ErrMsg,
  871. })
  872. return
  873. } else {
  874. if res.Output.Result.SscnoCheckStat == "0" {
  875. var msg string
  876. switch res.Output.Result.CardStat {
  877. case "00":
  878. msg = "未激活"
  879. break
  880. case "10":
  881. msg = "激活"
  882. break
  883. case "20":
  884. msg = "窗口挂失"
  885. break
  886. case "21":
  887. msg = "电话挂失"
  888. break
  889. case "22":
  890. msg = "单位网上申报挂失"
  891. break
  892. case "23":
  893. msg = "保健办挂失"
  894. break
  895. case "24":
  896. msg = "个人网上挂失"
  897. break
  898. case "25":
  899. msg = "网上服务大厅挂失"
  900. break
  901. case "30":
  902. msg = "注销"
  903. break
  904. case "40":
  905. msg = "回收"
  906. break
  907. case "99":
  908. msg = "制卡中(无效卡)"
  909. break
  910. }
  911. c.ServeSuccessJSON(map[string]interface{}{
  912. "failed_code": -10,
  913. "msg": msg,
  914. })
  915. return
  916. } else {
  917. c.ServeSuccessJSON(map[string]interface{}{
  918. "msg": "校验成功",
  919. })
  920. return
  921. }
  922. }
  923. }
  924. func (c *HisApiController) CheckCardPWDTwo() {
  925. //card_pwd := c.GetString("card_pwd")
  926. //his_patient_id, _ := c.GetInt64("his_patient_id")
  927. admin_user_id, _ := c.GetInt64("admin_user_id")
  928. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  929. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  930. result := service.Gdyb90991("44030000000629690364", miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, "000000", "BDM421363")
  931. var dat map[string]interface{}
  932. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  933. fmt.Println(dat)
  934. } else {
  935. fmt.Println(err)
  936. }
  937. userJSONBytes, _ := json.Marshal(dat)
  938. var res Result90991
  939. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  940. utils.ErrorLog("解析失败:%v", err)
  941. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  942. return
  943. }
  944. if res.Infcode != 0 {
  945. c.ServeSuccessJSON(map[string]interface{}{
  946. "failed_code": -10,
  947. "msg": res.ErrMsg,
  948. })
  949. return
  950. } else {
  951. if res.Output.Result.SscnoCheckStat == "0" {
  952. var msg string
  953. switch res.Output.Result.CardStat {
  954. case "00":
  955. msg = "未激活"
  956. break
  957. case "10":
  958. msg = "激活"
  959. break
  960. case "20":
  961. msg = "窗口挂失"
  962. break
  963. case "21":
  964. msg = "电话挂失"
  965. break
  966. case "22":
  967. msg = "单位网上申报挂失"
  968. break
  969. case "23":
  970. msg = "保健办挂失"
  971. break
  972. case "24":
  973. msg = "个人网上挂失"
  974. break
  975. case "25":
  976. msg = "网上服务大厅挂失"
  977. break
  978. case "30":
  979. msg = "注销"
  980. break
  981. case "40":
  982. msg = "回收"
  983. break
  984. case "99":
  985. msg = "制卡中(无效卡)"
  986. break
  987. }
  988. c.ServeSuccessJSON(map[string]interface{}{
  989. "failed_code": -10,
  990. "msg": msg,
  991. })
  992. return
  993. } else {
  994. c.ServeSuccessJSON(map[string]interface{}{
  995. "msg": "校验成功",
  996. })
  997. return
  998. }
  999. }
  1000. }
  1001. func (c *HisApiController) ReadCard() {
  1002. id_card_type, _ := c.GetInt64("id_card_type")
  1003. admin_user_id, _ := c.GetInt64("admin_user_id")
  1004. certificates, _ := c.GetInt64("certificates")
  1005. fmt.Println(c.GetAdminUserInfo().CurrentOrgId)
  1006. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  1007. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  1008. switch id_card_type {
  1009. case 1:
  1010. if miConfig.MdtrtareaAdmvs == "421300" {
  1011. var res ResultTwo
  1012. api := "http://192.168.124.4:9532/" + "hbyb/1101?cert_no=" + "" +
  1013. "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  1014. "&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)
  1015. resp, requestErr := http.Get(api)
  1016. if requestErr != nil {
  1017. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1018. return
  1019. }
  1020. body, ioErr := ioutil.ReadAll(resp.Body)
  1021. if ioErr != nil {
  1022. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  1023. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1024. return
  1025. }
  1026. var respJSON map[string]interface{}
  1027. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  1028. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  1029. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1030. return
  1031. }
  1032. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  1033. result, _ := json.Marshal(respJSON)
  1034. fmt.Println("log")
  1035. fmt.Println(string(result))
  1036. if err := json.Unmarshal([]byte(result), &res); err != nil {
  1037. utils.ErrorLog("解析失败:%v", err)
  1038. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1039. return
  1040. }
  1041. if res.Infcode == 0 {
  1042. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  1043. if err == gorm.ErrRecordNotFound {
  1044. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  1045. return
  1046. } else if err != nil {
  1047. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  1048. return
  1049. } else {
  1050. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  1051. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  1052. infoStr := string(Iinfos)
  1053. idetinfoStr := string(Idetinfos)
  1054. psn := &models.HisPsn{
  1055. PsnNo: res.Output.Baseinfo.PsnNo,
  1056. Age: res.Output.Baseinfo.Age,
  1057. PatientId: patient.ID,
  1058. Certno: res.Output.Baseinfo.Certno,
  1059. Brdy: res.Output.Baseinfo.Brdy,
  1060. Gend: res.Output.Baseinfo.Gend,
  1061. Naty: res.Output.Baseinfo.Naty,
  1062. PsnCertType: res.Output.Baseinfo.PsnCertType,
  1063. PsnName: res.Output.Baseinfo.PsnName,
  1064. Idetinfo: idetinfoStr,
  1065. Insuinfo: infoStr,
  1066. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  1067. }
  1068. service.CreateHisPsn(psn)
  1069. c.ServeSuccessJSON(map[string]interface{}{
  1070. "patient": patient,
  1071. "number": res.Output.Baseinfo.Certno,
  1072. })
  1073. }
  1074. } else {
  1075. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  1076. return
  1077. }
  1078. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  1079. var api string
  1080. if miConfig.MdtrtareaAdmvs == "320921" {
  1081. api = "http://192.168.2.110:9532/" + "jsyb/readcard?" + "fixmedins_code=" + miConfig.Code + "&secret_key=" + miConfig.SecretKey + "&ak=" + miConfig.AccessKey + "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName +
  1082. "&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
  1083. fmt.Println(api)
  1084. } else {
  1085. 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 +
  1086. "&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)
  1087. }
  1088. resp, requestErr := http.Get(api)
  1089. if requestErr != nil {
  1090. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1091. return
  1092. }
  1093. body, ioErr := ioutil.ReadAll(resp.Body)
  1094. if ioErr != nil {
  1095. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  1096. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1097. return
  1098. }
  1099. var respJSON map[string]interface{}
  1100. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  1101. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  1102. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1103. return
  1104. }
  1105. var status string
  1106. status = respJSON["data"].(map[string]interface{})["status"].(string)
  1107. card_type := respJSON["data"].(map[string]interface{})["type"].(string)
  1108. //console.log()
  1109. fmt.Println("type===")
  1110. fmt.Println(card_type)
  1111. var token string
  1112. var res ResultTwo //1101结果
  1113. var res10265 ResultTwo10265 //1101结果
  1114. var card_info string //卡信息
  1115. var busi_card_info string
  1116. card_info = respJSON["data"].(map[string]interface{})["card_info"].(string)
  1117. busi_card_info = respJSON["data"].(map[string]interface{})["busi_card_info"].(string)
  1118. if status == "0" { //读卡成功
  1119. if card_type == "1" {
  1120. respJSON = respJSON["data"].(map[string]interface{})["result"].(map[string]interface{})
  1121. result, _ := json.Marshal(respJSON)
  1122. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  1123. utils.ErrorLog("解析失败:%v", err)
  1124. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1125. return
  1126. }
  1127. res.ErrMsg = res10265.ErrMsg
  1128. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  1129. res.Infcode = infocode
  1130. res.Output = res10265.Output
  1131. res.InfRefmsgid = res10265.InfRefmsgid
  1132. } else {
  1133. //var card_info string //卡信息
  1134. //var busi_card_info string
  1135. token = respJSON["data"].(map[string]interface{})["token"].(string)
  1136. //busi_card_info = respJSON["data"].(map[string]interface{})["busi_card_info"].(string)
  1137. //fmt.Println(card_info)
  1138. //fmt.Println(busi_card_info)
  1139. respJSON = respJSON["data"].(map[string]interface{})["result"].(map[string]interface{})
  1140. result, _ := json.Marshal(respJSON)
  1141. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  1142. utils.ErrorLog("解析失败:%v", err)
  1143. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1144. return
  1145. }
  1146. res.ErrMsg = res10265.ErrMsg
  1147. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  1148. res.Infcode = infocode
  1149. res.Output = res10265.Output
  1150. res.InfRefmsgid = res10265.InfRefmsgid
  1151. }
  1152. if res.Infcode == 0 {
  1153. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  1154. if err == gorm.ErrRecordNotFound {
  1155. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  1156. return
  1157. } else if err != nil {
  1158. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  1159. return
  1160. } else {
  1161. if card_type == "1" {
  1162. bas := strings.Split(card_info, "|")
  1163. basNumber := bas[2]
  1164. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  1165. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  1166. infoStr := string(Iinfos)
  1167. idetinfoStr := string(Idetinfos)
  1168. psn := &models.HisPsn{
  1169. PsnNo: res.Output.Baseinfo.PsnNo,
  1170. Age: res.Output.Baseinfo.Age,
  1171. PatientId: patient.ID,
  1172. Certno: res.Output.Baseinfo.Certno,
  1173. Brdy: res.Output.Baseinfo.Brdy,
  1174. Gend: res.Output.Baseinfo.Gend,
  1175. Naty: res.Output.Baseinfo.Naty,
  1176. PsnCertType: res.Output.Baseinfo.PsnCertType,
  1177. PsnName: res.Output.Baseinfo.PsnName,
  1178. Idetinfo: idetinfoStr,
  1179. Insuinfo: infoStr,
  1180. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  1181. CardInfo: card_info,
  1182. VerifyNumber: busi_card_info,
  1183. }
  1184. service.CreateHisPsn(psn)
  1185. var rf []*ResultFive
  1186. json.Unmarshal([]byte(infoStr), &rf)
  1187. var insutypes []*ResultFive
  1188. var insutype string
  1189. var is390 int = 0
  1190. var is310 int = 0
  1191. for _, item := range rf {
  1192. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  1193. insutypes = append(insutypes, item)
  1194. }
  1195. }
  1196. if len(insutypes) == 1 {
  1197. insutype = insutypes[0].Insutype
  1198. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  1199. } else {
  1200. for _, i := range insutypes {
  1201. if i.Insutype == "390" {
  1202. is390 = 1
  1203. }
  1204. if i.Insutype == "310" {
  1205. is310 = 1
  1206. }
  1207. }
  1208. }
  1209. if is390 == 1 {
  1210. insutype = "390"
  1211. }
  1212. if is310 == 1 {
  1213. insutype = "310"
  1214. }
  1215. if len(insutypes) == 0 {
  1216. insutype = "310"
  1217. }
  1218. c.ServeSuccessJSON(map[string]interface{}{
  1219. "patient": patient,
  1220. "number": basNumber,
  1221. "insutype": insutype,
  1222. })
  1223. } else {
  1224. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  1225. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  1226. infoStr := string(Iinfos)
  1227. idetinfoStr := string(Idetinfos)
  1228. psn := &models.HisPsn{
  1229. PsnNo: res.Output.Baseinfo.PsnNo,
  1230. Age: res.Output.Baseinfo.Age,
  1231. PatientId: patient.ID,
  1232. Certno: res.Output.Baseinfo.Certno,
  1233. Brdy: res.Output.Baseinfo.Brdy,
  1234. Gend: res.Output.Baseinfo.Gend,
  1235. Naty: res.Output.Baseinfo.Naty,
  1236. PsnCertType: res.Output.Baseinfo.PsnCertType,
  1237. PsnName: res.Output.Baseinfo.PsnName,
  1238. Idetinfo: idetinfoStr,
  1239. Insuinfo: infoStr,
  1240. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  1241. CardInfo: card_info,
  1242. VerifyNumber: token,
  1243. }
  1244. service.CreateHisPsn(psn)
  1245. c.ServeSuccessJSON(map[string]interface{}{
  1246. "patient": patient,
  1247. "number": token,
  1248. })
  1249. }
  1250. }
  1251. } else {
  1252. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  1253. return
  1254. }
  1255. } else { //读卡失败
  1256. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  1257. return
  1258. }
  1259. } else if miConfig.MdtrtareaAdmvs == "350500" {
  1260. cardnum, cardCode, id_card_no, name, errmsg := c.GetFjBasBaseInfo()
  1261. cardnum = DeleteExtraSpaceTwo(cardnum)
  1262. cardCode = DeleteExtraSpaceTwo(cardCode)
  1263. id_card_no = DeleteExtraSpaceTwo(id_card_no)
  1264. name = DeleteExtraSpaceTwo(name)
  1265. errmsg = DeleteExtraSpaceTwo(errmsg)
  1266. cardnum = Remove0000(cardnum)
  1267. cardCode = Remove0000(cardCode)
  1268. id_card_no = Remove0000(id_card_no)
  1269. name = Remove0000(name)
  1270. errmsg = Remove0000(errmsg)
  1271. basStr := cardnum + "|" + cardCode + "|" + id_card_no + "|" + name
  1272. result, _ := service.FJyb1101(cardnum, miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, id_card_type, cardCode, certificates, miConfig.Url, miConfig.Cainfo, miConfig.AppSecret, miConfig.SignKey, miConfig.EncKey)
  1273. fmt.Println("result:")
  1274. fmt.Println(result)
  1275. var dat map[string]interface{}
  1276. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  1277. fmt.Println(dat)
  1278. } else {
  1279. fmt.Println(err)
  1280. }
  1281. userJSONBytes, _ := json.Marshal(dat)
  1282. var res ResultTwo
  1283. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  1284. utils.ErrorLog("解析失败:%v", err)
  1285. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1286. return
  1287. }
  1288. if res.Infcode == 0 {
  1289. patient, err := service.GetPatientByNumber(id_card_no, c.GetAdminUserInfo().CurrentOrgId)
  1290. if err == gorm.ErrRecordNotFound {
  1291. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  1292. return
  1293. } else if err != nil {
  1294. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  1295. return
  1296. } else {
  1297. fmt.Println(res)
  1298. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  1299. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  1300. infoStr := string(Iinfos)
  1301. idetinfoStr := string(Idetinfos)
  1302. psn := &models.HisPsn{
  1303. PsnNo: res.Output.Baseinfo.PsnNo,
  1304. Age: res.Output.Baseinfo.Age,
  1305. PatientId: patient.ID,
  1306. Certno: res.Output.Baseinfo.Certno,
  1307. Brdy: res.Output.Baseinfo.Brdy,
  1308. Gend: res.Output.Baseinfo.Gend,
  1309. Naty: res.Output.Baseinfo.Naty,
  1310. PsnCertType: res.Output.Baseinfo.PsnCertType,
  1311. PsnName: res.Output.Baseinfo.PsnName,
  1312. Idetinfo: idetinfoStr,
  1313. Insuinfo: infoStr,
  1314. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  1315. CardInfo: basStr,
  1316. VerifyNumber: "",
  1317. }
  1318. service.CreateHisPsn(psn)
  1319. c.ServeSuccessJSON(map[string]interface{}{
  1320. "patient": patient,
  1321. "number": cardnum,
  1322. })
  1323. }
  1324. } else {
  1325. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  1326. return
  1327. }
  1328. } else {
  1329. if initFlag == 0 {
  1330. c.TestGetBasBaseInit()
  1331. }
  1332. basStr := c.GetBasBaseInfo()
  1333. if len(basStr) == 0 {
  1334. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeReadCardException)
  1335. return
  1336. }
  1337. fmt.Println(basStr)
  1338. bas := strings.Split(basStr, "|")
  1339. basNumber := bas[1]
  1340. fmt.Println(basNumber)
  1341. card_sn := bas[3]
  1342. fmt.Println(card_sn)
  1343. result := service.Gdyb1101B(basNumber, miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, id_card_type, card_sn, certificates)
  1344. var dat map[string]interface{}
  1345. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  1346. fmt.Println(dat)
  1347. } else {
  1348. fmt.Println(err)
  1349. }
  1350. userJSONBytes, _ := json.Marshal(dat)
  1351. var res ResultTwo
  1352. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  1353. utils.ErrorLog("解析失败:%v", err)
  1354. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1355. return
  1356. }
  1357. if res.Infcode == 0 {
  1358. patient, err := service.GetPatientByNumber(basNumber, c.GetAdminUserInfo().CurrentOrgId)
  1359. if err == gorm.ErrRecordNotFound {
  1360. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  1361. return
  1362. } else if err != nil {
  1363. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  1364. return
  1365. } else {
  1366. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  1367. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  1368. infoStr := string(Iinfos)
  1369. idetinfoStr := string(Idetinfos)
  1370. psn := &models.HisPsn{
  1371. PsnNo: res.Output.Baseinfo.PsnNo,
  1372. Age: res.Output.Baseinfo.Age,
  1373. PatientId: patient.ID,
  1374. Certno: res.Output.Baseinfo.Certno,
  1375. Brdy: res.Output.Baseinfo.Brdy,
  1376. Gend: res.Output.Baseinfo.Gend,
  1377. Naty: res.Output.Baseinfo.Naty,
  1378. PsnCertType: res.Output.Baseinfo.PsnCertType,
  1379. PsnName: res.Output.Baseinfo.PsnName,
  1380. Idetinfo: idetinfoStr,
  1381. Insuinfo: infoStr,
  1382. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  1383. CardInfo: basStr,
  1384. VerifyNumber: "",
  1385. }
  1386. service.CreateHisPsn(psn)
  1387. c.ServeSuccessJSON(map[string]interface{}{
  1388. "patient": patient,
  1389. "number": basNumber,
  1390. })
  1391. }
  1392. } else {
  1393. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  1394. return
  1395. }
  1396. break
  1397. }
  1398. case 2:
  1399. SFZStr := c.GetSFZBaseInfo()
  1400. id_card_str := strings.Split(SFZStr, "^")
  1401. id_card_number := id_card_str[0]
  1402. card_sn := ""
  1403. result := service.Gdyb1101B(id_card_number, miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, id_card_type, card_sn, certificates)
  1404. var dat map[string]interface{}
  1405. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  1406. fmt.Println(dat)
  1407. } else {
  1408. fmt.Println(err)
  1409. }
  1410. userJSONBytes, _ := json.Marshal(dat)
  1411. var res ResultTwo
  1412. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  1413. utils.ErrorLog("解析失败:%v", err)
  1414. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1415. return
  1416. }
  1417. if res.Infcode == 0 {
  1418. patient, err := service.GetPatientByNumber(id_card_number, c.GetAdminUserInfo().CurrentOrgId)
  1419. if err == gorm.ErrRecordNotFound {
  1420. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  1421. return
  1422. } else if err != nil {
  1423. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  1424. return
  1425. } else {
  1426. c.ServeSuccessJSON(map[string]interface{}{
  1427. "patient": patient,
  1428. "number": id_card_number,
  1429. })
  1430. }
  1431. } else {
  1432. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  1433. return
  1434. }
  1435. break
  1436. case 3:
  1437. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  1438. var api string
  1439. if miConfig.MdtrtareaAdmvs == "320921" {
  1440. api = "http://192.168.2.110:9532/" + "jsyb/readcard?" + "fixmedins_code=" + miConfig.Code + "&secret_key=" + miConfig.SecretKey + "&ak=" + miConfig.AccessKey + "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName +
  1441. "&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
  1442. fmt.Println(api)
  1443. } else {
  1444. 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 +
  1445. "&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)
  1446. }
  1447. resp, requestErr := http.Get(api)
  1448. if requestErr != nil {
  1449. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1450. return
  1451. }
  1452. body, ioErr := ioutil.ReadAll(resp.Body)
  1453. if ioErr != nil {
  1454. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  1455. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1456. return
  1457. }
  1458. var respJSON map[string]interface{}
  1459. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  1460. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  1461. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1462. return
  1463. }
  1464. var status string
  1465. status = respJSON["data"].(map[string]interface{})["status"].(string)
  1466. card_type := respJSON["data"].(map[string]interface{})["type"].(string)
  1467. var token string
  1468. var res ResultTwo //1101结果
  1469. var res10265 ResultTwo10265 //1101结果
  1470. var card_info string //卡信息
  1471. var busi_card_info string
  1472. //card_info = respJSON["data"].(map[string]interface{})["card_info"].(string)
  1473. busi_card_info = respJSON["data"].(map[string]interface{})["busi_card_info"].(string)
  1474. if status == "0" { //读卡成功
  1475. if card_type == "1" {
  1476. respJSON = respJSON["data"].(map[string]interface{})["result"].(map[string]interface{})
  1477. result, _ := json.Marshal(respJSON)
  1478. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  1479. utils.ErrorLog("解析失败:%v", err)
  1480. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1481. return
  1482. }
  1483. res.ErrMsg = res10265.ErrMsg
  1484. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  1485. res.Infcode = infocode
  1486. res.Output = res10265.Output
  1487. res.InfRefmsgid = res10265.InfRefmsgid
  1488. } else {
  1489. //var card_info string //卡信息
  1490. //var busi_card_info string
  1491. token = respJSON["data"].(map[string]interface{})["token"].(string)
  1492. //busi_card_info = respJSON["data"].(map[string]interface{})["busi_card_info"].(string)
  1493. //fmt.Println(card_info)
  1494. //fmt.Println(busi_card_info)
  1495. respJSON = respJSON["data"].(map[string]interface{})["result"].(map[string]interface{})
  1496. result, _ := json.Marshal(respJSON)
  1497. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  1498. utils.ErrorLog("解析失败:%v", err)
  1499. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1500. return
  1501. }
  1502. res.ErrMsg = res10265.ErrMsg
  1503. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  1504. res.Infcode = infocode
  1505. res.Output = res10265.Output
  1506. res.InfRefmsgid = res10265.InfRefmsgid
  1507. }
  1508. if res.Infcode == 0 {
  1509. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  1510. if err == gorm.ErrRecordNotFound {
  1511. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  1512. return
  1513. } else if err != nil {
  1514. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  1515. return
  1516. } else {
  1517. if card_type == "1" {
  1518. bas := strings.Split(card_info, "|")
  1519. basNumber := bas[2]
  1520. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  1521. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  1522. infoStr := string(Iinfos)
  1523. idetinfoStr := string(Idetinfos)
  1524. psn := &models.HisPsn{
  1525. PsnNo: res.Output.Baseinfo.PsnNo,
  1526. Age: res.Output.Baseinfo.Age,
  1527. PatientId: patient.ID,
  1528. Certno: res.Output.Baseinfo.Certno,
  1529. Brdy: res.Output.Baseinfo.Brdy,
  1530. Gend: res.Output.Baseinfo.Gend,
  1531. Naty: res.Output.Baseinfo.Naty,
  1532. PsnCertType: res.Output.Baseinfo.PsnCertType,
  1533. PsnName: res.Output.Baseinfo.PsnName,
  1534. Idetinfo: idetinfoStr,
  1535. Insuinfo: infoStr,
  1536. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  1537. CardInfo: card_info,
  1538. VerifyNumber: busi_card_info,
  1539. }
  1540. service.CreateHisPsn(psn)
  1541. c.ServeSuccessJSON(map[string]interface{}{
  1542. "patient": patient,
  1543. "number": basNumber,
  1544. })
  1545. } else {
  1546. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  1547. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  1548. infoStr := string(Iinfos)
  1549. idetinfoStr := string(Idetinfos)
  1550. psn := &models.HisPsn{
  1551. PsnNo: res.Output.Baseinfo.PsnNo,
  1552. Age: res.Output.Baseinfo.Age,
  1553. PatientId: patient.ID,
  1554. Certno: res.Output.Baseinfo.Certno,
  1555. Brdy: res.Output.Baseinfo.Brdy,
  1556. Gend: res.Output.Baseinfo.Gend,
  1557. Naty: res.Output.Baseinfo.Naty,
  1558. PsnCertType: res.Output.Baseinfo.PsnCertType,
  1559. PsnName: res.Output.Baseinfo.PsnName,
  1560. Idetinfo: idetinfoStr,
  1561. Insuinfo: infoStr,
  1562. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  1563. CardInfo: card_info,
  1564. VerifyNumber: token,
  1565. }
  1566. service.CreateHisPsn(psn)
  1567. var rf []*ResultFive
  1568. json.Unmarshal([]byte(infoStr), &rf)
  1569. var insutypes []*ResultFive
  1570. var insutype string
  1571. var is390 int = 0
  1572. var is310 int = 0
  1573. for _, item := range rf {
  1574. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  1575. insutypes = append(insutypes, item)
  1576. }
  1577. }
  1578. if len(insutypes) == 1 {
  1579. insutype = insutypes[0].Insutype
  1580. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  1581. } else {
  1582. for _, i := range insutypes {
  1583. if i.Insutype == "390" {
  1584. is390 = 1
  1585. }
  1586. if i.Insutype == "310" {
  1587. is310 = 1
  1588. }
  1589. }
  1590. }
  1591. if is390 == 1 {
  1592. insutype = "390"
  1593. }
  1594. if is310 == 1 {
  1595. insutype = "310"
  1596. }
  1597. if len(insutypes) == 0 {
  1598. insutype = "310"
  1599. }
  1600. c.ServeSuccessJSON(map[string]interface{}{
  1601. "patient": patient,
  1602. "number": token,
  1603. "insutype": insutype,
  1604. })
  1605. }
  1606. }
  1607. } else {
  1608. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  1609. return
  1610. }
  1611. } else { //读卡失败
  1612. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  1613. return
  1614. }
  1615. }
  1616. break
  1617. case 4:
  1618. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  1619. var api string
  1620. if miConfig.MdtrtareaAdmvs == "320921" {
  1621. api = "http://192.168.2.110:9532/" + "jsyb/readcard?" + "fixmedins_code=" + miConfig.Code + "&secret_key=" + miConfig.SecretKey + "&ak=" + miConfig.AccessKey + "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName +
  1622. "&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
  1623. fmt.Println(api)
  1624. } else {
  1625. 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 +
  1626. "&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)
  1627. }
  1628. resp, requestErr := http.Get(api)
  1629. if requestErr != nil {
  1630. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1631. return
  1632. }
  1633. body, ioErr := ioutil.ReadAll(resp.Body)
  1634. if ioErr != nil {
  1635. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  1636. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1637. return
  1638. }
  1639. var respJSON map[string]interface{}
  1640. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  1641. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  1642. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1643. return
  1644. }
  1645. var status string
  1646. status = respJSON["data"].(map[string]interface{})["status"].(string)
  1647. //card_type := respJSON["data"].(map[string]interface{})["type"].(string)
  1648. var token string
  1649. var res ResultTwo //1101结果
  1650. var res10265 ResultTwo10265 //1101结果
  1651. if status == "0" { //读卡成功
  1652. var card_info string //卡信息
  1653. var busi_card_info string
  1654. token = respJSON["data"].(map[string]interface{})["token"].(string)
  1655. busi_card_info = respJSON["data"].(map[string]interface{})["busi_card_info"].(string)
  1656. card_info = respJSON["data"].(map[string]interface{})["card_info"].(string)
  1657. fmt.Println(card_info)
  1658. fmt.Println(busi_card_info)
  1659. respJSON = respJSON["data"].(map[string]interface{})["result"].(map[string]interface{})
  1660. result, _ := json.Marshal(respJSON)
  1661. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  1662. utils.ErrorLog("解析失败:%v", err)
  1663. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1664. return
  1665. }
  1666. res.ErrMsg = res10265.ErrMsg
  1667. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  1668. res.Infcode = infocode
  1669. res.Output = res10265.Output
  1670. res.InfRefmsgid = res10265.InfRefmsgid
  1671. if res.Infcode == 0 {
  1672. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  1673. if err == gorm.ErrRecordNotFound {
  1674. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  1675. return
  1676. } else if err != nil {
  1677. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  1678. return
  1679. } else {
  1680. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  1681. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  1682. infoStr := string(Iinfos)
  1683. idetinfoStr := string(Idetinfos)
  1684. psn := &models.HisPsn{
  1685. PsnNo: res.Output.Baseinfo.PsnNo,
  1686. Age: res.Output.Baseinfo.Age,
  1687. PatientId: patient.ID,
  1688. Certno: res.Output.Baseinfo.Certno,
  1689. Brdy: res.Output.Baseinfo.Brdy,
  1690. Gend: res.Output.Baseinfo.Gend,
  1691. Naty: res.Output.Baseinfo.Naty,
  1692. PsnCertType: res.Output.Baseinfo.PsnCertType,
  1693. PsnName: res.Output.Baseinfo.PsnName,
  1694. Idetinfo: idetinfoStr,
  1695. Insuinfo: infoStr,
  1696. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  1697. CardInfo: card_info,
  1698. VerifyNumber: token,
  1699. }
  1700. service.CreateHisPsn(psn)
  1701. c.ServeSuccessJSON(map[string]interface{}{
  1702. "patient": patient,
  1703. "number": token,
  1704. })
  1705. }
  1706. } else {
  1707. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  1708. return
  1709. }
  1710. } else { //读卡失败
  1711. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  1712. return
  1713. }
  1714. } else if miConfig.MdtrtareaAdmvs == "440300" || miConfig.MdtrtareaAdmvs == "440305" {
  1715. }
  1716. break
  1717. }
  1718. }
  1719. var initFlag int64 = 0
  1720. func (c *HisApiController) TestGetBasBaseInit() {
  1721. DllDef := syscall.MustLoadDLL("SSCard.dll")
  1722. Iinit := DllDef.MustFindProc("Init")
  1723. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  1724. ret, _, err := Iinit.Call(StrPtr("http://igb.hsa.gdgov.cn/gdyb_api/prd/api/card/initDll"), StrPtr(miConfig.InsuplcAdmdvs))
  1725. if ret != 0 {
  1726. fmt.Println("SSCard的报错原因:", err)
  1727. fmt.Println("SSCard的运算结果为:", ret)
  1728. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeReadCardException)
  1729. return
  1730. }
  1731. result := int(ret)
  1732. fmt.Println("SSCard的运算结果为1:", result)
  1733. initFlag = 1
  1734. return
  1735. }
  1736. func (c *HisApiController) GetSFZBaseInfo() string {
  1737. DllDef := syscall.MustLoadDLL("SSCard.dll")
  1738. readCard := DllDef.MustFindProc("ReadSFZ")
  1739. if readCard == nil {
  1740. fmt.Println("readcard is nil")
  1741. readCard = DllDef.MustFindProc("ReadSFZ")
  1742. }
  1743. str := make([]byte, 256)
  1744. str1 := make([]byte, 256)
  1745. r, _, _ := readCard.Call((uintptr)(unsafe.Pointer(&str[0])), IntPtr(1024), (uintptr)(unsafe.Pointer(&str1[0])), IntPtr(1024))
  1746. fmt.Println(r)
  1747. return string(str)
  1748. }
  1749. func (c *HisApiController) GetBasBaseInfo() string {
  1750. DllDef := syscall.MustLoadDLL("SSCard.dll")
  1751. readCard := DllDef.MustFindProc("ReadCardBas")
  1752. if readCard == nil {
  1753. fmt.Println("readcard is nil")
  1754. readCard = DllDef.MustFindProc("ReadCardBas")
  1755. }
  1756. str := make([]byte, 1024)
  1757. str1 := make([]byte, 1024)
  1758. ret2, _, _ := readCard.Call((uintptr)(unsafe.Pointer(&str[0])), uintptr(1024), (uintptr)(unsafe.Pointer(&str1[0])), uintptr(1024))
  1759. fmt.Println(string(str1))
  1760. fmt.Println(string(str))
  1761. fmt.Println(":", ConvertToString(string(str1), "gbk", "utf-8"))
  1762. fmt.Println(":", ConvertToString(string(str), "gbk", "utf-8"))
  1763. if ret2 != 0 {
  1764. return ""
  1765. }
  1766. return string(str)
  1767. }
  1768. func (c *HisApiController) GetFjBasBaseInfo() (string, string, string, string, string) {
  1769. DllDef := syscall.MustLoadDLL("chs_fjs_standard.dll")
  1770. readCard := DllDef.MustFindProc("read_cardinfo")
  1771. if readCard == nil {
  1772. fmt.Println("readcard is nil")
  1773. readCard = DllDef.MustFindProc("read_cardinfo")
  1774. }
  1775. str := make([]byte, 1024) //卡号
  1776. str1 := make([]byte, 1024) //卡识别码
  1777. str2 := make([]byte, 1024) //身份证号
  1778. str3 := make([]byte, 1024) //姓名
  1779. str4 := make([]byte, 1024) //错误信息
  1780. ret2, _, _ := readCard.Call((uintptr)(unsafe.Pointer(&str[0])), (uintptr)(unsafe.Pointer(&str1[0])), (uintptr)(unsafe.Pointer(&str2[0])), (uintptr)(unsafe.Pointer(&str3[0])), (uintptr)(unsafe.Pointer(&str4[0])))
  1781. fmt.Println(string(str1))
  1782. fmt.Println(string(str))
  1783. fmt.Println(string(str2))
  1784. fmt.Println(string(str3))
  1785. fmt.Println(string(str4))
  1786. fmt.Println(":", ConvertToString(string(str1), "gbk", "utf-8"))
  1787. fmt.Println(":", ConvertToString(string(str), "gbk", "utf-8"))
  1788. fmt.Println(":", ConvertToString(string(str2), "gbk", "utf-8"))
  1789. fmt.Println(":", ConvertToString(string(str3), "gbk", "utf-8"))
  1790. fmt.Println(":", ConvertToString(string(str4), "gbk", "utf-8"))
  1791. if ret2 != 0 {
  1792. return "", "", "", "", ""
  1793. }
  1794. return string(str), string(str1), string(str2), string(str3), string(str4)
  1795. }
  1796. type CustomFundPay struct {
  1797. FundPayType string `json:"fund_pay_type"`
  1798. FundPayamt float64 `json:"fund_payamt"`
  1799. }
  1800. func (c *HisApiController) GetSettleList() {
  1801. order_id, _ := c.GetInt64("order_id")
  1802. admin_user_id, _ := c.GetInt64("admin_user_id")
  1803. order, _ := service.GetHisOrderByIDTwo(order_id)
  1804. roles, _ := service.GetDoctorListTwo(c.GetAdminUserInfo().CurrentOrgId)
  1805. his, _ := service.GetHisPatientByNumber(order.MdtrtId)
  1806. admin, _ := service.GetAdminUserByUserID(roles[0].AdminUserId)
  1807. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  1808. depart, _ := service.GetDepartMentDetail(curRoles.DepartmentId)
  1809. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  1810. if order.ID == 0 {
  1811. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisOrderNoExistParamWrong)
  1812. return
  1813. }
  1814. last_order, _ := service.GetLastHisOrder(c.GetAdminUserInfo().CurrentOrgId)
  1815. max_order, _ := service.GetLastHisOrderTwo(c.GetAdminUserInfo().CurrentOrgId)
  1816. count, _ := strconv.ParseInt(max_order.FaPiaoNumber, 10, 64)
  1817. fmt.Println(count)
  1818. var zero string
  1819. number := count + 1
  1820. if number >= 1000 {
  1821. zero = "0000" + strconv.FormatInt(number, 10)
  1822. } else if number >= 10000 {
  1823. zero = "000" + strconv.FormatInt(number, 10)
  1824. } else if number >= 100000 {
  1825. zero = "00" + strconv.FormatInt(number, 10)
  1826. } else if number >= 1000000 {
  1827. zero = "0" + strconv.FormatInt(number, 10)
  1828. } else {
  1829. zero = strconv.FormatInt(number, 10)
  1830. }
  1831. fmt.Println(zero)
  1832. struct4101 := service.Struct4101{
  1833. PsnNo: order.PsnNo,
  1834. MdtrtId: order.MdtrtId,
  1835. SetlId: order.SetlId,
  1836. PsnName: order.PsnName,
  1837. Gend: order.Gend,
  1838. Brdy: his.Brdy,
  1839. Age: his.Age,
  1840. Naty: order.Naty,
  1841. PatnCertType: "01",
  1842. Certno: order.Certno,
  1843. Prfs: "90",
  1844. ConerName: roles[0].UserName,
  1845. PatnRlts: "99",
  1846. ConerAddr: miConfig.OrgName,
  1847. ConerTel: admin.Mobile,
  1848. HiType: order.Insutype,
  1849. Insuplc: miConfig.InsuplcAdmdvs,
  1850. MaindiagFlag: "1",
  1851. BillCode: last_order.FaPiaoCode,
  1852. BillNo: zero,
  1853. BizSn: order.Number,
  1854. PsnSelfPay: order.PsnPartAmt,
  1855. PsnOwnPay: order.PsnPartAmt,
  1856. AcctPay: order.AcctPay,
  1857. PsnCashpay: order.PsnCashPay,
  1858. HiPaymtd: "1",
  1859. Hsorg: miConfig.InsuplcAdmdvs,
  1860. HsorgOpter: miConfig.InsuplcAdmdvs,
  1861. MedinsFillPsn: curRoles.UserName,
  1862. MedinsFillDept: depart.Name,
  1863. IptMedType: "2",
  1864. }
  1865. struct4101.SetlBegnDate = order.SetlTime
  1866. struct4101.SetlEndDate = order.SetlTime
  1867. time_arr := strings.Split(order.SetlTime, " ")
  1868. struct4101.AdmTime = time_arr[0]
  1869. struct4101.AdmEndTime = time_arr[0]
  1870. var rf []CustomFundPay
  1871. json.Unmarshal([]byte(order.SetlDetail), &rf)
  1872. var tempFunPays []service.CustomStruct
  1873. for _, item := range rf {
  1874. var tempFunPay service.CustomStruct
  1875. tempFunPay.FundPayamt = item.FundPayamt
  1876. tempFunPay.FundPayType = item.FundPayType
  1877. tempFunPays = append(tempFunPays, tempFunPay)
  1878. }
  1879. struct4101.CustomStruct = tempFunPays
  1880. var tempDiaginfos []service.DiaginfoStructTwo
  1881. var tempOpspdiseinfo2 service.OpspdiseinfoStruct
  1882. var tempOpspdiseinfos []service.OpspdiseinfoStruct
  1883. diagnosis_ids := strings.Split(order.Diagnosis, ",")
  1884. var config []*models.HisXtDiagnoseConfig
  1885. for _, item := range diagnosis_ids {
  1886. id, _ := strconv.ParseInt(item, 10, 64)
  1887. diagnosisConfig, _ := service.FindDiagnoseById(id)
  1888. config = append(config, &diagnosisConfig)
  1889. }
  1890. for index, item := range config {
  1891. if index == 0 {
  1892. var tempDiaginfo service.DiaginfoStructTwo
  1893. tempDiaginfo.DiagCode = item.CountryCode
  1894. tempDiaginfo.DiagName = item.CountryContentName
  1895. tempDiaginfo.DiagType = "1"
  1896. tempDiaginfo.MaindiagFlag = "1"
  1897. tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  1898. } else {
  1899. var tempDiaginfo service.DiaginfoStructTwo
  1900. tempDiaginfo.DiagCode = item.CountryCode
  1901. tempDiaginfo.DiagName = item.CountryContentName
  1902. tempDiaginfo.DiagType = "2"
  1903. tempDiaginfo.MaindiagFlag = "0"
  1904. tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  1905. }
  1906. }
  1907. struct4101.Diseinfo = tempDiaginfos
  1908. sickConfigTwo, _ := service.FindSickById(his.SickType)
  1909. tempOpspdiseinfo2.DiagCode = sickConfigTwo.ContentCode
  1910. tempOpspdiseinfo2.DiagName = sickConfigTwo.CountryContentName
  1911. tempOpspdiseinfo2.OprnOprtCode = sickConfigTwo.ContentCode
  1912. tempOpspdiseinfo2.OprnOprtName = sickConfigTwo.CountryContentName
  1913. tempOpspdiseinfos = append(tempOpspdiseinfos, tempOpspdiseinfo2)
  1914. struct4101.OpspdiseinfoStruct = tempOpspdiseinfos
  1915. var iteminfo service.IteminfoStruct
  1916. var bedCostTotal float64 = 0 //床位总费
  1917. var bedCostSelfTotal float64 = 0 //床位自费
  1918. var bedCostPartSelfTotal float64 = 0 //床位部分项目自费
  1919. var operationCostTotal float64 = 0 //手术费
  1920. var operationCostSelfTotal float64 = 0 //手术费
  1921. var operationCostPartSelfTotal float64 = 0 //手术费
  1922. var otherCostTotal float64 = 0 //其他费用
  1923. var otherCostSelfTotal float64 = 0 //其他费用
  1924. var otherCostPartSelfTotal float64 = 0 //其他费用
  1925. var materialCostTotal float64 = 0 //材料费
  1926. var materialCostSelfTotal float64 = 0 //材料费
  1927. var materialCostPartSelfTotal float64 = 0 //材料费
  1928. var westernMedicineCostTotal float64 = 0 //西药费
  1929. var westernMedicineCostSelfTotal float64 = 0 //西药费
  1930. var westernMedicineCostPartSelfTotal float64 = 0 //西药费
  1931. var chineseTraditionalMedicineCostTotal float64 = 0 //中成药
  1932. var chineseTraditionalMedicineCostSelfTotal float64 = 0 //中成药
  1933. var chineseTraditionalMedicineCostPartSelfTotal float64 = 0 //中成药
  1934. var checkCostTotal float64 = 0 //检查费
  1935. var checkCostSelfTotal float64 = 0 //检查费
  1936. var checkCostPartSelfTotal float64 = 0 //检查费
  1937. var laboratoryCostTotal float64 = 0 //化验费
  1938. var laboratoryCostSelfTotal float64 = 0 //化验费
  1939. var laboratoryCostPartSelfTotal float64 = 0 //化验费
  1940. var treatCostTotal float64 = 0 //治疗费用
  1941. var treatCostSelfTotal float64 = 0 //治疗费用
  1942. var treatCostPartSelfTotal float64 = 0 //治疗费用
  1943. decimal.DivisionPrecision = 2
  1944. var bed_fulamt_ownpay_amt float64 = 0
  1945. var operation_fulamt_ownpay_amt float64 = 0
  1946. var other_fulamt_ownpay_amt float64 = 0
  1947. var westernMedicine_fulamt_ownpay_amt float64 = 0
  1948. var chineseTraditional_fulamt_ownpay_amt float64 = 0
  1949. var check_fulamt_ownpay_amt float64 = 0
  1950. var material_fulamt_ownpay_amt float64 = 0
  1951. var laboratory_fulamt_ownpay_amt float64 = 0
  1952. var treat_fulamt_ownpay_amt float64 = 0
  1953. var bed_claa_sunmfee float64 = 0
  1954. var bed_clab_amt float64 = 0
  1955. var bed_other_amt float64 = 0
  1956. var operation_claa_sunmfee float64 = 0
  1957. var operation_clab_amt float64 = 0
  1958. var operation_other_amt float64 = 0
  1959. var other_claa_sunmfee float64 = 0
  1960. var other_clab_amt float64 = 0
  1961. var other_other_amt float64 = 0
  1962. var westernMedicine_claa_sunmfee float64 = 0
  1963. var westernMedicine_clab_amt float64 = 0
  1964. var westernMedicine_other_amt float64 = 0
  1965. var chineseTraditional_claa_sunmfee float64 = 0
  1966. var chineseTraditional_clab_amt float64 = 0
  1967. var chineseTraditional_other_amt float64 = 0
  1968. var check_claa_sunmfee float64 = 0
  1969. var check_clab_amt float64 = 0
  1970. var check_other_amt float64 = 0
  1971. var material_claa_sunmfee float64 = 0
  1972. var material_clab_amt float64 = 0
  1973. var material_other_amt float64 = 0
  1974. var laboratory_claa_sunmfee float64 = 0
  1975. var laboratory_clab_amt float64 = 0
  1976. var laboratory_other_amt float64 = 0
  1977. var treat_claa_sunmfee float64 = 0
  1978. var treat_clab_amt float64 = 0
  1979. var treat_other_amt float64 = 0
  1980. for _, item := range order.HisOrderInfo {
  1981. if item.MedChrgitmType == "01" { //床位费
  1982. bedCostTotal, _ = decimal.NewFromFloat(bedCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  1983. bedCostSelfTotal, _ = decimal.NewFromFloat(bedCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  1984. bedCostPartSelfTotal, _ = decimal.NewFromFloat(bedCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  1985. bed_fulamt_ownpay_amt, _ = decimal.NewFromFloat(bed_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  1986. if item.ChrgitmLv == "1" {
  1987. bed_claa_sunmfee, _ = decimal.NewFromFloat(bed_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  1988. }
  1989. if item.ChrgitmLv == "2" {
  1990. bed_clab_amt, _ = decimal.NewFromFloat(bed_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  1991. }
  1992. if item.ChrgitmLv == "3" {
  1993. bed_other_amt, _ = decimal.NewFromFloat(bed_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  1994. }
  1995. }
  1996. if item.MedChrgitmType == "03" { //检查费
  1997. checkCostTotal, _ = decimal.NewFromFloat(checkCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  1998. checkCostSelfTotal, _ = decimal.NewFromFloat(checkCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  1999. checkCostPartSelfTotal, _ = decimal.NewFromFloat(checkCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2000. check_fulamt_ownpay_amt, _ = decimal.NewFromFloat(check_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  2001. if item.ChrgitmLv == "1" {
  2002. check_claa_sunmfee, _ = decimal.NewFromFloat(check_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2003. }
  2004. if item.ChrgitmLv == "2" {
  2005. check_clab_amt, _ = decimal.NewFromFloat(check_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2006. }
  2007. if item.ChrgitmLv == "3" {
  2008. check_other_amt, _ = decimal.NewFromFloat(check_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2009. }
  2010. }
  2011. if item.MedChrgitmType == "04" { //化验费
  2012. laboratoryCostTotal, _ = decimal.NewFromFloat(laboratoryCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2013. laboratoryCostSelfTotal, _ = decimal.NewFromFloat(laboratoryCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2014. laboratoryCostPartSelfTotal, _ = decimal.NewFromFloat(laboratoryCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2015. laboratory_fulamt_ownpay_amt, _ = decimal.NewFromFloat(laboratory_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  2016. if item.ChrgitmLv == "1" {
  2017. laboratory_claa_sunmfee, _ = decimal.NewFromFloat(laboratory_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2018. }
  2019. if item.ChrgitmLv == "2" {
  2020. laboratory_clab_amt, _ = decimal.NewFromFloat(laboratory_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2021. }
  2022. if item.ChrgitmLv == "3" {
  2023. laboratory_other_amt, _ = decimal.NewFromFloat(laboratory_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2024. }
  2025. }
  2026. if item.MedChrgitmType == "05" { //治疗费
  2027. treatCostTotal, _ = decimal.NewFromFloat(treatCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2028. treatCostSelfTotal, _ = decimal.NewFromFloat(treatCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2029. treatCostPartSelfTotal, _ = decimal.NewFromFloat(treatCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2030. treat_fulamt_ownpay_amt, _ = decimal.NewFromFloat(treat_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  2031. if item.ChrgitmLv == "1" {
  2032. treat_claa_sunmfee, _ = decimal.NewFromFloat(treat_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2033. }
  2034. if item.ChrgitmLv == "2" {
  2035. treat_clab_amt, _ = decimal.NewFromFloat(treat_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2036. }
  2037. if item.ChrgitmLv == "3" {
  2038. treat_other_amt, _ = decimal.NewFromFloat(treat_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2039. }
  2040. }
  2041. if item.MedChrgitmType == "06" { //手术费
  2042. operationCostTotal, _ = decimal.NewFromFloat(operationCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2043. operationCostSelfTotal, _ = decimal.NewFromFloat(operationCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2044. operationCostPartSelfTotal, _ = decimal.NewFromFloat(operationCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2045. operation_fulamt_ownpay_amt, _ = decimal.NewFromFloat(operation_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  2046. if item.ChrgitmLv == "1" {
  2047. operation_claa_sunmfee, _ = decimal.NewFromFloat(operation_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2048. }
  2049. if item.ChrgitmLv == "2" {
  2050. operation_clab_amt, _ = decimal.NewFromFloat(operation_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2051. }
  2052. if item.ChrgitmLv == "3" {
  2053. operation_other_amt, _ = decimal.NewFromFloat(operation_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2054. }
  2055. }
  2056. if item.MedChrgitmType == "08" { //材料费
  2057. materialCostTotal, _ = decimal.NewFromFloat(materialCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2058. materialCostSelfTotal, _ = decimal.NewFromFloat(materialCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2059. materialCostPartSelfTotal, _ = decimal.NewFromFloat(materialCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2060. material_fulamt_ownpay_amt, _ = decimal.NewFromFloat(material_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  2061. if item.ChrgitmLv == "1" {
  2062. material_claa_sunmfee, _ = decimal.NewFromFloat(material_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2063. }
  2064. if item.ChrgitmLv == "2" {
  2065. material_clab_amt, _ = decimal.NewFromFloat(material_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2066. }
  2067. if item.ChrgitmLv == "3" {
  2068. material_other_amt, _ = decimal.NewFromFloat(material_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2069. }
  2070. }
  2071. if item.MedChrgitmType == "09" { //西药费
  2072. westernMedicineCostTotal, _ = decimal.NewFromFloat(westernMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2073. westernMedicineCostSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2074. westernMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2075. westernMedicine_fulamt_ownpay_amt, _ = decimal.NewFromFloat(westernMedicine_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  2076. if item.ChrgitmLv == "1" {
  2077. westernMedicine_claa_sunmfee, _ = decimal.NewFromFloat(westernMedicine_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2078. }
  2079. if item.ChrgitmLv == "2" {
  2080. westernMedicine_clab_amt, _ = decimal.NewFromFloat(westernMedicine_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2081. }
  2082. if item.ChrgitmLv == "3" {
  2083. westernMedicine_other_amt, _ = decimal.NewFromFloat(westernMedicine_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2084. }
  2085. }
  2086. if item.MedChrgitmType == "11" { //中成费
  2087. chineseTraditionalMedicineCostTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2088. chineseTraditionalMedicineCostSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2089. chineseTraditionalMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2090. chineseTraditional_fulamt_ownpay_amt, _ = decimal.NewFromFloat(chineseTraditional_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  2091. if item.ChrgitmLv == "1" {
  2092. chineseTraditional_claa_sunmfee, _ = decimal.NewFromFloat(chineseTraditional_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2093. }
  2094. if item.ChrgitmLv == "2" {
  2095. chineseTraditional_clab_amt, _ = decimal.NewFromFloat(chineseTraditional_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2096. }
  2097. if item.ChrgitmLv == "3" {
  2098. chineseTraditional_other_amt, _ = decimal.NewFromFloat(chineseTraditional_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2099. }
  2100. }
  2101. if item.MedChrgitmType == "14" { //其他费
  2102. otherCostTotal, _ = decimal.NewFromFloat(otherCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2103. otherCostSelfTotal, _ = decimal.NewFromFloat(otherCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2104. otherCostPartSelfTotal, _ = decimal.NewFromFloat(otherCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2105. other_fulamt_ownpay_amt, _ = decimal.NewFromFloat(other_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  2106. if item.ChrgitmLv == "1" {
  2107. other_claa_sunmfee, _ = decimal.NewFromFloat(other_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2108. }
  2109. if item.ChrgitmLv == "2" {
  2110. other_clab_amt, _ = decimal.NewFromFloat(other_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2111. }
  2112. if item.ChrgitmLv == "3" {
  2113. other_other_amt, _ = decimal.NewFromFloat(other_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2114. }
  2115. }
  2116. }
  2117. var iteminfoStructs []service.IteminfoStruct
  2118. if bedCostTotal != 0 {
  2119. iteminfo.MedChrgitm = "01"
  2120. iteminfo.FulamtOwnpayAmt = bed_fulamt_ownpay_amt
  2121. iteminfo.Amt = bedCostTotal
  2122. iteminfo.ClaaSumfee = bed_claa_sunmfee
  2123. iteminfo.ClabAmt = bed_clab_amt
  2124. iteminfo.OthAmt = bed_other_amt
  2125. iteminfoStructs = append(iteminfoStructs, iteminfo)
  2126. }
  2127. if checkCostTotal != 0 {
  2128. iteminfo.MedChrgitm = "03"
  2129. iteminfo.FulamtOwnpayAmt = check_fulamt_ownpay_amt
  2130. iteminfo.Amt = checkCostTotal
  2131. iteminfo.ClaaSumfee = check_claa_sunmfee
  2132. iteminfo.ClabAmt = check_clab_amt
  2133. iteminfo.OthAmt = check_other_amt
  2134. iteminfoStructs = append(iteminfoStructs, iteminfo)
  2135. }
  2136. if laboratoryCostTotal != 0 {
  2137. iteminfo.MedChrgitm = "04"
  2138. iteminfo.FulamtOwnpayAmt = laboratory_fulamt_ownpay_amt
  2139. iteminfo.Amt = laboratoryCostTotal
  2140. iteminfo.ClaaSumfee = laboratory_claa_sunmfee
  2141. iteminfo.ClabAmt = laboratory_clab_amt
  2142. iteminfo.OthAmt = laboratory_other_amt
  2143. iteminfoStructs = append(iteminfoStructs, iteminfo)
  2144. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  2145. }
  2146. if treatCostTotal != 0 {
  2147. iteminfo.MedChrgitm = "05"
  2148. iteminfo.FulamtOwnpayAmt = treat_fulamt_ownpay_amt
  2149. iteminfo.Amt = treatCostTotal
  2150. iteminfo.ClaaSumfee = treat_claa_sunmfee
  2151. iteminfo.ClabAmt = treat_clab_amt
  2152. iteminfo.OthAmt = treat_other_amt
  2153. iteminfoStructs = append(iteminfoStructs, iteminfo)
  2154. //(struct4101.IteminfoStruct, iteminfo)
  2155. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  2156. }
  2157. if operationCostTotal != 0 {
  2158. iteminfo.MedChrgitm = "06"
  2159. iteminfo.FulamtOwnpayAmt = bed_fulamt_ownpay_amt
  2160. iteminfo.Amt = operationCostTotal
  2161. iteminfo.ClaaSumfee = operation_claa_sunmfee
  2162. iteminfo.ClabAmt = operation_clab_amt
  2163. iteminfo.OthAmt = operation_other_amt
  2164. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  2165. iteminfoStructs = append(iteminfoStructs, iteminfo)
  2166. }
  2167. if materialCostTotal != 0 {
  2168. iteminfo.MedChrgitm = "08"
  2169. iteminfo.FulamtOwnpayAmt = material_fulamt_ownpay_amt
  2170. iteminfo.Amt = materialCostTotal
  2171. iteminfo.ClaaSumfee = material_claa_sunmfee
  2172. iteminfo.ClabAmt = material_clab_amt
  2173. iteminfo.OthAmt = material_other_amt
  2174. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  2175. iteminfoStructs = append(iteminfoStructs, iteminfo)
  2176. }
  2177. if westernMedicineCostTotal != 0 {
  2178. iteminfo.MedChrgitm = "09"
  2179. iteminfo.FulamtOwnpayAmt = westernMedicine_fulamt_ownpay_amt
  2180. iteminfo.Amt = westernMedicineCostTotal
  2181. iteminfo.ClaaSumfee = westernMedicine_claa_sunmfee
  2182. iteminfo.ClabAmt = westernMedicine_clab_amt
  2183. iteminfo.OthAmt = westernMedicine_other_amt
  2184. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  2185. iteminfoStructs = append(iteminfoStructs, iteminfo)
  2186. }
  2187. if chineseTraditionalMedicineCostTotal != 0 {
  2188. iteminfo.MedChrgitm = "11"
  2189. iteminfo.FulamtOwnpayAmt = westernMedicine_fulamt_ownpay_amt
  2190. iteminfo.Amt = westernMedicineCostTotal
  2191. iteminfo.ClaaSumfee = westernMedicine_claa_sunmfee
  2192. iteminfo.ClabAmt = westernMedicine_clab_amt
  2193. iteminfo.OthAmt = westernMedicine_other_amt
  2194. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  2195. iteminfoStructs = append(iteminfoStructs, iteminfo)
  2196. }
  2197. if otherCostTotal != 0 {
  2198. iteminfo.MedChrgitm = "14"
  2199. iteminfo.FulamtOwnpayAmt = other_fulamt_ownpay_amt
  2200. iteminfo.Amt = otherCostTotal
  2201. iteminfo.ClaaSumfee = other_claa_sunmfee
  2202. iteminfo.ClabAmt = other_clab_amt
  2203. iteminfo.OthAmt = other_other_amt
  2204. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  2205. iteminfoStructs = append(iteminfoStructs, iteminfo)
  2206. }
  2207. struct4101.IteminfoStruct = iteminfoStructs
  2208. struct4101.Ntly = "中国"
  2209. struct4101.AdmCaty = "A03.06"
  2210. var res ResultSeventeen
  2211. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  2212. var resOther ResultSeventeenOther
  2213. var pp models.PublicParams
  2214. pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  2215. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  2216. pp.FixmedinsName = miConfig.OrgName
  2217. pp.FixmedinsCode = miConfig.Code
  2218. pp.RequestUrl = miConfig.Url
  2219. pp.Cainfo = miConfig.Cainfo
  2220. pp.SecretKey = miConfig.SecretKey
  2221. pp.AccessKey = miConfig.AccessKey
  2222. pp.OpterName = curRoles.UserName
  2223. client := &http.Client{}
  2224. var req *http.Request
  2225. data := make(map[string]interface{})
  2226. data["struct4101"] = struct4101
  2227. data["pp"] = pp
  2228. bytesData, _ := json.Marshal(data)
  2229. if miConfig.MdtrtareaAdmvs == "320921" {
  2230. req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/4101", bytes.NewReader(bytesData))
  2231. } else {
  2232. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/4101", bytes.NewReader(bytesData))
  2233. }
  2234. resp, _ := client.Do(req)
  2235. defer resp.Body.Close()
  2236. body, ioErr := ioutil.ReadAll(resp.Body)
  2237. if ioErr != nil {
  2238. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  2239. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2240. return
  2241. }
  2242. var respJSON map[string]interface{}
  2243. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  2244. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  2245. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2246. return
  2247. }
  2248. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  2249. userJSONBytes, _ := json.Marshal(respJSON)
  2250. fmt.Println("log")
  2251. fmt.Println(string(userJSONBytes))
  2252. if err := json.Unmarshal(userJSONBytes, &resOther); err != nil {
  2253. utils.ErrorLog("解析失败:%v", err)
  2254. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2255. return
  2256. }
  2257. res.InfRefmsgid = resOther.InfRefmsgid
  2258. res.Output = resOther.Output
  2259. res.ErrMsg = resOther.ErrMsg
  2260. infocode, _ := strconv.ParseInt(resOther.Infcode, 10, 64)
  2261. res.Infcode = infocode
  2262. } else {
  2263. result := service.Gdyb4101(struct4101, miConfig.SecretKey, miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.UserOrgId)
  2264. var dat map[string]interface{}
  2265. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  2266. fmt.Println(dat)
  2267. } else {
  2268. fmt.Println(err)
  2269. }
  2270. userJSONBytes, _ := json.Marshal(dat)
  2271. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  2272. utils.ErrorLog("解析失败:%v", err)
  2273. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2274. return
  2275. }
  2276. }
  2277. if res.Infcode != 0 {
  2278. c.ServeSuccessJSON(map[string]interface{}{
  2279. "failed_code": -10,
  2280. "msg": res.ErrMsg,
  2281. })
  2282. return
  2283. } else {
  2284. order.FaPiaoNumber = zero
  2285. order.FaPiaoCode = last_order.FaPiaoCode
  2286. service.UpdateOrder(order)
  2287. hisFundSettleListResult := &models.HisFundSettleListResult{
  2288. Number: res.Output.SetlListId,
  2289. Status: 1,
  2290. Ctime: time.Now().Unix(),
  2291. Mtime: time.Now().Unix(),
  2292. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  2293. IsUpload: 1,
  2294. OrderId: order_id,
  2295. }
  2296. service.CreateUploadRecord(hisFundSettleListResult)
  2297. c.ServeSuccessJSON(map[string]interface{}{
  2298. "msg": "上传成功",
  2299. "result": hisFundSettleListResult,
  2300. })
  2301. return
  2302. }
  2303. }
  2304. func (c *HisApiController) GetSettleListHospital() {
  2305. order_id, _ := c.GetInt64("order_id")
  2306. admin_user_id, _ := c.GetInt64("admin_user_id")
  2307. order, _ := service.GetHisOrderByIDTwo(order_id)
  2308. roles, _ := service.GetDoctorListTwo(c.GetAdminUserInfo().CurrentOrgId)
  2309. his, _ := service.GetInHospitalRecordByNumber(order.MdtrtId)
  2310. admin, _ := service.GetAdminUserByUserID(roles[0].AdminUserId)
  2311. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  2312. depart, _ := service.GetDepartMentDetail(curRoles.DepartmentId)
  2313. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  2314. if order.ID == 0 {
  2315. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisOrderNoExistParamWrong)
  2316. return
  2317. }
  2318. last_order, _ := service.GetLastHisOrder(c.GetAdminUserInfo().CurrentOrgId)
  2319. max_order, _ := service.GetLastHisOrderTwo(c.GetAdminUserInfo().CurrentOrgId)
  2320. count, _ := strconv.ParseInt(max_order.FaPiaoNumber, 10, 64)
  2321. fmt.Println(count)
  2322. var zero string
  2323. number := count + 1
  2324. if number >= 1000 {
  2325. zero = "0000" + strconv.FormatInt(number, 10)
  2326. } else if number >= 10000 {
  2327. zero = "000" + strconv.FormatInt(number, 10)
  2328. } else if number >= 100000 {
  2329. zero = "00" + strconv.FormatInt(number, 10)
  2330. } else if number >= 1000000 {
  2331. zero = "0" + strconv.FormatInt(number, 10)
  2332. } else {
  2333. zero = strconv.FormatInt(number, 10)
  2334. }
  2335. fmt.Println(zero)
  2336. struct4101 := service.Struct4101{
  2337. PsnNo: order.PsnNo,
  2338. MdtrtId: order.MdtrtId,
  2339. SetlId: order.SetlId,
  2340. PsnName: order.PsnName,
  2341. Gend: order.Gend,
  2342. Brdy: his.Brdy,
  2343. Age: int64(order.Age),
  2344. Naty: order.Naty,
  2345. PatnCertType: "01",
  2346. Certno: order.Certno,
  2347. Prfs: "90",
  2348. ConerName: roles[0].UserName,
  2349. PatnRlts: "99",
  2350. ConerAddr: miConfig.OrgName,
  2351. ConerTel: admin.Mobile,
  2352. HiType: order.Insutype,
  2353. Insuplc: miConfig.InsuplcAdmdvs,
  2354. MaindiagFlag: "1",
  2355. BillCode: last_order.FaPiaoCode,
  2356. BillNo: zero,
  2357. BizSn: order.Number,
  2358. PsnSelfPay: order.PsnPartAmt,
  2359. PsnOwnPay: order.PsnPartAmt,
  2360. AcctPay: order.AcctPay,
  2361. PsnCashpay: order.PsnCashPay,
  2362. HiPaymtd: "1",
  2363. Hsorg: miConfig.InsuplcAdmdvs,
  2364. HsorgOpter: miConfig.InsuplcAdmdvs,
  2365. MedinsFillPsn: curRoles.UserName,
  2366. MedinsFillDept: depart.Name,
  2367. IptMedType: "2",
  2368. AdmTime: his.InHosptialTime,
  2369. AdmEndTime: his.OutHosptialTime,
  2370. }
  2371. struct4101.SetlBegnDate = order.SetlTime
  2372. struct4101.SetlEndDate = order.SetlTime
  2373. var rf []CustomFundPay
  2374. json.Unmarshal([]byte(order.SetlDetail), &rf)
  2375. var tempFunPays []service.CustomStruct
  2376. for _, item := range rf {
  2377. var tempFunPay service.CustomStruct
  2378. tempFunPay.FundPayamt = item.FundPayamt
  2379. tempFunPay.FundPayType = item.FundPayType
  2380. tempFunPays = append(tempFunPays, tempFunPay)
  2381. }
  2382. struct4101.CustomStruct = tempFunPays
  2383. var tempDiaginfos []service.DiaginfoStructTwo
  2384. var tempOpspdiseinfo2 service.OpspdiseinfoStruct
  2385. var tempOpspdiseinfos []service.OpspdiseinfoStruct
  2386. diagnosis_ids := strings.Split(his.Diagnosis, ",")
  2387. var config []*models.HisXtDiagnoseConfig
  2388. for _, item := range diagnosis_ids {
  2389. id, _ := strconv.ParseInt(item, 10, 64)
  2390. diagnosisConfig, _ := service.FindDiagnoseById(id)
  2391. config = append(config, &diagnosisConfig)
  2392. }
  2393. for index, item := range config {
  2394. if index == 0 {
  2395. var tempDiaginfo service.DiaginfoStructTwo
  2396. tempDiaginfo.DiagCode = item.CountryCode
  2397. tempDiaginfo.DiagName = item.CountryContentName
  2398. tempDiaginfo.DiagType = "1"
  2399. tempDiaginfo.MaindiagFlag = "1"
  2400. tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  2401. } else {
  2402. var tempDiaginfo service.DiaginfoStructTwo
  2403. tempDiaginfo.DiagCode = item.CountryCode
  2404. tempDiaginfo.DiagName = item.CountryContentName
  2405. tempDiaginfo.DiagType = "2"
  2406. tempDiaginfo.MaindiagFlag = "0"
  2407. tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  2408. }
  2409. }
  2410. struct4101.Diseinfo = tempDiaginfos
  2411. sickConfigTwo, _ := service.FindSickById(his.SickType)
  2412. tempOpspdiseinfo2.DiagCode = sickConfigTwo.ContentCode
  2413. tempOpspdiseinfo2.DiagName = sickConfigTwo.CountryContentName
  2414. tempOpspdiseinfo2.OprnOprtCode = ""
  2415. tempOpspdiseinfo2.OprnOprtName = ""
  2416. tempOpspdiseinfos = append(tempOpspdiseinfos, tempOpspdiseinfo2)
  2417. struct4101.OpspdiseinfoStruct = tempOpspdiseinfos
  2418. var iteminfo service.IteminfoStruct
  2419. var bedCostTotal float64 = 0 //床位总费
  2420. var bedCostSelfTotal float64 = 0 //床位自费
  2421. var bedCostPartSelfTotal float64 = 0 //床位部分项目自费
  2422. var operationCostTotal float64 = 0 //手术费
  2423. var operationCostSelfTotal float64 = 0 //手术费
  2424. var operationCostPartSelfTotal float64 = 0 //手术费
  2425. var otherCostTotal float64 = 0 //其他费用
  2426. var otherCostSelfTotal float64 = 0 //其他费用
  2427. var otherCostPartSelfTotal float64 = 0 //其他费用
  2428. var materialCostTotal float64 = 0 //材料费
  2429. var materialCostSelfTotal float64 = 0 //材料费
  2430. var materialCostPartSelfTotal float64 = 0 //材料费
  2431. var westernMedicineCostTotal float64 = 0 //西药费
  2432. var westernMedicineCostSelfTotal float64 = 0 //西药费
  2433. var westernMedicineCostPartSelfTotal float64 = 0 //西药费
  2434. var chineseTraditionalMedicineCostTotal float64 = 0 //中成药
  2435. var chineseTraditionalMedicineCostSelfTotal float64 = 0 //中成药
  2436. var chineseTraditionalMedicineCostPartSelfTotal float64 = 0 //中成药
  2437. var checkCostTotal float64 = 0 //检查费
  2438. var checkCostSelfTotal float64 = 0 //检查费
  2439. var checkCostPartSelfTotal float64 = 0 //检查费
  2440. var laboratoryCostTotal float64 = 0 //化验费
  2441. var laboratoryCostSelfTotal float64 = 0 //化验费
  2442. var laboratoryCostPartSelfTotal float64 = 0 //化验费
  2443. var treatCostTotal float64 = 0 //治疗费用
  2444. var treatCostSelfTotal float64 = 0 //治疗费用
  2445. var treatCostPartSelfTotal float64 = 0 //治疗费用
  2446. decimal.DivisionPrecision = 2
  2447. var bed_fulamt_ownpay_amt float64 = 0
  2448. var operation_fulamt_ownpay_amt float64 = 0
  2449. var other_fulamt_ownpay_amt float64 = 0
  2450. var westernMedicine_fulamt_ownpay_amt float64 = 0
  2451. var chineseTraditional_fulamt_ownpay_amt float64 = 0
  2452. var check_fulamt_ownpay_amt float64 = 0
  2453. var material_fulamt_ownpay_amt float64 = 0
  2454. var laboratory_fulamt_ownpay_amt float64 = 0
  2455. var treat_fulamt_ownpay_amt float64 = 0
  2456. var bed_claa_sunmfee float64 = 0
  2457. var bed_clab_amt float64 = 0
  2458. var bed_other_amt float64 = 0
  2459. var operation_claa_sunmfee float64 = 0
  2460. var operation_clab_amt float64 = 0
  2461. var operation_other_amt float64 = 0
  2462. var other_claa_sunmfee float64 = 0
  2463. var other_clab_amt float64 = 0
  2464. var other_other_amt float64 = 0
  2465. var westernMedicine_claa_sunmfee float64 = 0
  2466. var westernMedicine_clab_amt float64 = 0
  2467. var westernMedicine_other_amt float64 = 0
  2468. var chineseTraditional_claa_sunmfee float64 = 0
  2469. var chineseTraditional_clab_amt float64 = 0
  2470. var chineseTraditional_other_amt float64 = 0
  2471. var check_claa_sunmfee float64 = 0
  2472. var check_clab_amt float64 = 0
  2473. var check_other_amt float64 = 0
  2474. var material_claa_sunmfee float64 = 0
  2475. var material_clab_amt float64 = 0
  2476. var material_other_amt float64 = 0
  2477. var laboratory_claa_sunmfee float64 = 0
  2478. var laboratory_clab_amt float64 = 0
  2479. var laboratory_other_amt float64 = 0
  2480. var treat_claa_sunmfee float64 = 0
  2481. var treat_clab_amt float64 = 0
  2482. var treat_other_amt float64 = 0
  2483. for _, item := range order.HisOrderInfo {
  2484. if item.MedChrgitmType == "01" { //床位费
  2485. bedCostTotal, _ = decimal.NewFromFloat(bedCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2486. bedCostSelfTotal, _ = decimal.NewFromFloat(bedCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2487. bedCostPartSelfTotal, _ = decimal.NewFromFloat(bedCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2488. bed_fulamt_ownpay_amt, _ = decimal.NewFromFloat(bed_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  2489. if item.ChrgitmLv == "1" {
  2490. bed_claa_sunmfee, _ = decimal.NewFromFloat(bed_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2491. }
  2492. if item.ChrgitmLv == "2" {
  2493. bed_clab_amt, _ = decimal.NewFromFloat(bed_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2494. }
  2495. if item.ChrgitmLv == "3" {
  2496. bed_other_amt, _ = decimal.NewFromFloat(bed_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2497. }
  2498. }
  2499. if item.MedChrgitmType == "03" { //检查费
  2500. checkCostTotal, _ = decimal.NewFromFloat(checkCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2501. checkCostSelfTotal, _ = decimal.NewFromFloat(checkCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2502. checkCostPartSelfTotal, _ = decimal.NewFromFloat(checkCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2503. check_fulamt_ownpay_amt, _ = decimal.NewFromFloat(check_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  2504. if item.ChrgitmLv == "1" {
  2505. check_claa_sunmfee, _ = decimal.NewFromFloat(check_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2506. }
  2507. if item.ChrgitmLv == "2" {
  2508. check_clab_amt, _ = decimal.NewFromFloat(check_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2509. }
  2510. if item.ChrgitmLv == "3" {
  2511. check_other_amt, _ = decimal.NewFromFloat(check_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2512. }
  2513. }
  2514. if item.MedChrgitmType == "04" { //化验费
  2515. laboratoryCostTotal, _ = decimal.NewFromFloat(laboratoryCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2516. laboratoryCostSelfTotal, _ = decimal.NewFromFloat(laboratoryCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2517. laboratoryCostPartSelfTotal, _ = decimal.NewFromFloat(laboratoryCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2518. laboratory_fulamt_ownpay_amt, _ = decimal.NewFromFloat(laboratory_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  2519. if item.ChrgitmLv == "1" {
  2520. laboratory_claa_sunmfee, _ = decimal.NewFromFloat(laboratory_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2521. }
  2522. if item.ChrgitmLv == "2" {
  2523. laboratory_clab_amt, _ = decimal.NewFromFloat(laboratory_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2524. }
  2525. if item.ChrgitmLv == "3" {
  2526. laboratory_other_amt, _ = decimal.NewFromFloat(laboratory_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2527. }
  2528. }
  2529. if item.MedChrgitmType == "05" { //治疗费
  2530. treatCostTotal, _ = decimal.NewFromFloat(treatCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2531. treatCostSelfTotal, _ = decimal.NewFromFloat(treatCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2532. treatCostPartSelfTotal, _ = decimal.NewFromFloat(treatCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2533. treat_fulamt_ownpay_amt, _ = decimal.NewFromFloat(treat_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  2534. if item.ChrgitmLv == "1" {
  2535. treat_claa_sunmfee, _ = decimal.NewFromFloat(treat_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2536. }
  2537. if item.ChrgitmLv == "2" {
  2538. treat_clab_amt, _ = decimal.NewFromFloat(treat_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2539. }
  2540. if item.ChrgitmLv == "3" {
  2541. treat_other_amt, _ = decimal.NewFromFloat(treat_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2542. }
  2543. }
  2544. if item.MedChrgitmType == "06" { //手术费
  2545. operationCostTotal, _ = decimal.NewFromFloat(operationCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2546. operationCostSelfTotal, _ = decimal.NewFromFloat(operationCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2547. operationCostPartSelfTotal, _ = decimal.NewFromFloat(operationCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2548. operation_fulamt_ownpay_amt, _ = decimal.NewFromFloat(operation_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  2549. if item.ChrgitmLv == "1" {
  2550. operation_claa_sunmfee, _ = decimal.NewFromFloat(operation_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2551. }
  2552. if item.ChrgitmLv == "2" {
  2553. operation_clab_amt, _ = decimal.NewFromFloat(operation_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2554. }
  2555. if item.ChrgitmLv == "3" {
  2556. operation_other_amt, _ = decimal.NewFromFloat(operation_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2557. }
  2558. }
  2559. if item.MedChrgitmType == "08" { //材料费
  2560. materialCostTotal, _ = decimal.NewFromFloat(materialCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2561. materialCostSelfTotal, _ = decimal.NewFromFloat(materialCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2562. materialCostPartSelfTotal, _ = decimal.NewFromFloat(materialCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2563. material_fulamt_ownpay_amt, _ = decimal.NewFromFloat(material_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  2564. if item.ChrgitmLv == "1" {
  2565. material_claa_sunmfee, _ = decimal.NewFromFloat(material_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2566. }
  2567. if item.ChrgitmLv == "2" {
  2568. material_clab_amt, _ = decimal.NewFromFloat(material_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2569. }
  2570. if item.ChrgitmLv == "3" {
  2571. material_other_amt, _ = decimal.NewFromFloat(material_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2572. }
  2573. }
  2574. if item.MedChrgitmType == "09" { //西药费
  2575. westernMedicineCostTotal, _ = decimal.NewFromFloat(westernMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2576. westernMedicineCostSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2577. westernMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2578. westernMedicine_fulamt_ownpay_amt, _ = decimal.NewFromFloat(westernMedicine_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  2579. if item.ChrgitmLv == "1" {
  2580. westernMedicine_claa_sunmfee, _ = decimal.NewFromFloat(westernMedicine_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2581. }
  2582. if item.ChrgitmLv == "2" {
  2583. westernMedicine_clab_amt, _ = decimal.NewFromFloat(westernMedicine_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2584. }
  2585. if item.ChrgitmLv == "3" {
  2586. westernMedicine_other_amt, _ = decimal.NewFromFloat(westernMedicine_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2587. }
  2588. }
  2589. if item.MedChrgitmType == "11" { //中成费
  2590. chineseTraditionalMedicineCostTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2591. chineseTraditionalMedicineCostSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2592. chineseTraditionalMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2593. chineseTraditional_fulamt_ownpay_amt, _ = decimal.NewFromFloat(chineseTraditional_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  2594. if item.ChrgitmLv == "1" {
  2595. chineseTraditional_claa_sunmfee, _ = decimal.NewFromFloat(chineseTraditional_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2596. }
  2597. if item.ChrgitmLv == "2" {
  2598. chineseTraditional_clab_amt, _ = decimal.NewFromFloat(chineseTraditional_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2599. }
  2600. if item.ChrgitmLv == "3" {
  2601. chineseTraditional_other_amt, _ = decimal.NewFromFloat(chineseTraditional_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2602. }
  2603. }
  2604. if item.MedChrgitmType == "14" { //其他费
  2605. otherCostTotal, _ = decimal.NewFromFloat(otherCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2606. otherCostSelfTotal, _ = decimal.NewFromFloat(otherCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2607. otherCostPartSelfTotal, _ = decimal.NewFromFloat(otherCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2608. other_fulamt_ownpay_amt, _ = decimal.NewFromFloat(other_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  2609. if item.ChrgitmLv == "1" {
  2610. other_claa_sunmfee, _ = decimal.NewFromFloat(other_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2611. }
  2612. if item.ChrgitmLv == "2" {
  2613. other_clab_amt, _ = decimal.NewFromFloat(other_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2614. }
  2615. if item.ChrgitmLv == "3" {
  2616. other_other_amt, _ = decimal.NewFromFloat(other_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2617. }
  2618. }
  2619. }
  2620. var iteminfoStructs []service.IteminfoStruct
  2621. if bedCostTotal != 0 {
  2622. iteminfo.MedChrgitm = "01"
  2623. iteminfo.FulamtOwnpayAmt = bed_fulamt_ownpay_amt
  2624. iteminfo.Amt = bedCostTotal
  2625. iteminfo.ClaaSumfee = bed_claa_sunmfee
  2626. iteminfo.ClabAmt = bed_clab_amt
  2627. iteminfo.OthAmt = bed_other_amt
  2628. iteminfoStructs = append(iteminfoStructs, iteminfo)
  2629. }
  2630. if checkCostTotal != 0 {
  2631. iteminfo.MedChrgitm = "03"
  2632. iteminfo.FulamtOwnpayAmt = check_fulamt_ownpay_amt
  2633. iteminfo.Amt = checkCostTotal
  2634. iteminfo.ClaaSumfee = check_claa_sunmfee
  2635. iteminfo.ClabAmt = check_clab_amt
  2636. iteminfo.OthAmt = check_other_amt
  2637. iteminfoStructs = append(iteminfoStructs, iteminfo)
  2638. }
  2639. if laboratoryCostTotal != 0 {
  2640. iteminfo.MedChrgitm = "04"
  2641. iteminfo.FulamtOwnpayAmt = laboratory_fulamt_ownpay_amt
  2642. iteminfo.Amt = laboratoryCostTotal
  2643. iteminfo.ClaaSumfee = laboratory_claa_sunmfee
  2644. iteminfo.ClabAmt = laboratory_clab_amt
  2645. iteminfo.OthAmt = laboratory_other_amt
  2646. iteminfoStructs = append(iteminfoStructs, iteminfo)
  2647. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  2648. }
  2649. if treatCostTotal != 0 {
  2650. iteminfo.MedChrgitm = "05"
  2651. iteminfo.FulamtOwnpayAmt = treat_fulamt_ownpay_amt
  2652. iteminfo.Amt = treatCostTotal
  2653. iteminfo.ClaaSumfee = treat_claa_sunmfee
  2654. iteminfo.ClabAmt = treat_clab_amt
  2655. iteminfo.OthAmt = treat_other_amt
  2656. iteminfoStructs = append(iteminfoStructs, iteminfo)
  2657. //(struct4101.IteminfoStruct, iteminfo)
  2658. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  2659. }
  2660. if operationCostTotal != 0 {
  2661. iteminfo.MedChrgitm = "06"
  2662. iteminfo.FulamtOwnpayAmt = bed_fulamt_ownpay_amt
  2663. iteminfo.Amt = operationCostTotal
  2664. iteminfo.ClaaSumfee = operation_claa_sunmfee
  2665. iteminfo.ClabAmt = operation_clab_amt
  2666. iteminfo.OthAmt = operation_other_amt
  2667. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  2668. iteminfoStructs = append(iteminfoStructs, iteminfo)
  2669. }
  2670. if materialCostTotal != 0 {
  2671. iteminfo.MedChrgitm = "08"
  2672. iteminfo.FulamtOwnpayAmt = material_fulamt_ownpay_amt
  2673. iteminfo.Amt = materialCostTotal
  2674. iteminfo.ClaaSumfee = material_claa_sunmfee
  2675. iteminfo.ClabAmt = material_clab_amt
  2676. iteminfo.OthAmt = material_other_amt
  2677. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  2678. iteminfoStructs = append(iteminfoStructs, iteminfo)
  2679. }
  2680. if westernMedicineCostTotal != 0 {
  2681. iteminfo.MedChrgitm = "09"
  2682. iteminfo.FulamtOwnpayAmt = westernMedicine_fulamt_ownpay_amt
  2683. iteminfo.Amt = westernMedicineCostTotal
  2684. iteminfo.ClaaSumfee = westernMedicine_claa_sunmfee
  2685. iteminfo.ClabAmt = westernMedicine_clab_amt
  2686. iteminfo.OthAmt = westernMedicine_other_amt
  2687. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  2688. iteminfoStructs = append(iteminfoStructs, iteminfo)
  2689. }
  2690. if chineseTraditionalMedicineCostTotal != 0 {
  2691. iteminfo.MedChrgitm = "11"
  2692. iteminfo.FulamtOwnpayAmt = westernMedicine_fulamt_ownpay_amt
  2693. iteminfo.Amt = westernMedicineCostTotal
  2694. iteminfo.ClaaSumfee = westernMedicine_claa_sunmfee
  2695. iteminfo.ClabAmt = westernMedicine_clab_amt
  2696. iteminfo.OthAmt = westernMedicine_other_amt
  2697. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  2698. iteminfoStructs = append(iteminfoStructs, iteminfo)
  2699. }
  2700. if otherCostTotal != 0 {
  2701. iteminfo.MedChrgitm = "14"
  2702. iteminfo.FulamtOwnpayAmt = other_fulamt_ownpay_amt
  2703. iteminfo.Amt = otherCostTotal
  2704. iteminfo.ClaaSumfee = other_claa_sunmfee
  2705. iteminfo.ClabAmt = other_clab_amt
  2706. iteminfo.OthAmt = other_other_amt
  2707. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  2708. iteminfoStructs = append(iteminfoStructs, iteminfo)
  2709. }
  2710. struct4101.IteminfoStruct = iteminfoStructs
  2711. struct4101.Ntly = "中国"
  2712. struct4101.AdmCaty = "A03.06"
  2713. result := service.Gdyb4101(struct4101, miConfig.SecretKey, miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.UserOrgId)
  2714. fmt.Println(result)
  2715. var dat map[string]interface{}
  2716. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  2717. fmt.Println(dat)
  2718. } else {
  2719. fmt.Println(err)
  2720. }
  2721. userJSONBytes, _ := json.Marshal(dat)
  2722. var res ResultSeventeen
  2723. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  2724. utils.ErrorLog("解析失败:%v", err)
  2725. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2726. return
  2727. }
  2728. if res.Infcode != 0 {
  2729. c.ServeSuccessJSON(map[string]interface{}{
  2730. "failed_code": -10,
  2731. "msg": res.ErrMsg,
  2732. })
  2733. return
  2734. } else {
  2735. order.FaPiaoNumber = zero
  2736. order.FaPiaoCode = last_order.FaPiaoCode
  2737. service.UpdateOrder(order)
  2738. hisFundSettleListResult := &models.HisFundSettleListResult{
  2739. Number: res.Output.SetlListId,
  2740. Status: 1,
  2741. Ctime: time.Now().Unix(),
  2742. Mtime: time.Now().Unix(),
  2743. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  2744. IsUpload: 1,
  2745. OrderId: order_id,
  2746. }
  2747. service.CreateUploadRecord(hisFundSettleListResult)
  2748. c.ServeSuccessJSON(map[string]interface{}{
  2749. "msg": "上传成功",
  2750. "result": hisFundSettleListResult,
  2751. })
  2752. return
  2753. }
  2754. }
  2755. func (c *HisApiController) GetBatchSettleList() {
  2756. orders, _ := service.GetAllHisOrder(10106)
  2757. for _, item := range orders {
  2758. order_id := item.ID
  2759. order, _ := service.GetHisOrderByIDTwo(order_id)
  2760. roles, _ := service.GetDoctorListTwo(c.GetAdminUserInfo().CurrentOrgId)
  2761. his, _ := service.GetHisPatientByNumber(order.MdtrtId)
  2762. admin, _ := service.GetAdminUserByUserID(roles[0].AdminUserId)
  2763. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, 2495)
  2764. depart, _ := service.GetDepartMentDetail(curRoles.DepartmentId)
  2765. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  2766. if order.ID == 0 {
  2767. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisOrderNoExistParamWrong)
  2768. return
  2769. }
  2770. if his.BalanceAccountsType == 2 {
  2771. continue
  2772. }
  2773. struct4101 := service.Struct4101{
  2774. PsnNo: order.PsnNo,
  2775. MdtrtId: order.MdtrtId,
  2776. SetlId: order.SetlId,
  2777. PsnName: order.PsnName,
  2778. Gend: order.Gend,
  2779. Brdy: his.Brdy,
  2780. Age: his.Age,
  2781. Naty: order.Naty,
  2782. PatnCertType: "01",
  2783. Certno: order.Certno,
  2784. Prfs: "90",
  2785. ConerName: roles[0].UserName,
  2786. PatnRlts: "99",
  2787. ConerAddr: miConfig.OrgName,
  2788. ConerTel: admin.Mobile,
  2789. HiType: order.Insutype,
  2790. Insuplc: his.InsuplcAdmdvs,
  2791. MaindiagFlag: "1",
  2792. BillCode: order.FaPiaoCode,
  2793. BillNo: order.FaPiaoNumber,
  2794. BizSn: order.Number,
  2795. PsnSelfPay: order.PsnPartAmt,
  2796. PsnOwnPay: order.PsnPartAmt,
  2797. AcctPay: order.AcctPay,
  2798. PsnCashpay: order.PsnCashPay,
  2799. HiPaymtd: "1",
  2800. Hsorg: his.InsuplcAdmdvs,
  2801. HsorgOpter: his.InsuplcAdmdvs,
  2802. MedinsFillPsn: curRoles.UserName,
  2803. MedinsFillDept: depart.Name,
  2804. IptMedType: "2",
  2805. }
  2806. struct4101.SetlBegnDate = order.SetlTime
  2807. struct4101.SetlEndDate = order.SetlTime
  2808. //if order.SettleType == 1 {
  2809. // t := time.Unix(int64(order.SettleAccountsDate), 0)
  2810. // dateStr := t.Format("2006-01-02")
  2811. // struct4101.SetlBegnDate = dateStr
  2812. // struct4101.SetlEndDate = dateStr
  2813. //} else {
  2814. // t := time.Unix(int64(order.SettleStartTime), 0)
  2815. // t2 := time.Unix(int64(order.SettleEndTime), 0)
  2816. // dateStartStr := t.Format("2006-01-02")
  2817. // dateEndStr := t2.Format("2006-01-02")
  2818. // struct4101.SetlBegnDate = dateStartStr
  2819. // struct4101.SetlEndDate = dateEndStr
  2820. //}
  2821. var rf []CustomFundPay
  2822. json.Unmarshal([]byte(order.SetlDetail), &rf)
  2823. var tempFunPays []service.CustomStruct
  2824. var tempFunPay610100 service.CustomStruct
  2825. for _, item := range rf {
  2826. if item.FundPayType == "610100" {
  2827. tempFunPay610100.FundPayamt, _ = decimal.NewFromFloat(tempFunPay610100.FundPayamt).Add(decimal.NewFromFloat(item.FundPayamt)).Float64()
  2828. tempFunPay610100.FundPayType = item.FundPayType
  2829. } else {
  2830. var tempFunPay service.CustomStruct
  2831. tempFunPay.FundPayamt = item.FundPayamt
  2832. tempFunPay.FundPayType = item.FundPayType
  2833. tempFunPays = append(tempFunPays, tempFunPay)
  2834. }
  2835. }
  2836. tempFunPays = append(tempFunPays, tempFunPay610100)
  2837. struct4101.CustomStruct = tempFunPays
  2838. var tempDiaginfos []service.DiaginfoStructTwo
  2839. var tempOpspdiseinfo2 service.OpspdiseinfoStruct
  2840. var tempOpspdiseinfos []service.OpspdiseinfoStruct
  2841. diagnosis_ids := strings.Split(his.Diagnosis, ",")
  2842. var config []*models.HisXtDiagnoseConfig
  2843. for _, item := range diagnosis_ids {
  2844. id, _ := strconv.ParseInt(item, 10, 64)
  2845. diagnosisConfig, _ := service.FindDiagnoseById(id)
  2846. config = append(config, &diagnosisConfig)
  2847. }
  2848. for index, item := range config {
  2849. if index == 0 {
  2850. var tempDiaginfo service.DiaginfoStructTwo
  2851. tempDiaginfo.DiagCode = item.CountryCode
  2852. tempDiaginfo.DiagName = item.CountryContentName
  2853. tempDiaginfo.DiagType = "1"
  2854. tempDiaginfo.MaindiagFlag = "1"
  2855. tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  2856. } else {
  2857. var tempDiaginfo service.DiaginfoStructTwo
  2858. tempDiaginfo.DiagCode = item.CountryCode
  2859. tempDiaginfo.DiagName = item.CountryContentName
  2860. tempDiaginfo.DiagType = "2"
  2861. tempDiaginfo.MaindiagFlag = "0"
  2862. tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  2863. }
  2864. }
  2865. struct4101.Diseinfo = tempDiaginfos
  2866. sickConfigTwo, _ := service.FindSickById(his.SickType)
  2867. tempOpspdiseinfo2.DiagCode = sickConfigTwo.ContentCode
  2868. tempOpspdiseinfo2.DiagName = sickConfigTwo.CountryContentName
  2869. tempOpspdiseinfo2.OprnOprtCode = ""
  2870. tempOpspdiseinfo2.OprnOprtName = ""
  2871. tempOpspdiseinfos = append(tempOpspdiseinfos, tempOpspdiseinfo2)
  2872. struct4101.OpspdiseinfoStruct = tempOpspdiseinfos
  2873. var iteminfo service.IteminfoStruct
  2874. var bedCostTotal float64 = 0 //床位总费
  2875. var bedCostSelfTotal float64 = 0 //床位自费
  2876. var bedCostPartSelfTotal float64 = 0 //床位部分项目自费
  2877. var examineCostTotal float64 = 0 //诊查总费
  2878. var examineCostSelfTotal float64 = 0 //诊查自费
  2879. var examineCostPartSelfTotal float64 = 0 //诊查部分项目自费
  2880. var nursingCostTotal float64 = 0 //护理总费
  2881. var nursingCostSelfTotal float64 = 0 //护理自费
  2882. var nursingCostPartSelfTotal float64 = 0 //护理部分项目自费
  2883. var chineseMedicineCostTotal float64 = 0 //中成药
  2884. var chineseMedicineCostSelfTotal float64 = 0 //中成药
  2885. var chineseMedicineCostPartSelfTotal float64 = 0 //中成药
  2886. var commonlyTreatmentCostTotal float64 = 0 //一般诊疗费
  2887. var commonlyTreatmentCostSelfTotal float64 = 0 //一般诊疗费
  2888. var commonlyTreatmentCostPartSelfTotal float64 = 0 //一般诊疗费
  2889. var registerCostTotal float64 = 0 //一般诊疗费
  2890. var registerCostSelfTotal float64 = 0 //一般诊疗费
  2891. var registerPartSelfTotal float64 = 0 //一般诊疗费
  2892. var operationCostTotal float64 = 0 //手术费
  2893. var operationCostSelfTotal float64 = 0 //手术费
  2894. var operationCostPartSelfTotal float64 = 0 //手术费
  2895. var otherCostTotal float64 = 0 //其他费用
  2896. var otherCostSelfTotal float64 = 0 //其他费用
  2897. var otherCostPartSelfTotal float64 = 0 //其他费用
  2898. var materialCostTotal float64 = 0 //材料费
  2899. var materialCostSelfTotal float64 = 0 //材料费
  2900. var materialCostPartSelfTotal float64 = 0 //材料费
  2901. var westernMedicineCostTotal float64 = 0 //西药费
  2902. var westernMedicineCostSelfTotal float64 = 0 //西药费
  2903. var westernMedicineCostPartSelfTotal float64 = 0 //西药费
  2904. var chineseTraditionalMedicineCostTotal float64 = 0 //中成药
  2905. var chineseTraditionalMedicineCostSelfTotal float64 = 0 //中成药
  2906. var chineseTraditionalMedicineCostPartSelfTotal float64 = 0 //中成药
  2907. var checkCostTotal float64 = 0 //检查费
  2908. var checkCostSelfTotal float64 = 0 //检查费
  2909. var checkCostPartSelfTotal float64 = 0 //检查费
  2910. var laboratoryCostTotal float64 = 0 //化验费
  2911. var laboratoryCostSelfTotal float64 = 0 //化验费
  2912. var laboratoryCostPartSelfTotal float64 = 0 //化验费
  2913. var treatCostTotal float64 = 0 //治疗费用
  2914. var treatCostSelfTotal float64 = 0 //治疗费用
  2915. var treatCostPartSelfTotal float64 = 0 //治疗费用
  2916. decimal.DivisionPrecision = 2
  2917. var bed_fulamt_ownpay_amt float64 = 0
  2918. var examine_fulamt_ownpay_amt float64 = 0
  2919. var nursing_fulamt_ownpay_amt float64 = 0
  2920. var chinese_medicine_fulamt_ownpay_amt float64 = 0
  2921. var commonly_treatment_fulamt_ownpay_amt float64 = 0
  2922. var register_fulamt_ownpay_amt float64 = 0
  2923. var operation_fulamt_ownpay_amt float64 = 0
  2924. var other_fulamt_ownpay_amt float64 = 0
  2925. var westernMedicine_fulamt_ownpay_amt float64 = 0
  2926. var chineseTraditional_fulamt_ownpay_amt float64 = 0
  2927. var check_fulamt_ownpay_amt float64 = 0
  2928. var material_fulamt_ownpay_amt float64 = 0
  2929. var laboratory_fulamt_ownpay_amt float64 = 0
  2930. var treat_fulamt_ownpay_amt float64 = 0
  2931. var bed_claa_sunmfee float64 = 0
  2932. var bed_clab_amt float64 = 0
  2933. var bed_other_amt float64 = 0
  2934. var examine_claa_sunmfee float64 = 0
  2935. var examine_clab_amt float64 = 0
  2936. var examine_other_amt float64 = 0
  2937. var nursing_claa_sunmfee float64 = 0
  2938. var nursing_clab_amt float64 = 0
  2939. var nursing_other_amt float64 = 0
  2940. var chinese_medicine_claa_sunmfee float64 = 0
  2941. var chinese_medicine_clab_amt float64 = 0
  2942. var chinese_medicine_other_amt float64 = 0
  2943. var commonly_treatment_claa_sunmfee float64 = 0
  2944. var commonly_treatment_clab_amt float64 = 0
  2945. var commonly_treatment_other_amt float64 = 0
  2946. var operation_claa_sunmfee float64 = 0
  2947. var operation_clab_amt float64 = 0
  2948. var operation_other_amt float64 = 0
  2949. var other_claa_sunmfee float64 = 0
  2950. var other_clab_amt float64 = 0
  2951. var other_other_amt float64 = 0
  2952. var westernMedicine_claa_sunmfee float64 = 0
  2953. var westernMedicine_clab_amt float64 = 0
  2954. var westernMedicine_other_amt float64 = 0
  2955. var chineseTraditional_claa_sunmfee float64 = 0
  2956. var chineseTraditional_clab_amt float64 = 0
  2957. var chineseTraditional_other_amt float64 = 0
  2958. var check_claa_sunmfee float64 = 0
  2959. var check_clab_amt float64 = 0
  2960. var check_other_amt float64 = 0
  2961. var material_claa_sunmfee float64 = 0
  2962. var material_clab_amt float64 = 0
  2963. var material_other_amt float64 = 0
  2964. var laboratory_claa_sunmfee float64 = 0
  2965. var laboratory_clab_amt float64 = 0
  2966. var laboratory_other_amt float64 = 0
  2967. var treat_claa_sunmfee float64 = 0
  2968. var treat_clab_amt float64 = 0
  2969. var treat_other_amt float64 = 0
  2970. var register_claa_sunmfee float64 = 0
  2971. var register_clab_amt float64 = 0
  2972. var register_other_amt float64 = 0
  2973. for _, item := range order.HisOrderInfo {
  2974. if item.MedChrgitmType == "01" { //床位费
  2975. bedCostTotal, _ = decimal.NewFromFloat(bedCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2976. bedCostSelfTotal, _ = decimal.NewFromFloat(bedCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2977. bedCostPartSelfTotal, _ = decimal.NewFromFloat(bedCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2978. bed_fulamt_ownpay_amt, _ = decimal.NewFromFloat(bed_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  2979. if item.ChrgitmLv == "1" {
  2980. bed_claa_sunmfee, _ = decimal.NewFromFloat(bed_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2981. }
  2982. if item.ChrgitmLv == "2" {
  2983. bed_clab_amt, _ = decimal.NewFromFloat(bed_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2984. }
  2985. if item.ChrgitmLv == "3" {
  2986. bed_other_amt, _ = decimal.NewFromFloat(bed_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2987. }
  2988. }
  2989. if item.MedChrgitmType == "02" { //诊查
  2990. examineCostTotal, _ = decimal.NewFromFloat(examineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2991. examineCostSelfTotal, _ = decimal.NewFromFloat(examineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2992. examineCostPartSelfTotal, _ = decimal.NewFromFloat(examineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2993. examine_fulamt_ownpay_amt, _ = decimal.NewFromFloat(examine_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  2994. if item.ChrgitmLv == "1" {
  2995. examine_claa_sunmfee, _ = decimal.NewFromFloat(examine_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2996. }
  2997. if item.ChrgitmLv == "2" {
  2998. examine_clab_amt, _ = decimal.NewFromFloat(examine_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2999. }
  3000. if item.ChrgitmLv == "3" {
  3001. examine_other_amt, _ = decimal.NewFromFloat(examine_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  3002. }
  3003. }
  3004. if item.MedChrgitmType == "03" { //检查费
  3005. checkCostTotal, _ = decimal.NewFromFloat(checkCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  3006. checkCostSelfTotal, _ = decimal.NewFromFloat(checkCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  3007. checkCostPartSelfTotal, _ = decimal.NewFromFloat(checkCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  3008. check_fulamt_ownpay_amt, _ = decimal.NewFromFloat(check_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  3009. if item.ChrgitmLv == "1" {
  3010. check_claa_sunmfee, _ = decimal.NewFromFloat(check_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  3011. }
  3012. if item.ChrgitmLv == "2" {
  3013. check_clab_amt, _ = decimal.NewFromFloat(check_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  3014. }
  3015. if item.ChrgitmLv == "3" {
  3016. check_other_amt, _ = decimal.NewFromFloat(check_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  3017. }
  3018. }
  3019. if item.MedChrgitmType == "04" { //化验费
  3020. laboratoryCostTotal, _ = decimal.NewFromFloat(laboratoryCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  3021. laboratoryCostSelfTotal, _ = decimal.NewFromFloat(laboratoryCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  3022. laboratoryCostPartSelfTotal, _ = decimal.NewFromFloat(laboratoryCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  3023. laboratory_fulamt_ownpay_amt, _ = decimal.NewFromFloat(laboratory_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  3024. if item.ChrgitmLv == "1" {
  3025. laboratory_claa_sunmfee, _ = decimal.NewFromFloat(laboratory_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  3026. }
  3027. if item.ChrgitmLv == "2" {
  3028. laboratory_clab_amt, _ = decimal.NewFromFloat(laboratory_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  3029. }
  3030. if item.ChrgitmLv == "3" {
  3031. laboratory_other_amt, _ = decimal.NewFromFloat(laboratory_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  3032. }
  3033. }
  3034. if item.MedChrgitmType == "05" { //治疗费
  3035. treatCostTotal, _ = decimal.NewFromFloat(treatCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  3036. treatCostSelfTotal, _ = decimal.NewFromFloat(treatCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  3037. treatCostPartSelfTotal, _ = decimal.NewFromFloat(treatCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  3038. treat_fulamt_ownpay_amt, _ = decimal.NewFromFloat(treat_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  3039. if item.ChrgitmLv == "1" {
  3040. treat_claa_sunmfee, _ = decimal.NewFromFloat(treat_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  3041. }
  3042. if item.ChrgitmLv == "2" {
  3043. treat_clab_amt, _ = decimal.NewFromFloat(treat_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  3044. }
  3045. if item.ChrgitmLv == "3" {
  3046. treat_other_amt, _ = decimal.NewFromFloat(treat_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  3047. }
  3048. }
  3049. if item.MedChrgitmType == "06" { //手术费
  3050. operationCostTotal, _ = decimal.NewFromFloat(operationCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  3051. operationCostSelfTotal, _ = decimal.NewFromFloat(operationCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  3052. operationCostPartSelfTotal, _ = decimal.NewFromFloat(operationCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  3053. operation_fulamt_ownpay_amt, _ = decimal.NewFromFloat(operation_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  3054. if item.ChrgitmLv == "1" {
  3055. operation_claa_sunmfee, _ = decimal.NewFromFloat(operation_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  3056. }
  3057. if item.ChrgitmLv == "2" {
  3058. operation_clab_amt, _ = decimal.NewFromFloat(operation_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  3059. }
  3060. if item.ChrgitmLv == "3" {
  3061. operation_other_amt, _ = decimal.NewFromFloat(operation_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  3062. }
  3063. }
  3064. if item.MedChrgitmType == "07" { //手术费
  3065. nursingCostTotal, _ = decimal.NewFromFloat(nursingCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  3066. nursingCostSelfTotal, _ = decimal.NewFromFloat(nursingCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  3067. nursingCostPartSelfTotal, _ = decimal.NewFromFloat(nursingCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  3068. nursing_fulamt_ownpay_amt, _ = decimal.NewFromFloat(nursing_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  3069. if item.ChrgitmLv == "1" {
  3070. nursing_claa_sunmfee, _ = decimal.NewFromFloat(nursing_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  3071. }
  3072. if item.ChrgitmLv == "2" {
  3073. nursing_clab_amt, _ = decimal.NewFromFloat(nursing_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  3074. }
  3075. if item.ChrgitmLv == "3" {
  3076. nursing_other_amt, _ = decimal.NewFromFloat(nursing_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  3077. }
  3078. }
  3079. if item.MedChrgitmType == "08" { //材料费
  3080. materialCostTotal, _ = decimal.NewFromFloat(materialCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  3081. materialCostSelfTotal, _ = decimal.NewFromFloat(materialCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  3082. materialCostPartSelfTotal, _ = decimal.NewFromFloat(materialCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  3083. material_fulamt_ownpay_amt, _ = decimal.NewFromFloat(material_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  3084. if item.ChrgitmLv == "1" {
  3085. material_claa_sunmfee, _ = decimal.NewFromFloat(material_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  3086. }
  3087. if item.ChrgitmLv == "2" {
  3088. material_clab_amt, _ = decimal.NewFromFloat(material_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  3089. }
  3090. if item.ChrgitmLv == "3" {
  3091. material_other_amt, _ = decimal.NewFromFloat(material_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  3092. }
  3093. }
  3094. if item.MedChrgitmType == "09" { //西药费
  3095. westernMedicineCostTotal, _ = decimal.NewFromFloat(westernMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  3096. westernMedicineCostSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  3097. westernMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  3098. westernMedicine_fulamt_ownpay_amt, _ = decimal.NewFromFloat(westernMedicine_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  3099. if item.ChrgitmLv == "1" {
  3100. westernMedicine_claa_sunmfee, _ = decimal.NewFromFloat(westernMedicine_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  3101. }
  3102. if item.ChrgitmLv == "2" {
  3103. westernMedicine_clab_amt, _ = decimal.NewFromFloat(westernMedicine_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  3104. }
  3105. if item.ChrgitmLv == "3" {
  3106. westernMedicine_other_amt, _ = decimal.NewFromFloat(westernMedicine_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  3107. }
  3108. }
  3109. if item.MedChrgitmType == "10" { //中药饮片
  3110. chineseMedicineCostTotal, _ = decimal.NewFromFloat(chineseMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  3111. chineseMedicineCostSelfTotal, _ = decimal.NewFromFloat(chineseMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  3112. chineseMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(chineseMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  3113. chinese_medicine_fulamt_ownpay_amt, _ = decimal.NewFromFloat(chinese_medicine_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  3114. if item.ChrgitmLv == "1" {
  3115. chinese_medicine_claa_sunmfee, _ = decimal.NewFromFloat(chinese_medicine_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  3116. }
  3117. if item.ChrgitmLv == "2" {
  3118. chinese_medicine_clab_amt, _ = decimal.NewFromFloat(chinese_medicine_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  3119. }
  3120. if item.ChrgitmLv == "3" {
  3121. chinese_medicine_other_amt, _ = decimal.NewFromFloat(chinese_medicine_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  3122. }
  3123. }
  3124. if item.MedChrgitmType == "11" { //中成费
  3125. chineseTraditionalMedicineCostTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  3126. chineseTraditionalMedicineCostSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  3127. chineseTraditionalMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  3128. chineseTraditional_fulamt_ownpay_amt, _ = decimal.NewFromFloat(chineseTraditional_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  3129. if item.ChrgitmLv == "1" {
  3130. chineseTraditional_claa_sunmfee, _ = decimal.NewFromFloat(chineseTraditional_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  3131. }
  3132. if item.ChrgitmLv == "2" {
  3133. chineseTraditional_clab_amt, _ = decimal.NewFromFloat(chineseTraditional_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  3134. }
  3135. if item.ChrgitmLv == "3" {
  3136. chineseTraditional_other_amt, _ = decimal.NewFromFloat(chineseTraditional_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  3137. }
  3138. }
  3139. if item.MedChrgitmType == "12" { //中成费
  3140. commonlyTreatmentCostTotal, _ = decimal.NewFromFloat(commonlyTreatmentCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  3141. commonlyTreatmentCostSelfTotal, _ = decimal.NewFromFloat(commonlyTreatmentCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  3142. commonlyTreatmentCostPartSelfTotal, _ = decimal.NewFromFloat(commonlyTreatmentCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  3143. commonly_treatment_fulamt_ownpay_amt, _ = decimal.NewFromFloat(commonly_treatment_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  3144. if item.ChrgitmLv == "1" {
  3145. commonly_treatment_claa_sunmfee, _ = decimal.NewFromFloat(commonly_treatment_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  3146. }
  3147. if item.ChrgitmLv == "2" {
  3148. commonly_treatment_clab_amt, _ = decimal.NewFromFloat(commonly_treatment_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  3149. }
  3150. if item.ChrgitmLv == "3" {
  3151. commonly_treatment_other_amt, _ = decimal.NewFromFloat(commonly_treatment_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  3152. }
  3153. }
  3154. if item.MedChrgitmType == "13" { //中成费
  3155. registerCostTotal, _ = decimal.NewFromFloat(registerCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  3156. registerCostSelfTotal, _ = decimal.NewFromFloat(registerCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  3157. registerPartSelfTotal, _ = decimal.NewFromFloat(registerPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  3158. register_fulamt_ownpay_amt, _ = decimal.NewFromFloat(register_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  3159. if item.ChrgitmLv == "1" {
  3160. register_claa_sunmfee, _ = decimal.NewFromFloat(register_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  3161. }
  3162. if item.ChrgitmLv == "2" {
  3163. register_clab_amt, _ = decimal.NewFromFloat(register_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  3164. }
  3165. if item.ChrgitmLv == "3" {
  3166. register_other_amt, _ = decimal.NewFromFloat(register_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  3167. }
  3168. }
  3169. if item.MedChrgitmType == "14" { //其他费
  3170. otherCostTotal, _ = decimal.NewFromFloat(otherCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  3171. otherCostSelfTotal, _ = decimal.NewFromFloat(otherCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  3172. otherCostPartSelfTotal, _ = decimal.NewFromFloat(otherCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  3173. other_fulamt_ownpay_amt, _ = decimal.NewFromFloat(other_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  3174. if item.ChrgitmLv == "1" {
  3175. other_claa_sunmfee, _ = decimal.NewFromFloat(other_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  3176. }
  3177. if item.ChrgitmLv == "2" {
  3178. other_clab_amt, _ = decimal.NewFromFloat(other_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  3179. }
  3180. if item.ChrgitmLv == "3" {
  3181. other_other_amt, _ = decimal.NewFromFloat(other_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  3182. }
  3183. }
  3184. }
  3185. var iteminfoStructs []service.IteminfoStruct
  3186. if bedCostTotal != 0 {
  3187. iteminfo.MedChrgitm = "01"
  3188. iteminfo.FulamtOwnpayAmt = bed_fulamt_ownpay_amt
  3189. iteminfo.Amt = bedCostTotal
  3190. iteminfo.ClaaSumfee = bed_claa_sunmfee
  3191. iteminfo.ClabAmt = bed_clab_amt
  3192. iteminfo.OthAmt = bed_other_amt
  3193. iteminfoStructs = append(iteminfoStructs, iteminfo)
  3194. }
  3195. if examineCostTotal != 0 {
  3196. iteminfo.MedChrgitm = "02"
  3197. iteminfo.FulamtOwnpayAmt = examine_fulamt_ownpay_amt
  3198. iteminfo.Amt = examineCostTotal
  3199. iteminfo.ClaaSumfee = examine_claa_sunmfee
  3200. iteminfo.ClabAmt = examine_clab_amt
  3201. iteminfo.OthAmt = examine_other_amt
  3202. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  3203. iteminfoStructs = append(iteminfoStructs, iteminfo)
  3204. }
  3205. if checkCostTotal != 0 {
  3206. iteminfo.MedChrgitm = "03"
  3207. iteminfo.FulamtOwnpayAmt = check_fulamt_ownpay_amt
  3208. iteminfo.Amt = checkCostTotal
  3209. iteminfo.ClaaSumfee = check_claa_sunmfee
  3210. iteminfo.ClabAmt = check_clab_amt
  3211. iteminfo.OthAmt = check_other_amt
  3212. iteminfoStructs = append(iteminfoStructs, iteminfo)
  3213. }
  3214. if laboratoryCostTotal != 0 {
  3215. iteminfo.MedChrgitm = "04"
  3216. iteminfo.FulamtOwnpayAmt = laboratory_fulamt_ownpay_amt
  3217. iteminfo.Amt = laboratoryCostTotal
  3218. iteminfo.ClaaSumfee = laboratory_claa_sunmfee
  3219. iteminfo.ClabAmt = laboratory_clab_amt
  3220. iteminfo.OthAmt = laboratory_other_amt
  3221. iteminfoStructs = append(iteminfoStructs, iteminfo)
  3222. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  3223. }
  3224. if treatCostTotal != 0 {
  3225. iteminfo.MedChrgitm = "05"
  3226. iteminfo.FulamtOwnpayAmt = treat_fulamt_ownpay_amt
  3227. iteminfo.Amt = treatCostTotal
  3228. iteminfo.ClaaSumfee = treat_claa_sunmfee
  3229. iteminfo.ClabAmt = treat_clab_amt
  3230. iteminfo.OthAmt = treat_other_amt
  3231. iteminfoStructs = append(iteminfoStructs, iteminfo)
  3232. //(struct4101.IteminfoStruct, iteminfo)
  3233. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  3234. }
  3235. if operationCostTotal != 0 {
  3236. iteminfo.MedChrgitm = "06"
  3237. iteminfo.FulamtOwnpayAmt = bed_fulamt_ownpay_amt
  3238. iteminfo.Amt = operationCostTotal
  3239. iteminfo.ClaaSumfee = operation_claa_sunmfee
  3240. iteminfo.ClabAmt = operation_clab_amt
  3241. iteminfo.OthAmt = operation_other_amt
  3242. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  3243. iteminfoStructs = append(iteminfoStructs, iteminfo)
  3244. }
  3245. if nursingCostTotal != 0 {
  3246. iteminfo.MedChrgitm = "07"
  3247. iteminfo.FulamtOwnpayAmt = nursing_fulamt_ownpay_amt
  3248. iteminfo.Amt = nursingCostTotal
  3249. iteminfo.ClaaSumfee = nursing_claa_sunmfee
  3250. iteminfo.ClabAmt = nursing_clab_amt
  3251. iteminfo.OthAmt = nursing_other_amt
  3252. iteminfoStructs = append(iteminfoStructs, iteminfo)
  3253. }
  3254. if materialCostTotal != 0 {
  3255. iteminfo.MedChrgitm = "08"
  3256. iteminfo.FulamtOwnpayAmt = material_fulamt_ownpay_amt
  3257. iteminfo.Amt = materialCostTotal
  3258. iteminfo.ClaaSumfee = material_claa_sunmfee
  3259. iteminfo.ClabAmt = material_clab_amt
  3260. iteminfo.OthAmt = material_other_amt
  3261. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  3262. iteminfoStructs = append(iteminfoStructs, iteminfo)
  3263. }
  3264. if westernMedicineCostTotal != 0 {
  3265. iteminfo.MedChrgitm = "09"
  3266. iteminfo.FulamtOwnpayAmt = westernMedicine_fulamt_ownpay_amt
  3267. iteminfo.Amt = westernMedicineCostTotal
  3268. iteminfo.ClaaSumfee = westernMedicine_claa_sunmfee
  3269. iteminfo.ClabAmt = westernMedicine_clab_amt
  3270. iteminfo.OthAmt = westernMedicine_other_amt
  3271. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  3272. iteminfoStructs = append(iteminfoStructs, iteminfo)
  3273. }
  3274. if chineseMedicineCostTotal != 0 {
  3275. iteminfo.MedChrgitm = "10"
  3276. iteminfo.FulamtOwnpayAmt = chinese_medicine_fulamt_ownpay_amt
  3277. iteminfo.Amt = chineseMedicineCostTotal
  3278. iteminfo.ClaaSumfee = chinese_medicine_claa_sunmfee
  3279. iteminfo.ClabAmt = chinese_medicine_clab_amt
  3280. iteminfo.OthAmt = chinese_medicine_other_amt
  3281. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  3282. iteminfoStructs = append(iteminfoStructs, iteminfo)
  3283. }
  3284. if chineseTraditionalMedicineCostTotal != 0 {
  3285. iteminfo.MedChrgitm = "11"
  3286. iteminfo.FulamtOwnpayAmt = westernMedicine_fulamt_ownpay_amt
  3287. iteminfo.Amt = westernMedicineCostTotal
  3288. iteminfo.ClaaSumfee = westernMedicine_claa_sunmfee
  3289. iteminfo.ClabAmt = westernMedicine_clab_amt
  3290. iteminfo.OthAmt = westernMedicine_other_amt
  3291. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  3292. iteminfoStructs = append(iteminfoStructs, iteminfo)
  3293. }
  3294. if commonlyTreatmentCostTotal != 0 {
  3295. iteminfo.MedChrgitm = "12"
  3296. iteminfo.FulamtOwnpayAmt = commonly_treatment_fulamt_ownpay_amt
  3297. iteminfo.Amt = commonlyTreatmentCostTotal
  3298. iteminfo.ClaaSumfee = commonly_treatment_claa_sunmfee
  3299. iteminfo.ClabAmt = commonly_treatment_clab_amt
  3300. iteminfo.OthAmt = commonly_treatment_other_amt
  3301. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  3302. iteminfoStructs = append(iteminfoStructs, iteminfo)
  3303. }
  3304. if registerCostTotal != 0 {
  3305. iteminfo.MedChrgitm = "13"
  3306. iteminfo.FulamtOwnpayAmt = register_fulamt_ownpay_amt
  3307. iteminfo.Amt = registerCostTotal
  3308. iteminfo.ClaaSumfee = register_claa_sunmfee
  3309. iteminfo.ClabAmt = register_clab_amt
  3310. iteminfo.OthAmt = register_other_amt
  3311. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  3312. iteminfoStructs = append(iteminfoStructs, iteminfo)
  3313. }
  3314. if otherCostTotal != 0 {
  3315. iteminfo.MedChrgitm = "14"
  3316. iteminfo.FulamtOwnpayAmt = other_fulamt_ownpay_amt
  3317. iteminfo.Amt = otherCostTotal
  3318. iteminfo.ClaaSumfee = other_claa_sunmfee
  3319. iteminfo.ClabAmt = other_clab_amt
  3320. iteminfo.OthAmt = other_other_amt
  3321. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  3322. iteminfoStructs = append(iteminfoStructs, iteminfo)
  3323. }
  3324. struct4101.IteminfoStruct = iteminfoStructs
  3325. struct4101.Ntly = "中国"
  3326. struct4101.AdmCaty = "A03.06"
  3327. result := service.Gdyb4101(struct4101, miConfig.SecretKey, miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, c.GetAdminUserInfo().CurrentOrgId)
  3328. fmt.Println(result)
  3329. var dat map[string]interface{}
  3330. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  3331. fmt.Println(dat)
  3332. } else {
  3333. fmt.Println(err)
  3334. }
  3335. userJSONBytes, _ := json.Marshal(dat)
  3336. var res ResultSeventeen
  3337. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  3338. utils.ErrorLog("解析失败:%v", err)
  3339. //c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3340. adminUser := c.GetAdminUserInfo()
  3341. errlog := &models.HisOrderError{
  3342. UserOrgId: adminUser.CurrentOrgId,
  3343. Ctime: time.Now().Unix(),
  3344. Mtime: time.Now().Unix(),
  3345. ErrMsg: res.ErrMsg + "解析失败",
  3346. Status: 1,
  3347. PatientId: order_id,
  3348. Stage: 10106,
  3349. }
  3350. service.CreateErrMsgLog(errlog)
  3351. continue
  3352. }
  3353. if res.Infcode != 0 {
  3354. adminUser := c.GetAdminUserInfo()
  3355. errlog := &models.HisOrderError{
  3356. UserOrgId: adminUser.CurrentOrgId,
  3357. Ctime: time.Now().Unix(),
  3358. Mtime: time.Now().Unix(),
  3359. ErrMsg: res.ErrMsg,
  3360. Status: 1,
  3361. PatientId: order_id,
  3362. Stage: 10106,
  3363. }
  3364. service.CreateErrMsgLog(errlog)
  3365. continue
  3366. } else {
  3367. hisFundSettleListResult := &models.HisFundSettleListResult{
  3368. Number: res.Output.SetlListId,
  3369. Status: 1,
  3370. Ctime: time.Now().Unix(),
  3371. Mtime: time.Now().Unix(),
  3372. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  3373. IsUpload: 1,
  3374. OrderId: order_id,
  3375. }
  3376. service.CreateUploadRecord(hisFundSettleListResult)
  3377. continue
  3378. }
  3379. }
  3380. }
  3381. func (c *HisApiController) GetOrgInfo() {
  3382. miConfig, _ := service.FindMedicalInsuranceInfo(4)
  3383. service.Gdyb1201("", miConfig.OrgName, "1122", miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, 1, "")
  3384. }
  3385. func (c *HisApiController) GetHisPatientInfo() {
  3386. medical_insurance_card := c.GetString("medical_insurance_card")
  3387. id_card_type, _ := c.GetInt64("id_card_type")
  3388. id_card := c.GetString("id_card")
  3389. adminInfo := c.GetAdminUserInfo()
  3390. config, _ := service.GetMedicalInsuranceConfig(adminInfo.CurrentOrgId)
  3391. miConfig, _ := service.FindMedicalInsuranceInfo(adminInfo.CurrentOrgId)
  3392. appRole, _ := service.GetAppRole(adminInfo.CurrentOrgId)
  3393. IdCardNo := ""
  3394. if id_card_type == 1 {
  3395. IdCardNo = medical_insurance_card
  3396. } else if id_card_type == 2 {
  3397. IdCardNo = id_card
  3398. }
  3399. if config.IsOpen == 1 {
  3400. 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
  3401. resp, requestErr := http.Get(api)
  3402. if requestErr != nil {
  3403. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3404. return
  3405. }
  3406. defer resp.Body.Close()
  3407. body, ioErr := ioutil.ReadAll(resp.Body)
  3408. if ioErr != nil {
  3409. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  3410. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3411. return
  3412. }
  3413. var respJSON map[string]interface{}
  3414. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  3415. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  3416. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3417. return
  3418. }
  3419. userJSON := respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  3420. userJSONBytes, _ := json.Marshal(userJSON)
  3421. var res ResultTwo
  3422. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  3423. utils.ErrorLog("解析失败:%v", err)
  3424. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3425. return
  3426. }
  3427. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  3428. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  3429. infoStr := string(Iinfos)
  3430. idetinfoStr := string(Idetinfos)
  3431. if res.Infcode == 0 {
  3432. his := models.VMHisPatient{
  3433. Status: 1,
  3434. Ctime: time.Now().Unix(),
  3435. Mtime: time.Now().Unix(),
  3436. PsnNo: res.Output.Baseinfo.PsnNo,
  3437. PsnCertType: res.Output.Baseinfo.PsnCertType,
  3438. Certno: res.Output.Baseinfo.Certno,
  3439. PsnName: res.Output.Baseinfo.PsnName,
  3440. Gend: res.Output.Baseinfo.Gend,
  3441. Naty: res.Output.Baseinfo.Naty,
  3442. Brdy: res.Output.Baseinfo.Brdy,
  3443. Age: res.Output.Baseinfo.Age,
  3444. Iinfo: infoStr,
  3445. Idetinfo: idetinfoStr,
  3446. UserOrgId: adminInfo.CurrentOrgId,
  3447. IsReturn: 1,
  3448. IdCardType: id_card_type,
  3449. }
  3450. c.ServeSuccessJSON(map[string]interface{}{
  3451. "info": his,
  3452. })
  3453. } else {
  3454. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  3455. return
  3456. }
  3457. }
  3458. }
  3459. //func GetBasBaseInfo() (jsonStr string, err error) {
  3460. //
  3461. // handle := syscall.NewLazyDLL("SSCard.dll")
  3462. // add := handle.NewProc("ReadCardBas")
  3463. // str := make([]byte, 1024)
  3464. // str1 := make([]byte, 1024)
  3465. // ret, _, _ := add.Call((uintptr)(unsafe.Pointer(&str[0])), IntPtr(1024), (uintptr)(unsafe.Pointer(&str1[0])), IntPtr(1024))
  3466. // fmt.Println(ConvertToString(string(str), "gbk", "utf-8"))
  3467. //
  3468. // fmt.Println(ConvertToString(string(str1), "gbk", "utf-8"))
  3469. //
  3470. // fmt.Println("> Add(4,5)的结果为:", ret)
  3471. // handle.Release()
  3472. //
  3473. // return "", nil
  3474. //
  3475. //}
  3476. //func GetQRBaseInfo() (jsonStr string, err error) {
  3477. // handle := syscall.LoadDLL("SSCard.dll")
  3478. // ReadCardBas := handle.FindProc("GetQRBase")
  3479. //
  3480. // str := make([]byte, 256)
  3481. // str1 := make([]byte, 256)
  3482. // r, _, _ := ReadCardBas.Call((uintptr)(unsafe.Pointer(&str[0])), IntPtr(1024), (uintptr)(unsafe.Pointer(&str1[0])), IntPtr(1024))
  3483. //
  3484. // fmt.Println(string(str))
  3485. // fmt.Println(r)
  3486. // return string(str), nil
  3487. //}
  3488. //func CardInit() int {
  3489. // DllTestDef := syscall.MustLoadDLL("SSCard.dll")
  3490. // add := DllTestDef.MustFindProc("Init")
  3491. // ret, _, err := add.Call(StrPtr("http://igb.hsa.gdgov.cn/gdyb_inf/poc/api/card/initDll"), StrPtr("440200"))
  3492. // if err != nil {
  3493. // fmt.Println("SSCard的运算结果为:", ret)
  3494. // }
  3495. // result := int(ret)
  3496. // return result
  3497. //}
  3498. //func CardInit() int {
  3499. // ret, _, err := add.Call(StrPtr("http://igb.hsa.gdgov.cn/gdyb_inf/poc/api/card/initDll"), StrPtr("440200"))
  3500. // if err != nil {
  3501. // fmt.Println("SSCard的运算结果为:", ret)
  3502. // }
  3503. // fmt.Println(err)
  3504. // result := int(ret)
  3505. // return result
  3506. //}
  3507. func IntPtr(n int) uintptr {
  3508. return uintptr(n)
  3509. }
  3510. func StrPtr(s string) uintptr {
  3511. return uintptr(unsafe.Pointer(syscall.StringBytePtr(s)))
  3512. }
  3513. type Result2001 struct {
  3514. Cainfo interface{} `json:"cainfo"`
  3515. ErrMsg string `json:"err_msg"`
  3516. InfRefmsgid string `json:"inf_refmsgid"`
  3517. Infcode int64 `json:"infcode"`
  3518. Output struct {
  3519. Trtinfo struct {
  3520. PsnNo string `json:"psn_no"`
  3521. TrtChkType string `json:"trt_chk_type"`
  3522. FundPayType string `json:"fund_pay_type"`
  3523. TrtEnjymntFlag string `json:"trt_enjymnt_flag"`
  3524. Begndate string `json:"begndate"`
  3525. Enddate string `json:"enddate"`
  3526. TrtChkRslt string `json:"trt_chk_rslt"`
  3527. } `json:"trtinfo"`
  3528. } `json:"output"`
  3529. RefmsgTime string `json:"refmsg_time"`
  3530. RespondTime string `json:"respond_time"`
  3531. Signtype interface{} `json:"signtype"`
  3532. WarnMsg interface{} `json:"warn_msg"`
  3533. }
  3534. type Result2001Org10265 struct {
  3535. Cainfo interface{} `json:"cainfo"`
  3536. ErrMsg string `json:"err_msg"`
  3537. InfRefmsgid string `json:"inf_refmsgid"`
  3538. Infcode string `json:"infcode"`
  3539. Output struct {
  3540. Trtinfo struct {
  3541. PsnNo string `json:"psn_no"`
  3542. TrtChkType string `json:"trt_chk_type"`
  3543. FundPayType string `json:"fund_pay_type"`
  3544. TrtEnjymntFlag string `json:"trt_enjymnt_flag"`
  3545. Begndate string `json:"begndate"`
  3546. Enddate string `json:"enddate"`
  3547. TrtChkRslt string `json:"trt_chk_rslt"`
  3548. } `json:"trtinfo"`
  3549. } `json:"output"`
  3550. RefmsgTime string `json:"refmsg_time"`
  3551. RespondTime string `json:"respond_time"`
  3552. Signtype interface{} `json:"signtype"`
  3553. WarnMsg interface{} `json:"warn_msg"`
  3554. }
  3555. type ResultTwo struct {
  3556. ErrMsg string `json:"err_msg"`
  3557. InfRefmsgid string `json:"inf_refmsgid"`
  3558. Infcode int64 `json:"infcode"`
  3559. Output struct {
  3560. Baseinfo struct {
  3561. Age float64 `json:"age"`
  3562. Brdy string `json:"brdy"`
  3563. Certno string `json:"certno"`
  3564. Gend string `json:"gend"`
  3565. Naty string `json:"naty"`
  3566. PsnCertType string `json:"psn_cert_type"`
  3567. PsnName string `json:"psn_name"`
  3568. PsnNo string `json:"psn_no"`
  3569. } `json:"baseinfo"`
  3570. Idetinfo []interface{} `json:"idetinfo"`
  3571. Iinfo []struct {
  3572. Balc float64 `json:"balc"`
  3573. CvlservFlag string `json:"cvlserv_flag"`
  3574. EmpName string `json:"emp_name"`
  3575. InsuplcAdmdvs string `json:"insuplc_admdvs"`
  3576. Insutype string `json:"insutype"`
  3577. PausInsuDansuplcAdmdvs string `json:"paus_insu_dansuplc_admdvs"`
  3578. PausInsuDate string `json:"paus_insu_date"`
  3579. PsnInsuDate string `json:"psn_insu_date"`
  3580. PsnInsuStas string `json:"psn_insu_stas"`
  3581. PsnType string `json:"psn_type"`
  3582. } `json:"insuinfo"`
  3583. } `json:"output"`
  3584. RefmsgTime string `json:"refmsg_time"`
  3585. RespondTime string `json:"respond_time"`
  3586. Signtype interface{} `json:"signtype"`
  3587. WarnInfo interface{} `json:"warn_info"`
  3588. }
  3589. type ResultTwo10265 struct {
  3590. ErrMsg string `json:"err_msg"`
  3591. InfRefmsgid string `json:"inf_refmsgid"`
  3592. Infcode string `json:"infcode"`
  3593. Output struct {
  3594. Baseinfo struct {
  3595. Age float64 `json:"age"`
  3596. Brdy string `json:"brdy"`
  3597. Certno string `json:"certno"`
  3598. Gend string `json:"gend"`
  3599. Naty string `json:"naty"`
  3600. PsnCertType string `json:"psn_cert_type"`
  3601. PsnName string `json:"psn_name"`
  3602. PsnNo string `json:"psn_no"`
  3603. } `json:"baseinfo"`
  3604. Idetinfo []interface{} `json:"idetinfo"`
  3605. Iinfo []struct {
  3606. Balc float64 `json:"balc"`
  3607. CvlservFlag string `json:"cvlserv_flag"`
  3608. EmpName string `json:"emp_name"`
  3609. InsuplcAdmdvs string `json:"insuplc_admdvs"`
  3610. Insutype string `json:"insutype"`
  3611. PausInsuDansuplcAdmdvs string `json:"paus_insu_dansuplc_admdvs"`
  3612. PausInsuDate string `json:"paus_insu_date"`
  3613. PsnInsuDate string `json:"psn_insu_date"`
  3614. PsnInsuStas string `json:"psn_insu_stas"`
  3615. PsnType string `json:"psn_type"`
  3616. } `json:"insuinfo"`
  3617. } `json:"output"`
  3618. RefmsgTime string `json:"refmsg_time"`
  3619. RespondTime string `json:"respond_time"`
  3620. Signtype interface{} `json:"signtype"`
  3621. WarnInfo interface{} `json:"warn_info"`
  3622. }
  3623. type ResultThree struct {
  3624. Cainfo interface{} `json:"cainfo"`
  3625. ErrMsg string `json:"err_msg"`
  3626. InfRefmsgid string `json:"inf_refmsgid"`
  3627. Infcode int64 `json:"infcode"`
  3628. Output struct {
  3629. Data struct {
  3630. IptOtpNo string `json:"ipt_otp_no"`
  3631. MdtrtID string `json:"mdtrt_id"`
  3632. PsnNo string `json:"psn_no"`
  3633. } `json:"data"`
  3634. } `json:"output"`
  3635. RefmsgTime string `json:"refmsg_time"`
  3636. RespondTime string `json:"respond_time"`
  3637. Signtype interface{} `json:"signtype"`
  3638. WarnMsg interface{} `json:"warn_msg"`
  3639. }
  3640. type ResultThree10265 struct {
  3641. Cainfo interface{} `json:"cainfo"`
  3642. ErrMsg string `json:"err_msg"`
  3643. InfRefmsgid string `json:"inf_refmsgid"`
  3644. Infcode string `json:"infcode"`
  3645. Output struct {
  3646. Data struct {
  3647. IptOtpNo string `json:"ipt_otp_no"`
  3648. MdtrtID string `json:"mdtrt_id"`
  3649. PsnNo string `json:"psn_no"`
  3650. } `json:"data"`
  3651. } `json:"output"`
  3652. RefmsgTime string `json:"refmsg_time"`
  3653. RespondTime string `json:"respond_time"`
  3654. Signtype interface{} `json:"signtype"`
  3655. WarnMsg interface{} `json:"warn_msg"`
  3656. }
  3657. type ResultFour struct {
  3658. Cainfo string `json:"cainfo"`
  3659. ErrMsg string `json:"err_msg"`
  3660. InfRefmsgid string `json:"inf_refmsgid"`
  3661. Infcode int64 `json:"infcode"`
  3662. Output struct {
  3663. Result []struct {
  3664. BasMednFlag string `json:"bas_medn_flag"`
  3665. ChldMedcFlag string `json:"chld_medc_flag"`
  3666. ChrgitmLv string `json:"chrgitm_lv"`
  3667. Cnt float64 `json:"cnt"`
  3668. DetItemFeeSumamt float64 `json:"det_item_fee_sumamt"`
  3669. DrtReimFlag string `json:"drt_reim_flag"`
  3670. FeedetlSn string `json:"feedetl_sn"`
  3671. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  3672. HiNegoDrugFlag string `json:"hi_nego_drug_flag"`
  3673. InscpScpAmt float64 `json:"inscp_scp_amt"`
  3674. ListSpItemFlag string `json:"list_sp_item_flag"`
  3675. LmtUsedFlag string `json:"lmt_used_flag"`
  3676. MedChrgitmType string `json:"med_chrgitm_type"`
  3677. Memo string `json:"memo"`
  3678. OverlmtAmt float64 `json:"overlmt_amt"`
  3679. PreselfpayAmt float64 `json:"preselfpay_amt"`
  3680. Pric float64 `json:"pric"`
  3681. PricUplmtAmt float64 `json:"pric_uplmt_amt"`
  3682. SelfpayProp float64 `json:"selfpay_prop"`
  3683. } `json:"result"`
  3684. } `json:"output"`
  3685. RefmsgTime string `json:"refmsg_time"`
  3686. RespondTime string `json:"respond_time"`
  3687. Signtype string `json:"signtype"`
  3688. WarnMsg string `json:"warn_msg"`
  3689. }
  3690. type ResultFour10265 struct {
  3691. Cainfo string `json:"cainfo"`
  3692. ErrMsg string `json:"err_msg"`
  3693. InfRefmsgid string `json:"inf_refmsgid"`
  3694. Infcode string `json:"infcode"`
  3695. Output struct {
  3696. Result []struct {
  3697. BasMednFlag string `json:"bas_medn_flag"`
  3698. ChldMedcFlag string `json:"chld_medc_flag"`
  3699. ChrgitmLv string `json:"chrgitm_lv"`
  3700. Cnt float64 `json:"cnt"`
  3701. DetItemFeeSumamt float64 `json:"det_item_fee_sumamt"`
  3702. DrtReimFlag string `json:"drt_reim_flag"`
  3703. FeedetlSn string `json:"feedetl_sn"`
  3704. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  3705. HiNegoDrugFlag string `json:"hi_nego_drug_flag"`
  3706. InscpScpAmt float64 `json:"inscp_scp_amt"`
  3707. ListSpItemFlag string `json:"list_sp_item_flag"`
  3708. LmtUsedFlag string `json:"lmt_used_flag"`
  3709. MedChrgitmType string `json:"med_chrgitm_type"`
  3710. Memo string `json:"memo"`
  3711. OverlmtAmt float64 `json:"overlmt_amt"`
  3712. PreselfpayAmt float64 `json:"preselfpay_amt"`
  3713. Pric float64 `json:"pric"`
  3714. PricUplmtAmt float64 `json:"pric_uplmt_amt"`
  3715. SelfpayProp float64 `json:"selfpay_prop"`
  3716. } `json:"result"`
  3717. } `json:"output"`
  3718. RefmsgTime string `json:"refmsg_time"`
  3719. RespondTime string `json:"respond_time"`
  3720. Signtype string `json:"signtype"`
  3721. WarnMsg string `json:"warn_msg"`
  3722. }
  3723. type ResultFive struct {
  3724. Balc float64 `json:"balc"`
  3725. CvlservFlag string `json:"cvlserv_flag"`
  3726. EmpName string `json:"emp_name"`
  3727. InsuplcAdmdvs string `json:"insuplc_admdvs"`
  3728. Insutype string `json:"insutype"`
  3729. PausInsuDansuplcAdmdvs string `json:"paus_insu_dansuplc_admdvs"`
  3730. PausInsuDate string `json:"paus_insu_date"`
  3731. PsnInsuDate string `json:"psn_insu_date"`
  3732. PsnInsuStas string `json:"psn_insu_stas"`
  3733. PsnType string `json:"psn_type"`
  3734. }
  3735. type ResultSix struct {
  3736. Cainfo interface{} `json:"cainfo"`
  3737. ErrMsg string `json:"err_msg"`
  3738. InfRefmsgid string `json:"inf_refmsgid"`
  3739. Infcode int64 `json:"infcode"`
  3740. Output struct {
  3741. } `json:"output"`
  3742. RefmsgTime string `json:"refmsg_time"`
  3743. RespondTime string `json:"respond_time"`
  3744. Signtype interface{} `json:"signtype"`
  3745. WarnMsg interface{} `json:"warn_msg"`
  3746. }
  3747. type ResultSix10265 struct {
  3748. Cainfo interface{} `json:"cainfo"`
  3749. ErrMsg string `json:"err_msg"`
  3750. InfRefmsgid string `json:"inf_refmsgid"`
  3751. Infcode string `json:"infcode"`
  3752. Output struct {
  3753. } `json:"output"`
  3754. RefmsgTime string `json:"refmsg_time"`
  3755. RespondTime string `json:"respond_time"`
  3756. Signtype interface{} `json:"signtype"`
  3757. WarnMsg interface{} `json:"warn_msg"`
  3758. }
  3759. type ResultSeven struct {
  3760. Cainfo string `json:"cainfo"`
  3761. ErrMsg string `json:"err_msg"`
  3762. InfRefmsgid string `json:"inf_refmsgid"`
  3763. Infcode int64 `json:"infcode"`
  3764. Output struct {
  3765. Setldetail []interface{} `json:"setldetail"`
  3766. Setlinfo struct {
  3767. AcctMulaidPay float64 `json:"acct_mulaid_pay"`
  3768. AcctPay float64 `json:"acct_pay"`
  3769. ActPayDedc float64 `json:"act_pay_dedc"`
  3770. Age float64 `json:"age"`
  3771. Balc float64 `json:"balc"`
  3772. Brdy string `json:"brdy"`
  3773. Certno string `json:"certno"`
  3774. ClrOptins string `json:"clr_optins"`
  3775. ClrType string `json:"clr_type"`
  3776. ClrWay string `json:"clr_way"`
  3777. CvlservFlag string `json:"cvlserv_flag"`
  3778. CvlservPay float64 `json:"cvlserv_pay"`
  3779. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  3780. FundPaySumamt float64 `json:"fund_pay_sumamt"`
  3781. Gend string `json:"gend"`
  3782. HifesPay float64 `json:"hifes_pay"`
  3783. HifmiPay float64 `json:"hifmi_pay"`
  3784. HifpPay float64 `json:"hifp_pay"`
  3785. HospPartAmt float64 `json:"hosp_part_amt"`
  3786. InscpScpAmt float64 `json:"inscp_scp_amt"`
  3787. Insutype string `json:"insutype"`
  3788. MafPay float64 `json:"maf_pay"`
  3789. MdtrtCertType string `json:"mdtrt_cert_type"`
  3790. HifobPay float64 `json:"hifob_pay"`
  3791. MdtrtID string `json:"mdtrt_id"`
  3792. MedType string `json:"med_type"`
  3793. MedfeeSumamt float64 `json:"medfee_sumamt"`
  3794. MedinsSetlID string `json:"medins_setl_id"`
  3795. Naty string `json:"naty"`
  3796. OthPay float64 `json:"oth_pay"`
  3797. OverlmtSelfpay float64 `json:"overlmt_selfpay"`
  3798. PoolPropSelfpay float64 `json:"pool_prop_selfpay"`
  3799. PreselfpayAmt float64 `json:"preselfpay_amt"`
  3800. PsnCashPay float64 `json:"psn_cash_pay"`
  3801. PsnCertType string `json:"psn_cert_type"`
  3802. PsnName string `json:"psn_name"`
  3803. PsnNo string `json:"psn_no"`
  3804. PsnPartAmt float64 `json:"psn_part_amt"`
  3805. PsnType string `json:"psn_type"`
  3806. SetlID string `json:"setl_id"`
  3807. SetlTime string `json:"setl_time"`
  3808. } `json:"setlinfo"`
  3809. } `json:"output"`
  3810. RefmsgTime string `json:"refmsg_time"`
  3811. RespondTime string `json:"respond_time"`
  3812. Signtype interface{} `json:"signtype"`
  3813. WarnMsg interface{} `json:"warn_msg"`
  3814. }
  3815. type ResultSeven10265 struct {
  3816. Cainfo string `json:"cainfo"`
  3817. ErrMsg string `json:"err_msg"`
  3818. InfRefmsgid string `json:"inf_refmsgid"`
  3819. Infcode string `json:"infcode"`
  3820. Output struct {
  3821. Setldetail []interface{} `json:"setldetail"`
  3822. Setlinfo struct {
  3823. AcctMulaidPay float64 `json:"acct_mulaid_pay"`
  3824. AcctPay float64 `json:"acct_pay"`
  3825. ActPayDedc float64 `json:"act_pay_dedc"`
  3826. Age float64 `json:"age"`
  3827. Balc float64 `json:"balc"`
  3828. Brdy string `json:"brdy"`
  3829. Certno string `json:"certno"`
  3830. ClrOptins string `json:"clr_optins"`
  3831. ClrType string `json:"clr_type"`
  3832. ClrWay string `json:"clr_way"`
  3833. CvlservFlag string `json:"cvlserv_flag"`
  3834. CvlservPay float64 `json:"cvlserv_pay"`
  3835. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  3836. FundPaySumamt float64 `json:"fund_pay_sumamt"`
  3837. Gend string `json:"gend"`
  3838. HifesPay float64 `json:"hifes_pay"`
  3839. HifmiPay float64 `json:"hifmi_pay"`
  3840. HifpPay float64 `json:"hifp_pay"`
  3841. HospPartAmt float64 `json:"hosp_part_amt"`
  3842. InscpScpAmt float64 `json:"inscp_scp_amt"`
  3843. Insutype string `json:"insutype"`
  3844. MafPay float64 `json:"maf_pay"`
  3845. MdtrtCertType string `json:"mdtrt_cert_type"`
  3846. HifobPay float64 `json:"hifob_pay"`
  3847. MdtrtID string `json:"mdtrt_id"`
  3848. MedType string `json:"med_type"`
  3849. MedfeeSumamt float64 `json:"medfee_sumamt"`
  3850. MedinsSetlID string `json:"medins_setl_id"`
  3851. Naty string `json:"naty"`
  3852. OthPay float64 `json:"oth_pay"`
  3853. OverlmtSelfpay float64 `json:"overlmt_selfpay"`
  3854. PoolPropSelfpay float64 `json:"pool_prop_selfpay"`
  3855. PreselfpayAmt float64 `json:"preselfpay_amt"`
  3856. PsnCashPay float64 `json:"psn_cash_pay"`
  3857. PsnCertType string `json:"psn_cert_type"`
  3858. PsnName string `json:"psn_name"`
  3859. PsnNo string `json:"psn_no"`
  3860. PsnPartAmt float64 `json:"psn_part_amt"`
  3861. PsnType string `json:"psn_type"`
  3862. SetlID string `json:"setl_id"`
  3863. SetlTime string `json:"setl_time"`
  3864. } `json:"setlinfo"`
  3865. } `json:"output"`
  3866. RefmsgTime string `json:"refmsg_time"`
  3867. RespondTime string `json:"respond_time"`
  3868. Signtype interface{} `json:"signtype"`
  3869. WarnMsg interface{} `json:"warn_msg"`
  3870. }
  3871. type ResultEight struct {
  3872. Cainfo string `json:"cainfo"`
  3873. ErrMsg string `json:"err_msg"`
  3874. InfRefmsgid string `json:"inf_refmsgid"`
  3875. Infcode int64 `json:"infcode"`
  3876. Output struct {
  3877. Stmtinfo struct {
  3878. SetlOptins string `json:"setl_optins"`
  3879. StmtRslt string `json:"stmt_rslt"`
  3880. StmtRsltDscr string `json:"stmt_rslt_dscr"`
  3881. } `json:"stmtinfo"`
  3882. } `json:"output"`
  3883. RefmsgTime string `json:"refmsg_time"`
  3884. RespondTime string `json:"respond_time"`
  3885. Signtype interface{} `json:"signtype"`
  3886. WarnMsg interface{} `json:"warn_msg"`
  3887. }
  3888. type ResultEightFor10188 struct {
  3889. Cainfo string `json:"cainfo"`
  3890. ErrMsg string `json:"err_msg"`
  3891. InfRefmsgid string `json:"inf_refmsgid"`
  3892. Infcode string `json:"infcode"`
  3893. Output struct {
  3894. Stmtinfo struct {
  3895. SetlOptins string `json:"setl_optins"`
  3896. StmtRslt string `json:"stmt_rslt"`
  3897. StmtRsltDscr string `json:"stmt_rslt_dscr"`
  3898. } `json:"stmtinfo"`
  3899. } `json:"output"`
  3900. RefmsgTime string `json:"refmsg_time"`
  3901. RespondTime string `json:"respond_time"`
  3902. Signtype interface{} `json:"signtype"`
  3903. WarnMsg interface{} `json:"warn_msg"`
  3904. }
  3905. type ResultNine struct {
  3906. Cainfo string `json:"cainfo"`
  3907. ErrMsg string `json:"err_msg"`
  3908. InfRefmsgid string `json:"inf_refmsgid"`
  3909. Infcode int64 `json:"infcode"`
  3910. Output struct {
  3911. FileQuryNo string `json:"file_qury_no"`
  3912. } `json:"output"`
  3913. RefmsgTime string `json:"refmsg_time"`
  3914. RespondTime string `json:"respond_time"`
  3915. Signtype interface{} `json:"signtype"`
  3916. WarnMsg interface{} `json:"warn_msg"`
  3917. }
  3918. type ResultTen struct {
  3919. Cainfo string `json:"cainfo"`
  3920. ErrMsg string `json:"err_msg"`
  3921. InfRefmsgid string `json:"inf_refmsgid"`
  3922. Infcode int64 `json:"infcode"`
  3923. Output struct {
  3924. DldEndtime string `json:"dld_endtime"`
  3925. FileQuryNo string `json:"file_qury_no"`
  3926. Filename string `json:"filename"`
  3927. } `json:"output"`
  3928. RefmsgTime string `json:"refmsg_time"`
  3929. RespondTime string `json:"respond_time"`
  3930. Signtype interface{} `json:"signtype"`
  3931. WarnMsg interface{} `json:"warn_msg"`
  3932. }
  3933. //type Autogenerated struct {
  3934. // Output struct {
  3935. // Setlinfo struct {
  3936. // SetlTime string `json:"setl_time"`
  3937. // CvlservPay float64 `json:"cvlserv_pay"`
  3938. // Year string `json:"year"`
  3939. // MedType string `json:"med_type"`
  3940. // PsnPay float64 `json:"psn_pay"`
  3941. // OpterID string `json:"opter_id"`
  3942. // Begndate string `json:"begndate"`
  3943. // FlxempeFlag string `json:"flxempe_flag"`
  3944. // HifmiPay float64 `json:"hifmi_pay"`
  3945. // PsnNo string `json:"psn_no"`
  3946. // ActPayDedc float64 `json:"act_pay_dedc"`
  3947. // MedinsSetlID interface{} `json:"medins_setl_id"`
  3948. // AcctMulaidPay interface{} `json:"acct_mulaid_pay"`
  3949. // ClrWay string `json:"clr_way"`
  3950. // OthPay float64 `json:"oth_pay"`
  3951. // Gend string `json:"gend"`
  3952. // MdtrtID string `json:"mdtrt_id"`
  3953. // AcctPay float64 `json:"acct_pay"`
  3954. // InscpScpAmt float64 `json:"inscp_scp_amt"`
  3955. // Insutype string `json:"insutype"`
  3956. // Invono interface{} `json:"invono"`
  3957. // Enddate string `json:"enddate"`
  3958. // CashPayamt float64 `json:"cash_payamt"`
  3959. // PsnType string `json:"psn_type"`
  3960. // FixmedinsName string `json:"fixmedins_name"`
  3961. // HifpPay float64 `json:"hifp_pay"`
  3962. // NewFlag interface{} `json:"new_flag"`
  3963. // OverlmtSelfpay float64 `json:"overlmt_selfpay"`
  3964. // PreselfpayAmt float64 `json:"preselfpay_amt"`
  3965. // PayLoc string `json:"pay_loc"`
  3966. // ClrType string `json:"clr_type"`
  3967. // RefdSetlFlag string `json:"refd_setl_flag"`
  3968. // CvlservFlag string `json:"cvlserv_flag"`
  3969. // EmpName string `json:"emp_name"`
  3970. // Brdy string `json:"brdy"`
  3971. // Naty string `json:"naty"`
  3972. // Certno string `json:"certno"`
  3973. // DiseCode string `json:"dise_code"`
  3974. // FixmedinsCode string `json:"fixmedins_code"`
  3975. // DedcHospLv string `json:"dedc_hosp_lv"`
  3976. // OpterName string `json:"opter_name"`
  3977. // Balc float64 `json:"balc"`
  3978. // FixmedinsPoolarea string `json:"fixmedins_poolarea"`
  3979. // PsnCertType string `json:"psn_cert_type"`
  3980. // HifobPay float64 `json:"hifob_pay"`
  3981. // MedfeeSumamt float64 `json:"medfee_sumamt"`
  3982. // HifesPay float64 `json:"hifes_pay"`
  3983. // FundPaySumamt float64 `json:"fund_pay_sumamt"`
  3984. // OptTime string `json:"opt_time"`
  3985. // FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  3986. // SetlID string `json:"setl_id"`
  3987. // MafPay float64 `json:"maf_pay"`
  3988. // PsnName string `json:"psn_name"`
  3989. // InsuOptins interface{} `json:"insu_optins"`
  3990. // PrefFundPay interface{} `json:"pref_fund_pay"`
  3991. // ClrOptins string `json:"clr_optins"`
  3992. // PoolPropSelfpay float64 `json:"pool_prop_selfpay"`
  3993. // DiseName string `json:"dise_name"`
  3994. // LmtpricHospLv string `json:"lmtpric_hosp_lv"`
  3995. // Age float64 `json:"age"`
  3996. // DtrtCertType string `json:"dtrt_cert_type"`
  3997. // HospLv string `json:"hosp_lv"`
  3998. // } `json:"setlinfo"`
  3999. // Setldetail []struct {
  4000. // FundPayType string `json:"fund_pay_type"`
  4001. // FundPayamt float64 `json:"fund_payamt"`
  4002. // SetlProcInfo interface{} `json:"setl_proc_info"`
  4003. // CrtPaybLmtAmt interface{} `json:"crt_payb_lmt_amt"`
  4004. // InscpScpAmt interface{} `json:"inscp_scp_amt"`
  4005. // FundPayTypeName interface{} `json:"fund_pay_type_name"`
  4006. // PrefFundPay interface{} `json:"pref_fund_pay"`
  4007. // } `json:"setldetail"`
  4008. // } `json:"output"`
  4009. // Infcode int `json:"infcode"`
  4010. // WarnMsg interface{} `json:"warn_msg"`
  4011. // Cainfo interface{} `json:"cainfo"`
  4012. // ErrMsg interface{} `json:"err_msg"`
  4013. // RefmsgTime string `json:"refmsg_time"`
  4014. // Signtype interface{} `json:"signtype"`
  4015. // RespondTime string `json:"respond_time"`
  4016. // InfRefmsgid string `json:"inf_refmsgid"`
  4017. //}
  4018. type ResultEleven struct {
  4019. Cainfo string `json:"cainfo"`
  4020. ErrMsg string `json:"err_msg"`
  4021. InfRefmsgid string `json:"inf_refmsgid"`
  4022. Infcode int64 `json:"infcode"`
  4023. Output struct {
  4024. Setlinfo struct {
  4025. SetlTime string `json:"setl_time"`
  4026. CvlservPay float64 `json:"cvlserv_pay"`
  4027. Year string `json:"year"`
  4028. MedType string `json:"med_type"`
  4029. PsnPay float64 `json:"psn_pay"`
  4030. OpterID string `json:"opter_id"`
  4031. Begndate string `json:"begndate"`
  4032. FlxempeFlag string `json:"flxempe_flag"`
  4033. HifmiPay float64 `json:"hifmi_pay"`
  4034. PsnNo string `json:"psn_no"`
  4035. ActPayDedc float64 `json:"act_pay_dedc"`
  4036. MedinsSetlID interface{} `json:"medins_setl_id"`
  4037. AcctMulaidPay interface{} `json:"acct_mulaid_pay"`
  4038. ClrWay string `json:"clr_way"`
  4039. OthPay float64 `json:"oth_pay"`
  4040. Gend string `json:"gend"`
  4041. MdtrtID string `json:"mdtrt_id"`
  4042. AcctPay float64 `json:"acct_pay"`
  4043. InscpScpAmt float64 `json:"inscp_scp_amt"`
  4044. Insutype string `json:"insutype"`
  4045. Invono interface{} `json:"invono"`
  4046. Enddate string `json:"enddate"`
  4047. CashPayamt float64 `json:"cash_payamt"`
  4048. PsnType string `json:"psn_type"`
  4049. FixmedinsName string `json:"fixmedins_name"`
  4050. HifpPay float64 `json:"hifp_pay"`
  4051. NewFlag interface{} `json:"new_flag"`
  4052. OverlmtSelfpay float64 `json:"overlmt_selfpay"`
  4053. PreselfpayAmt float64 `json:"preselfpay_amt"`
  4054. PayLoc string `json:"pay_loc"`
  4055. ClrType string `json:"clr_type"`
  4056. RefdSetlFlag string `json:"refd_setl_flag"`
  4057. CvlservFlag string `json:"cvlserv_flag"`
  4058. EmpName string `json:"emp_name"`
  4059. Brdy string `json:"brdy"`
  4060. Naty string `json:"naty"`
  4061. Certno string `json:"certno"`
  4062. DiseCode string `json:"dise_code"`
  4063. FixmedinsCode string `json:"fixmedins_code"`
  4064. DedcHospLv string `json:"dedc_hosp_lv"`
  4065. OpterName string `json:"opter_name"`
  4066. Balc float64 `json:"balc"`
  4067. FixmedinsPoolarea string `json:"fixmedins_poolarea"`
  4068. PsnCertType string `json:"psn_cert_type"`
  4069. HifobPay float64 `json:"hifob_pay"`
  4070. MedfeeSumamt float64 `json:"medfee_sumamt"`
  4071. HifesPay float64 `json:"hifes_pay"`
  4072. FundPaySumamt float64 `json:"fund_pay_sumamt"`
  4073. OptTime string `json:"opt_time"`
  4074. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  4075. SetlID string `json:"setl_id"`
  4076. MafPay float64 `json:"maf_pay"`
  4077. PsnName string `json:"psn_name"`
  4078. InsuOptins interface{} `json:"insu_optins"`
  4079. PrefFundPay interface{} `json:"pref_fund_pay"`
  4080. ClrOptins string `json:"clr_optins"`
  4081. PoolPropSelfpay float64 `json:"pool_prop_selfpay"`
  4082. DiseName string `json:"dise_name"`
  4083. LmtpricHospLv string `json:"lmtpric_hosp_lv"`
  4084. Age float64 `json:"age"`
  4085. DtrtCertType string `json:"dtrt_cert_type"`
  4086. HospLv string `json:"hosp_lv"`
  4087. } `json:"setlinfo"`
  4088. } `json:"output"`
  4089. RefmsgTime string `json:"refmsg_time"`
  4090. RespondTime string `json:"respond_time"`
  4091. Signtype interface{} `json:"signtype"`
  4092. WarnMsg interface{} `json:"warn_msg"`
  4093. }
  4094. type ResultEleven10265 struct {
  4095. Cainfo string `json:"cainfo"`
  4096. ErrMsg string `json:"err_msg"`
  4097. InfRefmsgid string `json:"inf_refmsgid"`
  4098. Infcode string `json:"infcode"`
  4099. Output struct {
  4100. Setlinfo struct {
  4101. SetlTime string `json:"setl_time"`
  4102. CvlservPay float64 `json:"cvlserv_pay"`
  4103. Year string `json:"year"`
  4104. MedType string `json:"med_type"`
  4105. PsnPay float64 `json:"psn_pay"`
  4106. OpterID string `json:"opter_id"`
  4107. Begndate string `json:"begndate"`
  4108. FlxempeFlag string `json:"flxempe_flag"`
  4109. HifmiPay float64 `json:"hifmi_pay"`
  4110. PsnNo string `json:"psn_no"`
  4111. ActPayDedc float64 `json:"act_pay_dedc"`
  4112. MedinsSetlID interface{} `json:"medins_setl_id"`
  4113. AcctMulaidPay interface{} `json:"acct_mulaid_pay"`
  4114. ClrWay string `json:"clr_way"`
  4115. OthPay float64 `json:"oth_pay"`
  4116. Gend string `json:"gend"`
  4117. MdtrtID string `json:"mdtrt_id"`
  4118. AcctPay float64 `json:"acct_pay"`
  4119. InscpScpAmt float64 `json:"inscp_scp_amt"`
  4120. Insutype string `json:"insutype"`
  4121. Invono interface{} `json:"invono"`
  4122. Enddate string `json:"enddate"`
  4123. CashPayamt float64 `json:"cash_payamt"`
  4124. PsnType string `json:"psn_type"`
  4125. FixmedinsName string `json:"fixmedins_name"`
  4126. HifpPay float64 `json:"hifp_pay"`
  4127. NewFlag interface{} `json:"new_flag"`
  4128. OverlmtSelfpay float64 `json:"overlmt_selfpay"`
  4129. PreselfpayAmt float64 `json:"preselfpay_amt"`
  4130. PayLoc string `json:"pay_loc"`
  4131. ClrType string `json:"clr_type"`
  4132. RefdSetlFlag string `json:"refd_setl_flag"`
  4133. CvlservFlag string `json:"cvlserv_flag"`
  4134. EmpName string `json:"emp_name"`
  4135. Brdy string `json:"brdy"`
  4136. Naty string `json:"naty"`
  4137. Certno string `json:"certno"`
  4138. DiseCode string `json:"dise_code"`
  4139. FixmedinsCode string `json:"fixmedins_code"`
  4140. DedcHospLv string `json:"dedc_hosp_lv"`
  4141. OpterName string `json:"opter_name"`
  4142. Balc float64 `json:"balc"`
  4143. FixmedinsPoolarea string `json:"fixmedins_poolarea"`
  4144. PsnCertType string `json:"psn_cert_type"`
  4145. HifobPay float64 `json:"hifob_pay"`
  4146. MedfeeSumamt float64 `json:"medfee_sumamt"`
  4147. HifesPay float64 `json:"hifes_pay"`
  4148. FundPaySumamt float64 `json:"fund_pay_sumamt"`
  4149. OptTime string `json:"opt_time"`
  4150. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  4151. SetlID string `json:"setl_id"`
  4152. MafPay float64 `json:"maf_pay"`
  4153. PsnName string `json:"psn_name"`
  4154. InsuOptins interface{} `json:"insu_optins"`
  4155. PrefFundPay interface{} `json:"pref_fund_pay"`
  4156. ClrOptins string `json:"clr_optins"`
  4157. PoolPropSelfpay float64 `json:"pool_prop_selfpay"`
  4158. DiseName string `json:"dise_name"`
  4159. LmtpricHospLv string `json:"lmtpric_hosp_lv"`
  4160. Age float64 `json:"age"`
  4161. DtrtCertType string `json:"dtrt_cert_type"`
  4162. HospLv string `json:"hosp_lv"`
  4163. } `json:"setlinfo"`
  4164. } `json:"output"`
  4165. RefmsgTime string `json:"refmsg_time"`
  4166. RespondTime string `json:"respond_time"`
  4167. Signtype interface{} `json:"signtype"`
  4168. WarnMsg interface{} `json:"warn_msg"`
  4169. }
  4170. type ResultTwelve struct {
  4171. Cainfo string `json:"cainfo"`
  4172. ErrMsg string `json:"err_msg"`
  4173. InfRefmsgid string `json:"inf_refmsgid"`
  4174. Infcode int64 `json:"infcode"`
  4175. Output struct {
  4176. MdtrtId string `json:"mdtrt_id"`
  4177. ChrgBchno string `json:"chrg_bchno"`
  4178. PsnNo string `json:"psn_no"`
  4179. } `json:"output"`
  4180. RefmsgTime string `json:"refmsg_time"`
  4181. RespondTime string `json:"respond_time"`
  4182. Signtype interface{} `json:"signtype"`
  4183. WarnMsg interface{} `json:"warn_msg"`
  4184. }
  4185. type ResultThirteen struct {
  4186. ErrMsg string `json:"err_msg"`
  4187. InfRefmsgid string `json:"inf_refmsgid"`
  4188. Infcode int64 `json:"infcode"`
  4189. Output struct {
  4190. Result struct {
  4191. TrtDclaDetlSn string `json:"trt_dcla_detl_sn"`
  4192. } `json:"result"`
  4193. } `json:"output"`
  4194. RefmsgTime string `json:"refmsg_time"`
  4195. RespondTime string `json:"respond_time"`
  4196. Signtype interface{} `json:"signtype"`
  4197. WarnInfo interface{} `json:"warn_info"`
  4198. }
  4199. type ResultThirteen10265 struct {
  4200. ErrMsg string `json:"err_msg"`
  4201. InfRefmsgid string `json:"inf_refmsgid"`
  4202. Infcode string `json:"infcode"`
  4203. Output struct {
  4204. Result struct {
  4205. TrtDclaDetlSn string `json:"trt_dcla_detl_sn"`
  4206. } `json:"result"`
  4207. } `json:"output"`
  4208. RefmsgTime string `json:"refmsg_time"`
  4209. RespondTime string `json:"respond_time"`
  4210. Signtype interface{} `json:"signtype"`
  4211. WarnInfo interface{} `json:"warn_info"`
  4212. }
  4213. type ResultFourteen struct {
  4214. ErrMsg string `json:"err_msg"`
  4215. InfRefmsgid string `json:"inf_refmsgid"`
  4216. Infcode int64 `json:"infcode"`
  4217. Output struct {
  4218. } `json:"output"`
  4219. RefmsgTime string `json:"refmsg_time"`
  4220. RespondTime string `json:"respond_time"`
  4221. Signtype interface{} `json:"signtype"`
  4222. WarnInfo interface{} `json:"warn_info"`
  4223. }
  4224. type ResultFourteen10265 struct {
  4225. ErrMsg string `json:"err_msg"`
  4226. InfRefmsgid string `json:"inf_refmsgid"`
  4227. Infcode string `json:"infcode"`
  4228. Output struct {
  4229. } `json:"output"`
  4230. RefmsgTime string `json:"refmsg_time"`
  4231. RespondTime string `json:"respond_time"`
  4232. Signtype interface{} `json:"signtype"`
  4233. WarnInfo interface{} `json:"warn_info"`
  4234. }
  4235. type ResultSixteen struct {
  4236. Cainfo string `json:"cainfo"`
  4237. ErrMsg string `json:"err_msg"`
  4238. InfRefmsgid string `json:"inf_refmsgid"`
  4239. Infcode int64 `json:"infcode"`
  4240. Output struct {
  4241. Setldetail []interface{} `json:"setldetail"`
  4242. Setlinfo struct {
  4243. MdtrtID string `json:"mdtrt_id"`
  4244. SetlID string `json:"setl_id"`
  4245. ClrOptins string `json:"clr_optins"`
  4246. SetlTime string `json:"setl_time"`
  4247. MedfeeSumamt float64 `json:"medfee_sumamt"`
  4248. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  4249. OverlmtSelfpay float64 `json:"overlmt_selfpay"`
  4250. PreselfpayAmt float64 `json:"preselfpay_amt"`
  4251. InscpScpAmt float64 `json:"inscp_scp_amt"`
  4252. ActPayDedc float64 `json:"act_pay_dedc"`
  4253. HifpPay float64 `json:"hifp_pay"`
  4254. PoolPropSe float64 `json:"pool_prop_selfpay"`
  4255. Lfpay float64 `json:"selfpay"`
  4256. CvlservPay float64 `json:"cvlserv_pay"`
  4257. HifesPay float64 `json:"hifes_pay"`
  4258. HifmiPay float64 `json:"hifmi_pay"`
  4259. HifobPay float64 `json:"hifob_pay"`
  4260. MafPay float64 `json:"maf_pay"`
  4261. OthPay float64 `json:"oth_pay"`
  4262. FundPaySumamt float64 `json:"fund_pay_sumamt"`
  4263. PsnPartAmt float64 `json:"psn_part_amt"`
  4264. AcctPay float64 `json:"acct_pay"`
  4265. Balc float64 `json:"balc"`
  4266. AcctMulaidPay float64 `json:"acct_mulaid_pay"`
  4267. HospPartAmt float64 `json:"hosp_part_amt"`
  4268. MedinsSetlID string `json:"medins_setl_id"`
  4269. PdnCashPay string `json:"pdn_cash_pay"`
  4270. } `json:"setlinfo"`
  4271. } `json:"output"`
  4272. RefmsgTime string `json:"refmsg_time"`
  4273. RespondTime string `json:"respond_time"`
  4274. Signtype interface{} `json:"signtype"`
  4275. WarnMsg interface{} `json:"warn_msg"`
  4276. }
  4277. type ResultSixteen10265 struct {
  4278. Cainfo string `json:"cainfo"`
  4279. ErrMsg string `json:"err_msg"`
  4280. InfRefmsgid string `json:"inf_refmsgid"`
  4281. Infcode string `json:"infcode"`
  4282. Output struct {
  4283. Setldetail []interface{} `json:"setldetail"`
  4284. Setlinfo struct {
  4285. MdtrtID string `json:"mdtrt_id"`
  4286. SetlID string `json:"setl_id"`
  4287. ClrOptins string `json:"clr_optins"`
  4288. SetlTime string `json:"setl_time"`
  4289. MedfeeSumamt float64 `json:"medfee_sumamt"`
  4290. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  4291. OverlmtSelfpay float64 `json:"overlmt_selfpay"`
  4292. PreselfpayAmt float64 `json:"preselfpay_amt"`
  4293. InscpScpAmt float64 `json:"inscp_scp_amt"`
  4294. ActPayDedc float64 `json:"act_pay_dedc"`
  4295. HifpPay float64 `json:"hifp_pay"`
  4296. PoolPropSe float64 `json:"pool_prop_selfpay"`
  4297. Lfpay float64 `json:"selfpay"`
  4298. CvlservPay float64 `json:"cvlserv_pay"`
  4299. HifesPay float64 `json:"hifes_pay"`
  4300. HifmiPay float64 `json:"hifmi_pay"`
  4301. HifobPay float64 `json:"hifob_pay"`
  4302. MafPay float64 `json:"maf_pay"`
  4303. OthPay float64 `json:"oth_pay"`
  4304. FundPaySumamt float64 `json:"fund_pay_sumamt"`
  4305. PsnPartAmt float64 `json:"psn_part_amt"`
  4306. AcctPay float64 `json:"acct_pay"`
  4307. Balc float64 `json:"balc"`
  4308. AcctMulaidPay float64 `json:"acct_mulaid_pay"`
  4309. HospPartAmt float64 `json:"hosp_part_amt"`
  4310. MedinsSetlID string `json:"medins_setl_id"`
  4311. PdnCashPay string `json:"pdn_cash_pay"`
  4312. } `json:"setlinfo"`
  4313. } `json:"output"`
  4314. RefmsgTime string `json:"refmsg_time"`
  4315. RespondTime string `json:"respond_time"`
  4316. Signtype interface{} `json:"signtype"`
  4317. WarnMsg interface{} `json:"warn_msg"`
  4318. }
  4319. type ResultSeventeen struct {
  4320. ErrMsg string `json:"err_msg"`
  4321. InfRefmsgid string `json:"inf_refmsgid"`
  4322. Infcode int64 `json:"infcode"`
  4323. Output struct {
  4324. SetlListId string `json:"setl_list_id"`
  4325. } `json:"output"`
  4326. RefmsgTime string `json:"refmsg_time"`
  4327. RespondTime string `json:"respond_time"`
  4328. Signtype string `json:"signtype"`
  4329. WarnInfo string `json:"warn_info"`
  4330. }
  4331. type ResultSeventeenOther struct {
  4332. ErrMsg string `json:"err_msg"`
  4333. InfRefmsgid string `json:"inf_refmsgid"`
  4334. Infcode string `json:"infcode"`
  4335. Output struct {
  4336. SetlListId string `json:"setl_list_id"`
  4337. } `json:"output"`
  4338. RefmsgTime string `json:"refmsg_time"`
  4339. RespondTime string `json:"respond_time"`
  4340. Signtype string `json:"signtype"`
  4341. WarnInfo string `json:"warn_info"`
  4342. }
  4343. type Result90991 struct {
  4344. ErrMsg string `json:"err_msg"`
  4345. InfRefmsgid string `json:"inf_refmsgid"`
  4346. Infcode int64 `json:"infcode"`
  4347. Output struct {
  4348. Result struct {
  4349. PsnNo string `json:"psn_no"`
  4350. CardStat string `json:"card_stat"`
  4351. Certno string `json:"certno"`
  4352. PsnName string `json:"psn_name"`
  4353. CheckStat string `json:"check_stat"`
  4354. SscnoCheckStat string `json:"sscno_check_stat"`
  4355. } `json:"result"`
  4356. } `json:"output"`
  4357. RefmsgTime string `json:"refmsg_time"`
  4358. RespondTime string `json:"respond_time"`
  4359. Signtype interface{} `json:"signtype"`
  4360. WarnInfo interface{} `json:"warn_info"`
  4361. }
  4362. type Result90100 struct {
  4363. ErrMsg string `json:"err_msg"`
  4364. InfRefmsgid string `json:"inf_refmsgid"`
  4365. Infcode int64 `json:"infcode"`
  4366. Output struct {
  4367. PoolareaNo string `json:"poolarea_no"`
  4368. PoolareaNoName string `json:"poolarea_no_name"`
  4369. Insutype string `json:"insutype"`
  4370. InsutypeName string `json:"insutype_name"`
  4371. ClctType string `json:"clct_type"`
  4372. ClctTypeName string `json:"clct_type_name"`
  4373. ClctFlag string `json:"clct_flag"`
  4374. ClctFlagName string `json:"clct_flag_name"`
  4375. AccrymBegn string `json:"accrym_begn"`
  4376. AccrymEnd string `json:"accrym_end"`
  4377. ClctTime string `json:"clct_time"`
  4378. ClctstdCrtfRuleCodg string `json:"clctstd_crtf_rule_codg"`
  4379. } `json:"output"`
  4380. RefmsgTime string `json:"refmsg_time"`
  4381. RespondTime string `json:"respond_time"`
  4382. Signtype interface{} `json:"signtype"`
  4383. WarnInfo interface{} `json:"warn_info"`
  4384. }
  4385. type Custom struct {
  4386. DetItemFeeSumamt string
  4387. Cut string
  4388. FeedetlSn string
  4389. Price string
  4390. MedListCodg string
  4391. Type int64
  4392. AdviceId int64
  4393. ProjectId int64
  4394. ItemId int64
  4395. }
  4396. type Result5301 struct {
  4397. ErrMsg string `json:"err_msg"`
  4398. InfRefmsgid string `json:"inf_refmsgid"`
  4399. Infcode int64 `json:"infcode"`
  4400. Output struct {
  4401. Result []struct {
  4402. OpspDiseCode string `json:"opsp_dise_code"`
  4403. OpspDiseName string `json:"opsp_dise_name"`
  4404. Begndate string `json:"begndate"`
  4405. Enddate string `json:"enddate"`
  4406. } `json:"feedetail"`
  4407. } `json:"output"`
  4408. RefmsgTime string `json:"refmsg_time"`
  4409. RespondTime string `json:"respond_time"`
  4410. Signtype interface{} `json:"signtype"`
  4411. WarnInfo interface{} `json:"warn_info"`
  4412. }
  4413. type Result5301For10265 struct {
  4414. ErrMsg string `json:"err_msg"`
  4415. InfRefmsgid string `json:"inf_refmsgid"`
  4416. Infcode string `json:"infcode"`
  4417. Output struct {
  4418. Result []struct {
  4419. OpspDiseCode string `json:"opsp_dise_code"`
  4420. OpspDiseName string `json:"opsp_dise_name"`
  4421. Begndate string `json:"begndate"`
  4422. Enddate string `json:"enddate"`
  4423. } `json:"feedetail"`
  4424. } `json:"output"`
  4425. RefmsgTime string `json:"refmsg_time"`
  4426. RespondTime string `json:"respond_time"`
  4427. Signtype interface{} `json:"signtype"`
  4428. WarnInfo interface{} `json:"warn_info"`
  4429. }
  4430. //获取个人信息----挂号-----上传就诊信息
  4431. func (c *HisApiController) GetRegisterInfo() {
  4432. id, _ := c.GetInt64("id")
  4433. record_time := c.GetString("record_time")
  4434. settlementValue, _ := c.GetInt64("settlement_value")
  4435. medical_insurance_card := c.GetString("medical_insurance_card")
  4436. name := c.GetString("name")
  4437. id_card_type, _ := c.GetInt64("id_card_type")
  4438. certificates, _ := c.GetInt64("certificates")
  4439. medical_care, _ := c.GetInt64("medical_care")
  4440. birthday := c.GetString("birthday")
  4441. id_card := c.GetString("id_card")
  4442. register_type, _ := c.GetInt64("register")
  4443. doctor, _ := c.GetInt64("doctor")
  4444. department, _ := c.GetInt64("department")
  4445. gender, _ := c.GetInt64("sex")
  4446. registration_fee, _ := c.GetFloat("registration_fee")
  4447. medical_expenses, _ := c.GetFloat("medical_expenses")
  4448. social_type, _ := c.GetInt64("social_type")
  4449. med_type := c.GetString("social_type")
  4450. admin_user_id, _ := c.GetInt64("admin_user_id")
  4451. insuplc_admdvs := c.GetString("insuplc_admdvs")
  4452. timeLayout := "2006-01-02"
  4453. loc, _ := time.LoadLocation("Local")
  4454. birthdays, _ := time.ParseInLocation(timeLayout+" 15:04:05", birthday+" 00:00:00", loc)
  4455. birthUnix := birthdays.Unix()
  4456. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  4457. if err != nil {
  4458. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  4459. return
  4460. }
  4461. recordDateTime := theTime.Unix()
  4462. adminInfo := c.GetAdminUserInfo()
  4463. var patient service.Patients
  4464. if id == 0 {
  4465. patient, _ = service.GetPatientByIDCard(id_card, adminInfo.CurrentOrgId)
  4466. } else {
  4467. patient, _ = service.GetPatientByIDTwo(adminInfo.CurrentOrgId, id)
  4468. }
  4469. patientPrescription, _ := service.FindPatientPrescriptionInfo(adminInfo.CurrentOrgId, id, recordDateTime)
  4470. if patientPrescription.ID == 0 {
  4471. patientPrescription, _ = service.FindLastPatientPrescriptionInfo(adminInfo.CurrentOrgId, id, recordDateTime)
  4472. }
  4473. miConfig, _ := service.FindMedicalInsuranceInfo(adminInfo.CurrentOrgId)
  4474. if patient.ID == 0 {
  4475. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodePatientNoExist)
  4476. return
  4477. }
  4478. if len(patient.IdCardNo) == 0 {
  4479. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeIDCartNo)
  4480. return
  4481. }
  4482. config, _ := service.GetMedicalInsuranceConfig(adminInfo.CurrentOrgId)
  4483. roles, _ := service.GetAdminUserInfoByID(adminInfo.CurrentOrgId, admin_user_id)
  4484. doctor_info, _ := service.GetAdminUserInfoByID(adminInfo.CurrentOrgId, doctor)
  4485. //就诊结算未完成,不能进行二次挂号
  4486. his, _ := service.GetHisPatientInfoTwo(adminInfo.CurrentOrgId, patient.ID, recordDateTime)
  4487. if len(his) >= 1 {
  4488. order, _ := service.GetNewHisOrderTwo(adminInfo.CurrentOrgId, his[len(his)-1].Number, his[len(his)-1].PatientId, recordDateTime)
  4489. if len(his) >= 1 && order.ID == 0 {
  4490. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisPatientParamWrong)
  4491. return
  4492. }
  4493. }
  4494. //var register_log string
  4495. if config.IsOpen == 1 {
  4496. var res ResultTwo
  4497. var res10265 ResultTwo10265
  4498. var PsnNo string
  4499. var PsnCertType string
  4500. var Certno string
  4501. var PsnName string
  4502. var Gend string
  4503. var Naty string
  4504. var Brdy string
  4505. var Age float64
  4506. var infoStr string
  4507. var idetinfoStr string
  4508. var infocode int64
  4509. var verify_number string
  4510. fmt.Println(verify_number)
  4511. if miConfig.MdtrtareaAdmvs == "421300" {
  4512. psn_info, _ := service.GetPsnByPatientId(id)
  4513. PsnNo = psn_info.PsnNo
  4514. PsnCertType = psn_info.PsnCertType
  4515. Certno = psn_info.Certno
  4516. PsnName = psn_info.PsnName
  4517. Gend = psn_info.Gend
  4518. Naty = psn_info.Naty
  4519. Brdy = psn_info.Brdy
  4520. Age = psn_info.Age
  4521. infoStr = psn_info.Insuinfo
  4522. idetinfoStr = psn_info.Idetinfo
  4523. infocode = 0
  4524. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  4525. psn_info, _ := service.GetPsnByPatientId(id)
  4526. PsnNo = psn_info.PsnNo
  4527. PsnCertType = psn_info.PsnCertType
  4528. Certno = psn_info.Certno
  4529. PsnName = psn_info.PsnName
  4530. Gend = psn_info.Gend
  4531. Naty = psn_info.Naty
  4532. Brdy = psn_info.Brdy
  4533. Age = psn_info.Age
  4534. infoStr = psn_info.Insuinfo
  4535. idetinfoStr = psn_info.Idetinfo
  4536. infocode = 0
  4537. verify_number = psn_info.VerifyNumber
  4538. } else if miConfig.MdtrtareaAdmvs == "350500" {
  4539. psn_info, _ := service.GetPsnByPatientId(id)
  4540. PsnNo = psn_info.PsnNo
  4541. PsnCertType = psn_info.PsnCertType
  4542. Certno = psn_info.Certno
  4543. PsnName = psn_info.PsnName
  4544. Gend = psn_info.Gend
  4545. Naty = psn_info.Naty
  4546. Brdy = psn_info.Brdy
  4547. Age = psn_info.Age
  4548. infoStr = psn_info.Insuinfo
  4549. idetinfoStr = psn_info.Idetinfo
  4550. infocode = 0
  4551. verify_number = psn_info.VerifyNumber
  4552. } else {
  4553. var result string
  4554. var requestLog string
  4555. if miConfig.UserOrgId == 10138 {
  4556. 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)
  4557. } else {
  4558. 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)
  4559. }
  4560. saveLog(result, requestLog, "1101", "人员基本信息获取")
  4561. if miConfig.Code == "H15049901371" {
  4562. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  4563. utils.ErrorLog("解析失败:%v", err)
  4564. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4565. return
  4566. }
  4567. res.ErrMsg = res10265.ErrMsg
  4568. res.Output = res10265.Output
  4569. res.InfRefmsgid = res10265.InfRefmsgid
  4570. } else {
  4571. if err := json.Unmarshal([]byte(result), &res); err != nil {
  4572. utils.ErrorLog("解析失败:%v", err)
  4573. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4574. return
  4575. }
  4576. }
  4577. PsnNo = res.Output.Baseinfo.PsnNo
  4578. PsnCertType = res.Output.Baseinfo.PsnCertType
  4579. Certno = res.Output.Baseinfo.Certno
  4580. PsnName = res.Output.Baseinfo.PsnName
  4581. Gend = res.Output.Baseinfo.Gend
  4582. Naty = res.Output.Baseinfo.Naty
  4583. Brdy = res.Output.Baseinfo.Brdy
  4584. Age = res.Output.Baseinfo.Age
  4585. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  4586. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  4587. infoStr = string(Iinfos)
  4588. idetinfoStr = string(Idetinfos)
  4589. if miConfig.Code == "H15049901371" {
  4590. infocode, _ = strconv.ParseInt(res10265.Infcode, 10, 64)
  4591. } else {
  4592. infocode = res.Infcode
  4593. }
  4594. }
  4595. if infocode == 0 {
  4596. his := models.VMHisPatient{
  4597. Name: name,
  4598. Gender: gender,
  4599. Birthday: birthUnix,
  4600. MedicalTreatmentType: medical_care,
  4601. IdType: certificates,
  4602. IdCardNo: id_card,
  4603. BalanceAccountsType: settlementValue,
  4604. SocialType: social_type,
  4605. MedicalInsuranceNumber: medical_insurance_card,
  4606. RegisterType: register_type,
  4607. RegisterCost: registration_fee,
  4608. TreatmentCost: medical_expenses,
  4609. Status: 1,
  4610. Ctime: time.Now().Unix(),
  4611. Mtime: time.Now().Unix(),
  4612. PsnNo: PsnNo,
  4613. PsnCertType: PsnCertType,
  4614. Certno: Certno,
  4615. PsnName: PsnName,
  4616. Gend: Gend,
  4617. Naty: Naty,
  4618. Brdy: Brdy,
  4619. Age: Age,
  4620. Iinfo: infoStr,
  4621. Idetinfo: idetinfoStr,
  4622. PatientId: patient.ID,
  4623. RecordDate: theTime.Unix(),
  4624. UserOrgId: adminInfo.CurrentOrgId,
  4625. AdminUserId: admin_user_id,
  4626. IsReturn: 1,
  4627. IdCardType: id_card_type,
  4628. Doctor: doctor,
  4629. Departments: department,
  4630. }
  4631. timestamp := time.Now().Unix()
  4632. tempTime := time.Unix(timestamp, 0)
  4633. timeFormat := tempTime.Format("20060102150405")
  4634. chrgBchno := rand.Intn(100000) + 10000
  4635. ipt_otp_no := timeFormat + strconv.FormatInt(int64(chrgBchno), 10) + strconv.FormatInt(his.PatientId, 10)
  4636. //count, _ := service.FindHisRegisterRecord(theTime.Unix(), patient.ID, adminInfo.CurrentOrgId)
  4637. department, _ := service.GetDepartMentDetail(department)
  4638. doctor_id := strconv.FormatInt(patientPrescription.DoctorId, 10)
  4639. IdCardNo := ""
  4640. if id_card_type == 1 {
  4641. // IdCardNo = medical_insurance_card
  4642. IdCardNo = patient.IdCardNo
  4643. } else {
  4644. IdCardNo = patient.IdCardNo
  4645. }
  4646. var rf []*ResultFive
  4647. json.Unmarshal([]byte(his.Iinfo), &rf)
  4648. var insutypes []*ResultFive
  4649. var insutype string
  4650. var insuplc_admdvs_temp string
  4651. var is390 int = 0
  4652. var is310 int = 0
  4653. for _, item := range rf {
  4654. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  4655. insutypes = append(insutypes, item)
  4656. }
  4657. }
  4658. if len(insutypes) == 1 {
  4659. insutype = insutypes[0].Insutype
  4660. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  4661. } else {
  4662. for _, i := range insutypes {
  4663. if i.Insutype == "390" {
  4664. is390 = 1
  4665. }
  4666. if i.Insutype == "310" {
  4667. is310 = 1
  4668. }
  4669. }
  4670. }
  4671. if is390 == 1 {
  4672. insutype = "390"
  4673. }
  4674. if is310 == 1 {
  4675. insutype = "310"
  4676. }
  4677. if len(insutypes) == 0 {
  4678. insutype = "310"
  4679. }
  4680. if len(insutypes) == 2 {
  4681. insutype = med_type
  4682. }
  4683. if len(med_type) > 0 {
  4684. insutype = med_type
  4685. }
  4686. //for _, item := range rf {
  4687. // if item.Insutype == insutype {
  4688. // insuplc_admdvs = item.InsuplcAdmdvs
  4689. // }
  4690. //}
  4691. var infocode int64
  4692. var resThree ResultThree
  4693. var resThree10265 ResultThree10265
  4694. if len(insuplc_admdvs) == 0 {
  4695. insuplc_admdvs_temp = miConfig.InsuplcAdmdvs
  4696. } else {
  4697. insuplc_admdvs_temp = insuplc_admdvs
  4698. }
  4699. if miConfig.MdtrtareaAdmvs == "421300" {
  4700. hb_doctor_info, _ := service.GetAdminUserInfoByID(adminInfo.CurrentOrgId, patientPrescription.DoctorId)
  4701. api := "http://192.168.124.4:9532/" + "hbyb/2201?psn_no=" + PsnNo + "&insutype=" + insutype + "&cert_no=" + Certno + "&ipt_otp_no=" + ipt_otp_no +
  4702. "&org_name=" + miConfig.OrgName + "&doctor=" + hb_doctor_info.UserName + "&fixmedins_code=" + miConfig.Code +
  4703. "&insuplc_admdvs=" + insuplc_admdvs_temp + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(id_card_type, 10) + "&dept_code=" + department.Number + "&dept=" + department.Name + "&doctor_id=" + hb_doctor_info.DoctorNumber + "&doctor_name=" + hb_doctor_info.UserName + "&opter=" + roles.UserName
  4704. resp, requestErr := http.Get(api)
  4705. if requestErr != nil {
  4706. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4707. return
  4708. }
  4709. body, ioErr := ioutil.ReadAll(resp.Body)
  4710. if ioErr != nil {
  4711. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  4712. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4713. return
  4714. }
  4715. var respJSON map[string]interface{}
  4716. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  4717. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  4718. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4719. return
  4720. }
  4721. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  4722. result, _ := json.Marshal(respJSON)
  4723. if err := json.Unmarshal([]byte(result), &resThree); err != nil {
  4724. utils.ErrorLog("解析失败:%v", err)
  4725. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4726. return
  4727. }
  4728. infocode = resThree.Infcode
  4729. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  4730. psn_info, _ := service.GetPsnByPatientId(id)
  4731. psn_info.VerifyNumber = strings.Replace(psn_info.VerifyNumber, "+", "%2B", -1)
  4732. var cert_no string
  4733. if id_card_type == 3 {
  4734. psn_info.VerifyNumber = IdCardNo + "|" + psn_info.VerifyNumber
  4735. cert_no = IdCardNo
  4736. } else if id_card_type == 4 {
  4737. cert_no = IdCardNo
  4738. psn_info.VerifyNumber = psn_info.VerifyNumber
  4739. } else {
  4740. bas := strings.Split(psn_info.CardInfo, "|")
  4741. cert_no = bas[2]
  4742. }
  4743. var api string
  4744. if miConfig.MdtrtareaAdmvs == "320921" {
  4745. api = "http://192.168.2.110:9532/" + "jsyb/2201?psn_no=" + PsnNo + "&insutype=" + insutype + "&cert_no=" + cert_no + "&ipt_otp_no=" + ipt_otp_no +
  4746. "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&doctor_name=" + doctor_info.UserName + "&fixmedins_code=" + miConfig.Code +
  4747. "&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
  4748. } else {
  4749. api = "http://192.168.5.251:9532/" + "jsyb/2201?psn_no=" + PsnNo + "&insutype=" + insutype + "&cert_no=" + cert_no + "&ipt_otp_no=" + ipt_otp_no +
  4750. "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&doctor_name=" + doctor_info.UserName + "&fixmedins_code=" + miConfig.Code +
  4751. "&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
  4752. }
  4753. resp, requestErr := http.Get(api)
  4754. if requestErr != nil {
  4755. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4756. return
  4757. }
  4758. body, ioErr := ioutil.ReadAll(resp.Body)
  4759. if ioErr != nil {
  4760. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  4761. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4762. return
  4763. }
  4764. var respJSON map[string]interface{}
  4765. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  4766. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  4767. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4768. return
  4769. }
  4770. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  4771. result, _ := json.Marshal(respJSON)
  4772. if err := json.Unmarshal([]byte(result), &resThree10265); err != nil {
  4773. utils.ErrorLog("解析失败:%v", err)
  4774. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4775. return
  4776. }
  4777. resThree.ErrMsg = resThree10265.ErrMsg
  4778. resThree.Output = resThree10265.Output
  4779. resThree.InfRefmsgid = resThree10265.InfRefmsgid
  4780. infocode, _ = strconv.ParseInt(resThree10265.Infcode, 10, 64)
  4781. } else if miConfig.MdtrtareaAdmvs == "350500" {
  4782. psn_info, _ := service.GetPsnByPatientId(id)
  4783. var cert_no string
  4784. if id_card_type == 1 {
  4785. cert_no = strings.Split(psn_info.CardInfo, "|")[0]
  4786. }
  4787. fmt.Println(cert_no)
  4788. result, requestLog := service.FJyb2201(psn_info.PsnNo, insutype, IdCardNo, miConfig.OrgName, doctor_info.UserName, ipt_otp_no, department.Name, miConfig.Code, department.Number, doctor_id, insuplc_admdvs_temp, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, id_card_type, roles.UserName, doctor_info.UserName, miConfig.Url, miConfig.Code, miConfig.AppSecret, miConfig.SignKey, miConfig.EncKey, cert_no)
  4789. saveLog(result, requestLog, "2201", "挂号")
  4790. if miConfig.Code == "H15049901371" {
  4791. if err := json.Unmarshal([]byte(result), &resThree10265); err != nil {
  4792. utils.ErrorLog("解析失败:%v", err)
  4793. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4794. return
  4795. }
  4796. resThree.ErrMsg = resThree10265.ErrMsg
  4797. resThree.Output = resThree10265.Output
  4798. resThree.InfRefmsgid = resThree10265.InfRefmsgid
  4799. } else {
  4800. if err := json.Unmarshal([]byte(result), &resThree); err != nil {
  4801. utils.ErrorLog("解析失败:%v", err)
  4802. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4803. return
  4804. }
  4805. }
  4806. infocode, _ = strconv.ParseInt(resThree10265.Infcode, 10, 64)
  4807. } else {
  4808. result, requestLog := service.Gdyb2201A(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, record_time)
  4809. saveLog(result, requestLog, "2201A", "挂号")
  4810. if miConfig.Code == "H15049901371" {
  4811. if err := json.Unmarshal([]byte(result), &resThree10265); err != nil {
  4812. utils.ErrorLog("解析失败:%v", err)
  4813. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4814. return
  4815. }
  4816. resThree.ErrMsg = resThree10265.ErrMsg
  4817. resThree.Output = resThree10265.Output
  4818. resThree.InfRefmsgid = resThree10265.InfRefmsgid
  4819. } else {
  4820. if err := json.Unmarshal([]byte(result), &resThree); err != nil {
  4821. utils.ErrorLog("解析失败:%v", err)
  4822. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4823. return
  4824. }
  4825. }
  4826. if miConfig.Code == "H15049901371" {
  4827. infocode, _ = strconv.ParseInt(resThree10265.Infcode, 10, 64)
  4828. } else {
  4829. infocode = resThree.Infcode
  4830. }
  4831. }
  4832. if infocode != 0 {
  4833. adminUser := c.GetAdminUserInfo()
  4834. errlog := &models.HisOrderError{
  4835. UserOrgId: adminUser.CurrentOrgId,
  4836. Ctime: time.Now().Unix(),
  4837. Mtime: time.Now().Unix(),
  4838. ErrMsg: resThree.ErrMsg,
  4839. Status: 1,
  4840. PatientId: id,
  4841. RecordTime: recordDateTime,
  4842. Stage: 2,
  4843. }
  4844. service.CreateErrMsgLog(errlog)
  4845. c.ServeSuccessJSON(map[string]interface{}{
  4846. "failed_code": -10,
  4847. "msg": resThree.ErrMsg,
  4848. })
  4849. return
  4850. }
  4851. his.Number = resThree.Output.Data.MdtrtID
  4852. his.PsnNo = resThree.Output.Data.PsnNo
  4853. his.IptOtpNo = resThree.Output.Data.IptOtpNo
  4854. his.IdCardNo = patient.IdCardNo
  4855. his.PhoneNumber = patient.Phone
  4856. his.UserOrgId = adminInfo.CurrentOrgId
  4857. his.Insutype = insutype
  4858. his.Ctime = time.Now().Unix()
  4859. his.Mtime = time.Now().Unix()
  4860. his.InsuplcAdmdvs = insuplc_admdvs_temp
  4861. his.Status = 1
  4862. service.UpdateHisPatientStatus(&his)
  4863. service.UpdateHisPrescriptionHisID(his.ID, patient.ID, recordDateTime, adminInfo.CurrentOrgId)
  4864. c.ServeSuccessJSON(map[string]interface{}{
  4865. "his_info": his,
  4866. })
  4867. } else {
  4868. adminUser := c.GetAdminUserInfo()
  4869. errlog := &models.HisOrderError{
  4870. UserOrgId: adminUser.CurrentOrgId,
  4871. Ctime: time.Now().Unix(),
  4872. Mtime: time.Now().Unix(),
  4873. ErrMsg: res.ErrMsg,
  4874. Status: 1,
  4875. PatientId: id,
  4876. RecordTime: recordDateTime,
  4877. Stage: 1,
  4878. }
  4879. service.CreateErrMsgLog(errlog)
  4880. c.ServeSuccessJSON(map[string]interface{}{
  4881. "failed_code": -10,
  4882. "msg": res.ErrMsg,
  4883. })
  4884. return
  4885. //c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeGdybOneException)
  4886. }
  4887. }
  4888. }
  4889. //上传明细----预结算----确认订单
  4890. func (c *HisApiController) GetUploadInfo() {
  4891. id, _ := c.GetInt64("id")
  4892. record_time := c.GetString("record_time")
  4893. his_patient_id, _ := c.GetInt64("his_patient_id")
  4894. order_id, _ := c.GetInt64("order_id")
  4895. pay_way, _ := c.GetInt64("pay_way")
  4896. pay_price, _ := c.GetFloat("pay_price")
  4897. pay_card_no := c.GetString("pay_card_no")
  4898. token := c.GetString("token")
  4899. discount_price, _ := c.GetFloat("discount_price")
  4900. preferential_price, _ := c.GetFloat("preferential_price")
  4901. reality_price, _ := c.GetFloat("reality_price")
  4902. found_price, _ := c.GetFloat("found_price")
  4903. medical_insurance_price, _ := c.GetFloat("medical_insurance_price")
  4904. private_price, _ := c.GetFloat("private_price")
  4905. settle_accounts_type, _ := c.GetInt64("settle_accounts_type")
  4906. admin_user_id, _ := c.GetInt64("admin_user_id")
  4907. fapiao_code := c.GetString("fapiao_code")
  4908. fapiao_number := c.GetString("fapiao_number")
  4909. diagnosis_id := c.GetString("diagnosis")
  4910. sick_type, _ := c.GetInt64("sick_type")
  4911. reg_type, _ := c.GetInt64("p_type")
  4912. begin_time := c.GetString("begin_time")
  4913. id_str := c.GetString("ids")
  4914. ids_arr := strings.Split(id_str, ",")
  4915. timeLayout := "2006-01-02"
  4916. loc, _ := time.LoadLocation("Local")
  4917. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  4918. if err != nil {
  4919. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  4920. return
  4921. }
  4922. recordDateTime := theTime.Unix()
  4923. adminUser := c.GetAdminUserInfo()
  4924. var tempOrder models.HisOrder
  4925. tempOrder, _ = service.GetHisOrderByID(order_id)
  4926. var prescriptions []*models.HisPrescription
  4927. var start_time int64
  4928. var end_time int64
  4929. //押金模块
  4930. dec_way := c.GetString("dec_way") //是否使用押金支付bool类型
  4931. tmp_decimal := c.GetString("tmp_decimal")
  4932. var decimal float64 //本次使用的押金
  4933. var errmsg error
  4934. if dec_way == "true" && tmp_decimal == "0" || dec_way == "true" && tmp_decimal == "" {
  4935. c.ServeFailJsonSend(enums.ErrorCodeParamWrong, "押金不能为0")
  4936. return
  4937. }
  4938. if len(tmp_decimal) > 0 {
  4939. if tmp_decimal[0] == 45 {
  4940. c.ServeFailJsonSend(enums.ErrorCodeParamWrong, "押金不能为负数")
  4941. return
  4942. }
  4943. }
  4944. tt, errs := strconv.ParseFloat(tmp_decimal, 64)
  4945. fmt.Println(errs)
  4946. decimal = tt
  4947. //if adminUser.CurrentOrgId == 10106{
  4948. // if len(fapiao_code) == 0{
  4949. // fapiao_code = "144072080589"
  4950. // }
  4951. // if len(fapiao_number) == 0{
  4952. // order, _ := service.GetLastHisOrder(adminUser.CurrentOrgId)
  4953. // if order.ID == 0{
  4954. // fapiao_number = "00001520"
  4955. // }else{
  4956. // //fapiao_code = "00001520"
  4957. // fpNumber, _ := strconv.Atoi(order.FaPiaoNumber)
  4958. // var zero string
  4959. // if fpNumber >= 1000{
  4960. // zero = "0000" + strconv.Itoa(fpNumber)
  4961. // }else if fpNumber >= 10000{
  4962. // zero = "000" + strconv.Itoa(fpNumber)
  4963. // } else if fpNumber >= 100000{
  4964. // zero = "00" + strconv.Itoa(fpNumber)
  4965. // } else if fpNumber >= 1000000{
  4966. // zero = "0" + strconv.Itoa(fpNumber)
  4967. // }else {
  4968. // zero = strconv.Itoa(fpNumber)
  4969. // }
  4970. // fapiao_number = zero
  4971. // }
  4972. // }
  4973. //}
  4974. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  4975. his, _ := service.GetNewHisPatientInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  4976. var patientPrescription models.HisPrescriptionInfo
  4977. patientPrescription, _ = service.FindHisPatientPrescriptionInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  4978. if patientPrescription.ID == 0 {
  4979. patientPrescription, _ = service.FindLastPatientPrescriptionInfo(adminUser.CurrentOrgId, id, recordDateTime)
  4980. }
  4981. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  4982. department, _ := service.GetDepartMentDetail(patientPrescription.Departments)
  4983. doctor_info, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, patientPrescription.DoctorId)
  4984. diagnosis_ids := strings.Split(diagnosis_id, ",")
  4985. var config []*models.HisXtDiagnoseConfig
  4986. for _, item := range diagnosis_ids {
  4987. id, _ := strconv.ParseInt(item, 10, 64)
  4988. diagnosisConfig, _ := service.FindDiagnoseById(id)
  4989. config = append(config, &diagnosisConfig)
  4990. }
  4991. sickConfig, _ := service.FindSickById(sick_type)
  4992. //if tempOrder.ID == 0 {
  4993. // tempOrder, _ = service.GetTodayHisOrder(adminUser.CurrentOrgId, id, recordDateTime, his.Number)
  4994. //}
  4995. if tempOrder.ID == 0 {
  4996. var result string
  4997. var requestLog string
  4998. var res2 ResultSix
  4999. var ressix10265 ResultSix10265
  5000. if miConfig.MdtrtareaAdmvs == "421300" {
  5001. data := make(map[string]interface{})
  5002. client := &http.Client{}
  5003. data["psn_no"] = his.PsnNo
  5004. data["mdtrt_id"] = his.Number
  5005. data["opter"] = roles.UserName
  5006. data["org_name"] = miConfig.OrgName
  5007. data["med_type"] = strconv.FormatInt(reg_type, 10)
  5008. data["doctor_id"] = doctor_info.DoctorNumber
  5009. data["doctor_name"] = doctor_info.UserName
  5010. data["department"] = department.Name
  5011. data["fixmedins_code"] = miConfig.Code
  5012. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  5013. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  5014. data["secret_key"] = miConfig.SecretKey
  5015. data["sick_code"] = sickConfig.CountryCode
  5016. data["sick_name"] = sickConfig.ClassName
  5017. data["dept"] = strconv.FormatInt(department.ID, 10)
  5018. data["config"] = config
  5019. data["begin_time"] = begin_time
  5020. bytesData, _ := json.Marshal(data)
  5021. req, _ := http.NewRequest("POST", "http://192.168.124.4:9532/"+"hbyb/2203", bytes.NewReader(bytesData))
  5022. resp, _ := client.Do(req)
  5023. defer resp.Body.Close()
  5024. body, ioErr := ioutil.ReadAll(resp.Body)
  5025. if ioErr != nil {
  5026. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  5027. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5028. return
  5029. }
  5030. var respJSON map[string]interface{}
  5031. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  5032. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  5033. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5034. return
  5035. }
  5036. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  5037. userJSONBytes, _ := json.Marshal(respJSON)
  5038. fmt.Println("log")
  5039. fmt.Println(string(userJSONBytes))
  5040. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  5041. utils.ErrorLog("解析失败:%v", err)
  5042. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5043. return
  5044. }
  5045. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  5046. //江苏地区国家医保医疗类别
  5047. //职工透析:医疗类别选特殊情况门诊9933
  5048. //居民血透门慢: 医疗类别选门诊慢病1402
  5049. //var med_type string
  5050. //if his.Insutype == "310" {
  5051. // if reg_type == 14 {
  5052. // med_type = "9933"
  5053. // } else if reg_type == 11 {
  5054. // med_type = "11"
  5055. //
  5056. // }
  5057. //} else if his.Insutype == "390" {
  5058. // if reg_type == 14 {
  5059. // med_type = "1402"
  5060. // } else if reg_type == 11 {
  5061. // med_type = "11"
  5062. // }
  5063. //}
  5064. data := make(map[string]interface{})
  5065. client := &http.Client{}
  5066. data["psn_no"] = his.PsnNo
  5067. data["mdtrt_id"] = his.Number
  5068. data["doctor"] = roles.UserName
  5069. data["department"] = department.Name
  5070. data["org_name"] = miConfig.OrgName
  5071. data["med_type"] = strconv.FormatInt(reg_type, 10)
  5072. data["doctor_id"] = strconv.FormatInt(doctor_info.AdminUserId, 10)
  5073. data["fixmedins_code"] = miConfig.Code
  5074. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  5075. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  5076. data["secret_key"] = miConfig.SecretKey
  5077. data["sick_code"] = sickConfig.CountryCode
  5078. data["sick_name"] = sickConfig.ClassName
  5079. data["url"] = miConfig.Url
  5080. data["ak"] = miConfig.AccessKey
  5081. data["begin_time"] = begin_time
  5082. data["cainfo"] = miConfig.Cainfo
  5083. data["dept"] = strconv.FormatInt(department.ID, 10)
  5084. data["config"] = config
  5085. bytesData, _ := json.Marshal(data)
  5086. var req *http.Request
  5087. if miConfig.MdtrtareaAdmvs == "320921" {
  5088. req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/2203", bytes.NewReader(bytesData))
  5089. //api = "http://192.168.2.110:9532/" + "jsyb/readcard?" + "fixmedins_code=" + miConfig.Code + "&secret_key=" + miConfig.SecretKey + "&ak=" + miConfig.AccessKey + "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName +
  5090. // "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&cainfo=" + miConfig.Cainfo
  5091. } else {
  5092. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2203", bytes.NewReader(bytesData))
  5093. }
  5094. resp, _ := client.Do(req)
  5095. defer resp.Body.Close()
  5096. body, ioErr := ioutil.ReadAll(resp.Body)
  5097. if ioErr != nil {
  5098. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  5099. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5100. return
  5101. }
  5102. var respJSON map[string]interface{}
  5103. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  5104. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  5105. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5106. return
  5107. }
  5108. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  5109. userJSONBytes, _ := json.Marshal(respJSON)
  5110. fmt.Println("log")
  5111. fmt.Println(string(userJSONBytes))
  5112. if err := json.Unmarshal(userJSONBytes, &ressix10265); err != nil {
  5113. utils.ErrorLog("解析失败:%v", err)
  5114. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5115. return
  5116. }
  5117. res2.InfRefmsgid = ressix10265.InfRefmsgid
  5118. res2.Output = ressix10265.Output
  5119. res2.ErrMsg = ressix10265.ErrMsg
  5120. res2.Cainfo = ressix10265.Cainfo
  5121. res2.WarnMsg = ressix10265.WarnMsg
  5122. infocode, _ := strconv.ParseInt(ressix10265.Infcode, 10, 64)
  5123. res2.Infcode = infocode
  5124. } else if miConfig.MdtrtareaAdmvs == "350500" {
  5125. result, requestLog = service.FJyb2203(his.PsnNo, his.Number, doctor_info.UserName, department.Name, miConfig.OrgName, strconv.FormatInt(reg_type, 10), doctor_info.DoctorNumber, miConfig.Code, his.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, sickConfig.ContentCode, sickConfig.ClassName, roles.UserName, config, begin_time, doctor_info.UserName, roles.UserName, miConfig.Url, miConfig.Code, miConfig.AppSecret, miConfig.SignKey, miConfig.EncKey)
  5126. saveLog(result, requestLog, "2203", "上传就诊信息")
  5127. var respJSON2 map[string]interface{}
  5128. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  5129. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  5130. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5131. return
  5132. }
  5133. userJSONBytes2, _ := json.Marshal(respJSON2)
  5134. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  5135. utils.ErrorLog("解析失败:%v", err)
  5136. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5137. return
  5138. }
  5139. } else {
  5140. if miConfig.MdtrtareaAdmvs == "440781" { //
  5141. 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)
  5142. } else {
  5143. if miConfig.Code == "H15049901371" {
  5144. //赤峰地区国家医保医疗类别
  5145. //职工透析:医疗类别选特殊情况门诊990502
  5146. //居民定额血透门慢: 医疗类别选门诊慢病140104
  5147. var med_type string
  5148. if his.Insutype == "390" {
  5149. if reg_type == 14 {
  5150. med_type = "9933"
  5151. } else if reg_type == 11 {
  5152. med_type = "11"
  5153. }
  5154. } else if his.Insutype == "310" {
  5155. if reg_type == 14 {
  5156. med_type = "990502"
  5157. } else if reg_type == 11 {
  5158. med_type = "11"
  5159. }
  5160. }
  5161. 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)
  5162. } else {
  5163. 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)
  5164. }
  5165. }
  5166. saveLog(result, requestLog, "2203", "上传就诊信息")
  5167. var respJSON2 map[string]interface{}
  5168. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  5169. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  5170. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5171. return
  5172. }
  5173. userJSONBytes2, _ := json.Marshal(respJSON2)
  5174. if miConfig.Code == "H15049901371" {
  5175. if err := json.Unmarshal(userJSONBytes2, &ressix10265); err != nil {
  5176. utils.ErrorLog("解析失败:%v", err)
  5177. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5178. return
  5179. }
  5180. res2.InfRefmsgid = ressix10265.InfRefmsgid
  5181. res2.Output = ressix10265.Output
  5182. res2.ErrMsg = ressix10265.ErrMsg
  5183. res2.Cainfo = ressix10265.Cainfo
  5184. res2.WarnMsg = ressix10265.WarnMsg
  5185. infocode, _ := strconv.ParseInt(ressix10265.Infcode, 10, 64)
  5186. res2.Infcode = infocode
  5187. } else {
  5188. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  5189. utils.ErrorLog("解析失败:%v", err)
  5190. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5191. return
  5192. }
  5193. }
  5194. }
  5195. if res2.Infcode != 0 {
  5196. adminUser := c.GetAdminUserInfo()
  5197. errlog := &models.HisOrderError{
  5198. UserOrgId: adminUser.CurrentOrgId,
  5199. Ctime: time.Now().Unix(),
  5200. Mtime: time.Now().Unix(),
  5201. ErrMsg: res2.ErrMsg,
  5202. Status: 1,
  5203. PatientId: id,
  5204. RecordTime: recordDateTime,
  5205. Stage: 3,
  5206. }
  5207. service.CreateErrMsgLog(errlog)
  5208. c.ServeSuccessJSON(map[string]interface{}{
  5209. "failed_code": -10,
  5210. "msg": res2.ErrMsg,
  5211. })
  5212. return
  5213. } else {
  5214. his.Diagnosis = diagnosis_id
  5215. his.SickType = sickConfig.ID
  5216. //var p_type int64
  5217. //if reg_type == 1111 || reg_type == 1112 {
  5218. // p_type = 11
  5219. //
  5220. //}
  5221. his.PType = fmt.Sprintf("%d", reg_type)
  5222. service.UpdateHisPatientThree(&his)
  5223. data := make(map[string]interface{})
  5224. if settle_accounts_type == 1 { //日结
  5225. if reg_type == 11 || reg_type == 1111 || reg_type == 1112 {
  5226. prescriptions, _ = service.GetPrescriptionByIds(ids_arr, adminUser.CurrentOrgId)
  5227. } else {
  5228. prescriptions, _ = service.GetNewHisPrescription(adminUser.CurrentOrgId, his_patient_id, recordDateTime, strconv.Itoa(int(reg_type)))
  5229. }
  5230. //prescriptions, _ = service.GetNewHisPrescriptionTwo(adminUser.CurrentOrgId, his_patient_id, recordDateTime, reg_type)
  5231. data["pre"] = prescriptions
  5232. } else { //月结
  5233. start_time_str := c.GetString("start_time")
  5234. end_time_str := c.GetString("end_time")
  5235. timeLayout := "2006-01-02"
  5236. loc, _ := time.LoadLocation("Local")
  5237. theStartTime, err := time.ParseInLocation(timeLayout+" 15:04:05", start_time_str+" 00:00:00", loc)
  5238. if err != nil {
  5239. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  5240. return
  5241. }
  5242. recordStartTime := theStartTime.Unix()
  5243. start_time = recordStartTime
  5244. theEndTime, err := time.ParseInLocation(timeLayout+" 15:04:05", end_time_str+" 00:00:00", loc)
  5245. if err != nil {
  5246. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  5247. return
  5248. }
  5249. recordEndTime := theEndTime.Unix()
  5250. end_time = recordEndTime
  5251. prescriptions, _ = service.GetMonthHisPrescriptionTwo(adminUser.CurrentOrgId, id, recordStartTime, recordEndTime, reg_type)
  5252. data["pre"] = prescriptions
  5253. }
  5254. timestamp := time.Now().Unix()
  5255. tempTime := time.Unix(timestamp, 0)
  5256. timeFormat := tempTime.Format("20060102150405")
  5257. chrgBchno := rand.Intn(100000) + 10000
  5258. chrg_bchno := timeFormat + strconv.FormatInt(int64(chrgBchno), 10) + strconv.FormatInt(his.PatientId, 10)
  5259. strconv.FormatInt(his.PatientId, 10)
  5260. client := &http.Client{}
  5261. data["psn_no"] = his.PsnNo
  5262. data["mdtrt_id"] = his.Number
  5263. data["chrg_bchno"] = chrg_bchno
  5264. data["org_name"] = miConfig.OrgName
  5265. data["doctor"] = doctor_info.UserName
  5266. data["doctor_id"] = doctor_info.DoctorNumber
  5267. data["dept"] = strconv.FormatInt(patientPrescription.Departments, 10)
  5268. data["fixmedins_code"] = miConfig.Code
  5269. data["opter"] = roles.UserName
  5270. data["dept_code"] = department.Number
  5271. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  5272. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  5273. data["secret_key"] = miConfig.SecretKey
  5274. data["balance_accounts_type"] = strconv.FormatInt(his.BalanceAccountsType, 10)
  5275. data["url"] = miConfig.Url
  5276. data["ak"] = miConfig.AccessKey
  5277. data["new_doctor_name"] = patientPrescription.Doctor
  5278. data["diag_code"] = sickConfig.CountryCode
  5279. data["cainfo"] = miConfig.Cainfo
  5280. var ids []int64
  5281. for _, item := range prescriptions {
  5282. ids = append(ids, item.ID)
  5283. }
  5284. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  5285. if config.IsOpen == 1 { //对接了医保,走医保流程
  5286. var res ResultFour
  5287. var resFour10265 ResultFour10265
  5288. if miConfig.MdtrtareaAdmvs == "421300" {
  5289. bytesData, _ := json.Marshal(data)
  5290. req, _ := http.NewRequest("POST", "http://192.168.124.4:9532/"+"hbyb/2204", bytes.NewReader(bytesData))
  5291. resp, _ := client.Do(req)
  5292. defer resp.Body.Close()
  5293. body, ioErr := ioutil.ReadAll(resp.Body)
  5294. if ioErr != nil {
  5295. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  5296. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5297. return
  5298. }
  5299. var respJSON map[string]interface{}
  5300. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  5301. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  5302. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5303. return
  5304. }
  5305. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  5306. userJSONBytes, _ := json.Marshal(respJSON)
  5307. fmt.Println("log")
  5308. fmt.Println(string(userJSONBytes))
  5309. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  5310. utils.ErrorLog("解析失败:%v", err)
  5311. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5312. return
  5313. }
  5314. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  5315. bytesData, _ := json.Marshal(data)
  5316. var req *http.Request
  5317. if miConfig.MdtrtareaAdmvs == "320921" {
  5318. req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  5319. } else {
  5320. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  5321. }
  5322. resp, _ := client.Do(req)
  5323. defer resp.Body.Close()
  5324. body, ioErr := ioutil.ReadAll(resp.Body)
  5325. if ioErr != nil {
  5326. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  5327. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5328. return
  5329. }
  5330. var respJSON map[string]interface{}
  5331. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  5332. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  5333. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5334. return
  5335. }
  5336. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  5337. userJSONBytes, _ := json.Marshal(respJSON)
  5338. fmt.Println("log")
  5339. fmt.Println(string(userJSONBytes))
  5340. if err := json.Unmarshal(userJSONBytes, &resFour10265); err != nil {
  5341. utils.ErrorLog("解析失败:%v", err)
  5342. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5343. return
  5344. }
  5345. res.InfRefmsgid = resFour10265.InfRefmsgid
  5346. res.Output = resFour10265.Output
  5347. res.ErrMsg = resFour10265.ErrMsg
  5348. res.Cainfo = resFour10265.Cainfo
  5349. res.WarnMsg = resFour10265.WarnMsg
  5350. infocode, _ := strconv.ParseInt(resFour10265.Infcode, 10, 64)
  5351. res.Infcode = infocode
  5352. } else if miConfig.MdtrtareaAdmvs == "350500" {
  5353. result, request_log := service.FJyb2204(his.PsnNo, his.Number, prescriptions, chrg_bchno, miConfig.OrgName, roles.UserName, strconv.FormatInt(patientPrescription.Departments, 10), miConfig.Code, department.Number, strconv.FormatInt(roles.AdminUserId, 10), his.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, strconv.FormatInt(his.BalanceAccountsType, 10), roles.UserName, miConfig.Url, miConfig.Code, miConfig.AppSecret, miConfig.SignKey, miConfig.EncKey)
  5354. var dat map[string]interface{}
  5355. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  5356. fmt.Println(dat)
  5357. } else {
  5358. fmt.Println(err)
  5359. }
  5360. saveLog(result, request_log, "2204", "上传费用明细")
  5361. userJSONBytes, _ := json.Marshal(dat)
  5362. if err := json.Unmarshal(userJSONBytes, &resFour10265); err != nil {
  5363. utils.ErrorLog("解析失败:%v", err)
  5364. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5365. return
  5366. }
  5367. res.InfRefmsgid = resFour10265.InfRefmsgid
  5368. res.Output = resFour10265.Output
  5369. res.ErrMsg = resFour10265.ErrMsg
  5370. res.Cainfo = resFour10265.Cainfo
  5371. res.WarnMsg = resFour10265.WarnMsg
  5372. infocode, _ := strconv.ParseInt(resFour10265.Infcode, 10, 64)
  5373. res.Infcode = infocode
  5374. } else {
  5375. if miConfig.Code == "H15049901371" {
  5376. 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)
  5377. var dat map[string]interface{}
  5378. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  5379. fmt.Println(dat)
  5380. } else {
  5381. fmt.Println(err)
  5382. }
  5383. saveLog(result, request_log, "2204", "上传费用明细")
  5384. userJSONBytes, _ := json.Marshal(dat)
  5385. if err := json.Unmarshal(userJSONBytes, &resFour10265); err != nil {
  5386. utils.ErrorLog("解析失败:%v", err)
  5387. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5388. return
  5389. }
  5390. res.InfRefmsgid = resFour10265.InfRefmsgid
  5391. res.Output = resFour10265.Output
  5392. res.ErrMsg = resFour10265.ErrMsg
  5393. res.Cainfo = resFour10265.Cainfo
  5394. res.WarnMsg = resFour10265.WarnMsg
  5395. infocode, _ := strconv.ParseInt(resFour10265.Infcode, 10, 64)
  5396. res.Infcode = infocode
  5397. } else {
  5398. 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)
  5399. var dat map[string]interface{}
  5400. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  5401. fmt.Println(dat)
  5402. } else {
  5403. fmt.Println(err)
  5404. }
  5405. saveLog(result, request_log, "2204", "上传费用明细")
  5406. userJSONBytes, _ := json.Marshal(dat)
  5407. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  5408. utils.ErrorLog("解析失败:%v", err)
  5409. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5410. return
  5411. }
  5412. }
  5413. }
  5414. if res.Infcode == 0 {
  5415. order := &models.HisOrder{
  5416. UserOrgId: adminUser.CurrentOrgId,
  5417. HisPatientId: his.ID,
  5418. PatientId: his.PatientId,
  5419. SettleAccountsDate: recordDateTime,
  5420. MdtrtId: his.Number,
  5421. PsnNo: his.PsnNo,
  5422. MedType: strconv.FormatInt(reg_type, 10),
  5423. Ctime: time.Now().Unix(),
  5424. Mtime: time.Now().Unix(),
  5425. Status: 1,
  5426. Number: chrg_bchno,
  5427. Infcode: res.Infcode,
  5428. WarnMsg: res.WarnMsg,
  5429. Cainfo: res.Cainfo,
  5430. ErrMsg: res.ErrMsg,
  5431. RespondTime: res.RefmsgTime,
  5432. InfRefmsgid: res.InfRefmsgid,
  5433. OrderStatus: 1,
  5434. PayWay: pay_way,
  5435. PayPrice: pay_price,
  5436. PayCardNo: pay_card_no,
  5437. DiscountPrice: discount_price,
  5438. PreferentialPrice: preferential_price,
  5439. RealityPrice: reality_price,
  5440. FoundPrice: found_price,
  5441. MedicalInsurancePrice: medical_insurance_price,
  5442. PrivatePrice: private_price,
  5443. IsMedicineInsurance: 1,
  5444. SettleType: settle_accounts_type,
  5445. SettleStartTime: start_time,
  5446. SettleEndTime: end_time,
  5447. Creator: roles.AdminUserId,
  5448. Modify: roles.AdminUserId,
  5449. FaPiaoNumber: fapiao_number,
  5450. FaPiaoCode: fapiao_code,
  5451. PType: 2,
  5452. Diagnosis: diagnosis_id,
  5453. }
  5454. err = service.CreateOrder(order)
  5455. if err != nil {
  5456. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCreatePreOrderException)
  5457. return
  5458. }
  5459. for _, item := range res.Output.Result {
  5460. temp := strings.Split(item.FeedetlSn, "-")
  5461. var advice_id int64 = 0
  5462. var project_id int64 = 0
  5463. var types int64 = 0
  5464. id, _ := strconv.ParseInt(temp[2], 10, 64)
  5465. types, _ = strconv.ParseInt(temp[1], 10, 64)
  5466. if temp[1] == "1" {
  5467. advice_id = id
  5468. project_id = 0
  5469. } else if temp[1] == "2" {
  5470. advice_id = 0
  5471. project_id = id
  5472. }
  5473. info := &models.HisOrderInfo{
  5474. OrderNumber: order.Number,
  5475. FeedetlSn: item.FeedetlSn,
  5476. UploadDate: time.Now().Unix(),
  5477. AdviceId: advice_id,
  5478. DetItemFeeSumamt: item.DetItemFeeSumamt,
  5479. Cnt: item.Cnt,
  5480. Pric: float64(item.Pric),
  5481. PatientId: his.PatientId,
  5482. PricUplmtAmt: item.PricUplmtAmt,
  5483. SelfpayProp: item.SelfpayProp,
  5484. FulamtOwnpayAmt: item.FulamtOwnpayAmt,
  5485. OverlmtAmt: item.OverlmtAmt,
  5486. PreselfpayAmt: item.PreselfpayAmt,
  5487. BasMednFlag: item.BasMednFlag,
  5488. MedChrgitmType: item.MedChrgitmType,
  5489. HiNegoDrugFlag: item.HiNegoDrugFlag,
  5490. Status: 1,
  5491. Memo: item.Memo,
  5492. Mtime: time.Now().Unix(),
  5493. InscpScpAmt: item.InscpScpAmt,
  5494. DrtReimFlag: item.DrtReimFlag,
  5495. Ctime: time.Now().Unix(),
  5496. ListSpItemFlag: item.ListSpItemFlag,
  5497. ChldMedcFlag: item.ChldMedcFlag,
  5498. LmtUsedFlag: item.LmtUsedFlag,
  5499. ChrgitmLv: item.ChrgitmLv,
  5500. UserOrgId: adminUser.CurrentOrgId,
  5501. HisPatientId: his.ID,
  5502. OrderId: order.ID,
  5503. ProjectId: project_id,
  5504. Type: types,
  5505. }
  5506. service.CreateOrderInfo(info)
  5507. }
  5508. service.UpDatePrescriptionNumber(adminUser.CurrentOrgId, ids, chrg_bchno)
  5509. service.UpDateHisPrescriptionInfoNumber(adminUser.CurrentOrgId, his_patient_id, chrg_bchno, recordDateTime)
  5510. var total float64
  5511. for _, item := range prescriptions {
  5512. if item.Type == 1 { //药品
  5513. for _, subItem := range item.HisDoctorAdviceInfo {
  5514. total = total + (subItem.Price * subItem.PrescribingNumber)
  5515. }
  5516. }
  5517. if item.Type == 2 { //项目
  5518. for _, subItem := range item.HisPrescriptionProject {
  5519. cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  5520. total = total + (subItem.Price * cnt)
  5521. }
  5522. }
  5523. }
  5524. for _, item := range prescriptions {
  5525. for _, subItem := range item.HisAdditionalCharge {
  5526. total = total + (subItem.Price * float64(subItem.Count))
  5527. }
  5528. }
  5529. var allTotal string
  5530. if adminUser.CurrentOrgId == 9919 {
  5531. allTotal = fmt.Sprintf("%.4f", total)
  5532. } else {
  5533. allTotal = fmt.Sprintf("%.4f", total)
  5534. }
  5535. if res.Infcode == 0 {
  5536. var rf []*ResultFive
  5537. json.Unmarshal([]byte(his.Iinfo), &rf)
  5538. chrg_bchno := chrg_bchno
  5539. cert_no := his.Certno
  5540. var insutypes []string
  5541. var insutype string
  5542. var is390 int = 0
  5543. var is310 int = 0
  5544. for _, item := range rf {
  5545. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  5546. insutypes = append(insutypes, item.Insutype)
  5547. }
  5548. }
  5549. if len(insutypes) == 1 {
  5550. insutype = insutypes[0]
  5551. } else {
  5552. for _, i := range insutypes {
  5553. if i == "390" {
  5554. is390 = 1
  5555. }
  5556. if i == "310" {
  5557. is310 = 1
  5558. }
  5559. }
  5560. }
  5561. if is390 == 1 {
  5562. insutype = "390"
  5563. }
  5564. if is310 == 1 {
  5565. insutype = "310"
  5566. }
  5567. if len(insutypes) == 0 {
  5568. insutype = "310"
  5569. }
  5570. if len(insutypes) == 2 {
  5571. insutype = strconv.FormatInt(his.SocialType, 10)
  5572. }
  5573. insutype = strconv.FormatInt(his.SocialType, 10)
  5574. //insutype = "390"
  5575. if his.IdCardType == 1 {
  5576. // cert_no = his.MedicalInsuranceNumber
  5577. cert_no = his.Certno
  5578. } else {
  5579. cert_no = his.Certno
  5580. }
  5581. var res ResultSeven
  5582. var resSeven10265 ResultSeven10265
  5583. var src_resquest string
  5584. var result2 string
  5585. var acct_used_flag string
  5586. fmt.Println("pay_way")
  5587. fmt.Println(pay_way)
  5588. fmt.Println("pay_way")
  5589. if pay_way == 4 {
  5590. acct_used_flag = "1"
  5591. } else {
  5592. acct_used_flag = "0"
  5593. }
  5594. if miConfig.MdtrtareaAdmvs == "421300" {
  5595. api := "http://192.168.124.4:9532/" + "hbyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  5596. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  5597. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  5598. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  5599. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  5600. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  5601. "&insutype=" + insutype + "&total=" + allTotal + "&med_type=" + strconv.FormatInt(reg_type, 10) + "&acct_used_flag=" + acct_used_flag
  5602. resp, requestErr := http.Get(api)
  5603. if requestErr != nil {
  5604. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5605. return
  5606. }
  5607. body, ioErr := ioutil.ReadAll(resp.Body)
  5608. if ioErr != nil {
  5609. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  5610. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5611. return
  5612. }
  5613. var respJSON map[string]interface{}
  5614. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  5615. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  5616. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5617. return
  5618. }
  5619. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  5620. result, _ := json.Marshal(respJSON)
  5621. if miConfig.Code == "H15049901371" {
  5622. if err := json.Unmarshal([]byte(result), &resSeven10265); err != nil {
  5623. utils.ErrorLog("解析失败:%v", err)
  5624. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5625. return
  5626. }
  5627. res.InfRefmsgid = resSeven10265.InfRefmsgid
  5628. res.Output = resSeven10265.Output
  5629. res.ErrMsg = resSeven10265.ErrMsg
  5630. res.Cainfo = resSeven10265.Cainfo
  5631. res.WarnMsg = resSeven10265.WarnMsg
  5632. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  5633. res.Infcode = infocode
  5634. } else {
  5635. if err := json.Unmarshal([]byte(result), &res); err != nil {
  5636. utils.ErrorLog("解析失败:%v", err)
  5637. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5638. return
  5639. }
  5640. }
  5641. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  5642. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  5643. psn_info.VerifyNumber = strings.Replace(psn_info.VerifyNumber, "+", "%2B", -1)
  5644. bas := strings.Split(psn_info.CardInfo, "|")
  5645. if his.IdCardType == 1 {
  5646. cert_no = bas[2]
  5647. } else if his.IdCardType == 3 {
  5648. cert_no = his.Certno
  5649. psn_info.VerifyNumber = his.Certno + "|" + psn_info.VerifyNumber
  5650. } else if his.IdCardType == 4 {
  5651. cert_no = his.Certno
  5652. psn_info.VerifyNumber = token
  5653. }
  5654. var api string
  5655. if miConfig.MdtrtareaAdmvs == "320921" {
  5656. api = "http://192.168.2.110:9532/" + "jsyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  5657. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  5658. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  5659. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  5660. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  5661. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  5662. "&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
  5663. } else {
  5664. api = "http://192.168.5.251:9532/" + "jsyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  5665. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  5666. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  5667. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  5668. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  5669. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  5670. "&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
  5671. }
  5672. resp, requestErr := http.Get(api)
  5673. if requestErr != nil {
  5674. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5675. return
  5676. }
  5677. body, ioErr := ioutil.ReadAll(resp.Body)
  5678. if ioErr != nil {
  5679. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  5680. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5681. return
  5682. }
  5683. var respJSON map[string]interface{}
  5684. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  5685. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  5686. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5687. return
  5688. }
  5689. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  5690. result, _ := json.Marshal(respJSON)
  5691. if err := json.Unmarshal([]byte(result), &resSeven10265); err != nil {
  5692. utils.ErrorLog("解析失败:%v", err)
  5693. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5694. return
  5695. }
  5696. res.InfRefmsgid = resSeven10265.InfRefmsgid
  5697. res.Output = resSeven10265.Output
  5698. res.ErrMsg = resSeven10265.ErrMsg
  5699. res.Cainfo = resSeven10265.Cainfo
  5700. res.WarnMsg = resSeven10265.WarnMsg
  5701. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  5702. res.Infcode = infocode
  5703. } else if miConfig.MdtrtareaAdmvs == "350500" {
  5704. result2, src_resquest = service.FJyb2207(his.PsnNo, his.Number, chrg_bchno, cert_no, insutype, allTotal, miConfig.OrgName, roles.UserName, miConfig.Code, his.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, strconv.FormatInt(reg_type, 10), his.IdCardType, tempOrder.FulamtOwnpayAmt, tempOrder.OverlmtSelfPay, tempOrder.PreselfpayAmt, tempOrder.InscpScpAmt, his.IdType, acct_used_flag, miConfig.Url, miConfig.Code, miConfig.AppSecret, miConfig.SignKey, miConfig.EncKey)
  5705. //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)
  5706. var dat map[string]interface{}
  5707. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  5708. fmt.Println(dat)
  5709. } else {
  5710. fmt.Println(err)
  5711. }
  5712. saveLog(result2, src_resquest, "2207", "结算")
  5713. userJSONBytes, _ := json.Marshal(dat)
  5714. if err := json.Unmarshal(userJSONBytes, &resSeven10265); err != nil {
  5715. utils.ErrorLog("解析失败:%v", err)
  5716. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5717. return
  5718. }
  5719. res.InfRefmsgid = resSeven10265.InfRefmsgid
  5720. res.Output = resSeven10265.Output
  5721. res.ErrMsg = resSeven10265.ErrMsg
  5722. res.Cainfo = resSeven10265.Cainfo
  5723. res.WarnMsg = resSeven10265.WarnMsg
  5724. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  5725. res.Infcode = infocode
  5726. } else {
  5727. if miConfig.Code == "H15049901371" {
  5728. //赤峰地区国家医保医疗类别
  5729. //职工透析:医疗类别选特殊情况门诊990502
  5730. //居民定额血透门慢: 医疗类别选门诊慢病140104
  5731. var med_type string
  5732. if his.Insutype == "390" {
  5733. if reg_type == 14 {
  5734. med_type = "9933"
  5735. } else if reg_type == 11 {
  5736. med_type = "11"
  5737. }
  5738. } else if his.Insutype == "310" {
  5739. if reg_type == 14 {
  5740. med_type = "990502"
  5741. } else if reg_type == 11 {
  5742. med_type = "11"
  5743. }
  5744. }
  5745. 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)
  5746. } else {
  5747. 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)
  5748. }
  5749. //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)
  5750. var dat map[string]interface{}
  5751. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  5752. fmt.Println(dat)
  5753. } else {
  5754. fmt.Println(err)
  5755. }
  5756. saveLog(result2, src_resquest, "2207", "结算")
  5757. userJSONBytes, _ := json.Marshal(dat)
  5758. if miConfig.Code == "H15049901371" {
  5759. if err := json.Unmarshal(userJSONBytes, &resSeven10265); err != nil {
  5760. utils.ErrorLog("解析失败:%v", err)
  5761. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5762. return
  5763. }
  5764. res.InfRefmsgid = resSeven10265.InfRefmsgid
  5765. res.Output = resSeven10265.Output
  5766. res.ErrMsg = resSeven10265.ErrMsg
  5767. res.Cainfo = resSeven10265.Cainfo
  5768. res.WarnMsg = resSeven10265.WarnMsg
  5769. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  5770. res.Infcode = infocode
  5771. } else {
  5772. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  5773. utils.ErrorLog("解析失败:%v", err)
  5774. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5775. return
  5776. }
  5777. }
  5778. }
  5779. if res.Infcode != 0 {
  5780. errlog := &models.HisOrderError{
  5781. UserOrgId: adminUser.CurrentOrgId,
  5782. Ctime: time.Now().Unix(),
  5783. Mtime: time.Now().Unix(),
  5784. Number: chrg_bchno,
  5785. ErrMsg: res.ErrMsg,
  5786. Status: 1,
  5787. PatientId: id,
  5788. RecordTime: recordDateTime,
  5789. Stage: 6,
  5790. }
  5791. service.CreateErrMsgLog(errlog)
  5792. c.ServeSuccessJSON(map[string]interface{}{
  5793. "failed_code": -10,
  5794. "msg": res.ErrMsg,
  5795. })
  5796. return
  5797. } else {
  5798. order, _ := service.GetHisOrderTwo(adminUser.CurrentOrgId, chrg_bchno, id)
  5799. order.OrderStatus = 2
  5800. order.Status = 1
  5801. order.MdtrtId = res.Output.Setlinfo.MdtrtID
  5802. order.SetlId = res.Output.Setlinfo.SetlID
  5803. order.PsnNo = res.Output.Setlinfo.PsnNo
  5804. order.PsnName = res.Output.Setlinfo.PsnName
  5805. order.PsnCertType = res.Output.Setlinfo.PsnCertType
  5806. order.Certno = res.Output.Setlinfo.Certno
  5807. order.Gend = res.Output.Setlinfo.Gend
  5808. order.Naty = res.Output.Setlinfo.Naty
  5809. order.Age = res.Output.Setlinfo.Age
  5810. order.Insutype = res.Output.Setlinfo.Insutype
  5811. order.PsnType = res.Output.Setlinfo.PsnType
  5812. order.CvlservFlag = res.Output.Setlinfo.CvlservFlag
  5813. order.SetlTime = res.Output.Setlinfo.SetlTime
  5814. order.MdtrtCertType = res.Output.Setlinfo.MdtrtCertType
  5815. if res.Output.Setlinfo.MedType == "140101" {
  5816. order.MedType = "14"
  5817. } else {
  5818. order.MedType = res.Output.Setlinfo.MedType
  5819. }
  5820. if reg_type == 1112 {
  5821. order.MedType = "1112"
  5822. }
  5823. if reg_type == 1111 {
  5824. order.MedType = "1111"
  5825. }
  5826. order.MedfeeSumamt = res.Output.Setlinfo.MedfeeSumamt
  5827. order.FulamtOwnpayAmt = res.Output.Setlinfo.FulamtOwnpayAmt
  5828. order.OverlmtSelfPay = res.Output.Setlinfo.OverlmtSelfpay
  5829. order.PreselfpayAmt = res.Output.Setlinfo.PreselfpayAmt
  5830. order.InscpScpAmt = res.Output.Setlinfo.InscpScpAmt
  5831. order.ActPayDedc = res.Output.Setlinfo.ActPayDedc
  5832. order.HifpPay = res.Output.Setlinfo.HifpPay
  5833. order.CvlservPay = res.Output.Setlinfo.CvlservPay
  5834. order.PoolPropSelfpay = res.Output.Setlinfo.PoolPropSelfpay
  5835. order.HifesPay = res.Output.Setlinfo.HifesPay
  5836. order.HifobPay = res.Output.Setlinfo.HifobPay
  5837. order.MafPay = res.Output.Setlinfo.MafPay
  5838. order.HifmiPay = res.Output.Setlinfo.HifmiPay
  5839. order.OthPay = res.Output.Setlinfo.OthPay
  5840. order.FundPaySumamt = res.Output.Setlinfo.FundPaySumamt
  5841. order.PsnPartAmt = res.Output.Setlinfo.PsnPartAmt
  5842. order.AcctPay = res.Output.Setlinfo.AcctPay
  5843. order.PsnCashPay = res.Output.Setlinfo.PsnCashPay
  5844. order.HospPartAmt = res.Output.Setlinfo.HospPartAmt
  5845. order.Balc = res.Output.Setlinfo.Balc
  5846. order.AcctMulaidPay = res.Output.Setlinfo.AcctMulaidPay
  5847. order.MedinsSetlId = res.Output.Setlinfo.MedinsSetlID
  5848. order.ClrOptins = res.Output.Setlinfo.ClrOptins
  5849. order.ClrType = res.Output.Setlinfo.ClrType
  5850. order.ClrWay = res.Output.Setlinfo.ClrWay
  5851. order.Creator = order.Creator
  5852. order.Modify = roles.AdminUserId
  5853. order.RequestLog = src_resquest
  5854. setlDetail, _ := json.Marshal(res.Output.Setldetail)
  5855. detailStr := string(setlDetail)
  5856. order.SetlDetail = detailStr
  5857. err := service.UpdataOrderStatusTwo(chrg_bchno, adminUser.CurrentOrgId)
  5858. err = service.UpDateOrder(order)
  5859. if err == nil {
  5860. //判断是否使用了押金
  5861. if dec_way == "true" {
  5862. tmpstring := strconv.FormatInt(order.ID, 10)
  5863. order.Decimal = decimal
  5864. service.UpDateOrder(order)
  5865. //扣押金
  5866. errmsg = service.SpendDeposit(c.GetAdminUserInfo().CurrentOrgId, id, c.GetAdminUserInfo().AdminUser.Id, tmpstring, decimal)
  5867. if errmsg != nil {
  5868. c.ServeFailJsonSend(enums.ErrorCodeParamWrong, errmsg.Error())
  5869. return
  5870. }
  5871. }
  5872. c.ServeSuccessJSON(map[string]interface{}{
  5873. "msg": "结算成功",
  5874. })
  5875. } else {
  5876. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeAmountAccountException)
  5877. return
  5878. }
  5879. }
  5880. } else {
  5881. adminUser := c.GetAdminUserInfo()
  5882. errlog := &models.HisOrderError{
  5883. UserOrgId: adminUser.CurrentOrgId,
  5884. Ctime: time.Now().Unix(),
  5885. Mtime: time.Now().Unix(),
  5886. ErrMsg: res.ErrMsg,
  5887. Status: 1,
  5888. PatientId: id,
  5889. RecordTime: recordDateTime,
  5890. Stage: 4,
  5891. }
  5892. service.CreateErrMsgLog(errlog)
  5893. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeRegisterRepeatException)
  5894. return
  5895. }
  5896. } else {
  5897. adminUser := c.GetAdminUserInfo()
  5898. errlog := &models.HisOrderError{
  5899. UserOrgId: adminUser.CurrentOrgId,
  5900. Ctime: time.Now().Unix(),
  5901. Mtime: time.Now().Unix(),
  5902. ErrMsg: res.ErrMsg,
  5903. Status: 1,
  5904. PatientId: id,
  5905. RecordTime: recordDateTime,
  5906. Stage: 4,
  5907. }
  5908. service.CreateErrMsgLog(errlog)
  5909. c.ServeSuccessJSON(map[string]interface{}{
  5910. "failed_code": -10,
  5911. "msg": res.ErrMsg,
  5912. })
  5913. return
  5914. //c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCalOrderException)
  5915. //return
  5916. }
  5917. }
  5918. }
  5919. } else if tempOrder.ID > 0 {
  5920. if tempOrder.IsPre == 1 {
  5921. allTotal := fmt.Sprintf("%.4f", tempOrder.MedfeeSumamt)
  5922. var rf []*ResultFive
  5923. json.Unmarshal([]byte(his.Iinfo), &rf)
  5924. chrg_bchno := tempOrder.Number
  5925. cert_no := his.Certno
  5926. var insutypes []string
  5927. var insutype string
  5928. var is390 int = 0
  5929. var is310 int = 0
  5930. for _, item := range rf {
  5931. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  5932. insutypes = append(insutypes, item.Insutype)
  5933. }
  5934. }
  5935. if len(insutypes) == 1 {
  5936. insutype = insutypes[0]
  5937. } else {
  5938. for _, i := range insutypes {
  5939. if i == "390" {
  5940. is390 = 1
  5941. }
  5942. if i == "310" {
  5943. is310 = 1
  5944. }
  5945. }
  5946. }
  5947. if is390 == 1 {
  5948. insutype = "390"
  5949. }
  5950. if is310 == 1 {
  5951. insutype = "310"
  5952. }
  5953. if len(insutypes) == 0 {
  5954. insutype = "310"
  5955. }
  5956. if len(insutypes) == 2 {
  5957. insutype = strconv.FormatInt(his.SocialType, 64)
  5958. }
  5959. //insutype = "390"
  5960. if his.IdCardType == 1 {
  5961. // cert_no = his.MedicalInsuranceNumber
  5962. cert_no = his.Certno
  5963. } else {
  5964. cert_no = his.Certno
  5965. }
  5966. var res ResultSeven
  5967. var resSeven10265 ResultSeven10265
  5968. var src_resquest string
  5969. var result2 string
  5970. var acct_used_flag string
  5971. fmt.Println("pay_way")
  5972. fmt.Println(pay_way)
  5973. fmt.Println("pay_way")
  5974. if pay_way == 4 {
  5975. acct_used_flag = "1"
  5976. } else {
  5977. acct_used_flag = "0"
  5978. }
  5979. if miConfig.MdtrtareaAdmvs == "421300" {
  5980. api := "http://192.168.124.4:9532/" + "hbyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  5981. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  5982. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  5983. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  5984. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  5985. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  5986. "&insutype=" + insutype + "&total=" + allTotal + "&med_type=" + strconv.FormatInt(reg_type, 10) + "&acct_used_flag=" + acct_used_flag
  5987. resp, requestErr := http.Get(api)
  5988. if requestErr != nil {
  5989. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5990. return
  5991. }
  5992. body, ioErr := ioutil.ReadAll(resp.Body)
  5993. if ioErr != nil {
  5994. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  5995. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5996. return
  5997. }
  5998. var respJSON map[string]interface{}
  5999. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  6000. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  6001. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6002. return
  6003. }
  6004. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  6005. result, _ := json.Marshal(respJSON)
  6006. fmt.Println("log")
  6007. fmt.Println(string(result))
  6008. if err := json.Unmarshal([]byte(result), &res); err != nil {
  6009. utils.ErrorLog("解析失败:%v", err)
  6010. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6011. return
  6012. }
  6013. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  6014. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  6015. psn_info.VerifyNumber = strings.Replace(psn_info.VerifyNumber, "+", "%2B", -1)
  6016. //psn_info, _ := service.GetPsnByPatientId(id)
  6017. bas := strings.Split(psn_info.CardInfo, "|")
  6018. if his.IdCardType == 1 {
  6019. cert_no = bas[2]
  6020. } else {
  6021. cert_no = bas[1]
  6022. }
  6023. //江苏地区国家医保医疗类别
  6024. //职工透析:医疗类别选特殊情况门诊9933
  6025. //居民血透门慢: 医疗类别选门诊慢病1402
  6026. //var med_type string
  6027. //if his.Insutype == "310" {
  6028. // if reg_type == 14 {
  6029. // med_type = "9933"
  6030. // } else if reg_type == 11 {
  6031. // med_type = "11"
  6032. //
  6033. // }
  6034. //} else if his.Insutype == "390" {
  6035. // if reg_type == 14 {
  6036. // med_type = "1402"
  6037. // } else if reg_type == 11 {
  6038. // med_type = "11"
  6039. // }
  6040. //}
  6041. var api string
  6042. if miConfig.MdtrtareaAdmvs == "320921" {
  6043. api = "http://192.168.2.110:9532/" + "jsyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  6044. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  6045. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  6046. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  6047. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  6048. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  6049. "&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
  6050. //req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  6051. } else {
  6052. //req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  6053. api = "http://192.168.5.251:9532/" + "jsyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  6054. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  6055. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  6056. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  6057. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  6058. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  6059. "&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
  6060. }
  6061. resp, requestErr := http.Get(api)
  6062. if requestErr != nil {
  6063. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6064. return
  6065. }
  6066. body, ioErr := ioutil.ReadAll(resp.Body)
  6067. if ioErr != nil {
  6068. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  6069. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6070. return
  6071. }
  6072. var respJSON map[string]interface{}
  6073. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  6074. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  6075. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6076. return
  6077. }
  6078. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  6079. result, _ := json.Marshal(respJSON)
  6080. fmt.Println("log")
  6081. fmt.Println(string(result))
  6082. if err := json.Unmarshal([]byte(result), &resSeven10265); err != nil {
  6083. utils.ErrorLog("解析失败:%v", err)
  6084. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6085. return
  6086. }
  6087. res.InfRefmsgid = resSeven10265.InfRefmsgid
  6088. res.Output = resSeven10265.Output
  6089. res.ErrMsg = resSeven10265.ErrMsg
  6090. res.Cainfo = resSeven10265.Cainfo
  6091. res.WarnMsg = resSeven10265.WarnMsg
  6092. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  6093. res.Infcode = infocode
  6094. } else if miConfig.MdtrtareaAdmvs == "350500" {
  6095. result2, src_resquest = service.FJyb2207(his.PsnNo, his.Number, chrg_bchno, cert_no, insutype, allTotal, miConfig.OrgName, roles.UserName, miConfig.Code, his.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, strconv.FormatInt(reg_type, 10), his.IdCardType, tempOrder.FulamtOwnpayAmt, tempOrder.OverlmtSelfPay, tempOrder.PreselfpayAmt, tempOrder.InscpScpAmt, his.IdType, acct_used_flag, miConfig.Url, miConfig.Code, miConfig.AppSecret, miConfig.SignKey, miConfig.EncKey)
  6096. var dat map[string]interface{}
  6097. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  6098. fmt.Println(dat)
  6099. } else {
  6100. fmt.Println(err)
  6101. }
  6102. saveLog(result2, src_resquest, "2207", "结算")
  6103. userJSONBytes, _ := json.Marshal(dat)
  6104. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  6105. utils.ErrorLog("解析失败:%v", err)
  6106. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6107. return
  6108. }
  6109. } else {
  6110. var src_resquest string
  6111. if miConfig.Code == "H15049901371" {
  6112. //赤峰地区国家医保医疗类别
  6113. //职工透析:医疗类别选特殊情况门诊990502
  6114. //居民定额血透门慢: 医疗类别选门诊慢病140104
  6115. var med_type string
  6116. if his.Insutype == "390" {
  6117. if reg_type == 14 {
  6118. med_type = "9933"
  6119. } else if reg_type == 11 {
  6120. med_type = "11"
  6121. }
  6122. } else if his.Insutype == "310" {
  6123. if reg_type == 14 {
  6124. med_type = "990502"
  6125. } else if reg_type == 11 {
  6126. med_type = "11"
  6127. }
  6128. }
  6129. 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)
  6130. } else {
  6131. 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)
  6132. }
  6133. var dat map[string]interface{}
  6134. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  6135. fmt.Println(dat)
  6136. } else {
  6137. fmt.Println(err)
  6138. }
  6139. saveLog(result2, src_resquest, "2207", "结算")
  6140. userJSONBytes, _ := json.Marshal(dat)
  6141. if miConfig.Code == "H15049901371" {
  6142. if err := json.Unmarshal(userJSONBytes, &resSeven10265); err != nil {
  6143. utils.ErrorLog("解析失败:%v", err)
  6144. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6145. return
  6146. }
  6147. res.InfRefmsgid = resSeven10265.InfRefmsgid
  6148. res.Output = resSeven10265.Output
  6149. res.ErrMsg = resSeven10265.ErrMsg
  6150. res.Cainfo = resSeven10265.Cainfo
  6151. res.WarnMsg = resSeven10265.WarnMsg
  6152. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  6153. res.Infcode = infocode
  6154. } else {
  6155. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  6156. utils.ErrorLog("解析失败:%v", err)
  6157. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6158. return
  6159. }
  6160. }
  6161. }
  6162. if res.Infcode != 0 {
  6163. errlog := &models.HisOrderError{
  6164. UserOrgId: adminUser.CurrentOrgId,
  6165. Ctime: time.Now().Unix(),
  6166. Mtime: time.Now().Unix(),
  6167. Number: chrg_bchno,
  6168. ErrMsg: res.ErrMsg,
  6169. Status: 1,
  6170. PatientId: id,
  6171. RecordTime: recordDateTime,
  6172. Stage: 6,
  6173. }
  6174. service.CreateErrMsgLog(errlog)
  6175. c.ServeSuccessJSON(map[string]interface{}{
  6176. "failed_code": -10,
  6177. "msg": res.ErrMsg,
  6178. })
  6179. return
  6180. } else {
  6181. order, _ := service.GetHisOrderTwo(adminUser.CurrentOrgId, chrg_bchno, id)
  6182. order.OrderStatus = 2
  6183. order.MdtrtId = res.Output.Setlinfo.MdtrtID
  6184. order.SetlId = res.Output.Setlinfo.SetlID
  6185. order.PsnNo = res.Output.Setlinfo.PsnNo
  6186. order.PsnName = res.Output.Setlinfo.PsnName
  6187. order.PsnCertType = res.Output.Setlinfo.PsnCertType
  6188. order.Certno = res.Output.Setlinfo.Certno
  6189. order.Gend = res.Output.Setlinfo.Gend
  6190. order.Naty = res.Output.Setlinfo.Naty
  6191. order.Age = res.Output.Setlinfo.Age
  6192. order.Insutype = res.Output.Setlinfo.Insutype
  6193. order.PsnType = res.Output.Setlinfo.PsnType
  6194. order.CvlservFlag = res.Output.Setlinfo.CvlservFlag
  6195. order.SetlTime = res.Output.Setlinfo.SetlTime
  6196. order.MdtrtCertType = res.Output.Setlinfo.MdtrtCertType
  6197. //order.MedType = res.Output.Setlinfo.MedType
  6198. if reg_type == 1112 {
  6199. order.MedType = "1112"
  6200. }
  6201. if reg_type == 1111 {
  6202. order.MedType = "1111"
  6203. }
  6204. order.MedfeeSumamt = res.Output.Setlinfo.MedfeeSumamt
  6205. order.FulamtOwnpayAmt = res.Output.Setlinfo.FulamtOwnpayAmt
  6206. order.OverlmtSelfPay = res.Output.Setlinfo.OverlmtSelfpay
  6207. order.PreselfpayAmt = res.Output.Setlinfo.PreselfpayAmt
  6208. order.InscpScpAmt = res.Output.Setlinfo.InscpScpAmt
  6209. order.ActPayDedc = res.Output.Setlinfo.ActPayDedc
  6210. order.HifpPay = res.Output.Setlinfo.HifpPay
  6211. order.CvlservPay = res.Output.Setlinfo.CvlservPay
  6212. order.PoolPropSelfpay = res.Output.Setlinfo.PoolPropSelfpay
  6213. order.HifesPay = res.Output.Setlinfo.HifesPay
  6214. order.HifobPay = res.Output.Setlinfo.HifobPay
  6215. order.MafPay = res.Output.Setlinfo.MafPay
  6216. order.HifmiPay = res.Output.Setlinfo.HifmiPay
  6217. order.OthPay = res.Output.Setlinfo.OthPay
  6218. order.FundPaySumamt = res.Output.Setlinfo.FundPaySumamt
  6219. order.PsnPartAmt = res.Output.Setlinfo.PsnPartAmt
  6220. order.AcctPay = res.Output.Setlinfo.AcctPay
  6221. order.PsnCashPay = res.Output.Setlinfo.PsnCashPay
  6222. order.HospPartAmt = res.Output.Setlinfo.HospPartAmt
  6223. order.Balc = res.Output.Setlinfo.Balc
  6224. order.AcctMulaidPay = res.Output.Setlinfo.AcctMulaidPay
  6225. order.MedinsSetlId = res.Output.Setlinfo.MedinsSetlID
  6226. order.ClrOptins = res.Output.Setlinfo.ClrOptins
  6227. order.ClrWay = res.Output.Setlinfo.ClrWay
  6228. order.Creator = order.Creator
  6229. order.Modify = roles.AdminUserId
  6230. order.RequestLog = src_resquest
  6231. order.Diagnosis = diagnosis_id
  6232. setlDetail, _ := json.Marshal(res.Output.Setldetail)
  6233. detailStr := string(setlDetail)
  6234. order.SetlDetail = detailStr
  6235. err := service.UpdataOrderStatusTwo(chrg_bchno, adminUser.CurrentOrgId)
  6236. err = service.UpDateOrder(order)
  6237. if err == nil {
  6238. //判断是否使用了押金
  6239. if dec_way == "true" {
  6240. tmpstring := strconv.FormatInt(order.ID, 10)
  6241. //扣押金
  6242. order.Decimal = decimal
  6243. service.UpDateOrder(order)
  6244. errmsg = service.SpendDeposit(c.GetAdminUserInfo().CurrentOrgId, id, c.GetAdminUserInfo().AdminUser.Id, tmpstring, decimal)
  6245. if errmsg != nil {
  6246. c.ServeFailJsonSend(enums.ErrorCodeParamWrong, errmsg.Error())
  6247. return
  6248. }
  6249. }
  6250. c.ServeSuccessJSON(map[string]interface{}{
  6251. "msg": "结算成功",
  6252. })
  6253. } else {
  6254. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeAmountAccountException)
  6255. return
  6256. }
  6257. }
  6258. }
  6259. }
  6260. }
  6261. //func (c *HisApiController) GetPreUploadInfo() {
  6262. // id, _ := c.GetInt64("id")
  6263. // record_time := c.GetString("record_time")
  6264. // settle_accounts_type, _ := c.GetInt64("settle_accounts_type")
  6265. // admin_user_id, _ := c.GetInt64("admin_user_id")
  6266. //
  6267. // timeLayout := "2006-01-02"
  6268. // loc, _ := time.LoadLocation("Local")
  6269. // theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  6270. // if err != nil {
  6271. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  6272. // return
  6273. // }
  6274. // recordDateTime := theTime.Unix()
  6275. // adminUser := c.GetAdminUserInfo()
  6276. //
  6277. // var prescriptions []*models.HisPrescription
  6278. //
  6279. // var start_time int64
  6280. // var end_time int64
  6281. //
  6282. // data := make(map[string]interface{})
  6283. // if settle_accounts_type == 1 { //日结
  6284. // prescriptions, _ = service.GetHisPrescription(adminUser.CurrentOrgId, id, recordDateTime)
  6285. // data["pre"] = prescriptions
  6286. //
  6287. // } else { //月结
  6288. // start_time_str := c.GetString("start_time")
  6289. // end_time_str := c.GetString("end_time")
  6290. // timeLayout := "2006-01-02"
  6291. // loc, _ := time.LoadLocation("Local")
  6292. // theStartTime, err := time.ParseInLocation(timeLayout+" 15:04:05", start_time_str+" 00:00:00", loc)
  6293. // if err != nil {
  6294. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  6295. // return
  6296. // }
  6297. // recordStartTime := theStartTime.Unix()
  6298. // start_time = recordStartTime
  6299. // theEndTime, err := time.ParseInLocation(timeLayout+" 15:04:05", end_time_str+" 00:00:00", loc)
  6300. // if err != nil {
  6301. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  6302. // return
  6303. // }
  6304. // recordEndTime := theEndTime.Unix()
  6305. // end_time = recordEndTime
  6306. // prescriptions, _ = service.GetMonthHisPrescription(adminUser.CurrentOrgId, id, recordStartTime, recordEndTime)
  6307. // data["pre"] = prescriptions
  6308. //
  6309. // }
  6310. //
  6311. // roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  6312. //
  6313. // his, _ := service.GetVMHisPatientInfo(adminUser.CurrentOrgId, id, recordDateTime)
  6314. // timestamp := time.Now().Unix()
  6315. // tempTime := time.Unix(timestamp, 0)
  6316. // timeFormat := tempTime.Format("20060102150405")
  6317. // chrgBchno := rand.Intn(100000) + 10000
  6318. // chrg_bchno := timeFormat + strconv.FormatInt(int64(chrgBchno), 10) + strconv.FormatInt(his.PatientId, 10)
  6319. // miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  6320. // patientPrescription, _ := service.FindPatientPrescriptionInfo(adminUser.CurrentOrgId, id, recordDateTime)
  6321. // department, _ := service.GetDepartMentDetail(patientPrescription.Departments)
  6322. // strconv.FormatInt(his.PatientId, 10)
  6323. // client := &http.Client{}
  6324. // data["psn_no"] = his.PsnNo
  6325. // data["mdtrt_id"] = his.Number
  6326. // data["chrg_bchno"] = chrg_bchno
  6327. // data["org_name"] = miConfig.OrgName
  6328. // data["doctor"] = roles.UserName
  6329. // data["doctor_id"] = strconv.FormatInt(roles.AdminUserId, 10)
  6330. // data["dept"] = strconv.FormatInt(patientPrescription.Departments, 10)
  6331. // data["fixmedins_code"] = miConfig.Code
  6332. // data["dept_code"] = department.Number
  6333. // data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  6334. // data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  6335. // data["secret_key"] = miConfig.SecretKey
  6336. // var ids []int64
  6337. //
  6338. // for _, item := range prescriptions {
  6339. // ids = append(ids, item.ID)
  6340. // }
  6341. // config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  6342. // if config.IsOpen == 1 { //对接了医保,走医保流程
  6343. // bytesData, _ := json.Marshal(data)
  6344. // req, _ := http.NewRequest("POST", "http://127.0.0.1:9532/"+"gdyb/five", bytes.NewReader(bytesData))
  6345. // resp, _ := client.Do(req)
  6346. // defer resp.Body.Close()
  6347. // body, ioErr := ioutil.ReadAll(resp.Body)
  6348. // if ioErr != nil {
  6349. // utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  6350. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6351. // return
  6352. // }
  6353. // var respJSON map[string]interface{}
  6354. // if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  6355. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  6356. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6357. // return
  6358. // }
  6359. //
  6360. // respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  6361. // userJSONBytes, _ := json.Marshal(respJSON)
  6362. // var res ResultFour
  6363. // if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  6364. // utils.ErrorLog("解析失败:%v", err)
  6365. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6366. // return
  6367. // }
  6368. //
  6369. // if res.Infcode == 0 {
  6370. // order := &models.HisOrder{
  6371. // UserOrgId: adminUser.CurrentOrgId,
  6372. // HisPatientId: his.ID,
  6373. // PatientId: his.PatientId,
  6374. // SettleAccountsDate: recordDateTime,
  6375. // Ctime: time.Now().Unix(),
  6376. // Mtime: time.Now().Unix(),
  6377. // Status: 1,
  6378. // Number: chrg_bchno,
  6379. // Infcode: res.Infcode,
  6380. // WarnMsg: res.WarnMsg,
  6381. // Cainfo: res.Cainfo,
  6382. // ErrMsg: res.ErrMsg,
  6383. // RespondTime: res.RefmsgTime,
  6384. // InfRefmsgid: res.InfRefmsgid,
  6385. // OrderStatus: 1,
  6386. // IsMedicineInsurance: 1,
  6387. // SettleType: settle_accounts_type,
  6388. // SettleStartTime: start_time,
  6389. // SettleEndTime: end_time,
  6390. // Creator: roles.ID,
  6391. // Modify: roles.ID,
  6392. // PType: 2,
  6393. // }
  6394. // err = service.CreateOrder(order)
  6395. // if err != nil {
  6396. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCreatePreOrderException)
  6397. // return
  6398. // }
  6399. //
  6400. // for _, item := range res.Output.Result {
  6401. // temp := strings.Split(item.FeedetlSn, "-")
  6402. // var advice_id int64 = 0
  6403. // var project_id int64 = 0
  6404. // var types int64 = 0
  6405. //
  6406. // id, _ := strconv.ParseInt(temp[2], 10, 64)
  6407. // types, _ = strconv.ParseInt(temp[1], 10, 64)
  6408. //
  6409. // if temp[1] == "1" {
  6410. // advice_id = id
  6411. // project_id = 0
  6412. // } else if temp[1] == "2" {
  6413. // advice_id = 0
  6414. // project_id = id
  6415. // }
  6416. //
  6417. // info := &models.HisOrderInfo{
  6418. // OrderNumber: order.Number,
  6419. // FeedetlSn: item.FeedetlSn,
  6420. // UploadDate: time.Now().Unix(),
  6421. // AdviceId: advice_id,
  6422. // DetItemFeeSumamt: item.DetItemFeeSumamt,
  6423. // Cnt: item.Cnt,
  6424. // Pric: float64(item.Pric),
  6425. // PatientId: his.PatientId,
  6426. // PricUplmtAmt: item.PricUplmtAmt,
  6427. // SelfpayProp: item.SelfpayProp,
  6428. // FulamtOwnpayAmt: item.FulamtOwnpayAmt,
  6429. // OverlmtAmt: item.OverlmtAmt,
  6430. // PreselfpayAmt: item.PreselfpayAmt,
  6431. // BasMednFlag: item.BasMednFlag,
  6432. // MedChrgitmType: item.MedChrgitmType,
  6433. // HiNegoDrugFlag: item.HiNegoDrugFlag,
  6434. // Status: 1,
  6435. // Memo: item.Memo,
  6436. // Mtime: time.Now().Unix(),
  6437. // InscpScpAmt: item.InscpScpAmt,
  6438. // DrtReimFlag: item.DrtReimFlag,
  6439. // Ctime: time.Now().Unix(),
  6440. // ListSpItemFlag: item.ListSpItemFlag,
  6441. // ChldMedcFlag: item.ChldMedcFlag,
  6442. // LmtUsedFlag: item.LmtUsedFlag,
  6443. // ChrgitmLv: item.ChrgitmLv,
  6444. // UserOrgId: adminUser.CurrentOrgId,
  6445. // HisPatientId: his.ID,
  6446. // OrderId: order.ID,
  6447. // ProjectId: project_id,
  6448. // Type: types,
  6449. // }
  6450. // service.CreateOrderInfo(info)
  6451. //
  6452. // }
  6453. // service.UpDatePrescriptionNumber(adminUser.CurrentOrgId, ids, chrg_bchno)
  6454. // service.UpDatePrescriptionInfoNumber(adminUser.CurrentOrgId, patientPrescription.PatientId, chrg_bchno, recordDateTime)
  6455. //
  6456. // var total float64
  6457. // for _, item := range prescriptions {
  6458. // if item.Type == 1 { //药品
  6459. // for _, subItem := range item.HisDoctorAdviceInfo {
  6460. // total = total + (subItem.Price * subItem.PrescribingNumber)
  6461. // }
  6462. // }
  6463. // if item.Type == 2 { //项目
  6464. // for _, subItem := range item.HisPrescriptionProject {
  6465. // total = total + (subItem.Price * float64(subItem.Count))
  6466. // }
  6467. // }
  6468. // }
  6469. //
  6470. // for _, item := range prescriptions {
  6471. // for _, subItem := range item.HisAdditionalCharge {
  6472. // total = total + (subItem.Price * float64(subItem.Count))
  6473. // }
  6474. // }
  6475. //
  6476. // allTotal := fmt.Sprintf("%.2f", total)
  6477. // if res.Infcode == 0 {
  6478. // var rf []*ResultFive
  6479. // json.Unmarshal([]byte(his.Iinfo), &rf)
  6480. // psn_no := his.PsnNo
  6481. // mdtrt_id := his.Number
  6482. // chrg_bchno := chrg_bchno
  6483. // cert_no := his.Certno
  6484. // insutype := rf[0].Insutype
  6485. //
  6486. // if his.IdCardType == 1 {
  6487. // cert_no = his.MedicalInsuranceNumber
  6488. //
  6489. // } else {
  6490. //
  6491. // cert_no = his.Certno
  6492. //
  6493. // }
  6494. //
  6495. // api := "http://127.0.0.1:9532/" + "gdyb/seven?cert_no=" + cert_no + "&insutype=" +
  6496. // insutype + "&psn_no=" + psn_no + "&chrg_bchno=" + chrg_bchno + "&mdtrt_id=" + mdtrt_id +
  6497. // "&total=" + allTotal + "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code + "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" +
  6498. // miConfig.SecretKey + "&med_type=" + strconv.FormatInt(patientPrescription.RegisterType, 10) + "&id_card_type=" + strconv.FormatInt(int64(his.IdCardType), 10)
  6499. // resp, requestErr := http.Get(api)
  6500. // if requestErr != nil {
  6501. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6502. // return
  6503. // }
  6504. // defer resp.Body.Close()
  6505. // body, ioErr := ioutil.ReadAll(resp.Body)
  6506. // if ioErr != nil {
  6507. // utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  6508. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6509. // return
  6510. // }
  6511. // var respJSON map[string]interface{}
  6512. // if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  6513. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  6514. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6515. // return
  6516. // }
  6517. // fmt.Println(respJSON)
  6518. // respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  6519. // userJSONBytes, _ := json.Marshal(respJSON)
  6520. // var res ResultSeven
  6521. // if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  6522. // utils.ErrorLog("解析失败:%v", err)
  6523. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6524. // return
  6525. // }
  6526. // if res.Infcode != 0 {
  6527. // errlog := &models.HisOrderError{
  6528. // UserOrgId: adminUser.CurrentOrgId,
  6529. // Ctime: time.Now().Unix(),
  6530. // Mtime: time.Now().Unix(),
  6531. // Number: chrg_bchno,
  6532. // ErrMsg: res.ErrMsg,
  6533. // Status: 1,
  6534. // PatientId: id,
  6535. // RecordTime: recordDateTime,
  6536. // Stage: 7,
  6537. // }
  6538. // service.CreateErrMsgLog(errlog)
  6539. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeRegisterRepeatException)
  6540. // return
  6541. // } else {
  6542. // order, _ := service.GetHisOrderTwo(adminUser.CurrentOrgId, chrg_bchno, id)
  6543. // order.OrderStatus = 1
  6544. // order.MdtrtId = res.Output.Setlinfo.MdtrtID
  6545. // order.SetlId = res.Output.Setlinfo.SetlID
  6546. // order.PsnNo = res.Output.Setlinfo.PsnNo
  6547. // order.PsnName = res.Output.Setlinfo.PsnName
  6548. // order.PsnCertType = res.Output.Setlinfo.PsnCertType
  6549. // order.Certno = res.Output.Setlinfo.Certno
  6550. // order.Gend = res.Output.Setlinfo.Gend
  6551. // order.Naty = res.Output.Setlinfo.Naty
  6552. // order.Age = res.Output.Setlinfo.Age
  6553. // order.Insutype = res.Output.Setlinfo.Insutype
  6554. // order.PsnType = res.Output.Setlinfo.PsnType
  6555. // order.CvlservFlag = res.Output.Setlinfo.CvlservFlag
  6556. // order.SetlTime = res.Output.Setlinfo.SetlTime
  6557. // order.MdtrtCertType = res.Output.Setlinfo.MdtrtCertType
  6558. // order.MedType = res.Output.Setlinfo.MedType
  6559. // order.MedfeeSumamt = res.Output.Setlinfo.MedfeeSumamt
  6560. // order.FulamtOwnpayAmt = res.Output.Setlinfo.FulamtOwnpayAmt
  6561. // order.OverlmtSelfPay = res.Output.Setlinfo.OverlmtSelfpay
  6562. // order.PreselfpayAmt = res.Output.Setlinfo.PreselfpayAmt
  6563. // order.InscpScpAmt = res.Output.Setlinfo.InscpScpAmt
  6564. // order.ActPayDedc = res.Output.Setlinfo.ActPayDedc
  6565. // order.HifpPay = res.Output.Setlinfo.HifpPay
  6566. // order.CvlservPay = res.Output.Setlinfo.CvlservPay
  6567. // order.PoolPropSelfpay = res.Output.Setlinfo.PoolPropSelfpay
  6568. // order.HifesPay = res.Output.Setlinfo.HifesPay
  6569. // order.HifobPay = res.Output.Setlinfo.HifobPay
  6570. // order.MafPay = res.Output.Setlinfo.MafPay
  6571. // order.OthPay = res.Output.Setlinfo.OthPay
  6572. // order.FundPaySumamt = res.Output.Setlinfo.FundPaySumamt
  6573. // order.PsnPartAmt = res.Output.Setlinfo.PsnPartAmt
  6574. // order.AcctPay = res.Output.Setlinfo.AcctPay
  6575. // order.PsnCashPay = res.Output.Setlinfo.PsnCashPay
  6576. // order.HospPartAmt = res.Output.Setlinfo.HospPartAmt
  6577. // order.Balc = res.Output.Setlinfo.Balc
  6578. // order.AcctMulaidPay = res.Output.Setlinfo.AcctMulaidPay
  6579. // order.MedinsSetlId = res.Output.Setlinfo.MedinsSetlID
  6580. // order.ClrOptins = res.Output.Setlinfo.ClrOptins
  6581. // order.ClrWay = res.Output.Setlinfo.ClrWay
  6582. // order.Creator = order.Creator
  6583. // order.Modify = roles.ID
  6584. // setlDetail, _ := json.Marshal(res.Output.Setldetail)
  6585. // detailStr := string(setlDetail)
  6586. // order.SetlDetail = detailStr
  6587. // //err := service.UpdataOrderStatusTwo(chrg_bchno, adminUser.CurrentOrgId)
  6588. // err = service.UpDateOrder(order)
  6589. // if err == nil {
  6590. // c.ServeSuccessJSON(map[string]interface{}{
  6591. // "msg": "预结算成功",
  6592. // })
  6593. // } else {
  6594. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeAmountAccountException)
  6595. // return
  6596. // }
  6597. // }
  6598. // } else {
  6599. // adminUser := c.GetAdminUserInfo()
  6600. // errlog := &models.HisOrderError{
  6601. // UserOrgId: adminUser.CurrentOrgId,
  6602. // Ctime: time.Now().Unix(),
  6603. // Mtime: time.Now().Unix(),
  6604. // ErrMsg: res.ErrMsg,
  6605. // Status: 1,
  6606. // PatientId: id,
  6607. // RecordTime: recordDateTime,
  6608. // Stage: 4,
  6609. // }
  6610. // service.CreateErrMsgLog(errlog)
  6611. //
  6612. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeRegisterRepeatException)
  6613. // return
  6614. // }
  6615. // } else {
  6616. // adminUser := c.GetAdminUserInfo()
  6617. // errlog := &models.HisOrderError{
  6618. // UserOrgId: adminUser.CurrentOrgId,
  6619. // Ctime: time.Now().Unix(),
  6620. // Mtime: time.Now().Unix(),
  6621. // ErrMsg: res.ErrMsg,
  6622. // Status: 1,
  6623. // PatientId: id,
  6624. // RecordTime: recordDateTime,
  6625. // Stage: 4,
  6626. // }
  6627. // service.CreateErrMsgLog(errlog)
  6628. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCalOrderException)
  6629. // return
  6630. // }
  6631. //
  6632. // } else {
  6633. // var total float64
  6634. // for _, item := range prescriptions {
  6635. // if item.Type == 1 { //药品
  6636. // for _, subItem := range item.HisDoctorAdviceInfo {
  6637. // total = total + (subItem.Price * subItem.PrescribingNumber)
  6638. // }
  6639. // }
  6640. // if item.Type == 2 { //项目
  6641. // for _, subItem := range item.HisPrescriptionProject {
  6642. // total = total + (subItem.Price * float64(subItem.Count))
  6643. // }
  6644. // }
  6645. //
  6646. // for _, subItem := range item.HisAdditionalCharge {
  6647. // total = total + (subItem.Price * float64(subItem.Count))
  6648. // }
  6649. // }
  6650. //
  6651. // allTotal := fmt.Sprintf("%.2f", total)
  6652. // totals, _ := strconv.ParseFloat(allTotal, 64)
  6653. // order := &models.HisOrder{
  6654. // UserOrgId: adminUser.CurrentOrgId,
  6655. // HisPatientId: his.ID,
  6656. // PatientId: id,
  6657. // SettleAccountsDate: recordDateTime,
  6658. // Ctime: time.Now().Unix(),
  6659. // Mtime: time.Now().Unix(),
  6660. // Status: 1,
  6661. // OrderStatus: 2,
  6662. // Number: chrg_bchno,
  6663. // MedfeeSumamt: totals,
  6664. // }
  6665. // err = service.CreateOrder(order)
  6666. // if err != nil {
  6667. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCreatePreOrderException)
  6668. // return
  6669. // }
  6670. //
  6671. // var customs []*Custom
  6672. // for _, item := range prescriptions {
  6673. //
  6674. // if item.Type == 1 { //药品
  6675. // for _, subItem := range item.HisDoctorAdviceInfo {
  6676. // cus := &Custom{
  6677. // AdviceId: subItem.ID,
  6678. // ProjectId: 0,
  6679. // DetItemFeeSumamt: fmt.Sprintf("%.2f", subItem.Price*subItem.PrescribingNumber),
  6680. // Cut: fmt.Sprintf("%.2f", subItem.PrescribingNumber),
  6681. // FeedetlSn: subItem.FeedetlSn,
  6682. // Price: fmt.Sprintf("%.2f", subItem.Price),
  6683. // MedListCodg: subItem.MedListCodg,
  6684. // Type: 1,
  6685. // }
  6686. // customs = append(customs, cus)
  6687. // }
  6688. // }
  6689. //
  6690. // if item.Type == 2 { //项目
  6691. // for _, subItem := range item.HisPrescriptionProject {
  6692. //
  6693. // cus := &Custom{
  6694. // AdviceId: 0,
  6695. // ProjectId: subItem.ID,
  6696. // DetItemFeeSumamt: fmt.Sprintf("%.2f", subItem.Price*float64(subItem.Count)),
  6697. // Cut: fmt.Sprintf("%.2f", float64(subItem.Count)),
  6698. // FeedetlSn: subItem.FeedetlSn,
  6699. // Price: fmt.Sprintf("%.2f", float64(subItem.Price)),
  6700. // MedListCodg: subItem.MedListCodg,
  6701. // Type: 2,
  6702. // }
  6703. //
  6704. // customs = append(customs, cus)
  6705. // }
  6706. // }
  6707. //
  6708. // for _, item := range item.HisAdditionalCharge {
  6709. // cus := &Custom{
  6710. // ItemId: item.ID,
  6711. // AdviceId: 0,
  6712. // ProjectId: 0,
  6713. // DetItemFeeSumamt: fmt.Sprintf("%.2f", item.Price),
  6714. // Cut: fmt.Sprintf("%.2f", float64(item.Count)),
  6715. // FeedetlSn: item.FeedetlSn,
  6716. // Price: fmt.Sprintf("%.2f", float64(item.Price)),
  6717. // MedListCodg: item.XtHisAddtionConfig.Code,
  6718. // Type: 3,
  6719. // }
  6720. //
  6721. // customs = append(customs, cus)
  6722. // }
  6723. //
  6724. // }
  6725. //
  6726. // for _, item := range customs {
  6727. // var advice_id int64 = 0
  6728. // var project_id int64 = 0
  6729. // var item_id int64 = 0
  6730. //
  6731. // var types int64 = 0
  6732. //
  6733. // if item.Type == 1 {
  6734. // advice_id = item.AdviceId
  6735. // project_id = 0
  6736. // item_id = 0
  6737. // } else if item.Type == 2 {
  6738. // advice_id = 0
  6739. // item_id = 0
  6740. //
  6741. // project_id = item.ProjectId
  6742. // } else if item.Type == 3 {
  6743. // advice_id = 0
  6744. // item_id = item.ItemId
  6745. // project_id = 0
  6746. // }
  6747. //
  6748. // detItemFeeSumamt, _ := strconv.ParseFloat(item.DetItemFeeSumamt, 32)
  6749. // cut, _ := strconv.ParseFloat(item.Cut, 32)
  6750. // pric, _ := strconv.ParseFloat(item.Price, 32)
  6751. //
  6752. // info := &models.HisOrderInfo{
  6753. // OrderNumber: order.Number,
  6754. // UploadDate: time.Now().Unix(),
  6755. // AdviceId: advice_id,
  6756. // DetItemFeeSumamt: detItemFeeSumamt,
  6757. // Cnt: cut,
  6758. // Pric: pric,
  6759. // PatientId: id,
  6760. // Status: 1,
  6761. // Mtime: time.Now().Unix(),
  6762. // Ctime: time.Now().Unix(),
  6763. // UserOrgId: adminUser.CurrentOrgId,
  6764. // HisPatientId: his.ID,
  6765. // OrderId: order.ID,
  6766. // ProjectId: project_id,
  6767. // Type: types,
  6768. // ItemId: item_id,
  6769. // }
  6770. // service.CreateOrderInfo(info)
  6771. // }
  6772. // //err := service.UpDateAddtionNumber(adminUser.CurrentOrgId, ids, chrg_bchno)
  6773. // err = service.UpDatePrescriptionNumber(adminUser.CurrentOrgId, ids, chrg_bchno)
  6774. // err = service.UpDatePrescriptionInfoNumber(adminUser.CurrentOrgId, id, chrg_bchno, recordDateTime)
  6775. // err = service.UpdataOrderStatusTwo(chrg_bchno, adminUser.CurrentOrgId)
  6776. // if err == nil {
  6777. // c.ServeSuccessJSON(map[string]interface{}{
  6778. // "msg": "结算成功",
  6779. // })
  6780. // } else {
  6781. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeAmountAccountException)
  6782. // return
  6783. // }
  6784. // }
  6785. //}
  6786. //上传明细-预结算-
  6787. func (c *HisApiController) GetPreUploadInfo() {
  6788. id, _ := c.GetInt64("id")
  6789. record_time := c.GetString("record_time")
  6790. his_patient_id, _ := c.GetInt64("his_patient_id")
  6791. settle_accounts_type, _ := c.GetInt64("settle_accounts_type")
  6792. admin_user_id, _ := c.GetInt64("admin_user_id")
  6793. diagnosis_id := c.GetString("diagnosis")
  6794. sick_type, _ := c.GetInt64("sick_type")
  6795. reg_type, _ := c.GetInt64("p_type")
  6796. begin_time := c.GetString("begin_time")
  6797. id_str := c.GetString("ids")
  6798. ids_arr := strings.Split(id_str, ",")
  6799. timeLayout := "2006-01-02"
  6800. loc, _ := time.LoadLocation("Local")
  6801. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  6802. if err != nil {
  6803. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  6804. return
  6805. }
  6806. recordDateTime := theTime.Unix()
  6807. adminUser := c.GetAdminUserInfo()
  6808. diagnosis_ids := strings.Split(diagnosis_id, ",")
  6809. var config []*models.HisXtDiagnoseConfig
  6810. for _, item := range diagnosis_ids {
  6811. id, _ := strconv.ParseInt(item, 10, 64)
  6812. diagnosisConfig, _ := service.FindDiagnoseById(id)
  6813. config = append(config, &diagnosisConfig)
  6814. }
  6815. //diagnosisConfig, _ := service.FindDiagnoseById(diagnosis_id)
  6816. sickConfig, _ := service.FindSickById(sick_type)
  6817. var prescriptions []*models.HisPrescription
  6818. var start_time int64
  6819. var end_time int64
  6820. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  6821. fmt.Println(his_patient_id)
  6822. his, _ := service.GetNewHisPatientInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  6823. timestamp := time.Now().Unix()
  6824. tempTime := time.Unix(timestamp, 0)
  6825. timeFormat := tempTime.Format("20060102150405")
  6826. chrgBchno := rand.Intn(100000) + 10000
  6827. chrg_bchno := timeFormat + strconv.FormatInt(int64(chrgBchno), 10) + strconv.FormatInt(his.PatientId, 10)
  6828. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  6829. var patientPrescription models.HisPrescriptionInfo
  6830. patientPrescription, _ = service.FindHisPatientPrescriptionInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  6831. if patientPrescription.ID == 0 {
  6832. patientPrescription, _ = service.FindLastPatientPrescriptionInfo(adminUser.CurrentOrgId, id, recordDateTime)
  6833. }
  6834. //miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  6835. department, _ := service.GetDepartMentDetail(patientPrescription.Departments)
  6836. doctor_info, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, patientPrescription.DoctorId)
  6837. strconv.FormatInt(his.PatientId, 10)
  6838. var res2 ResultSix
  6839. var resSix10265 ResultSix10265
  6840. var time_stamp string
  6841. if miConfig.MdtrtareaAdmvs == "421300" {
  6842. data := make(map[string]interface{})
  6843. client := &http.Client{}
  6844. data["psn_no"] = his.PsnNo
  6845. data["mdtrt_id"] = his.Number
  6846. data["department"] = department.Name
  6847. data["org_name"] = miConfig.OrgName
  6848. data["med_type"] = strconv.FormatInt(reg_type, 10)
  6849. data["doctor_id"] = doctor_info.DoctorNumber
  6850. data["doctor_name"] = roles.UserName
  6851. data["fixmedins_code"] = miConfig.Code
  6852. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  6853. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  6854. data["secret_key"] = miConfig.SecretKey
  6855. data["sick_code"] = sickConfig.CountryCode
  6856. data["sick_name"] = sickConfig.ClassName
  6857. data["begin_time"] = begin_time
  6858. data["dept"] = strconv.FormatInt(department.ID, 10)
  6859. data["config"] = config
  6860. data["opter"] = roles.UserName
  6861. fmt.Println(data)
  6862. bytesData, _ := json.Marshal(data)
  6863. req, _ := http.NewRequest("POST", "http://192.168.124.4:9532/"+"hbyb/2203", bytes.NewReader(bytesData))
  6864. resp, _ := client.Do(req)
  6865. defer resp.Body.Close()
  6866. body, ioErr := ioutil.ReadAll(resp.Body)
  6867. if ioErr != nil {
  6868. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  6869. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6870. return
  6871. }
  6872. var respJSON map[string]interface{}
  6873. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  6874. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  6875. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6876. return
  6877. }
  6878. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  6879. userJSONBytes, _ := json.Marshal(respJSON)
  6880. fmt.Println("log")
  6881. fmt.Println(string(userJSONBytes))
  6882. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  6883. utils.ErrorLog("解析失败:%v", err)
  6884. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6885. return
  6886. }
  6887. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  6888. data := make(map[string]interface{})
  6889. client := &http.Client{}
  6890. data["psn_no"] = his.PsnNo
  6891. data["mdtrt_id"] = his.Number
  6892. data["doctor"] = roles.UserName
  6893. data["department"] = department.Name
  6894. data["org_name"] = miConfig.OrgName
  6895. data["med_type"] = strconv.FormatInt(reg_type, 10)
  6896. data["doctor_id"] = strconv.FormatInt(doctor_info.AdminUserId, 10)
  6897. data["fixmedins_code"] = miConfig.Code
  6898. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  6899. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  6900. data["secret_key"] = miConfig.SecretKey
  6901. data["sick_code"] = sickConfig.CountryCode
  6902. data["sick_name"] = sickConfig.ClassName
  6903. data["begin_time"] = begin_time
  6904. data["dept"] = strconv.FormatInt(department.ID, 10)
  6905. data["config"] = config
  6906. data["url"] = miConfig.Url
  6907. data["ak"] = miConfig.AccessKey
  6908. data["cainfo"] = miConfig.Cainfo
  6909. bytesData, _ := json.Marshal(data)
  6910. var req *http.Request
  6911. if miConfig.MdtrtareaAdmvs == "320921" {
  6912. req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/2203", bytes.NewReader(bytesData))
  6913. //api = "http://192.168.2.110:9532/" + "jsyb/readcard?" + "fixmedins_code=" + miConfig.Code + "&secret_key=" + miConfig.SecretKey + "&ak=" + miConfig.AccessKey + "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName +
  6914. // "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&cainfo=" + miConfig.Cainfo
  6915. } else {
  6916. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2203", bytes.NewReader(bytesData))
  6917. }
  6918. resp, _ := client.Do(req)
  6919. defer resp.Body.Close()
  6920. body, ioErr := ioutil.ReadAll(resp.Body)
  6921. if ioErr != nil {
  6922. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  6923. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6924. return
  6925. }
  6926. var respJSON map[string]interface{}
  6927. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  6928. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  6929. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6930. return
  6931. }
  6932. time_stamp = strconv.FormatInt(int64(respJSON["data"].(map[string]interface{})["time_stamp"].(float64)), 10)
  6933. //fmt.Println(respJSON["data"].(map[string]interface{})["time_stamp"].(string))
  6934. //time_stamp = respJSON["data"].(map[string]interface{})["time_stamp"].(string)
  6935. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  6936. userJSONBytes, _ := json.Marshal(respJSON)
  6937. fmt.Println("log")
  6938. fmt.Println(string(userJSONBytes))
  6939. if err := json.Unmarshal(userJSONBytes, &resSix10265); err != nil {
  6940. utils.ErrorLog("解析失败:%v", err)
  6941. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6942. return
  6943. }
  6944. res2.InfRefmsgid = resSix10265.InfRefmsgid
  6945. res2.Output = resSix10265.Output
  6946. res2.ErrMsg = resSix10265.ErrMsg
  6947. res2.Cainfo = resSix10265.Cainfo
  6948. res2.WarnMsg = resSix10265.WarnMsg
  6949. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  6950. res2.Infcode = infocode
  6951. } else if miConfig.MdtrtareaAdmvs == "350500" {
  6952. result, requestLog := service.FJyb2203(his.PsnNo, his.Number, doctor_info.UserName, department.Name, miConfig.OrgName, strconv.FormatInt(reg_type, 10), doctor_info.DoctorNumber, miConfig.Code, his.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, sickConfig.ContentCode, sickConfig.ClassName, roles.UserName, config, begin_time, doctor_info.UserName, roles.UserName, miConfig.Url, miConfig.Code, miConfig.AppSecret, miConfig.SignKey, miConfig.EncKey)
  6953. saveLog(result, requestLog, "2203", "上传就诊信息")
  6954. var respJSON2 map[string]interface{}
  6955. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  6956. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  6957. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6958. return
  6959. }
  6960. userJSONBytes2, _ := json.Marshal(respJSON2)
  6961. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  6962. utils.ErrorLog("解析失败:%v", err)
  6963. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6964. return
  6965. }
  6966. } else {
  6967. var result string
  6968. var requestLog string
  6969. if miConfig.MdtrtareaAdmvs == "440781" { //
  6970. 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)
  6971. } else {
  6972. if miConfig.Code == "H15049901371" {
  6973. //赤峰地区国家医保医疗类别
  6974. //职工透析:医疗类别选特殊情况门诊990502
  6975. //居民定额血透门慢: 医疗类别选门诊慢病140104
  6976. var med_type string
  6977. if his.Insutype == "390" {
  6978. if reg_type == 14 {
  6979. med_type = "9933"
  6980. } else if reg_type == 11 {
  6981. med_type = "11"
  6982. }
  6983. } else if his.Insutype == "310" {
  6984. if reg_type == 14 {
  6985. med_type = "990502"
  6986. } else if reg_type == 11 {
  6987. med_type = "11"
  6988. }
  6989. }
  6990. 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)
  6991. } else {
  6992. 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)
  6993. }
  6994. saveLog(result, requestLog, "2203", "上传就诊信息")
  6995. var respJSON2 map[string]interface{}
  6996. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  6997. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  6998. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6999. return
  7000. }
  7001. userJSONBytes2, _ := json.Marshal(respJSON2)
  7002. if miConfig.Code == "H15049901371" {
  7003. if err := json.Unmarshal(userJSONBytes2, &resSix10265); err != nil {
  7004. utils.ErrorLog("解析失败:%v", err)
  7005. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7006. return
  7007. }
  7008. res2.InfRefmsgid = resSix10265.InfRefmsgid
  7009. res2.Output = resSix10265.Output
  7010. res2.ErrMsg = resSix10265.ErrMsg
  7011. res2.Cainfo = resSix10265.Cainfo
  7012. res2.WarnMsg = resSix10265.WarnMsg
  7013. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  7014. res2.Infcode = infocode
  7015. } else {
  7016. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  7017. utils.ErrorLog("解析失败:%v", err)
  7018. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7019. return
  7020. }
  7021. }
  7022. }
  7023. }
  7024. if res2.Infcode != 0 {
  7025. adminUser := c.GetAdminUserInfo()
  7026. errlog := &models.HisOrderError{
  7027. UserOrgId: adminUser.CurrentOrgId,
  7028. Ctime: time.Now().Unix(),
  7029. Mtime: time.Now().Unix(),
  7030. ErrMsg: res2.ErrMsg,
  7031. Status: 1,
  7032. PatientId: id,
  7033. RecordTime: recordDateTime,
  7034. Stage: 3,
  7035. }
  7036. service.CreateErrMsgLog(errlog)
  7037. c.ServeSuccessJSON(map[string]interface{}{
  7038. "failed_code": -10,
  7039. "msg": res2.ErrMsg,
  7040. })
  7041. return
  7042. } else {
  7043. his.Diagnosis = diagnosis_id
  7044. his.SickType = sickConfig.ID
  7045. his.PType = fmt.Sprintf("%d", reg_type)
  7046. service.UpdateHisPatientThree(&his)
  7047. data := make(map[string]interface{})
  7048. if settle_accounts_type == 1 { //日结
  7049. if reg_type == 11 || reg_type == 1111 || reg_type == 1112 {
  7050. prescriptions, _ = service.GetPrescriptionByIds(ids_arr, adminUser.CurrentOrgId)
  7051. } else {
  7052. prescriptions, _ = service.GetNewHisPrescription(adminUser.CurrentOrgId, his_patient_id, recordDateTime, strconv.Itoa(int(reg_type)))
  7053. }
  7054. data["pre"] = prescriptions
  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. start_time = recordStartTime
  7067. theEndTime, err := time.ParseInLocation(timeLayout+" 15:04:05", end_time_str+" 00:00:00", loc)
  7068. if err != nil {
  7069. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  7070. return
  7071. }
  7072. recordEndTime := theEndTime.Unix()
  7073. end_time = recordEndTime
  7074. prescriptions, _ = service.GetMonthHisPrescriptionTwo(adminUser.CurrentOrgId, id, recordStartTime, recordEndTime, reg_type)
  7075. data["pre"] = prescriptions
  7076. }
  7077. client := &http.Client{}
  7078. data["psn_no"] = his.PsnNo
  7079. data["mdtrt_id"] = his.Number
  7080. data["chrg_bchno"] = chrg_bchno
  7081. data["org_name"] = miConfig.OrgName
  7082. data["doctor"] = roles.UserName
  7083. data["doctor_id"] = strconv.FormatInt(roles.AdminUserId, 10)
  7084. data["dept"] = strconv.FormatInt(patientPrescription.Departments, 10)
  7085. data["fixmedins_code"] = miConfig.Code
  7086. data["balance_accounts_type"] = strconv.FormatInt(his.BalanceAccountsType, 10)
  7087. if (department.ID == 0 && adminUser.CurrentOrgId == 9919) || (department.ID == 0 && adminUser.CurrentOrgId == 10106) {
  7088. data["dept_code"] = "15"
  7089. } else {
  7090. data["dept_code"] = department.Number
  7091. }
  7092. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  7093. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  7094. data["secret_key"] = miConfig.SecretKey
  7095. data["url"] = miConfig.Url
  7096. data["ak"] = miConfig.AccessKey
  7097. data["new_doctor_name"] = patientPrescription.Doctor
  7098. data["diag_code"] = sickConfig.CountryCode
  7099. data["time_stamp"] = time_stamp
  7100. data["cainfo"] = miConfig.Cainfo
  7101. var ids []int64
  7102. for _, item := range prescriptions {
  7103. ids = append(ids, item.ID)
  7104. }
  7105. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  7106. if config.IsOpen == 1 { //对接了医保,走医保流程
  7107. var res ResultFour
  7108. var resFour10265 ResultFour10265
  7109. if miConfig.MdtrtareaAdmvs == "421300" {
  7110. bytesData, _ := json.Marshal(data)
  7111. req, _ := http.NewRequest("POST", "http://192.168.124.4:9532/"+"hbyb/2204", bytes.NewReader(bytesData))
  7112. resp, _ := client.Do(req)
  7113. defer resp.Body.Close()
  7114. body, ioErr := ioutil.ReadAll(resp.Body)
  7115. if ioErr != nil {
  7116. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  7117. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7118. return
  7119. }
  7120. var respJSON map[string]interface{}
  7121. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  7122. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  7123. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7124. return
  7125. }
  7126. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  7127. userJSONBytes, _ := json.Marshal(respJSON)
  7128. fmt.Println("log")
  7129. fmt.Println(string(userJSONBytes))
  7130. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  7131. utils.ErrorLog("解析失败:%v", err)
  7132. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7133. return
  7134. }
  7135. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  7136. bytesData, _ := json.Marshal(data)
  7137. var req *http.Request
  7138. if miConfig.MdtrtareaAdmvs == "320921" {
  7139. req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  7140. } else {
  7141. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  7142. }
  7143. resp, _ := client.Do(req)
  7144. defer resp.Body.Close()
  7145. body, ioErr := ioutil.ReadAll(resp.Body)
  7146. if ioErr != nil {
  7147. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  7148. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7149. return
  7150. }
  7151. var respJSON map[string]interface{}
  7152. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  7153. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  7154. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7155. return
  7156. }
  7157. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  7158. userJSONBytes, _ := json.Marshal(respJSON)
  7159. fmt.Println("log")
  7160. fmt.Println(string(userJSONBytes))
  7161. if err := json.Unmarshal(userJSONBytes, &resFour10265); err != nil {
  7162. utils.ErrorLog("解析失败:%v", err)
  7163. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7164. return
  7165. }
  7166. res.InfRefmsgid = resFour10265.InfRefmsgid
  7167. res.Output = resFour10265.Output
  7168. res.ErrMsg = resFour10265.ErrMsg
  7169. res.Cainfo = resFour10265.Cainfo
  7170. res.WarnMsg = resFour10265.WarnMsg
  7171. infocode, _ := strconv.ParseInt(resFour10265.Infcode, 10, 64)
  7172. res.Infcode = infocode
  7173. } else if miConfig.MdtrtareaAdmvs == "350500" {
  7174. result, request_log := service.FJyb2204(his.PsnNo, his.Number, prescriptions, chrg_bchno, miConfig.OrgName, roles.UserName, strconv.FormatInt(patientPrescription.Departments, 10), miConfig.Code, department.Number, strconv.FormatInt(roles.AdminUserId, 10), his.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, strconv.FormatInt(his.BalanceAccountsType, 10), roles.UserName, miConfig.Url, miConfig.Code, miConfig.AppSecret, miConfig.SignKey, miConfig.EncKey)
  7175. var dat map[string]interface{}
  7176. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  7177. fmt.Println(dat)
  7178. } else {
  7179. fmt.Println(err)
  7180. }
  7181. saveLog(result, request_log, "2204", "上传费用明细")
  7182. userJSONBytes, _ := json.Marshal(dat)
  7183. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  7184. utils.ErrorLog("解析失败:%v", err)
  7185. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7186. return
  7187. }
  7188. } else {
  7189. if miConfig.Code == "H15049901371" {
  7190. 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)
  7191. var dat map[string]interface{}
  7192. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  7193. fmt.Println(dat)
  7194. } else {
  7195. fmt.Println(err)
  7196. }
  7197. saveLog(result, request_log, "2204", "上传费用明细")
  7198. userJSONBytes, _ := json.Marshal(dat)
  7199. if err := json.Unmarshal(userJSONBytes, &resFour10265); err != nil {
  7200. utils.ErrorLog("解析失败:%v", err)
  7201. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7202. return
  7203. }
  7204. res.InfRefmsgid = resFour10265.InfRefmsgid
  7205. res.Output = resFour10265.Output
  7206. res.ErrMsg = resFour10265.ErrMsg
  7207. res.Cainfo = resFour10265.Cainfo
  7208. res.WarnMsg = resFour10265.WarnMsg
  7209. infocode, _ := strconv.ParseInt(resFour10265.Infcode, 10, 64)
  7210. res.Infcode = infocode
  7211. } else {
  7212. 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)
  7213. var dat map[string]interface{}
  7214. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  7215. fmt.Println(dat)
  7216. } else {
  7217. fmt.Println(err)
  7218. }
  7219. saveLog(result, request_log, "2204", "上传费用明细")
  7220. userJSONBytes, _ := json.Marshal(dat)
  7221. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  7222. utils.ErrorLog("解析失败:%v", err)
  7223. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7224. return
  7225. }
  7226. }
  7227. }
  7228. if res.Infcode == 0 {
  7229. order := &models.HisOrder{
  7230. UserOrgId: adminUser.CurrentOrgId,
  7231. HisPatientId: his.ID,
  7232. PatientId: his.PatientId,
  7233. SettleAccountsDate: recordDateTime,
  7234. Ctime: time.Now().Unix(),
  7235. Mtime: time.Now().Unix(),
  7236. MdtrtId: his.Number,
  7237. PsnNo: his.PsnNo,
  7238. MedType: strconv.FormatInt(reg_type, 10),
  7239. Status: 1,
  7240. Number: chrg_bchno,
  7241. Infcode: res.Infcode,
  7242. WarnMsg: res.WarnMsg,
  7243. Cainfo: res.Cainfo,
  7244. ErrMsg: res.ErrMsg,
  7245. RespondTime: res.RefmsgTime,
  7246. InfRefmsgid: res.InfRefmsgid,
  7247. OrderStatus: 1,
  7248. IsMedicineInsurance: 1,
  7249. SettleType: settle_accounts_type,
  7250. SettleStartTime: start_time,
  7251. SettleEndTime: end_time,
  7252. Creator: roles.AdminUserId,
  7253. Modify: roles.AdminUserId,
  7254. PType: 2,
  7255. Diagnosis: diagnosis_id,
  7256. }
  7257. err = service.CreateOrder(order)
  7258. if err != nil {
  7259. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCreatePreOrderException)
  7260. return
  7261. }
  7262. for _, item := range res.Output.Result {
  7263. temp := strings.Split(item.FeedetlSn, "-")
  7264. var advice_id int64 = 0
  7265. var project_id int64 = 0
  7266. var types int64 = 0
  7267. id, _ := strconv.ParseInt(temp[2], 10, 64)
  7268. types, _ = strconv.ParseInt(temp[1], 10, 64)
  7269. if temp[1] == "1" {
  7270. advice_id = id
  7271. project_id = 0
  7272. } else if temp[1] == "2" {
  7273. advice_id = 0
  7274. project_id = id
  7275. }
  7276. info := &models.HisOrderInfo{
  7277. OrderNumber: order.Number,
  7278. FeedetlSn: item.FeedetlSn,
  7279. UploadDate: time.Now().Unix(),
  7280. AdviceId: advice_id,
  7281. DetItemFeeSumamt: item.DetItemFeeSumamt,
  7282. Cnt: item.Cnt,
  7283. Pric: float64(item.Pric),
  7284. PatientId: his.PatientId,
  7285. PricUplmtAmt: item.PricUplmtAmt,
  7286. SelfpayProp: item.SelfpayProp,
  7287. FulamtOwnpayAmt: item.FulamtOwnpayAmt,
  7288. OverlmtAmt: item.OverlmtAmt,
  7289. PreselfpayAmt: item.PreselfpayAmt,
  7290. BasMednFlag: item.BasMednFlag,
  7291. MedChrgitmType: item.MedChrgitmType,
  7292. HiNegoDrugFlag: item.HiNegoDrugFlag,
  7293. Status: 1,
  7294. Memo: item.Memo,
  7295. Mtime: time.Now().Unix(),
  7296. InscpScpAmt: item.InscpScpAmt,
  7297. DrtReimFlag: item.DrtReimFlag,
  7298. Ctime: time.Now().Unix(),
  7299. ListSpItemFlag: item.ListSpItemFlag,
  7300. ChldMedcFlag: item.ChldMedcFlag,
  7301. LmtUsedFlag: item.LmtUsedFlag,
  7302. ChrgitmLv: item.ChrgitmLv,
  7303. UserOrgId: adminUser.CurrentOrgId,
  7304. HisPatientId: his.ID,
  7305. OrderId: order.ID,
  7306. ProjectId: project_id,
  7307. Type: types,
  7308. }
  7309. service.CreateOrderInfo(info)
  7310. }
  7311. service.UpDatePrescriptionNumber(adminUser.CurrentOrgId, ids, chrg_bchno)
  7312. service.UpDateHisPrescriptionInfoNumber(adminUser.CurrentOrgId, his_patient_id, chrg_bchno, recordDateTime)
  7313. var total float64
  7314. for _, item := range prescriptions {
  7315. if item.Type == 1 { //药品
  7316. for _, subItem := range item.HisDoctorAdviceInfo {
  7317. total = total + (subItem.Price * subItem.PrescribingNumber)
  7318. }
  7319. }
  7320. if item.Type == 2 { //项目
  7321. for _, subItem := range item.HisPrescriptionProject {
  7322. cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  7323. total = total + (subItem.Price * cnt)
  7324. }
  7325. }
  7326. }
  7327. for _, item := range prescriptions {
  7328. for _, subItem := range item.HisAdditionalCharge {
  7329. total = total + (subItem.Price * float64(subItem.Count))
  7330. }
  7331. }
  7332. allTotal := fmt.Sprintf("%.4f", total)
  7333. if res.Infcode == 0 {
  7334. var rf []*ResultFive
  7335. json.Unmarshal([]byte(his.Iinfo), &rf)
  7336. chrg_bchno := chrg_bchno
  7337. cert_no := his.Certno
  7338. var insutypes []string
  7339. var insutype string
  7340. var is390 int = 0
  7341. var is310 int = 0
  7342. for _, item := range rf {
  7343. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  7344. insutypes = append(insutypes, item.Insutype)
  7345. }
  7346. }
  7347. if len(insutypes) == 1 {
  7348. insutype = insutypes[0]
  7349. } else {
  7350. for _, i := range insutypes {
  7351. if i == "390" {
  7352. is390 = 1
  7353. }
  7354. if i == "310" {
  7355. is310 = 1
  7356. }
  7357. }
  7358. }
  7359. if is390 == 1 {
  7360. insutype = "390"
  7361. }
  7362. if is310 == 1 {
  7363. insutype = "310"
  7364. }
  7365. if len(insutypes) == 0 {
  7366. insutype = "310"
  7367. }
  7368. if len(insutypes) == 2 {
  7369. insutype = strconv.FormatInt(his.SocialType, 64)
  7370. }
  7371. //insutype = "390"
  7372. if his.IdCardType == 1 {
  7373. cert_no = his.MedicalInsuranceNumber
  7374. } else {
  7375. cert_no = his.Certno
  7376. }
  7377. var res ResultSeven
  7378. var resSeven10265 ResultSeven10265
  7379. if miConfig.MdtrtareaAdmvs == "421300" {
  7380. api := "http://192.168.124.4:9532/" + "hbyb/2206?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  7381. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  7382. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  7383. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  7384. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  7385. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  7386. "&insutype=" + insutype + "&total=" + allTotal + "&med_type=" + strconv.FormatInt(reg_type, 10)
  7387. resp, requestErr := http.Get(api)
  7388. if requestErr != nil {
  7389. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7390. return
  7391. }
  7392. body, ioErr := ioutil.ReadAll(resp.Body)
  7393. if ioErr != nil {
  7394. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  7395. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7396. return
  7397. }
  7398. var respJSON map[string]interface{}
  7399. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  7400. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  7401. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7402. return
  7403. }
  7404. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  7405. result, _ := json.Marshal(respJSON)
  7406. fmt.Println("log")
  7407. fmt.Println(string(result))
  7408. if err := json.Unmarshal([]byte(result), &res); err != nil {
  7409. utils.ErrorLog("解析失败:%v", err)
  7410. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7411. return
  7412. }
  7413. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  7414. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  7415. psn_info.VerifyNumber = strings.Replace(psn_info.VerifyNumber, "+", "%2B", -1)
  7416. bas := strings.Split(psn_info.CardInfo, "|")
  7417. if his.IdCardType == 1 {
  7418. cert_no = bas[2]
  7419. } else {
  7420. cert_no = bas[1]
  7421. }
  7422. //江苏地区国家医保医疗类别
  7423. //职工透析:医疗类别选特殊情况门诊9933
  7424. //居民血透门慢: 医疗类别选门诊慢病1402
  7425. //var med_type string
  7426. //if his.Insutype == "310" {
  7427. // if reg_type == 14 {
  7428. // med_type = "9933"
  7429. // } else if reg_type == 11 {
  7430. // med_type = "11"
  7431. //
  7432. // }
  7433. //} else if his.Insutype == "390" {
  7434. // if reg_type == 14 {
  7435. // med_type = "1402"
  7436. // } else if reg_type == 11 {
  7437. // med_type = "11"
  7438. // }
  7439. //}
  7440. var api string
  7441. if miConfig.MdtrtareaAdmvs == "320921" {
  7442. api = "http://192.168.2.110:9532/" + "jsyb/2206?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  7443. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  7444. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  7445. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  7446. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  7447. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  7448. "&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
  7449. //req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  7450. } else {
  7451. //req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  7452. api = "http://192.168.5.251:9532/" + "jsyb/2206?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  7453. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  7454. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  7455. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  7456. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  7457. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  7458. "&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
  7459. }
  7460. resp, requestErr := http.Get(api)
  7461. if requestErr != nil {
  7462. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7463. return
  7464. }
  7465. body, ioErr := ioutil.ReadAll(resp.Body)
  7466. if ioErr != nil {
  7467. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  7468. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7469. return
  7470. }
  7471. var respJSON map[string]interface{}
  7472. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  7473. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  7474. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7475. return
  7476. }
  7477. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  7478. result, _ := json.Marshal(respJSON)
  7479. fmt.Println("log")
  7480. fmt.Println(string(result))
  7481. if err := json.Unmarshal([]byte(result), &resSeven10265); err != nil {
  7482. utils.ErrorLog("解析失败:%v", err)
  7483. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7484. return
  7485. }
  7486. res.InfRefmsgid = resSeven10265.InfRefmsgid
  7487. res.Output = resSeven10265.Output
  7488. res.ErrMsg = resSeven10265.ErrMsg
  7489. res.Cainfo = resSeven10265.Cainfo
  7490. res.WarnMsg = resSeven10265.WarnMsg
  7491. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  7492. res.Infcode = infocode
  7493. } else if miConfig.MdtrtareaAdmvs == "350500" {
  7494. result, request_log := service.FJyb2206(his.PsnNo, his.Number, chrg_bchno, cert_no, insutype, allTotal, miConfig.OrgName, roles.UserName, miConfig.Code, his.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, strconv.FormatInt(reg_type, 10), his.IdCardType, 0, 0, 0, 0, his.IdType, miConfig.Url, miConfig.Code, miConfig.AppSecret, miConfig.SignKey, miConfig.EncKey)
  7495. var dat map[string]interface{}
  7496. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  7497. fmt.Println(dat)
  7498. } else {
  7499. fmt.Println(err)
  7500. }
  7501. saveLog(result, request_log, "2206", "预结算")
  7502. userJSONBytes, _ := json.Marshal(dat)
  7503. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  7504. utils.ErrorLog("解析失败:%v", err)
  7505. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7506. return
  7507. }
  7508. } else {
  7509. var result string
  7510. var request_log string
  7511. if miConfig.Code == "H15049901371" {
  7512. //赤峰地区国家医保医疗类别
  7513. //职工透析:医疗类别选特殊情况门诊990502
  7514. //居民定额血透门慢: 医疗类别选门诊慢病140104
  7515. var med_type string
  7516. if his.Insutype == "390" {
  7517. if reg_type == 14 {
  7518. med_type = "9933"
  7519. } else if reg_type == 11 {
  7520. med_type = "11"
  7521. }
  7522. } else if his.Insutype == "310" {
  7523. if reg_type == 14 {
  7524. med_type = "990502"
  7525. } else if reg_type == 11 {
  7526. med_type = "11"
  7527. }
  7528. }
  7529. 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)
  7530. } else {
  7531. 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)
  7532. }
  7533. var dat map[string]interface{}
  7534. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  7535. fmt.Println(dat)
  7536. } else {
  7537. fmt.Println(err)
  7538. }
  7539. saveLog(result, request_log, "2206", "预结算")
  7540. //userJSONBytes, _ := json.Marshal(dat)
  7541. //
  7542. //if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  7543. // utils.ErrorLog("解析失败:%v", err)
  7544. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7545. // return
  7546. //}
  7547. userJSONBytes, _ := json.Marshal(dat)
  7548. if miConfig.Code == "H15049901371" {
  7549. if err := json.Unmarshal(userJSONBytes, &resSeven10265); err != nil {
  7550. utils.ErrorLog("解析失败:%v", err)
  7551. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7552. return
  7553. }
  7554. res.InfRefmsgid = resSeven10265.InfRefmsgid
  7555. res.Output = resSeven10265.Output
  7556. res.ErrMsg = resSeven10265.ErrMsg
  7557. res.Cainfo = resSeven10265.Cainfo
  7558. res.WarnMsg = resSeven10265.WarnMsg
  7559. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  7560. res.Infcode = infocode
  7561. } else {
  7562. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  7563. utils.ErrorLog("解析失败:%v", err)
  7564. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7565. return
  7566. }
  7567. }
  7568. }
  7569. if res.Infcode != 0 {
  7570. errlog := &models.HisOrderError{
  7571. UserOrgId: adminUser.CurrentOrgId,
  7572. Ctime: time.Now().Unix(),
  7573. Mtime: time.Now().Unix(),
  7574. Number: chrg_bchno,
  7575. ErrMsg: res.ErrMsg,
  7576. Status: 1,
  7577. PatientId: id,
  7578. RecordTime: recordDateTime,
  7579. Stage: 20,
  7580. }
  7581. service.CreateErrMsgLog(errlog)
  7582. c.ServeSuccessJSON(map[string]interface{}{
  7583. "failed_code": -10,
  7584. "msg": res.ErrMsg,
  7585. })
  7586. return
  7587. } else {
  7588. order, _ := service.GetHisOrderTwo(adminUser.CurrentOrgId, chrg_bchno, id)
  7589. order.OrderStatus = 1
  7590. order.IsPre = 1
  7591. order.Status = 1
  7592. order.MdtrtId = res.Output.Setlinfo.MdtrtID
  7593. order.SetlId = res.Output.Setlinfo.SetlID
  7594. order.PsnNo = res.Output.Setlinfo.PsnNo
  7595. order.PsnName = res.Output.Setlinfo.PsnName
  7596. order.PsnCertType = res.Output.Setlinfo.PsnCertType
  7597. order.Certno = res.Output.Setlinfo.Certno
  7598. order.Gend = res.Output.Setlinfo.Gend
  7599. order.Naty = res.Output.Setlinfo.Naty
  7600. order.Age = res.Output.Setlinfo.Age
  7601. order.Insutype = res.Output.Setlinfo.Insutype
  7602. order.PsnType = res.Output.Setlinfo.PsnType
  7603. order.CvlservFlag = res.Output.Setlinfo.CvlservFlag
  7604. order.SetlTime = res.Output.Setlinfo.SetlTime
  7605. order.MdtrtCertType = res.Output.Setlinfo.MdtrtCertType
  7606. if res.Output.Setlinfo.MedType == "140101" {
  7607. order.MedType = "14"
  7608. } else {
  7609. order.MedType = res.Output.Setlinfo.MedType
  7610. }
  7611. if reg_type == 1112 {
  7612. order.MedType = "1112"
  7613. }
  7614. if reg_type == 1111 {
  7615. order.MedType = "1111"
  7616. }
  7617. order.MedfeeSumamt = res.Output.Setlinfo.MedfeeSumamt
  7618. order.FulamtOwnpayAmt = res.Output.Setlinfo.FulamtOwnpayAmt
  7619. order.OverlmtSelfPay = res.Output.Setlinfo.OverlmtSelfpay
  7620. order.PreselfpayAmt = res.Output.Setlinfo.PreselfpayAmt
  7621. order.InscpScpAmt = res.Output.Setlinfo.InscpScpAmt
  7622. order.ActPayDedc = res.Output.Setlinfo.ActPayDedc
  7623. order.HifpPay = res.Output.Setlinfo.HifpPay
  7624. order.CvlservPay = res.Output.Setlinfo.CvlservPay
  7625. order.PoolPropSelfpay = res.Output.Setlinfo.PoolPropSelfpay
  7626. order.HifesPay = res.Output.Setlinfo.HifesPay
  7627. order.HifobPay = res.Output.Setlinfo.HifobPay
  7628. order.MafPay = res.Output.Setlinfo.MafPay
  7629. order.HifmiPay = res.Output.Setlinfo.HifmiPay
  7630. order.OthPay = res.Output.Setlinfo.OthPay
  7631. order.FundPaySumamt = res.Output.Setlinfo.FundPaySumamt
  7632. order.PsnPartAmt = res.Output.Setlinfo.PsnPartAmt
  7633. order.AcctPay = res.Output.Setlinfo.AcctPay
  7634. order.PsnCashPay = res.Output.Setlinfo.PsnCashPay
  7635. order.HospPartAmt = res.Output.Setlinfo.HospPartAmt
  7636. order.Balc = res.Output.Setlinfo.Balc
  7637. order.AcctMulaidPay = res.Output.Setlinfo.AcctMulaidPay
  7638. order.MedinsSetlId = res.Output.Setlinfo.MedinsSetlID
  7639. order.ClrOptins = res.Output.Setlinfo.ClrOptins
  7640. order.ClrWay = res.Output.Setlinfo.ClrWay
  7641. order.Creator = order.Creator
  7642. order.Modify = roles.AdminUserId
  7643. setlDetail, _ := json.Marshal(res.Output.Setldetail)
  7644. detailStr := string(setlDetail)
  7645. order.SetlDetail = detailStr
  7646. //err := service.UpdataOrderStatusTwo(chrg_bchno, adminUser.CurrentOrgId)
  7647. err = service.UpDateOrder(order)
  7648. if err == nil {
  7649. c.ServeSuccessJSON(map[string]interface{}{
  7650. "msg": "预结算成功",
  7651. })
  7652. } else {
  7653. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeAmountAccountException)
  7654. return
  7655. }
  7656. }
  7657. } else {
  7658. adminUser := c.GetAdminUserInfo()
  7659. errlog := &models.HisOrderError{
  7660. UserOrgId: adminUser.CurrentOrgId,
  7661. Ctime: time.Now().Unix(),
  7662. Mtime: time.Now().Unix(),
  7663. ErrMsg: res.ErrMsg,
  7664. Status: 1,
  7665. PatientId: id,
  7666. RecordTime: recordDateTime,
  7667. Stage: 4,
  7668. }
  7669. service.CreateErrMsgLog(errlog)
  7670. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeRegisterRepeatException)
  7671. return
  7672. }
  7673. } else {
  7674. adminUser := c.GetAdminUserInfo()
  7675. errlog := &models.HisOrderError{
  7676. UserOrgId: adminUser.CurrentOrgId,
  7677. Ctime: time.Now().Unix(),
  7678. Mtime: time.Now().Unix(),
  7679. ErrMsg: res.ErrMsg,
  7680. Status: 1,
  7681. PatientId: id,
  7682. RecordTime: recordDateTime,
  7683. Stage: 4,
  7684. }
  7685. service.CreateErrMsgLog(errlog)
  7686. c.ServeSuccessJSON(map[string]interface{}{
  7687. "failed_code": -10,
  7688. "msg": res.ErrMsg,
  7689. })
  7690. return
  7691. }
  7692. }
  7693. }
  7694. }
  7695. //退款
  7696. func (c *HisApiController) Refund() {
  7697. order_id, _ := c.GetInt64("order_id")
  7698. admin_user_id, _ := c.GetInt64("admin_user_id")
  7699. adminUser := c.GetAdminUserInfo()
  7700. var order models.HisOrder
  7701. order, _ = service.GetHisOrderByID(order_id)
  7702. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  7703. if order.ID == 0 {
  7704. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  7705. return
  7706. }
  7707. his, _ := service.GetHisPatientByNumber(order.MdtrtId)
  7708. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  7709. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  7710. if config.IsOpen == 1 { //对接了医保,走医保流程
  7711. var res ResultSixteen
  7712. var resSixteen10265 ResultSixteen10265
  7713. var src_resquest string
  7714. var result string
  7715. if miConfig.MdtrtareaAdmvs == "421300" {
  7716. api3 := "http://192.168.124.4:9532/" + "hbyb/2208?psn_no=" + order.PsnNo +
  7717. "&mdtrt_id=" + order.MdtrtId + "&setl_id=" + order.SetlId + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  7718. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  7719. resp3, requestErr3 := http.Get(api3)
  7720. if requestErr3 != nil {
  7721. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7722. return
  7723. }
  7724. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  7725. if ioErr3 != nil {
  7726. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  7727. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7728. return
  7729. }
  7730. var respJSON3 map[string]interface{}
  7731. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  7732. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  7733. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7734. return
  7735. }
  7736. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  7737. userJSONBytes3, _ := json.Marshal(respJSON3)
  7738. fmt.Println("log")
  7739. fmt.Println(string(userJSONBytes3))
  7740. if err := json.Unmarshal(userJSONBytes3, &res); err != nil {
  7741. utils.ErrorLog("解析失败:%v", err)
  7742. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7743. return
  7744. }
  7745. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  7746. var api3 string
  7747. if miConfig.MdtrtareaAdmvs == "320921" {
  7748. api3 = "http://192.168.2.110:9532/" + "jsyb/2208?psn_no=" + order.PsnNo +
  7749. "&mdtrt_id=" + order.MdtrtId + "&setl_id=" + order.SetlId + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  7750. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  7751. //req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  7752. } else {
  7753. //req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  7754. api3 = "http://192.168.5.251:9532/" + "jsyb/2208?psn_no=" + order.PsnNo +
  7755. "&mdtrt_id=" + order.MdtrtId + "&setl_id=" + order.SetlId + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  7756. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  7757. }
  7758. resp3, requestErr3 := http.Get(api3)
  7759. if requestErr3 != nil {
  7760. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7761. return
  7762. }
  7763. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  7764. if ioErr3 != nil {
  7765. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  7766. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7767. return
  7768. }
  7769. var respJSON3 map[string]interface{}
  7770. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  7771. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  7772. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7773. return
  7774. }
  7775. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  7776. userJSONBytes3, _ := json.Marshal(respJSON3)
  7777. if err := json.Unmarshal(userJSONBytes3, &resSixteen10265); err != nil {
  7778. utils.ErrorLog("解析失败:%v", err)
  7779. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7780. return
  7781. }
  7782. res.InfRefmsgid = resSixteen10265.InfRefmsgid
  7783. res.Output = resSixteen10265.Output
  7784. res.ErrMsg = resSixteen10265.ErrMsg
  7785. res.Cainfo = resSixteen10265.Cainfo
  7786. res.WarnMsg = resSixteen10265.WarnMsg
  7787. infocode, _ := strconv.ParseInt(resSixteen10265.Infcode, 10, 64)
  7788. res.Infcode = infocode
  7789. } else if miConfig.MdtrtareaAdmvs == "350500" {
  7790. result, src_resquest = service.FJyb2208(order.PsnNo, order.MdtrtId, order.SetlId, miConfig.OrgName, roles.UserName, miConfig.SecretKey, miConfig.Code, his.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.Url, miConfig.Code, miConfig.AppSecret, miConfig.SignKey, miConfig.EncKey)
  7791. var dat map[string]interface{}
  7792. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  7793. fmt.Println(dat)
  7794. } else {
  7795. fmt.Println(err)
  7796. }
  7797. saveLog(result, src_resquest, "2208", "退费")
  7798. userJSONBytes, _ := json.Marshal(dat)
  7799. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  7800. utils.ErrorLog("解析失败:%v", err)
  7801. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7802. return
  7803. }
  7804. } else {
  7805. if miConfig.Code == "H15049901371" {
  7806. result, src_resquest = service.Gdyb2208(order.PsnNo, order.MdtrtId, order.SetlId, miConfig.OrgName, roles.UserName, miConfig.SecretKey, miConfig.Code, his.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs)
  7807. var dat map[string]interface{}
  7808. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  7809. fmt.Println(dat)
  7810. } else {
  7811. fmt.Println(err)
  7812. }
  7813. saveLog(result, src_resquest, "2208", "退费")
  7814. userJSONBytes, _ := json.Marshal(dat)
  7815. if err := json.Unmarshal(userJSONBytes, &resSixteen10265); err != nil {
  7816. utils.ErrorLog("解析失败:%v", err)
  7817. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7818. return
  7819. }
  7820. res.InfRefmsgid = resSixteen10265.InfRefmsgid
  7821. res.Output = resSixteen10265.Output
  7822. res.ErrMsg = resSixteen10265.ErrMsg
  7823. res.Cainfo = resSixteen10265.Cainfo
  7824. res.WarnMsg = resSixteen10265.WarnMsg
  7825. infocode, _ := strconv.ParseInt(resSixteen10265.Infcode, 10, 64)
  7826. res.Infcode = infocode
  7827. } else {
  7828. result, src_resquest = service.Gdyb2208(order.PsnNo, order.MdtrtId, order.SetlId, miConfig.OrgName, roles.UserName, miConfig.SecretKey, miConfig.Code, his.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs)
  7829. var dat map[string]interface{}
  7830. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  7831. fmt.Println(dat)
  7832. } else {
  7833. fmt.Println(err)
  7834. }
  7835. saveLog(result, src_resquest, "2208", "退费")
  7836. userJSONBytes, _ := json.Marshal(dat)
  7837. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  7838. utils.ErrorLog("解析失败:%v", err)
  7839. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7840. return
  7841. }
  7842. }
  7843. }
  7844. if res.Infcode == 0 {
  7845. var res2 ResultSix
  7846. var resSix10265 ResultSix10265
  7847. if miConfig.MdtrtareaAdmvs == "421300" {
  7848. api3 := "http://192.168.124.4:9532/" + "hbyb/2205?psn_no=" + order.PsnNo +
  7849. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  7850. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  7851. resp3, requestErr3 := http.Get(api3)
  7852. if requestErr3 != nil {
  7853. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7854. return
  7855. }
  7856. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  7857. if ioErr3 != nil {
  7858. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  7859. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7860. return
  7861. }
  7862. var respJSON3 map[string]interface{}
  7863. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  7864. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  7865. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7866. return
  7867. }
  7868. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  7869. userJSONBytes3, _ := json.Marshal(respJSON3)
  7870. fmt.Println("log")
  7871. fmt.Println(string(userJSONBytes3))
  7872. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  7873. utils.ErrorLog("解析失败:%v", err)
  7874. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7875. return
  7876. }
  7877. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  7878. var api3 string
  7879. if miConfig.MdtrtareaAdmvs == "320921" {
  7880. api3 = "http://192.168.2.110:9532/" + "jsyb/2205?psn_no=" + order.PsnNo +
  7881. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  7882. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  7883. //req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  7884. } else {
  7885. //req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  7886. api3 = "http://192.168.5.251:9532/" + "jsyb/2205?psn_no=" + order.PsnNo +
  7887. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  7888. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  7889. }
  7890. resp3, requestErr3 := http.Get(api3)
  7891. if requestErr3 != nil {
  7892. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7893. return
  7894. }
  7895. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  7896. if ioErr3 != nil {
  7897. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  7898. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7899. return
  7900. }
  7901. var respJSON3 map[string]interface{}
  7902. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  7903. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  7904. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7905. return
  7906. }
  7907. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  7908. userJSONBytes3, _ := json.Marshal(respJSON3)
  7909. fmt.Println("log")
  7910. fmt.Println(string(userJSONBytes3))
  7911. if err := json.Unmarshal(userJSONBytes3, &resSix10265); err != nil {
  7912. utils.ErrorLog("解析失败:%v", err)
  7913. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7914. return
  7915. }
  7916. res2.InfRefmsgid = resSix10265.InfRefmsgid
  7917. res2.Output = resSix10265.Output
  7918. res2.ErrMsg = resSix10265.ErrMsg
  7919. res2.Cainfo = resSix10265.Cainfo
  7920. res2.WarnMsg = resSix10265.WarnMsg
  7921. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  7922. res2.Infcode = infocode
  7923. } else if miConfig.MdtrtareaAdmvs == "350500" {
  7924. result2, src_request := service.FJyb2205(order.PsnNo, order.MdtrtId, order.Number, miConfig.OrgName, roles.UserName, his.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, miConfig.Code, miConfig.Url, miConfig.Code, miConfig.AppSecret, miConfig.SignKey, miConfig.EncKey)
  7925. var dat map[string]interface{}
  7926. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  7927. fmt.Println(dat)
  7928. } else {
  7929. fmt.Println(err)
  7930. }
  7931. saveLog(result2, src_request, "2205", "撤销明细")
  7932. userJSONBytes, _ := json.Marshal(dat)
  7933. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  7934. utils.ErrorLog("解析失败:%v", err)
  7935. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7936. return
  7937. }
  7938. } else {
  7939. if miConfig.Code == "H15049901371" {
  7940. result2, src_request := service.Gdyb2205(order.PsnNo, order.MdtrtId, order.Number, miConfig.OrgName, roles.UserName, his.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, miConfig.Code)
  7941. var dat map[string]interface{}
  7942. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  7943. fmt.Println(dat)
  7944. } else {
  7945. fmt.Println(err)
  7946. }
  7947. saveLog(result2, src_request, "2205", "撤销明细")
  7948. userJSONBytes, _ := json.Marshal(dat)
  7949. if err := json.Unmarshal(userJSONBytes, &resSix10265); err != nil {
  7950. utils.ErrorLog("解析失败:%v", err)
  7951. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7952. return
  7953. }
  7954. res2.InfRefmsgid = resSix10265.InfRefmsgid
  7955. res2.Output = resSix10265.Output
  7956. res2.ErrMsg = resSix10265.ErrMsg
  7957. res2.Cainfo = resSix10265.Cainfo
  7958. res2.WarnMsg = resSix10265.WarnMsg
  7959. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  7960. res2.Infcode = infocode
  7961. } else {
  7962. result2, src_request := service.Gdyb2205(order.PsnNo, order.MdtrtId, order.Number, miConfig.OrgName, roles.UserName, his.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, miConfig.Code)
  7963. var dat map[string]interface{}
  7964. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  7965. fmt.Println(dat)
  7966. } else {
  7967. fmt.Println(err)
  7968. }
  7969. saveLog(result2, src_request, "2205", "撤销明细")
  7970. userJSONBytes, _ := json.Marshal(dat)
  7971. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  7972. utils.ErrorLog("解析失败:%v", err)
  7973. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7974. return
  7975. }
  7976. }
  7977. }
  7978. if res2.Infcode == 0 {
  7979. err := service.UpdataOrderStatus(order_id, order.Number, adminUser.CurrentOrgId, src_resquest, result)
  7980. if err == nil {
  7981. //当押金不为零时产生退费记录
  7982. if order.Decimal != 0 {
  7983. tmp := strconv.FormatInt(order.ID, 10)
  7984. err = service.MoneyIncrease(adminUser.CurrentOrgId, order.PatientId, tmp, order.Decimal)
  7985. if err != nil {
  7986. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7987. return
  7988. }
  7989. }
  7990. c.ServeSuccessJSON(map[string]interface{}{
  7991. "msg": "退费成功",
  7992. })
  7993. } else {
  7994. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7995. return
  7996. }
  7997. } else {
  7998. c.ServeSuccessJSON(map[string]interface{}{
  7999. "code": -10,
  8000. "msg": res2.ErrMsg,
  8001. })
  8002. }
  8003. } else {
  8004. c.ServeSuccessJSON(map[string]interface{}{
  8005. "code": -10,
  8006. "msg": res.ErrMsg,
  8007. })
  8008. }
  8009. }
  8010. }
  8011. func (c *HisApiController) RefundNumber() {
  8012. record_time := c.GetString("record_time")
  8013. //patient_id, _ := c.GetInt64("patient_id")
  8014. admin_user_id, _ := c.GetInt64("admin_user_id")
  8015. his_patient_id, _ := c.GetInt64("id")
  8016. timeLayout := "2006-01-02"
  8017. loc, _ := time.LoadLocation("Local")
  8018. adminUser := c.GetAdminUserInfo()
  8019. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  8020. fmt.Println(err)
  8021. if err != nil {
  8022. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  8023. return
  8024. }
  8025. recordDateTime := theTime.Unix()
  8026. //his, _ := service.GetVMHisPatientInfo(adminUser.CurrentOrgId, patient_id, recordDateTime)
  8027. his, _ := service.GetHisPatientRecord(adminUser.CurrentOrgId, his_patient_id)
  8028. //patientPrescription, _ := service.FindPatientPrescriptionInfo(adminUser.CurrentOrgId, patient_id, recordDateTime)
  8029. //order, _ := service.GetHisOrderByID(order_id)
  8030. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  8031. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  8032. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  8033. count, _ := service.GetOrderCountByNumber(adminUser.CurrentOrgId, his.PatientId, recordDateTime, his.Number)
  8034. if count > 0 {
  8035. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeOrderParamWrong)
  8036. return
  8037. }
  8038. if config.IsOpen == 1 { //对接了医保,走医保流程
  8039. var res2 ResultSix
  8040. var resSix10265 ResultSix10265
  8041. if miConfig.MdtrtareaAdmvs == "421300" {
  8042. api3 := "http://192.168.124.4:9532/" + "hbyb/2202?psn_no=" + his.PsnNo +
  8043. "&mdtrt_id=" + his.Number + "&ipt_otp_no=" + his.IptOtpNo + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  8044. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  8045. resp3, requestErr3 := http.Get(api3)
  8046. if requestErr3 != nil {
  8047. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8048. return
  8049. }
  8050. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  8051. if ioErr3 != nil {
  8052. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  8053. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8054. return
  8055. }
  8056. var respJSON3 map[string]interface{}
  8057. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  8058. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  8059. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8060. return
  8061. }
  8062. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  8063. userJSONBytes3, _ := json.Marshal(respJSON3)
  8064. fmt.Println("log")
  8065. fmt.Println(string(userJSONBytes3))
  8066. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  8067. utils.ErrorLog("解析失败:%v", err)
  8068. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8069. return
  8070. }
  8071. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  8072. var api3 string
  8073. if miConfig.MdtrtareaAdmvs == "320921" {
  8074. api3 = "http://192.168.2.110:9532/" + "jsyb/2202?psn_no=" + his.PsnNo +
  8075. "&mdtrt_id=" + his.Number + "&ipt_otp_no=" + his.IptOtpNo + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  8076. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  8077. //req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  8078. } else {
  8079. //req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  8080. api3 = "http://192.168.5.251:9532/" + "jsyb/2202?psn_no=" + his.PsnNo +
  8081. "&mdtrt_id=" + his.Number + "&ipt_otp_no=" + his.IptOtpNo + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  8082. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  8083. }
  8084. resp3, requestErr3 := http.Get(api3)
  8085. if requestErr3 != nil {
  8086. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8087. return
  8088. }
  8089. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  8090. if ioErr3 != nil {
  8091. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  8092. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8093. return
  8094. }
  8095. var respJSON3 map[string]interface{}
  8096. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  8097. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  8098. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8099. return
  8100. }
  8101. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  8102. userJSONBytes3, _ := json.Marshal(respJSON3)
  8103. if err := json.Unmarshal(userJSONBytes3, &resSix10265); err != nil {
  8104. utils.ErrorLog("解析失败:%v", err)
  8105. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8106. return
  8107. }
  8108. res2.InfRefmsgid = resSix10265.InfRefmsgid
  8109. res2.Output = resSix10265.Output
  8110. res2.ErrMsg = resSix10265.ErrMsg
  8111. res2.Cainfo = resSix10265.Cainfo
  8112. res2.WarnMsg = resSix10265.WarnMsg
  8113. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  8114. res2.Infcode = infocode
  8115. } else if miConfig.MdtrtareaAdmvs == "350500" {
  8116. result, request := service.FJyb2202(his.PsnNo, his.Number, his.IptOtpNo, miConfig.OrgName, roles.UserName, his.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, miConfig.Code, miConfig.Url, miConfig.Code, miConfig.AppSecret, miConfig.SignKey, miConfig.EncKey)
  8117. var dat map[string]interface{}
  8118. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  8119. fmt.Println(dat)
  8120. } else {
  8121. fmt.Println(err)
  8122. }
  8123. saveLog(result, request, "2202", "退号")
  8124. userJSONBytes, _ := json.Marshal(dat)
  8125. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  8126. utils.ErrorLog("解析失败:%v", err)
  8127. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8128. return
  8129. }
  8130. } else {
  8131. var api3 string
  8132. if miConfig.Code == "H15049901371" {
  8133. api3 = "http://127.0.0.1:9532/" + "gdyb/three?psn_no=" + his.PsnNo +
  8134. "&mdtrt_id=" + his.Number + "&ipt_otp_no=" + his.IptOtpNo + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  8135. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  8136. } else {
  8137. api3 = "http://127.0.0.1:9532/" + "gdyb/three?psn_no=" + his.PsnNo +
  8138. "&mdtrt_id=" + his.Number + "&ipt_otp_no=" + his.IptOtpNo + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  8139. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  8140. }
  8141. resp3, requestErr3 := http.Get(api3)
  8142. if requestErr3 != nil {
  8143. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8144. return
  8145. }
  8146. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  8147. if ioErr3 != nil {
  8148. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  8149. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8150. return
  8151. }
  8152. var respJSON3 map[string]interface{}
  8153. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  8154. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  8155. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8156. return
  8157. }
  8158. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  8159. userJSONBytes3, _ := json.Marshal(respJSON3)
  8160. if miConfig.Code == "H15049901371" {
  8161. if err := json.Unmarshal(userJSONBytes3, &resSix10265); err != nil {
  8162. utils.ErrorLog("解析失败:%v", err)
  8163. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8164. return
  8165. }
  8166. res2.InfRefmsgid = resSix10265.InfRefmsgid
  8167. res2.Output = resSix10265.Output
  8168. res2.ErrMsg = resSix10265.ErrMsg
  8169. res2.Cainfo = resSix10265.Cainfo
  8170. res2.WarnMsg = resSix10265.WarnMsg
  8171. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  8172. res2.Infcode = infocode
  8173. } else {
  8174. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  8175. utils.ErrorLog("解析失败:%v", err)
  8176. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8177. return
  8178. }
  8179. }
  8180. }
  8181. if res2.Infcode == 0 {
  8182. if err == nil {
  8183. c.ServeSuccessJSON(map[string]interface{}{
  8184. "msg": "退号成功",
  8185. })
  8186. service.UpdataRegStatusTwo(his_patient_id, recordDateTime, adminUser.CurrentOrgId)
  8187. } else {
  8188. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8189. return
  8190. }
  8191. } else {
  8192. c.ServeSuccessJSON(map[string]interface{}{
  8193. "code": -10,
  8194. "msg": res2.ErrMsg,
  8195. })
  8196. }
  8197. } else {
  8198. //err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId)
  8199. //if err == nil {
  8200. // c.ServeSuccessJSON(map[string]interface{}{
  8201. // "msg": "退费成功",
  8202. // })
  8203. //} else {
  8204. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8205. // return
  8206. //}
  8207. }
  8208. }
  8209. func (c *HisApiController) RefundDetail() {
  8210. order_id, _ := c.GetInt64("order_id")
  8211. admin_user_id, _ := c.GetInt64("admin_user_id")
  8212. //his_patient_id, _ := c.GetInt64("his_patient_id")
  8213. number := c.GetString("number")
  8214. record_time := c.GetString("record_time")
  8215. patient_id, _ := c.GetInt64("patient_id")
  8216. //med_type, _ := c.GetInt64("med_type")
  8217. timeLayout := "2006-01-02"
  8218. loc, _ := time.LoadLocation("Local")
  8219. adminUser := c.GetAdminUserInfo()
  8220. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  8221. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  8222. fmt.Println(err)
  8223. if err != nil {
  8224. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  8225. return
  8226. }
  8227. recordDateTime := theTime.Unix()
  8228. //his, _ := service.GetNewVMHisPatientInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  8229. patientPrescription, _ := service.FindPatientPrescriptionInfo(adminUser.CurrentOrgId, patient_id, recordDateTime)
  8230. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  8231. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  8232. var order models.HisOrder
  8233. order, _ = service.GetHisOrderByID(order_id)
  8234. his, _ := service.GetHisPatientByNumber(order.MdtrtId)
  8235. if config.IsOpen == 1 { //对接了医保,走医保流程
  8236. var res2 ResultSix
  8237. if miConfig.MdtrtareaAdmvs == "421300" {
  8238. api3 := "http://192.168.124.4:9532/" + "hbyb/2205?psn_no=" + order.PsnNo +
  8239. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + patientPrescription.Doctor + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  8240. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  8241. resp3, requestErr3 := http.Get(api3)
  8242. if requestErr3 != nil {
  8243. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8244. return
  8245. }
  8246. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  8247. if ioErr3 != nil {
  8248. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  8249. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8250. return
  8251. }
  8252. var respJSON3 map[string]interface{}
  8253. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  8254. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  8255. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8256. return
  8257. }
  8258. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  8259. userJSONBytes3, _ := json.Marshal(respJSON3)
  8260. fmt.Println("log")
  8261. fmt.Println(string(userJSONBytes3))
  8262. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  8263. utils.ErrorLog("解析失败:%v", err)
  8264. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8265. return
  8266. }
  8267. err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId, "", "")
  8268. if err == nil {
  8269. c.ServeSuccessJSON(map[string]interface{}{
  8270. "msg": "撤销明细成功",
  8271. })
  8272. return
  8273. } else {
  8274. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8275. return
  8276. }
  8277. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  8278. var resSix10265 ResultSix10265
  8279. var api3 string
  8280. if miConfig.MdtrtareaAdmvs == "320921" {
  8281. api3 = "http://192.168.2.110:9532/" + "jsyb/2205?psn_no=" + order.PsnNo +
  8282. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + patientPrescription.Doctor + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  8283. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  8284. //req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  8285. } else {
  8286. //req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  8287. api3 = "http://192.168.5.251:9532/" + "jsyb/2205?psn_no=" + order.PsnNo +
  8288. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + patientPrescription.Doctor + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  8289. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  8290. }
  8291. resp3, requestErr3 := http.Get(api3)
  8292. if requestErr3 != nil {
  8293. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8294. return
  8295. }
  8296. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  8297. if ioErr3 != nil {
  8298. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  8299. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8300. return
  8301. }
  8302. var respJSON3 map[string]interface{}
  8303. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  8304. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  8305. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8306. return
  8307. }
  8308. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  8309. userJSONBytes3, _ := json.Marshal(respJSON3)
  8310. fmt.Println("log")
  8311. fmt.Println(string(userJSONBytes3))
  8312. if err := json.Unmarshal(userJSONBytes3, &resSix10265); err != nil {
  8313. utils.ErrorLog("解析失败:%v", err)
  8314. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8315. return
  8316. }
  8317. res2.InfRefmsgid = resSix10265.InfRefmsgid
  8318. res2.Output = resSix10265.Output
  8319. res2.ErrMsg = resSix10265.ErrMsg
  8320. res2.Cainfo = resSix10265.Cainfo
  8321. res2.WarnMsg = resSix10265.WarnMsg
  8322. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  8323. res2.Infcode = infocode
  8324. err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId, "", "")
  8325. if err == nil {
  8326. c.ServeSuccessJSON(map[string]interface{}{
  8327. "msg": "撤销明细成功",
  8328. })
  8329. return
  8330. } else {
  8331. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8332. return
  8333. }
  8334. } else if miConfig.MdtrtareaAdmvs == "350500" {
  8335. result2, src_request := service.FJyb2205(his.PsnNo, his.Number, order.Number, miConfig.OrgName, roles.UserName, his.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, miConfig.Code, miConfig.Url, miConfig.Code, miConfig.AppSecret, miConfig.SignKey, miConfig.EncKey)
  8336. var dat map[string]interface{}
  8337. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  8338. fmt.Println(dat)
  8339. } else {
  8340. fmt.Println(err)
  8341. }
  8342. saveLog(result2, src_request, "2205", "撤销明细")
  8343. userJSONBytes, _ := json.Marshal(dat)
  8344. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  8345. utils.ErrorLog("解析失败:%v", err)
  8346. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8347. return
  8348. }
  8349. if res2.Infcode == 0 {
  8350. err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId, "", "")
  8351. if err == nil {
  8352. c.ServeSuccessJSON(map[string]interface{}{
  8353. "msg": "撤销明细成功",
  8354. })
  8355. return
  8356. } else {
  8357. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8358. return
  8359. }
  8360. } else {
  8361. c.ServeSuccessJSON(map[string]interface{}{
  8362. "code": -10,
  8363. "msg": res2.ErrMsg,
  8364. })
  8365. }
  8366. } else {
  8367. api2 := "http://127.0.0.1:9532/" + "gdyb/six?psn_no=" + his.PsnNo +
  8368. "&mdtrt_id=" + his.Number + "&chrg_bchno=" + order.Number + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  8369. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  8370. resp2, requestErr2 := http.Get(api2)
  8371. if requestErr2 != nil {
  8372. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8373. return
  8374. }
  8375. body2, ioErr2 := ioutil.ReadAll(resp2.Body)
  8376. if ioErr2 != nil {
  8377. utils.ErrorLog("接口返回数据读取失败: %v", ioErr2)
  8378. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8379. return
  8380. }
  8381. var respJSON2 map[string]interface{}
  8382. if err := json.Unmarshal([]byte(string(body2)), &respJSON2); err != nil {
  8383. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  8384. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8385. return
  8386. }
  8387. err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId, "", "")
  8388. if err == nil {
  8389. c.ServeSuccessJSON(map[string]interface{}{
  8390. "msg": "撤销明细成功",
  8391. })
  8392. return
  8393. } else {
  8394. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8395. return
  8396. }
  8397. }
  8398. } else {
  8399. err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId, "", "")
  8400. if err == nil {
  8401. c.ServeSuccessJSON(map[string]interface{}{
  8402. "msg": "退费成功",
  8403. })
  8404. } else {
  8405. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8406. return
  8407. }
  8408. }
  8409. }
  8410. //对账
  8411. func (c *HisApiController) GetCheckAccount() {
  8412. start_time := c.GetString("start_time")
  8413. end_time := c.GetString("end_time")
  8414. insutype := c.GetString("insutype")
  8415. clr_type := c.GetString("clr_type")
  8416. clr_org := c.GetString("clr_optins")
  8417. admin_user_id, _ := c.GetInt64("admin_user_id")
  8418. adminUser := c.GetAdminUserInfo()
  8419. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  8420. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  8421. if len(clr_org) == 0 {
  8422. clr_org = miConfig.MdtrtareaAdmvs
  8423. }
  8424. timeLayout := "2006-01-02"
  8425. loc, _ := time.LoadLocation("Local")
  8426. startime, _ := time.ParseInLocation(timeLayout+" 15:04:05", start_time+" 00:00:00", loc)
  8427. endtime, _ := time.ParseInLocation(timeLayout+" 15:04:05", end_time+" 23:59:59", loc)
  8428. orders, _ := service.GetOrderByTime(startime.Unix(), endtime.Unix(), adminUser.CurrentOrgId, insutype, "", clr_type)
  8429. fixmedins_setl_cnt := int64(len(orders))
  8430. var medfee_sumamt float64
  8431. var acct_pay float64
  8432. var fund_pay_sumamt float64
  8433. for _, item := range orders {
  8434. medfee_sumamt = medfee_sumamt + item.MedfeeSumamt
  8435. acct_pay = acct_pay + item.AcctPay
  8436. fund_pay_sumamt = fund_pay_sumamt + item.FundPaySumamt
  8437. }
  8438. var user_name string
  8439. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  8440. if role.ID == 0 {
  8441. user_name = "xxx"
  8442. } else {
  8443. user_name = role.UserName
  8444. }
  8445. var res ResultEight
  8446. var res10188 ResultEightFor10188
  8447. if config.IsOpen == 1 {
  8448. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  8449. api := "http://192.168.2.110:9532/" + "jsyb/3201?" +
  8450. "insutype=" + insutype +
  8451. "&clr_type=" + clr_type +
  8452. "&setl_optins=" + clr_org +
  8453. "&stmt_begndate=" + start_time +
  8454. "&stm_enddate=" + end_time +
  8455. "&medfee_sumamt=" + fmt.Sprintf("%.4f", medfee_sumamt) +
  8456. "&fund_pay_sumamt=" + fmt.Sprintf("%.4f", fund_pay_sumamt) +
  8457. "&acct_pay=" + fmt.Sprintf("%.4f", acct_pay) +
  8458. "&fixmedins_setl_cnt=" + strconv.FormatInt(fixmedins_setl_cnt, 10) +
  8459. "&fixmedins_code=" + miConfig.Code +
  8460. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs +
  8461. "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  8462. "&secret_key=" + miConfig.SecretKey +
  8463. "&org_name=" + miConfig.OrgName +
  8464. "&doctor=" + user_name +
  8465. "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  8466. fmt.Println(api)
  8467. resp, requestErr := http.Get(api)
  8468. if requestErr != nil {
  8469. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8470. return
  8471. }
  8472. body, ioErr := ioutil.ReadAll(resp.Body)
  8473. fmt.Println(body)
  8474. if ioErr != nil {
  8475. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  8476. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8477. return
  8478. }
  8479. var respJSON map[string]interface{}
  8480. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  8481. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  8482. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8483. return
  8484. }
  8485. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  8486. userJSONBytes, _ := json.Marshal(respJSON)
  8487. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  8488. utils.ErrorLog("解析失败:%v", err)
  8489. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8490. return
  8491. }
  8492. res.InfRefmsgid = res10188.InfRefmsgid
  8493. res.Output = res10188.Output
  8494. res.ErrMsg = res10188.ErrMsg
  8495. res.Cainfo = res10188.Cainfo
  8496. res.WarnMsg = res10188.WarnMsg
  8497. infocode, _ := strconv.ParseInt(res10188.Infcode, 10, 64)
  8498. res.Infcode = infocode
  8499. } else if miConfig.MdtrtareaAdmvs == "150499" {
  8500. api := "http://172.16.13.254:9532/" + "nmyb/3201?" +
  8501. "insutype=" + insutype +
  8502. "&clr_type=" + clr_type +
  8503. "&setl_optins=" + clr_org +
  8504. "&stmt_begndate=" + start_time +
  8505. "&stm_enddate=" + end_time +
  8506. "&medfee_sumamt=" + fmt.Sprintf("%.4f", medfee_sumamt) +
  8507. "&fund_pay_sumamt=" + fmt.Sprintf("%.4f", fund_pay_sumamt) +
  8508. "&acct_pay=" + fmt.Sprintf("%.4f", acct_pay) +
  8509. "&fixmedins_setl_cnt=" + strconv.FormatInt(fixmedins_setl_cnt, 10) +
  8510. "&fixmedins_code=" + miConfig.Code +
  8511. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs +
  8512. "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  8513. "&secret_key=" + miConfig.SecretKey +
  8514. "&org_name=" + miConfig.OrgName +
  8515. "&doctor=" + user_name
  8516. resp, requestErr := http.Get(api)
  8517. if requestErr != nil {
  8518. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8519. return
  8520. }
  8521. body, ioErr := ioutil.ReadAll(resp.Body)
  8522. if ioErr != nil {
  8523. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  8524. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8525. return
  8526. }
  8527. var respJSON map[string]interface{}
  8528. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  8529. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  8530. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8531. return
  8532. }
  8533. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  8534. result, _ := json.Marshal(respJSON)
  8535. fmt.Println("log")
  8536. fmt.Println(string(result))
  8537. if err := json.Unmarshal([]byte(result), &res10188); err != nil {
  8538. utils.ErrorLog("解析失败:%v", err)
  8539. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8540. return
  8541. }
  8542. res.InfRefmsgid = res10188.InfRefmsgid
  8543. res.Output = res10188.Output
  8544. res.ErrMsg = res10188.ErrMsg
  8545. res.Cainfo = res10188.Cainfo
  8546. res.WarnMsg = res10188.WarnMsg
  8547. infocode, _ := strconv.ParseInt(res10188.Infcode, 10, 64)
  8548. res.Infcode = infocode
  8549. } else {
  8550. api := "http://127.0.0.1:9532/" + "gdyb/ten?" +
  8551. "insutype=" + insutype +
  8552. "&clr_type=" + clr_type +
  8553. "&setl_optins=" + clr_org +
  8554. "&stmt_begndate=" + start_time +
  8555. "&stm_enddate=" + end_time +
  8556. "&medfee_sumamt=" + fmt.Sprintf("%.4f", medfee_sumamt) +
  8557. "&fund_pay_sumamt=" + fmt.Sprintf("%.4f", fund_pay_sumamt) +
  8558. "&acct_pay=" + fmt.Sprintf("%.4f", acct_pay) +
  8559. "&fixmedins_setl_cnt=" + strconv.FormatInt(fixmedins_setl_cnt, 10) +
  8560. "&fixmedins_code=" + miConfig.Code +
  8561. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs +
  8562. "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  8563. "&secret_key=" + miConfig.SecretKey +
  8564. "&org_name=" + miConfig.OrgName +
  8565. "&doctor=" + user_name
  8566. fmt.Println(api)
  8567. resp, requestErr := http.Get(api)
  8568. if requestErr != nil {
  8569. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8570. return
  8571. }
  8572. body, ioErr := ioutil.ReadAll(resp.Body)
  8573. fmt.Println(body)
  8574. if ioErr != nil {
  8575. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  8576. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8577. return
  8578. }
  8579. var respJSON map[string]interface{}
  8580. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  8581. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  8582. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8583. return
  8584. }
  8585. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  8586. userJSONBytes, _ := json.Marshal(respJSON)
  8587. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  8588. utils.ErrorLog("解析失败:%v", err)
  8589. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8590. return
  8591. }
  8592. }
  8593. if res.Infcode == 0 {
  8594. if res.Output.Stmtinfo.StmtRslt == "0" {
  8595. micc := &models.MedicalInsuranceCostCompare{
  8596. StartTime: startime.Unix(),
  8597. EndTime: endtime.Unix(),
  8598. Insutype: insutype,
  8599. CheckType: 1,
  8600. Num: fixmedins_setl_cnt,
  8601. Mtime: time.Now().Unix(),
  8602. Status: 1,
  8603. UserOrgId: adminUser.CurrentOrgId,
  8604. CostTotal: medfee_sumamt,
  8605. FuncTotal: fund_pay_sumamt,
  8606. PsnPay: acct_pay,
  8607. Creator: admin_user_id,
  8608. Ctime: time.Now().Unix(),
  8609. ClrType: clr_type,
  8610. }
  8611. err := service.CreateMedicalInsuranceCostCompareRecord(micc)
  8612. if err == nil {
  8613. c.ServeSuccessJSON(map[string]interface{}{
  8614. "stmt_rslt": res.Output.Stmtinfo.StmtRslt,
  8615. "stmt_rslt_dscr": res.Output.Stmtinfo.StmtRsltDscr,
  8616. })
  8617. } else {
  8618. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8619. }
  8620. } else {
  8621. c.ServeSuccessJSON(map[string]interface{}{
  8622. "stmt_rslt": res.Output.Stmtinfo.StmtRslt,
  8623. "stmt_rslt_dscr": res.Output.Stmtinfo.StmtRsltDscr,
  8624. })
  8625. }
  8626. } else {
  8627. c.ServeSuccessJSON(map[string]interface{}{
  8628. "code": -10,
  8629. "msg": res.ErrMsg,
  8630. })
  8631. }
  8632. }
  8633. }
  8634. func (c *HisApiController) Check310() {
  8635. adminUser := c.GetAdminUserInfo()
  8636. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  8637. var user_name string
  8638. user_name = "高慧裕"
  8639. api := "http://127.0.0.1:9532/" + "gdyb/ten?" +
  8640. "insutype=" + "310" +
  8641. "&clr_type=" + "" +
  8642. "&setl_optins=" + "441202" +
  8643. "&stmt_begndate=" + "2022-03-01" +
  8644. "&stm_enddate=" + "2022-03-31" +
  8645. "&medfee_sumamt=" + "194930.12" +
  8646. "&fund_pay_sumamt=" + "188741.46" +
  8647. "&acct_pay=" + "0" +
  8648. "&fixmedins_setl_cnt=" + "452" +
  8649. "&fixmedins_code=" + miConfig.Code +
  8650. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs +
  8651. "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  8652. "&secret_key=" + miConfig.SecretKey +
  8653. "&org_name=" + miConfig.OrgName +
  8654. "&doctor=" + user_name
  8655. fmt.Println(api)
  8656. resp, requestErr := http.Get(api)
  8657. if requestErr != nil {
  8658. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8659. return
  8660. }
  8661. body, ioErr := ioutil.ReadAll(resp.Body)
  8662. fmt.Println(body)
  8663. if ioErr != nil {
  8664. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  8665. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8666. return
  8667. }
  8668. var respJSON map[string]interface{}
  8669. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  8670. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  8671. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8672. return
  8673. }
  8674. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  8675. userJSONBytes, _ := json.Marshal(respJSON)
  8676. var res ResultEight
  8677. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  8678. utils.ErrorLog("解析失败:%v", err)
  8679. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8680. return
  8681. }
  8682. }
  8683. func (c *HisApiController) Check390() {
  8684. adminUser := c.GetAdminUserInfo()
  8685. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  8686. var user_name string
  8687. user_name = "高慧裕"
  8688. api := "http://127.0.0.1:9532/" + "gdyb/ten?" +
  8689. "insutype=" + "390" +
  8690. "&clr_type=" + "" +
  8691. "&setl_optins=" + "441202" +
  8692. "&stmt_begndate=" + "2022-03-01" +
  8693. "&stm_enddate=" + "2022-03-31" +
  8694. "&medfee_sumamt=" + "1068448.89" +
  8695. "&fund_pay_sumamt=" + "1014677.62" +
  8696. "&acct_pay=" + "0" +
  8697. "&fixmedins_setl_cnt=" + "1950" +
  8698. "&fixmedins_code=" + miConfig.Code +
  8699. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs +
  8700. "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  8701. "&secret_key=" + miConfig.SecretKey +
  8702. "&org_name=" + miConfig.OrgName +
  8703. "&doctor=" + user_name
  8704. fmt.Println(api)
  8705. resp, requestErr := http.Get(api)
  8706. if requestErr != nil {
  8707. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8708. return
  8709. }
  8710. body, ioErr := ioutil.ReadAll(resp.Body)
  8711. fmt.Println(body)
  8712. if ioErr != nil {
  8713. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  8714. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8715. return
  8716. }
  8717. var respJSON map[string]interface{}
  8718. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  8719. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  8720. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8721. return
  8722. }
  8723. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  8724. userJSONBytes, _ := json.Marshal(respJSON)
  8725. var res ResultEight
  8726. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  8727. utils.ErrorLog("解析失败:%v", err)
  8728. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8729. return
  8730. }
  8731. }
  8732. //对账明细
  8733. func (c *HisApiController) GetCheckDetailAccount() {
  8734. start_time := c.GetString("start_time")
  8735. end_time := c.GetString("end_time")
  8736. admin_user_id, _ := c.GetInt64("admin_user_id")
  8737. adminUser := c.GetAdminUserInfo()
  8738. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  8739. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  8740. timeLayout := "2006-01-02"
  8741. loc, _ := time.LoadLocation("Local")
  8742. startime, _ := time.ParseInLocation(timeLayout+" 15:04:05", start_time+" 00:00:00", loc)
  8743. endtime, _ := time.ParseInLocation(timeLayout+" 15:04:05", end_time+" 23:59:59", loc)
  8744. orders, _ := service.GetOrderByTimeTwo(startime.Unix(), endtime.Unix(), adminUser.CurrentOrgId)
  8745. rand.Seed(time.Now().UnixNano())
  8746. num := rand.Intn(30000)
  8747. Mkdir(miConfig.OrgName)
  8748. file := strconv.FormatInt(int64(num), 10)
  8749. file_name := file + ".txt"
  8750. zip_name := file + ".zip"
  8751. zip_path := miConfig.OrgName + "/" + zip_name
  8752. file_path := miConfig.OrgName + "/" + file_name
  8753. decimal.DivisionPrecision = 2
  8754. var medfee_sumamt float64
  8755. var psn_cash_pay float64
  8756. var fund_pay_sumamt float64
  8757. fixmedins_setl_cnt := int64(len(orders))
  8758. for _, item := range orders {
  8759. medfee_sumamt = medfee_sumamt + item.MedfeeSumamt
  8760. psn_cash_pay = psn_cash_pay + item.PsnCashPay
  8761. fund_pay_sumamt = fund_pay_sumamt + item.FundPaySumamt
  8762. }
  8763. f, err := os.Create(miConfig.OrgName + "/" + file_name)
  8764. defer f.Close()
  8765. if err != nil {
  8766. fmt.Println(err.Error())
  8767. } else {
  8768. for _, item := range orders {
  8769. var refd_setl_flag string
  8770. if item.OrderStatus == 2 {
  8771. refd_setl_flag = "0"
  8772. var str string
  8773. str = item.SetlId + " " +
  8774. item.MdtrtId + " " +
  8775. item.PsnNo + " " +
  8776. fmt.Sprintf("%.4f", item.MedfeeSumamt) + " " +
  8777. fmt.Sprintf("%.4f", item.FundPaySumamt) + " " +
  8778. fmt.Sprintf("%.4f", item.AcctPay) + " " + refd_setl_flag + "\r\n"
  8779. _, err = f.Write([]byte(str))
  8780. }
  8781. if item.OrderStatus == 3 {
  8782. var str string
  8783. str = item.SetlId + " " +
  8784. item.MdtrtId + " " +
  8785. item.PsnNo + " " +
  8786. fmt.Sprintf("%.4f", item.MedfeeSumamt) + " " +
  8787. fmt.Sprintf("%.4f", item.FundPaySumamt) + " " +
  8788. fmt.Sprintf("%.4f", item.AcctPay) + " " + "1" + "\r\n"
  8789. _, err = f.Write([]byte(str))
  8790. var str2 string
  8791. str2 = item.SetlId + " " +
  8792. item.MdtrtId + " " +
  8793. item.PsnNo + " " +
  8794. fmt.Sprintf("%.4f", 0-item.MedfeeSumamt) + " " +
  8795. fmt.Sprintf("%.4f", 0-item.FundPaySumamt) + " " +
  8796. fmt.Sprintf("%.4f", 0-item.AcctPay) + " " + "1" + "\r\n"
  8797. _, err = f.Write([]byte(str2))
  8798. }
  8799. }
  8800. }
  8801. Zip(file_path, zip_path)
  8802. fmt.Println(ReadFile(zip_path))
  8803. fmt.Println(string(ReadFile(zip_path)))
  8804. if config.IsOpen == 1 {
  8805. var user_name string
  8806. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  8807. if role.ID == 0 {
  8808. user_name = "管理员"
  8809. } else {
  8810. user_name = role.UserName
  8811. }
  8812. baseParams := models.BaseParams{
  8813. SecretKey: miConfig.SecretKey,
  8814. FixmedinsCode: miConfig.Code,
  8815. InsuplcAdmdvs: miConfig.InsuplcAdmdvs,
  8816. MdtrtareaAdmvs: miConfig.MdtrtareaAdmvs,
  8817. OrgName: miConfig.OrgName,
  8818. Doctor: user_name,
  8819. }
  8820. result := service.Gdyb9101(baseParams, file_name, ReadFile(file_path))
  8821. var dat map[string]interface{}
  8822. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  8823. fmt.Println(dat)
  8824. } else {
  8825. fmt.Println(err)
  8826. }
  8827. userJSONBytes, _ := json.Marshal(dat)
  8828. var res ResultNine
  8829. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  8830. utils.ErrorLog("解析失败:%v", err)
  8831. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8832. return
  8833. }
  8834. if res.Infcode == 0 {
  8835. fileNo := res.Output.FileQuryNo
  8836. api := "http://127.0.0.1:9532/" + "gdyb/twelve?" +
  8837. "file_qury_no=" + fileNo +
  8838. "&setl_optins=" + "定点医保中心" +
  8839. "&stmt_begndate=" + start_time +
  8840. "&stm_enddate=" + end_time +
  8841. "&medfee_sumamt=" + fmt.Sprintf("%.4f", medfee_sumamt) +
  8842. "&fund_pay_sumamt=" + fmt.Sprintf("%.4f", fund_pay_sumamt) +
  8843. "&cash_payamt=" + fmt.Sprintf("%.4f", psn_cash_pay) +
  8844. "&fixmedins_setl_cnt=" + strconv.FormatInt(fixmedins_setl_cnt, 10) +
  8845. "&fixmedins_code=" + miConfig.Code +
  8846. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs +
  8847. "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  8848. "&secret_key=" + miConfig.SecretKey +
  8849. "&org_name=" + miConfig.OrgName +
  8850. "&doctor=" + user_name
  8851. resp, requestErr := http.Get(api)
  8852. if requestErr != nil {
  8853. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8854. return
  8855. }
  8856. body, ioErr := ioutil.ReadAll(resp.Body)
  8857. if ioErr != nil {
  8858. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  8859. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8860. return
  8861. }
  8862. var respJSON map[string]interface{}
  8863. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  8864. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  8865. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8866. return
  8867. }
  8868. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  8869. userJSONBytes, _ := json.Marshal(respJSON)
  8870. var res ResultTen
  8871. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  8872. utils.ErrorLog("解析失败:%v", err)
  8873. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8874. return
  8875. }
  8876. if res.Infcode == 0 {
  8877. service.Gdyb9102(baseParams, zip_name, fileNo)
  8878. micc := &models.MedicalInsuranceCostCompare{
  8879. StartTime: startime.Unix(),
  8880. EndTime: endtime.Unix(),
  8881. Insutype: "0",
  8882. CheckType: 2,
  8883. Num: fixmedins_setl_cnt,
  8884. Mtime: time.Now().Unix(),
  8885. Status: 1,
  8886. UserOrgId: adminUser.CurrentOrgId,
  8887. CostTotal: medfee_sumamt,
  8888. FuncTotal: fund_pay_sumamt,
  8889. PsnPay: psn_cash_pay,
  8890. Creator: admin_user_id,
  8891. Ctime: time.Now().Unix(),
  8892. }
  8893. service.CreateMedicalInsuranceCostCompareRecord(micc)
  8894. c.ServeSuccessJSON(map[string]interface{}{
  8895. "msg": "明细对账成功",
  8896. })
  8897. }
  8898. } else {
  8899. }
  8900. }
  8901. }
  8902. type CustomOrderInfo struct {
  8903. Name string
  8904. Spec string
  8905. Unit string
  8906. Count float64
  8907. Price float64
  8908. Total float64
  8909. }
  8910. func (c *HisApiController) GetSettleAccounts() {
  8911. //id, _ := c.GetInt64("id")
  8912. //record_time := c.GetString("record_time")
  8913. order_id, _ := c.GetInt64("order_id")
  8914. admin_user_id, _ := c.GetInt64("admin_user_id")
  8915. //timeLayout := "2006-01-02"
  8916. //loc, _ := time.LoadLocation("Local")
  8917. //
  8918. //theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  8919. //if err != nil {
  8920. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  8921. // return
  8922. //}
  8923. //recordDateTime := theTime.Unix()
  8924. adminUser := c.GetAdminUserInfo()
  8925. order, _ := service.GetHisOrderByID(order_id)
  8926. his, _ := service.GetHisPatientByNumber(order.MdtrtId)
  8927. orderInfos, _ := service.GetHisOrderInfoByNumber(order.Number)
  8928. orderInfos_two, _ := service.GetHisOrderInfoByNumberTwo(order.Number)
  8929. orderInfos = append(orderInfos, orderInfos_two...)
  8930. his_hospital, _ := service.GetInHospitalRecordByNumber(order.MdtrtId)
  8931. //diagnosisConfig, _ := service.FindDiagnoseById(his.Diagnosis)
  8932. var diagnosis_ids []string
  8933. if his.ID > 0 {
  8934. diagnosis_ids = strings.Split(his.Diagnosis, ",")
  8935. } else {
  8936. diagnosis_ids = strings.Split(his_hospital.Diagnosis, ",")
  8937. }
  8938. patient, _ := service.GetPatientByIDTwo(adminUser.CurrentOrgId, order.PatientId)
  8939. var dia_config []*models.HisXtDiagnoseConfig
  8940. var name string
  8941. for _, item := range diagnosis_ids {
  8942. id, _ := strconv.ParseInt(item, 10, 64)
  8943. diagnosisConfig, _ := service.FindDiagnoseById(id)
  8944. dia_config = append(dia_config, &diagnosisConfig)
  8945. if len(name) == 0 {
  8946. name = diagnosisConfig.ClassName
  8947. } else {
  8948. name = name + "," + diagnosisConfig.ClassName
  8949. }
  8950. }
  8951. var bedCostTotal float64 = 0 //床位总费
  8952. var bedCostSelfTotal float64 = 0 //床位自费
  8953. var bedCostPartSelfTotal float64 = 0 //床位部分项目自费
  8954. var operationCostTotal float64 = 0 //手术费
  8955. var operationCostSelfTotal float64 = 0 //手术费
  8956. var operationCostPartSelfTotal float64 = 0 //手术费
  8957. var otherCostTotal float64 = 0 //其他费用
  8958. var otherCostSelfTotal float64 = 0 //其他费用
  8959. var otherCostPartSelfTotal float64 = 0 //其他费用
  8960. var materialCostTotal float64 = 0 //材料费
  8961. var materialCostSelfTotal float64 = 0 //材料费
  8962. var materialCostPartSelfTotal float64 = 0 //材料费
  8963. var westernMedicineCostTotal float64 = 0 //西药费
  8964. var westernMedicineCostSelfTotal float64 = 0 //西药费
  8965. var westernMedicineCostPartSelfTotal float64 = 0 //西药费
  8966. var chineseTraditionalMedicineCostTotal float64 = 0 //中成药
  8967. var chineseTraditionalMedicineCostSelfTotal float64 = 0 //中成药
  8968. var chineseTraditionalMedicineCostPartSelfTotal float64 = 0 //中成药
  8969. var checkCostTotal float64 = 0 //检查费
  8970. var checkCostSelfTotal float64 = 0 //检查费
  8971. var checkCostPartSelfTotal float64 = 0 //检查费
  8972. var laboratoryCostTotal float64 = 0 //化验费
  8973. var laboratoryCostSelfTotal float64 = 0 //化验费
  8974. var laboratoryCostPartSelfTotal float64 = 0 //化验费
  8975. var treatCostTotal float64 = 0 //治疗费用
  8976. var treatCostSelfTotal float64 = 0 //治疗费用
  8977. var treatCostPartSelfTotal float64 = 0 //治疗费用
  8978. decimal.DivisionPrecision = 2
  8979. for _, item := range orderInfos {
  8980. if item.MedChrgitmType == "01" { //床位费
  8981. bedCostTotal, _ = decimal.NewFromFloat(bedCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  8982. bedCostSelfTotal, _ = decimal.NewFromFloat(bedCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  8983. bedCostPartSelfTotal, _ = decimal.NewFromFloat(bedCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  8984. }
  8985. if c.GetAdminUserInfo().CurrentOrgId == 10188 || c.GetAdminUserInfo().CurrentOrgId == 10217 {
  8986. if item.MedChrgitmType == "03" { //检查费
  8987. laboratoryCostTotal, _ = decimal.NewFromFloat(laboratoryCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  8988. laboratoryCostSelfTotal, _ = decimal.NewFromFloat(laboratoryCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  8989. laboratoryCostPartSelfTotal, _ = decimal.NewFromFloat(laboratoryCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  8990. }
  8991. } else {
  8992. if item.MedChrgitmType == "03" { //检查费
  8993. checkCostTotal, _ = decimal.NewFromFloat(checkCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  8994. checkCostSelfTotal, _ = decimal.NewFromFloat(checkCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  8995. checkCostPartSelfTotal, _ = decimal.NewFromFloat(checkCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  8996. }
  8997. }
  8998. if item.MedChrgitmType == "04" { //化验费
  8999. laboratoryCostTotal, _ = decimal.NewFromFloat(laboratoryCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  9000. laboratoryCostSelfTotal, _ = decimal.NewFromFloat(laboratoryCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  9001. laboratoryCostPartSelfTotal, _ = decimal.NewFromFloat(laboratoryCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  9002. }
  9003. if item.MedChrgitmType == "05" || item.MedChrgitmType == "1402" || item.MedChrgitmType == "1403" { //治疗费
  9004. treatCostTotal, _ = decimal.NewFromFloat(treatCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  9005. treatCostSelfTotal, _ = decimal.NewFromFloat(treatCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  9006. treatCostPartSelfTotal, _ = decimal.NewFromFloat(treatCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  9007. }
  9008. if item.MedChrgitmType == "06" { //手术费
  9009. operationCostTotal, _ = decimal.NewFromFloat(operationCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  9010. operationCostSelfTotal, _ = decimal.NewFromFloat(operationCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  9011. operationCostPartSelfTotal, _ = decimal.NewFromFloat(operationCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  9012. }
  9013. if item.MedChrgitmType == "08" { //材料费
  9014. materialCostTotal, _ = decimal.NewFromFloat(materialCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  9015. materialCostSelfTotal, _ = decimal.NewFromFloat(materialCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  9016. materialCostPartSelfTotal, _ = decimal.NewFromFloat(materialCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  9017. }
  9018. if item.MedChrgitmType == "09" { //西药费
  9019. westernMedicineCostTotal, _ = decimal.NewFromFloat(westernMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  9020. westernMedicineCostSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  9021. westernMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  9022. }
  9023. if item.MedChrgitmType == "11" { //中成费
  9024. chineseTraditionalMedicineCostTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  9025. chineseTraditionalMedicineCostSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  9026. chineseTraditionalMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  9027. }
  9028. if item.MedChrgitmType == "14" || item.MedChrgitmType == "0" || item.MedChrgitmType == "12" || item.MedChrgitmType == "02" { //其他费
  9029. otherCostTotal, _ = decimal.NewFromFloat(otherCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  9030. otherCostSelfTotal, _ = decimal.NewFromFloat(otherCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  9031. otherCostPartSelfTotal, _ = decimal.NewFromFloat(otherCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  9032. }
  9033. }
  9034. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  9035. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  9036. var user_name string
  9037. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  9038. if role.ID == 0 {
  9039. user_name = "管理员"
  9040. } else {
  9041. user_name = role.UserName
  9042. }
  9043. baseParams := models.BaseParams{
  9044. SecretKey: miConfig.SecretKey,
  9045. FixmedinsCode: miConfig.Code,
  9046. InsuplcAdmdvs: miConfig.InsuplcAdmdvs,
  9047. MdtrtareaAdmvs: miConfig.MdtrtareaAdmvs,
  9048. OrgName: miConfig.OrgName,
  9049. Doctor: user_name,
  9050. }
  9051. businessParams := models.BusinessParams{
  9052. PsnNo: order.PsnNo,
  9053. MdtrtId: order.MdtrtId,
  9054. SetlId: order.SetlId,
  9055. }
  9056. var res ResultEleven
  9057. var resEleven10265 ResultEleven10265
  9058. if config.IsOpen == 1 {
  9059. if miConfig.MdtrtareaAdmvs == "421300" {
  9060. api := "http://192.168.124.4:9532/" + "hbyb/5203?psn_no=" + businessParams.PsnNo + "&mdtrt_id=" + businessParams.MdtrtId + "&setl_id=" + businessParams.SetlId +
  9061. "&org_name=" + miConfig.OrgName + "&doctor=" + baseParams.Doctor + "&fixmedins_code=" + miConfig.Code +
  9062. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  9063. resp, requestErr := http.Get(api)
  9064. if requestErr != nil {
  9065. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9066. return
  9067. }
  9068. body, ioErr := ioutil.ReadAll(resp.Body)
  9069. if ioErr != nil {
  9070. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  9071. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9072. return
  9073. }
  9074. var respJSON map[string]interface{}
  9075. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  9076. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  9077. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9078. return
  9079. }
  9080. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  9081. result, _ := json.Marshal(respJSON)
  9082. fmt.Println("log")
  9083. fmt.Println(string(result))
  9084. if err := json.Unmarshal([]byte(result), &res); err != nil {
  9085. utils.ErrorLog("解析失败:%v", err)
  9086. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9087. return
  9088. }
  9089. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  9090. var api string
  9091. if miConfig.MdtrtareaAdmvs == "320921" {
  9092. api = "http://192.168.2.110:9532/" + "jsyb/5203?psn_no=" + businessParams.PsnNo + "&mdtrt_id=" + businessParams.MdtrtId + "&setl_id=" + businessParams.SetlId +
  9093. "&org_name=" + miConfig.OrgName + "&doctor=" + baseParams.Doctor + "&fixmedins_code=" + miConfig.Code +
  9094. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  9095. //req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  9096. } else {
  9097. //req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  9098. api = "http://192.168.5.251:9532/" + "jsyb/5203?psn_no=" + businessParams.PsnNo + "&mdtrt_id=" + businessParams.MdtrtId + "&setl_id=" + businessParams.SetlId +
  9099. "&org_name=" + miConfig.OrgName + "&doctor=" + baseParams.Doctor + "&fixmedins_code=" + miConfig.Code +
  9100. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  9101. }
  9102. resp, requestErr := http.Get(api)
  9103. if requestErr != nil {
  9104. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9105. return
  9106. }
  9107. body, ioErr := ioutil.ReadAll(resp.Body)
  9108. if ioErr != nil {
  9109. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  9110. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9111. return
  9112. }
  9113. var respJSON map[string]interface{}
  9114. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  9115. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  9116. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9117. return
  9118. }
  9119. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  9120. result, _ := json.Marshal(respJSON)
  9121. fmt.Println("log")
  9122. fmt.Println(string(result))
  9123. if err := json.Unmarshal([]byte(result), &resEleven10265); err != nil {
  9124. utils.ErrorLog("解析失败:%v", err)
  9125. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9126. return
  9127. }
  9128. res.InfRefmsgid = resEleven10265.InfRefmsgid
  9129. res.Output = resEleven10265.Output
  9130. res.ErrMsg = resEleven10265.ErrMsg
  9131. res.Cainfo = resEleven10265.Cainfo
  9132. res.WarnMsg = resEleven10265.WarnMsg
  9133. infocode, _ := strconv.ParseInt(resEleven10265.Infcode, 10, 64)
  9134. res.Infcode = infocode
  9135. } else if miConfig.MdtrtareaAdmvs == "350500" {
  9136. result := service.FJyb5203(baseParams, businessParams, miConfig.Url, miConfig.Code, miConfig.AppSecret, miConfig.SignKey, miConfig.EncKey)
  9137. var dat map[string]interface{}
  9138. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  9139. fmt.Println(dat)
  9140. } else {
  9141. fmt.Println(err)
  9142. }
  9143. userJSONBytes, _ := json.Marshal(dat)
  9144. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  9145. utils.ErrorLog("解析失败:%v", err)
  9146. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9147. return
  9148. }
  9149. } else if miConfig.MdtrtareaAdmvs == "150499" {
  9150. fmt.Println("~~~~~~~")
  9151. api := "http://172.16.13.254:9532/" + "nmyb/5203?psn_no=" + businessParams.PsnNo + "&mdtrt_id=" + businessParams.MdtrtId + "&setl_id=" + businessParams.SetlId +
  9152. "&org_name=" + miConfig.OrgName + "&doctor=" + baseParams.Doctor + "&fixmedins_code=" + miConfig.Code +
  9153. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  9154. resp, requestErr := http.Get(api)
  9155. if requestErr != nil {
  9156. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9157. return
  9158. }
  9159. body, ioErr := ioutil.ReadAll(resp.Body)
  9160. if ioErr != nil {
  9161. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  9162. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9163. return
  9164. }
  9165. var respJSON map[string]interface{}
  9166. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  9167. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  9168. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9169. return
  9170. }
  9171. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  9172. result, _ := json.Marshal(respJSON)
  9173. fmt.Println("log")
  9174. fmt.Println(string(result))
  9175. if err := json.Unmarshal([]byte(result), &resEleven10265); err != nil {
  9176. utils.ErrorLog("解析失败:%v", err)
  9177. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9178. return
  9179. }
  9180. res.InfRefmsgid = resEleven10265.InfRefmsgid
  9181. res.Output = resEleven10265.Output
  9182. res.ErrMsg = resEleven10265.ErrMsg
  9183. res.Cainfo = resEleven10265.Cainfo
  9184. res.WarnMsg = resEleven10265.WarnMsg
  9185. infocode, _ := strconv.ParseInt(resEleven10265.Infcode, 10, 64)
  9186. res.Infcode = infocode
  9187. } else {
  9188. result := service.Gdyb5203(baseParams, businessParams)
  9189. //service.Gdyb5204(baseParams, businessParams)
  9190. //service.Gdyb5302(businessParams.PsnNo, baseParams.OrgName, baseParams.Doctor, baseParams.FixmedinsCode, baseParams.InsuplcAdmdvs, baseParams.MdtrtareaAdmvs, baseParams.SecretKey)
  9191. var dat map[string]interface{}
  9192. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  9193. fmt.Println(dat)
  9194. } else {
  9195. fmt.Println(err)
  9196. }
  9197. userJSONBytes, _ := json.Marshal(dat)
  9198. if miConfig.Code == "H15049901371" {
  9199. if err := json.Unmarshal(userJSONBytes, &resEleven10265); err != nil {
  9200. utils.ErrorLog("解析失败:%v", err)
  9201. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9202. return
  9203. }
  9204. res.InfRefmsgid = resEleven10265.InfRefmsgid
  9205. res.Output = resEleven10265.Output
  9206. res.ErrMsg = resEleven10265.ErrMsg
  9207. res.Cainfo = resEleven10265.Cainfo
  9208. res.WarnMsg = resEleven10265.WarnMsg
  9209. infocode, _ := strconv.ParseInt(resEleven10265.Infcode, 10, 64)
  9210. res.Infcode = infocode
  9211. } else {
  9212. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  9213. utils.ErrorLog("解析失败:%v", err)
  9214. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9215. return
  9216. }
  9217. }
  9218. }
  9219. printor_admin, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  9220. charge_admin, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, order.Creator)
  9221. patientPrescription, _ := service.FindPatientPrescriptionInfo(adminUser.CurrentOrgId, order.PatientId, order.SettleAccountsDate)
  9222. adminRole_two, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, patientPrescription.DoctorId)
  9223. doctor_info, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, his_hospital.Doctor)
  9224. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  9225. var doctor_name string
  9226. if roles.ID == 0 {
  9227. doctor_name = "管理员"
  9228. } else {
  9229. doctor_name = roles.UserName
  9230. }
  9231. yiliao_leibie := ""
  9232. switch order.MedType {
  9233. case "11":
  9234. yiliao_leibie = "普通门诊"
  9235. break
  9236. case "12":
  9237. yiliao_leibie = "门诊挂号"
  9238. break
  9239. case "13":
  9240. yiliao_leibie = "急诊"
  9241. break
  9242. case "14":
  9243. yiliao_leibie = "门诊特殊病"
  9244. break
  9245. case "15":
  9246. yiliao_leibie = "门诊统筹"
  9247. break
  9248. case "16":
  9249. yiliao_leibie = "门诊慢性病"
  9250. break
  9251. case "21":
  9252. yiliao_leibie = "普通住院"
  9253. break
  9254. }
  9255. departments, _ := service.GetDepartMentDetail(patientPrescription.Departments)
  9256. if res.Infcode == 0 {
  9257. c.ServeSuccessJSON(map[string]interface{}{
  9258. "diagnosis": name,
  9259. "order_infos": orderInfos,
  9260. "number": order.MdtrtId,
  9261. "date": order.SettleAccountsDate,
  9262. "charge_admin": charge_admin,
  9263. "printor_admin": printor_admin,
  9264. "info": res.Output.Setlinfo,
  9265. "order": order,
  9266. "bedCostTotal": bedCostTotal,
  9267. "bedCostSelfTotal": bedCostSelfTotal,
  9268. "bedCostPartSelfTotal": bedCostPartSelfTotal,
  9269. "operationCostTotal": operationCostTotal,
  9270. "operationCostSelfTotal": operationCostSelfTotal,
  9271. "operationCostPartSelfTotal": operationCostPartSelfTotal,
  9272. "otherCostTotal": otherCostTotal,
  9273. "otherCostSelfTotal": otherCostSelfTotal,
  9274. "otherCostPartSelfTotal": otherCostPartSelfTotal,
  9275. "materialCostTotal": materialCostTotal,
  9276. "materialCostSelfTotal": materialCostSelfTotal,
  9277. "materialCostPartSelfTotal": materialCostPartSelfTotal,
  9278. "westernMedicineCostTotal": westernMedicineCostTotal,
  9279. "westernMedicineCostSelfTotal": westernMedicineCostSelfTotal,
  9280. "westernMedicineCostPartSelfTotal": westernMedicineCostPartSelfTotal,
  9281. "chineseTraditionalMedicineCostTotal": chineseTraditionalMedicineCostTotal,
  9282. "chineseTraditionalMedicineCostSelfTotal": chineseTraditionalMedicineCostSelfTotal,
  9283. "chineseTraditionalMedicineCostPartSelfTotal": chineseTraditionalMedicineCostPartSelfTotal,
  9284. "checkCostTotal": checkCostTotal,
  9285. "checkCostSelfTotal": checkCostSelfTotal,
  9286. "checkCostPartSelfTotal": checkCostPartSelfTotal,
  9287. "laboratoryCostTotal": laboratoryCostTotal,
  9288. "laboratoryCostSelfTotal": laboratoryCostSelfTotal,
  9289. "laboratoryCostPartSelfTotal": laboratoryCostPartSelfTotal,
  9290. "treatCostTotal": treatCostTotal,
  9291. "treatCostSelfTotal": treatCostSelfTotal,
  9292. "treatCostPartSelfTotal": treatCostPartSelfTotal,
  9293. "doctor_info": doctor_info,
  9294. "doctor_code": adminRole_two.DoctorCode,
  9295. "doctor_name": doctor_name,
  9296. "health_card_no": order.PsnNo,
  9297. "department": departments.Name,
  9298. "yiliao_leibie": yiliao_leibie,
  9299. "after_money": order.AccountPrice,
  9300. "patient": patient,
  9301. "org_name": miConfig.OrgName,
  9302. "org_code": miConfig.Code,
  9303. "order_number": order.Number,
  9304. "his_hospital": his_hospital,
  9305. "his": his,
  9306. "dia_config": dia_config,
  9307. //"check_order_info": cus_slice,
  9308. })
  9309. }
  9310. }
  9311. }
  9312. func (c *HisApiController) CheckTreatment() {
  9313. patient_id, _ := c.GetInt64("patient_id")
  9314. id_card_no := c.GetString("id_card_no")
  9315. insutype := c.GetString("insutype")
  9316. med_type := c.GetString("med_type")
  9317. admin_user_id, _ := c.GetInt64("admin_user_id")
  9318. adminUser := c.GetAdminUserInfo()
  9319. patient, _ := service.GetPatientByID(adminUser.CurrentOrgId, patient_id)
  9320. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  9321. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  9322. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  9323. if miConfig.MdtrtareaAdmvs == "421300" {
  9324. var res ResultTwo
  9325. api := "http://192.168.124.4:9532/" + "hbyb/1101?cert_no=" + "" +
  9326. "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  9327. "&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)
  9328. resp, requestErr := http.Get(api)
  9329. if requestErr != nil {
  9330. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9331. return
  9332. }
  9333. body, ioErr := ioutil.ReadAll(resp.Body)
  9334. if ioErr != nil {
  9335. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  9336. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9337. return
  9338. }
  9339. var respJSON map[string]interface{}
  9340. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  9341. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  9342. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9343. return
  9344. }
  9345. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  9346. result, _ := json.Marshal(respJSON)
  9347. if err := json.Unmarshal([]byte(result), &res); err != nil {
  9348. utils.ErrorLog("解析失败:%v", err)
  9349. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9350. return
  9351. }
  9352. if res.Infcode == 0 {
  9353. api := "http://192.168.124.4:9532/" + "hbyb/2001?cert_no=" + "" +
  9354. "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  9355. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&psn_no=" + res.Output.Baseinfo.PsnNo + "&insutype=" + insutype + "&med_type=" + med_type
  9356. resp, requestErr := http.Get(api)
  9357. if requestErr != nil {
  9358. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9359. return
  9360. }
  9361. body, ioErr := ioutil.ReadAll(resp.Body)
  9362. if ioErr != nil {
  9363. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  9364. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9365. return
  9366. }
  9367. var respJSON map[string]interface{}
  9368. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  9369. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  9370. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9371. return
  9372. }
  9373. var res Result2001
  9374. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  9375. result2, _ := json.Marshal(respJSON)
  9376. if err := json.Unmarshal([]byte(result2), &res); err != nil {
  9377. utils.ErrorLog("解析失败:%v", err)
  9378. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9379. return
  9380. }
  9381. if res.Infcode == 0 {
  9382. c.ServeSuccessJSON(map[string]interface{}{
  9383. "msg": res.Output.Trtinfo,
  9384. })
  9385. }
  9386. } else {
  9387. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  9388. return
  9389. }
  9390. } else {
  9391. result := service.Gdyb1101A(id_card_no, miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, patient.Name)
  9392. var dat map[string]interface{}
  9393. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  9394. fmt.Println(dat)
  9395. } else {
  9396. fmt.Println(err)
  9397. }
  9398. userJSONBytes, _ := json.Marshal(dat)
  9399. var res ResultTwo
  9400. var res10265 ResultTwo10265
  9401. if miConfig.Code == "H15049901371" {
  9402. if err := json.Unmarshal(userJSONBytes, &res10265); err != nil {
  9403. utils.ErrorLog("解析失败:%v", err)
  9404. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9405. return
  9406. }
  9407. res.ErrMsg = res10265.ErrMsg
  9408. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  9409. res.Infcode = infocode
  9410. res.Output = res10265.Output
  9411. res.InfRefmsgid = res10265.InfRefmsgid
  9412. } else {
  9413. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  9414. utils.ErrorLog("解析失败:%v", err)
  9415. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9416. return
  9417. }
  9418. }
  9419. var user_name string
  9420. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, adminUser.AdminUser.Id)
  9421. if role.ID == 0 {
  9422. user_name = "xxx"
  9423. } else {
  9424. user_name = role.UserName
  9425. }
  9426. baseParams := models.BaseParams{
  9427. SecretKey: miConfig.SecretKey,
  9428. FixmedinsCode: miConfig.Code,
  9429. InsuplcAdmdvs: miConfig.InsuplcAdmdvs,
  9430. MdtrtareaAdmvs: miConfig.MdtrtareaAdmvs,
  9431. OrgName: miConfig.OrgName,
  9432. Doctor: user_name,
  9433. }
  9434. if config.IsOpen == 1 {
  9435. if miConfig.Code == "H15049901371" {
  9436. if med_type == "14" {
  9437. if insutype == "390" {
  9438. med_type = "9933"
  9439. } else if insutype == "310" {
  9440. med_type = "990502"
  9441. }
  9442. } else if med_type == "11" {
  9443. med_type = "11"
  9444. }
  9445. }
  9446. result := service.Gdyb2001(baseParams, res.Output.Baseinfo.PsnNo, insutype, med_type)
  9447. var dat map[string]interface{}
  9448. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  9449. fmt.Println(dat)
  9450. } else {
  9451. fmt.Println(err)
  9452. }
  9453. var res Result2001
  9454. var res10265 Result2001Org10265
  9455. if miConfig.Code == "H15049901371" {
  9456. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  9457. utils.ErrorLog("解析失败:%v", err)
  9458. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9459. return
  9460. }
  9461. res.ErrMsg = res10265.ErrMsg
  9462. res.Output = res10265.Output
  9463. res.InfRefmsgid = res10265.InfRefmsgid
  9464. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  9465. res.Infcode = infocode
  9466. } else {
  9467. if err := json.Unmarshal([]byte(result), &res); err != nil {
  9468. utils.ErrorLog("解析失败:%v", err)
  9469. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9470. return
  9471. }
  9472. }
  9473. if res.Infcode == 0 {
  9474. c.ServeSuccessJSON(map[string]interface{}{
  9475. "msg": res.Output.Trtinfo,
  9476. })
  9477. }
  9478. }
  9479. }
  9480. }
  9481. //func (c *HisApiController) PutRecord() {
  9482. // id, _ := c.GetInt64("id")
  9483. // record_time := c.GetString("record_time")
  9484. // timeLayout := "2006-01-02"
  9485. // loc, _ := time.LoadLocation("Local")
  9486. // theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  9487. // if err != nil {
  9488. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  9489. // return
  9490. // }
  9491. // recordDateTime := theTime.Unix()
  9492. //
  9493. // adminInfo := c.GetAdminUserInfo()
  9494. // patient, _ := service.GetPatientByID(adminInfo.CurrentOrgId, id)
  9495. // patientPrescription, _ := service.FindPatientPrescriptionInfo(adminInfo.CurrentOrgId, id, recordDateTime)
  9496. //
  9497. // miConfig, _ := service.FindMedicalInsuranceInfo(adminInfo.CurrentOrgId)
  9498. //
  9499. // fmt.Println(miConfig.SecretKey)
  9500. //
  9501. // if patient == nil {
  9502. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodePatientNoExist)
  9503. // return
  9504. // }
  9505. // if len(patient.IdCardNo) == 0 {
  9506. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeIDCartNo)
  9507. // return
  9508. // }
  9509. // config, _ := service.GetMedicalInsuranceConfig(adminInfo.CurrentOrgId)
  9510. // if config.IsOpen == 1 {
  9511. // 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
  9512. // resp, requestErr := http.Get(api)
  9513. // if requestErr != nil {
  9514. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9515. // return
  9516. // }
  9517. // defer resp.Body.Close()
  9518. // body, ioErr := ioutil.ReadAll(resp.Body)
  9519. // if ioErr != nil {
  9520. // utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  9521. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9522. // return
  9523. // }
  9524. // var respJSON map[string]interface{}
  9525. //
  9526. // if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  9527. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  9528. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9529. // return
  9530. // }
  9531. //
  9532. // userJSON := respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  9533. // userJSONBytes, _ := json.Marshal(userJSON)
  9534. // var res ResultTwo
  9535. // if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  9536. // utils.ErrorLog("解析失败:%v", err)
  9537. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9538. // return
  9539. // }
  9540. // Iinfos, _ := json.Marshal(res.Output.Iinfo)
  9541. // Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  9542. // infoStr := string(Iinfos)
  9543. // idetinfoStr := string(Idetinfos)
  9544. //
  9545. // if res.Infcode == 0 {
  9546. // his := models.VMHisPatient{
  9547. // Status: 1,
  9548. // Ctime: time.Now().Unix(),
  9549. // Mtime: time.Now().Unix(),
  9550. // PsnNo: res.Output.Baseinfo.PsnNo,
  9551. // PsnCertType: res.Output.Baseinfo.PsnCertType,
  9552. // Certno: res.Output.Baseinfo.Certno,
  9553. // PsnName: res.Output.Baseinfo.PsnName,
  9554. // Gend: res.Output.Baseinfo.Gend,
  9555. // Naty: res.Output.Baseinfo.Naty,
  9556. // Brdy: res.Output.Baseinfo.Brdy,
  9557. // Age: res.Output.Baseinfo.Age,
  9558. // Iinfo: infoStr,
  9559. // Idetinfo: idetinfoStr,
  9560. // PatientId: patient.ID,
  9561. // RecordDate: theTime.Unix(),
  9562. // UserOrgId: adminInfo.CurrentOrgId,
  9563. // AdminUserId: adminInfo.AdminUser.Id,
  9564. // IsReturn: 1,
  9565. // }
  9566. //
  9567. // //doctor_id := strconv.FormatInt(patientPrescription.DoctorId, 10)
  9568. // //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")
  9569. // //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")
  9570. //
  9571. // //var dat map[string]interface{}
  9572. // //if err := json.Unmarshal([]byte(result), &dat); err == nil {
  9573. // // fmt.Println(dat)
  9574. // //} else {
  9575. // // fmt.Println(err)
  9576. // //}
  9577. //
  9578. // var dat2 map[string]interface{}
  9579. // if err := json.Unmarshal([]byte(result2), &dat2); err == nil {
  9580. // fmt.Println(dat2)
  9581. // } else {
  9582. // fmt.Println(err)
  9583. // }
  9584. //
  9585. // } else {
  9586. // adminUser := c.GetAdminUserInfo()
  9587. // errlog := &models.HisOrderError{
  9588. // UserOrgId: adminUser.CurrentOrgId,
  9589. // Ctime: time.Now().Unix(),
  9590. // Mtime: time.Now().Unix(),
  9591. // ErrMsg: res.ErrMsg,
  9592. // Status: 1,
  9593. // PatientId: id,
  9594. // RecordTime: recordDateTime,
  9595. // Stage: 1,
  9596. // }
  9597. // service.CreateErrMsgLog(errlog)
  9598. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeGdybOneException)
  9599. // return
  9600. // }
  9601. // }
  9602. //
  9603. //}
  9604. //func (c *HisApiController) GetUploadDiag() {
  9605. // id, _ := c.GetInt64("id")
  9606. // record_time := c.GetString("record_time")
  9607. //
  9608. // diagnosis_id, _ := c.GetInt64("diagnosis")
  9609. // sick_type, _ := c.GetInt64("sick_type")
  9610. // reg_type, _ := c.GetInt64("reg_type")
  9611. //
  9612. // timeLayout := "2006-01-02"
  9613. // loc, _ := time.LoadLocation("Local")
  9614. // theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  9615. // if err != nil {
  9616. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  9617. // return
  9618. // }
  9619. //
  9620. // var patientPrescription models.HisPrescriptionInfo
  9621. // recordDateTime := theTime.Unix()
  9622. // adminInfo := c.GetAdminUserInfo()
  9623. // patientPrescription, _ = service.FindPatientPrescriptionInfo(adminInfo.CurrentOrgId, id, recordDateTime)
  9624. //
  9625. // if patientPrescription.ID == 0 {
  9626. // patientPrescription, _ = service.FindLastPatientPrescriptionInfo(adminInfo.CurrentOrgId, id, recordDateTime)
  9627. // }
  9628. //
  9629. // miConfig, _ := service.FindMedicalInsuranceInfo(adminInfo.CurrentOrgId)
  9630. // diagnosisConfig, _ := service.FindDiagnoseById(diagnosis_id)
  9631. // his, _ := service.GetVMHisPatientInfo(adminInfo.CurrentOrgId, id, recordDateTime)
  9632. // sickConfig, _ := service.FindSickById(sick_type)
  9633. // department, _ := service.GetDepartMentDetail(patientPrescription.Departments)
  9634. //
  9635. // api2 := "http://127.0.0.1:9532/" + "gdyb/four?psn_no=" + his.PsnNo +
  9636. // "&mdtrt_id=" + his.Number + "&doctor=" + patientPrescription.Doctor + "&department=" + department.Name +
  9637. // "&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 +
  9638. // "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&sick_code=" + sickConfig.ContentCode + "&sick_name=" + sickConfig.ClassName
  9639. // resp2, requestErr2 := http.Get(api2)
  9640. // if requestErr2 != nil {
  9641. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9642. // return
  9643. // }
  9644. // body2, ioErr2 := ioutil.ReadAll(resp2.Body)
  9645. // if ioErr2 != nil {
  9646. // utils.ErrorLog("接口返回数据读取失败: %v", ioErr2)
  9647. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9648. // return
  9649. // }
  9650. // var respJSON2 map[string]interface{}
  9651. // if err := json.Unmarshal([]byte(string(body2)), &respJSON2); err != nil {
  9652. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  9653. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9654. // return
  9655. // }
  9656. // respJSON2 = respJSON2["data"].(map[string]interface{})["pre"].(map[string]interface{})
  9657. // userJSONBytes2, _ := json.Marshal(respJSON2)
  9658. //
  9659. // var res2 ResultSix
  9660. // if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  9661. // utils.ErrorLog("解析失败:%v", err)
  9662. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9663. // return
  9664. // }
  9665. // if res2.Infcode != 0 {
  9666. // adminUser := c.GetAdminUserInfo()
  9667. // errlog := &models.HisOrderError{
  9668. // UserOrgId: adminUser.CurrentOrgId,
  9669. // Ctime: time.Now().Unix(),
  9670. // Mtime: time.Now().Unix(),
  9671. // ErrMsg: res2.ErrMsg,
  9672. // Status: 1,
  9673. // PatientId: id,
  9674. // RecordTime: recordDateTime,
  9675. // Stage: 3,
  9676. // }
  9677. // service.CreateErrMsgLog(errlog)
  9678. //
  9679. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeRegisterThreeException)
  9680. // return
  9681. // }
  9682. //
  9683. // c.ServeSuccessJSON(map[string]interface{}{
  9684. // "msg": "上传成功",
  9685. // })
  9686. //
  9687. //}
  9688. type QueryResult struct {
  9689. ID int64
  9690. Name string
  9691. Code string
  9692. List_type_code string
  9693. }
  9694. func (c *HisApiController) GetCheckCode() {
  9695. ids_str := c.GetString("ids")
  9696. record_type, _ := c.GetInt64("record_type") //1.药品 2.耗材 3.项目
  9697. ids_arr := strings.Split(ids_str, ",")
  9698. var queryResult []QueryResult
  9699. ids := make([]int64, 0)
  9700. for _, item := range ids_arr {
  9701. id, _ := strconv.ParseInt(item, 10, 64)
  9702. ids = append(ids, id)
  9703. }
  9704. if record_type == 1 {
  9705. drugs, _ := service.GetBatchDrugList(ids)
  9706. for _, item := range drugs {
  9707. result := QueryResult{
  9708. ID: item.ID,
  9709. Name: item.DrugName,
  9710. Code: item.MedicalInsuranceNumber,
  9711. List_type_code: "101",
  9712. }
  9713. queryResult = append(queryResult, result)
  9714. }
  9715. } else if record_type == 2 {
  9716. goods, _ := service.GetBatchGoodInformationList(ids)
  9717. for _, item := range goods {
  9718. result := QueryResult{
  9719. ID: item.ID,
  9720. Name: item.GoodName,
  9721. Code: item.MedicalInsuranceNumber,
  9722. List_type_code: "301",
  9723. }
  9724. queryResult = append(queryResult, result)
  9725. }
  9726. } else if record_type == 3 {
  9727. projects, _ := service.GetBathchMyPorjecgList(ids)
  9728. for _, item := range projects {
  9729. result := QueryResult{
  9730. ID: item.ID,
  9731. Name: item.ProjectName,
  9732. Code: item.MedicalCode,
  9733. List_type_code: "201",
  9734. }
  9735. queryResult = append(queryResult, result)
  9736. }
  9737. }
  9738. admin_user_id, _ := c.GetInt64("admin_user_id")
  9739. adminUser := c.GetAdminUserInfo()
  9740. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  9741. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  9742. var user_name string
  9743. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  9744. if role.ID == 0 {
  9745. user_name = "xxx"
  9746. } else {
  9747. user_name = role.UserName
  9748. }
  9749. baseParams := &models.BaseParams{
  9750. SecretKey: miConfig.SecretKey,
  9751. FixmedinsCode: miConfig.Code,
  9752. InsuplcAdmdvs: miConfig.InsuplcAdmdvs,
  9753. MdtrtareaAdmvs: miConfig.MdtrtareaAdmvs,
  9754. OrgName: miConfig.OrgName,
  9755. Doctor: user_name,
  9756. }
  9757. if config.IsOpen == 1 {
  9758. for _, item := range queryResult {
  9759. var result string
  9760. if record_type == 1 {
  9761. result = service.Gdyb3301(baseParams, item.Name, item.Code, item.List_type_code, "2021-04-26", "", item.List_type_code)
  9762. } else if record_type == 2 {
  9763. result = service.Gdyb3301(baseParams, item.Name, item.Code, item.List_type_code, "2021-04-26", "", item.List_type_code)
  9764. } else if record_type == 3 {
  9765. result = service.Gdyb3301(baseParams, item.Name, item.Code, item.List_type_code, "2021-04-26", "", item.List_type_code)
  9766. }
  9767. var dat map[string]interface{}
  9768. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  9769. fmt.Println(dat)
  9770. } else {
  9771. fmt.Println(err)
  9772. }
  9773. userJSONBytes, _ := json.Marshal(dat)
  9774. var res ResultSix
  9775. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  9776. utils.ErrorLog("解析失败:%v", err)
  9777. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9778. return
  9779. }
  9780. if res.Infcode == 0 {
  9781. if record_type == 1 {
  9782. service.UpdateBaseDrugById(item.ID)
  9783. } else if record_type == 2 {
  9784. service.UpdateGoodInformaitonByDetail(item.ID)
  9785. } else if record_type == 3 {
  9786. service.UpdateProjectById(item.ID)
  9787. }
  9788. c.ServeSuccessJSON(map[string]interface{}{
  9789. "failed_code": 0,
  9790. "msg": "目录对照成功",
  9791. })
  9792. } else {
  9793. c.ServeSuccessJSON(map[string]interface{}{
  9794. "failed_code": -10,
  9795. "msg": res.ErrMsg,
  9796. })
  9797. }
  9798. }
  9799. }
  9800. }
  9801. func (c *HisApiController) UnCheckCode() {
  9802. ids_str := c.GetString("ids")
  9803. record_type, _ := c.GetInt64("record_type") //1.药品 2.耗材 3.项目
  9804. admin_user_id, _ := c.GetInt64("admin_user_id")
  9805. ids_arr := strings.Split(ids_str, ",")
  9806. var queryResult []QueryResult
  9807. ids := make([]int64, 0)
  9808. for _, item := range ids_arr {
  9809. id, _ := strconv.ParseInt(item, 10, 64)
  9810. ids = append(ids, id)
  9811. }
  9812. if record_type == 1 {
  9813. drugs, _ := service.GetBatchDrugList(ids)
  9814. for _, item := range drugs {
  9815. result := QueryResult{
  9816. ID: item.ID,
  9817. Name: item.DrugName,
  9818. Code: item.MedicalInsuranceNumber,
  9819. List_type_code: "101",
  9820. }
  9821. queryResult = append(queryResult, result)
  9822. }
  9823. } else if record_type == 2 {
  9824. goods, _ := service.GetBatchGoodInformationList(ids)
  9825. for _, item := range goods {
  9826. result := QueryResult{
  9827. ID: item.ID,
  9828. Name: item.GoodName,
  9829. Code: item.MedicalInsuranceNumber,
  9830. List_type_code: "301",
  9831. }
  9832. queryResult = append(queryResult, result)
  9833. }
  9834. } else if record_type == 3 {
  9835. projects, _ := service.GetBathchMyPorjecgList(ids)
  9836. for _, item := range projects {
  9837. result := QueryResult{
  9838. ID: item.ID,
  9839. Name: item.ProjectName,
  9840. Code: item.MedicalCode,
  9841. List_type_code: "201",
  9842. }
  9843. queryResult = append(queryResult, result)
  9844. }
  9845. }
  9846. adminUser := c.GetAdminUserInfo()
  9847. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  9848. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  9849. var user_name string
  9850. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  9851. if role.ID == 0 {
  9852. user_name = "xxx"
  9853. } else {
  9854. user_name = role.UserName
  9855. }
  9856. baseParams := &models.BaseParams{
  9857. SecretKey: miConfig.SecretKey,
  9858. FixmedinsCode: miConfig.Code,
  9859. InsuplcAdmdvs: miConfig.InsuplcAdmdvs,
  9860. MdtrtareaAdmvs: miConfig.MdtrtareaAdmvs,
  9861. OrgName: miConfig.OrgName,
  9862. Doctor: user_name,
  9863. }
  9864. if config.IsOpen == 1 {
  9865. for _, item := range queryResult {
  9866. var result string
  9867. if record_type == 1 {
  9868. result = service.Gdyb3302(baseParams, item.Name, item.Code, item.List_type_code)
  9869. } else if record_type == 2 {
  9870. result = service.Gdyb3302(baseParams, item.Name, item.Code, item.List_type_code)
  9871. } else if record_type == 3 {
  9872. result = service.Gdyb3302(baseParams, item.Name, item.Code, item.List_type_code)
  9873. }
  9874. var dat2 map[string]interface{}
  9875. if err := json.Unmarshal([]byte(result), &dat2); err == nil {
  9876. fmt.Println(dat2)
  9877. } else {
  9878. fmt.Println(err)
  9879. }
  9880. userJSONBytes, _ := json.Marshal(dat2)
  9881. var res ResultSix
  9882. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  9883. utils.ErrorLog("解析失败:%v", err)
  9884. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9885. return
  9886. }
  9887. if res.Infcode == 0 {
  9888. if record_type == 1 {
  9889. service.UpdateDrugByIdDetail(item.ID)
  9890. } else if record_type == 2 {
  9891. service.UpdateGoodInfoById(item.ID)
  9892. } else if record_type == 3 {
  9893. service.UpdateMyProjectById(item.ID)
  9894. }
  9895. c.ServeSuccessJSON(map[string]interface{}{
  9896. "failed_code": 0,
  9897. "msg": "撤销目录对照成功",
  9898. })
  9899. } else {
  9900. c.ServeSuccessJSON(map[string]interface{}{
  9901. "failed_code": -10,
  9902. "msg": res.ErrMsg,
  9903. })
  9904. }
  9905. }
  9906. }
  9907. }
  9908. func (c *HisApiController) GetPatientInfo() {
  9909. id_card_no := c.GetString("id_card_no")
  9910. admin_user_id, _ := c.GetInt64("admin_user_id")
  9911. patient, _ := service.GetPatientByIDCard(id_card_no, c.GetAdminUserInfo().CurrentOrgId)
  9912. if patient.ID == 0 {
  9913. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodePatientNoExist)
  9914. return
  9915. }
  9916. role, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  9917. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  9918. config, _ := service.GetMedicalInsuranceConfig(c.GetAdminUserInfo().CurrentOrgId)
  9919. if config.IsOpen == 1 {
  9920. result := service.Gdyb1101A(id_card_no, miConfig.OrgName, role.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, patient.Name)
  9921. var dat map[string]interface{}
  9922. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  9923. fmt.Println(dat)
  9924. } else {
  9925. fmt.Println(err)
  9926. }
  9927. userJSONBytes, _ := json.Marshal(dat)
  9928. var res ResultTwo
  9929. var res10265 ResultTwo10265
  9930. if miConfig.Code == "H15049901371" {
  9931. if err := json.Unmarshal(userJSONBytes, &res10265); err != nil {
  9932. utils.ErrorLog("解析失败:%v", err)
  9933. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9934. return
  9935. }
  9936. res.ErrMsg = res10265.ErrMsg
  9937. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  9938. res.Infcode = infocode
  9939. res.Output = res10265.Output
  9940. res.InfRefmsgid = res10265.InfRefmsgid
  9941. } else {
  9942. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  9943. utils.ErrorLog("解析失败:%v", err)
  9944. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9945. return
  9946. }
  9947. }
  9948. //if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  9949. // utils.ErrorLog("解析失败:%v", err)
  9950. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9951. // return
  9952. //}
  9953. if res.Infcode != 0 {
  9954. c.ServeSuccessJSON(map[string]interface{}{
  9955. "failed_code": -10,
  9956. "msg": res.ErrMsg,
  9957. })
  9958. } else {
  9959. c.ServeSuccessJSON(map[string]interface{}{
  9960. "failed_code": 0,
  9961. "info": res,
  9962. })
  9963. }
  9964. }
  9965. }
  9966. func (c *HisApiController) PsnPutOnRecord() {
  9967. record_type, _ := c.GetInt64("type")
  9968. patient_id, _ := c.GetInt64("patient_id")
  9969. admin_user_id, _ := c.GetInt64("admin_user_id")
  9970. start_time := c.GetString("start_time")
  9971. end_time := c.GetString("end_time")
  9972. adminUser := c.GetAdminUserInfo()
  9973. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  9974. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  9975. var patients []*models.Patients
  9976. if record_type == 1 { //全部备案
  9977. patient, _ := service.GetAllPatient(adminUser.CurrentOrgId)
  9978. patients = append(patients, patient...)
  9979. } else { //单个备案
  9980. patient, _ := service.GetPatientByID(adminUser.CurrentOrgId, patient_id)
  9981. patients = append(patients, patient)
  9982. }
  9983. var user_name string
  9984. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  9985. if role.ID == 0 {
  9986. user_name = "xxx"
  9987. } else {
  9988. user_name = role.UserName
  9989. }
  9990. if config.IsOpen == 1 {
  9991. for _, item := range patients {
  9992. 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
  9993. resp, requestErr := http.Get(api)
  9994. if requestErr != nil {
  9995. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9996. return
  9997. }
  9998. defer resp.Body.Close()
  9999. body, ioErr := ioutil.ReadAll(resp.Body)
  10000. if ioErr != nil {
  10001. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  10002. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10003. return
  10004. }
  10005. var respJSON map[string]interface{}
  10006. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  10007. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  10008. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10009. return
  10010. }
  10011. userJSON := respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  10012. userJSONBytes, _ := json.Marshal(userJSON)
  10013. var res ResultTwo
  10014. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  10015. utils.ErrorLog("解析失败:%v", err)
  10016. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10017. return
  10018. }
  10019. if res.Infcode == 0 {
  10020. result := service.Gdyb2505(res.Output.Baseinfo.PsnNo, user_name, miConfig.OrgName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, start_time, end_time)
  10021. var dat map[string]interface{}
  10022. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  10023. fmt.Println(dat)
  10024. } else {
  10025. fmt.Println(err)
  10026. }
  10027. userJSONBytes, _ := json.Marshal(dat)
  10028. var res2 ResultThirteen
  10029. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  10030. utils.ErrorLog("解析失败:%v", err)
  10031. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10032. return
  10033. }
  10034. if res2.Infcode == 0 {
  10035. psnResult := &models.GdybPsnRecord{
  10036. UserOrgId: adminUser.CurrentOrgId,
  10037. PatientId: item.ID,
  10038. PsnNo: res.Output.Baseinfo.PsnNo,
  10039. Ctime: time.Now().Unix(),
  10040. Mtime: time.Now().Unix(),
  10041. Status: 1,
  10042. IsCancel: 1,
  10043. TrtDclaDetlSn: res2.Output.Result.TrtDclaDetlSn,
  10044. }
  10045. service.CreatePsnRecord(psnResult)
  10046. } else {
  10047. c.ServeSuccessJSON(map[string]interface{}{
  10048. "failed_code": -10,
  10049. "msg": res2.ErrMsg,
  10050. })
  10051. return
  10052. }
  10053. }
  10054. }
  10055. }
  10056. }
  10057. func (c *HisApiController) PsnUnPutOnRecord() {
  10058. id, _ := c.GetInt64("id")
  10059. //record_type, _ := c.GetInt64("type")
  10060. admin_user_id, _ := c.GetInt64("admin_user_id")
  10061. adminUser := c.GetAdminUserInfo()
  10062. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  10063. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  10064. var user_name string
  10065. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  10066. if role.ID == 0 {
  10067. user_name = "xxx"
  10068. } else {
  10069. user_name = role.UserName
  10070. }
  10071. psn_record, _ := service.GetPsnRecordById(id)
  10072. if psn_record.ID == 0 {
  10073. c.ServeFailJSONWithSGJErrorCode(enums.ErrorPsnRecordNoExistWrong)
  10074. return
  10075. }
  10076. if config.IsOpen == 1 {
  10077. result := service.Gdyb2506(psn_record.PsnNo, user_name, miConfig.OrgName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, psn_record.TrtDclaDetlSn)
  10078. var dat map[string]interface{}
  10079. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  10080. fmt.Println(dat)
  10081. } else {
  10082. fmt.Println(err)
  10083. }
  10084. userJSONBytes, _ := json.Marshal(dat)
  10085. var res ResultFourteen
  10086. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  10087. utils.ErrorLog("解析失败:%v", err)
  10088. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10089. return
  10090. }
  10091. if res.Infcode == 0 {
  10092. psn_record.IsCancel = 2
  10093. service.CreatePsnRecord(&psn_record)
  10094. } else {
  10095. c.ServeSuccessJSON(map[string]interface{}{
  10096. "failed_code": -10,
  10097. "msg": res.ErrMsg,
  10098. })
  10099. return
  10100. }
  10101. }
  10102. }
  10103. func (c *HisApiController) PsnPutNCDSOnRecord() {
  10104. patient_id, _ := c.GetInt64("patient_id")
  10105. insutype_two := c.GetString("insutype")
  10106. psn_no := c.GetString("psn_no")
  10107. doctor_id, _ := c.GetInt64("doctor_id")
  10108. sick_id, _ := c.GetInt64("sick_id")
  10109. department_id, _ := c.GetInt64("department_id")
  10110. start_time := c.GetString("start_time")
  10111. end_time := c.GetString("end_time")
  10112. check_time := c.GetString("check_time")
  10113. adminUser := c.GetAdminUserInfo()
  10114. patient, _ := service.GetPatientByID(adminUser.CurrentOrgId, patient_id)
  10115. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  10116. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  10117. sick, _ := service.FindSickById(sick_id)
  10118. doctor, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, doctor_id)
  10119. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, doctor_id)
  10120. var res ResultTwo
  10121. var res10265 ResultTwo10265
  10122. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  10123. psn_info, _ := service.GetPsnByPatientId(patient.ID)
  10124. api := "http://192.168.2.110:9532/" + "hbyb/1101?cert_no=" + "" +
  10125. "&org_name=" + miConfig.OrgName + "&doctor=" + role.UserName + "&fixmedins_code=" + miConfig.Code +
  10126. "&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
  10127. resp, requestErr := http.Get(api)
  10128. if requestErr != nil {
  10129. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10130. return
  10131. }
  10132. body, ioErr := ioutil.ReadAll(resp.Body)
  10133. if ioErr != nil {
  10134. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  10135. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10136. return
  10137. }
  10138. var respJSON map[string]interface{}
  10139. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  10140. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  10141. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10142. return
  10143. }
  10144. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  10145. result, _ := json.Marshal(respJSON)
  10146. fmt.Println("log")
  10147. fmt.Println(string(result))
  10148. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  10149. utils.ErrorLog("解析失败:%v", err)
  10150. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10151. return
  10152. }
  10153. res.ErrMsg = res10265.ErrMsg
  10154. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  10155. res.Infcode = infocode
  10156. res.Output = res10265.Output
  10157. res.InfRefmsgid = res10265.InfRefmsgid
  10158. } else {
  10159. result, _ := service.Gdyb1101(patient.IdCardNo, miConfig.OrgName, role.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, 2, "", "0", patient.Name)
  10160. if miConfig.Code == "H15049901371" {
  10161. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  10162. utils.ErrorLog("解析失败:%v", err)
  10163. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10164. return
  10165. }
  10166. res.ErrMsg = res10265.ErrMsg
  10167. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  10168. res.Infcode = infocode
  10169. res.Output = res10265.Output
  10170. res.InfRefmsgid = res10265.InfRefmsgid
  10171. } else {
  10172. if err := json.Unmarshal([]byte(result), &res); err != nil {
  10173. utils.ErrorLog("解析失败:%v", err)
  10174. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10175. return
  10176. }
  10177. }
  10178. }
  10179. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  10180. infoStr := string(Iinfos)
  10181. var rf []*ResultFive
  10182. json.Unmarshal([]byte(infoStr), &rf)
  10183. var insuplc_admdvs string
  10184. var insutype string
  10185. var is390 int = 0
  10186. var is310 int = 0
  10187. var insutypes []*ResultFive
  10188. for _, item := range rf {
  10189. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  10190. insutypes = append(insutypes, item)
  10191. }
  10192. }
  10193. if len(insutypes) == 1 {
  10194. insutype = insutypes[0].Insutype
  10195. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  10196. } else {
  10197. for _, i := range insutypes {
  10198. if i.Insutype == "390" {
  10199. is390 = 1
  10200. }
  10201. if i.Insutype == "310" {
  10202. is310 = 1
  10203. }
  10204. }
  10205. }
  10206. if is390 == 1 {
  10207. insutype = "390"
  10208. }
  10209. if is310 == 1 {
  10210. insutype = "310"
  10211. }
  10212. if len(insutypes) == 2 {
  10213. insutype = insutype_two
  10214. }
  10215. if len(insutypes) == 0 {
  10216. insutype = "310"
  10217. }
  10218. insutype = insutype_two
  10219. fmt.Println(insutype)
  10220. for _, item := range rf {
  10221. fmt.Println(item.Insutype)
  10222. fmt.Println(insutype)
  10223. if item.Insutype == insutype {
  10224. fmt.Println(item.Insutype)
  10225. fmt.Println(insutype)
  10226. insuplc_admdvs = item.InsuplcAdmdvs
  10227. }
  10228. }
  10229. fmt.Println(insuplc_admdvs)
  10230. var res2 ResultThirteen
  10231. var res10265_2 ResultThirteen10265
  10232. if config.IsOpen == 1 {
  10233. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  10234. } else {
  10235. 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)
  10236. var dat map[string]interface{}
  10237. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  10238. fmt.Println(dat)
  10239. } else {
  10240. fmt.Println(err)
  10241. }
  10242. userJSONBytes, _ := json.Marshal(dat)
  10243. if miConfig.Code == "H15049901371" {
  10244. if err := json.Unmarshal(userJSONBytes, &res10265_2); err != nil {
  10245. utils.ErrorLog("解析失败:%v", err)
  10246. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10247. return
  10248. }
  10249. res2.ErrMsg = res10265_2.ErrMsg
  10250. infocode, _ := strconv.ParseInt(res10265_2.Infcode, 10, 64)
  10251. res2.Infcode = infocode
  10252. res2.Output = res10265_2.Output
  10253. res2.InfRefmsgid = res10265_2.InfRefmsgid
  10254. } else {
  10255. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  10256. utils.ErrorLog("解析失败:%v", err)
  10257. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10258. return
  10259. }
  10260. }
  10261. }
  10262. if res2.Infcode == 0 {
  10263. psnResult := &models.GdybPsnNcdsRecord{
  10264. UserOrgId: adminUser.CurrentOrgId,
  10265. PatientId: patient.ID,
  10266. PsnNo: psn_no,
  10267. DoctorId: doctor.AdminUserId,
  10268. DepartmentId: department_id,
  10269. SickType: sick_id,
  10270. Insutype: insutype,
  10271. Ctime: time.Now().Unix(),
  10272. Mtime: time.Now().Unix(),
  10273. Status: 1,
  10274. IsCancel: 1,
  10275. TrtDclaDetlSn: res2.Output.Result.TrtDclaDetlSn,
  10276. }
  10277. service.CreatePsnNCDSRecord(psnResult)
  10278. c.ServeSuccessJSON(map[string]interface{}{
  10279. "failed_code": 0,
  10280. "msg": "备案成功",
  10281. "result": psnResult,
  10282. })
  10283. } else {
  10284. c.ServeSuccessJSON(map[string]interface{}{
  10285. "failed_code": -10,
  10286. "msg": res2.ErrMsg,
  10287. })
  10288. return
  10289. }
  10290. }
  10291. }
  10292. func (c *HisApiController) PsnPutUnNCDSOnRecord() {
  10293. id, _ := c.GetInt64("id")
  10294. admin_user_id, _ := c.GetInt64("admin_user_id")
  10295. adminUser := c.GetAdminUserInfo()
  10296. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  10297. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  10298. //config, _ := service.Ge(adminUser.CurrentOrgId)
  10299. patient, _ := service.GetPatientByID(c.GetAdminUserInfo().CurrentOrgId, id)
  10300. //role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  10301. //var user_name string
  10302. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  10303. //if role.ID == 0 {
  10304. // user_name = "xxx"
  10305. //} else {
  10306. // user_name = role.UserName
  10307. //}
  10308. psn_record, _ := service.GetPsnNCDSRecordById(id)
  10309. if psn_record.ID == 0 {
  10310. c.ServeFailJSONWithSGJErrorCode(enums.ErrorPsnRecordNoExistWrong)
  10311. return
  10312. }
  10313. result, _ := service.Gdyb1101(patient.IdCardNo, miConfig.OrgName, role.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, 2, "", "0", patient.Name)
  10314. var res ResultTwo
  10315. var res10265 ResultTwo10265
  10316. if miConfig.Code == "H15049901371" {
  10317. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  10318. utils.ErrorLog("解析失败:%v", err)
  10319. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10320. return
  10321. }
  10322. res.ErrMsg = res10265.ErrMsg
  10323. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  10324. res.Infcode = infocode
  10325. res.Output = res10265.Output
  10326. res.InfRefmsgid = res10265.InfRefmsgid
  10327. } else {
  10328. if err := json.Unmarshal([]byte(result), &res); err != nil {
  10329. utils.ErrorLog("解析失败:%v", err)
  10330. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10331. return
  10332. }
  10333. }
  10334. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  10335. infoStr := string(Iinfos)
  10336. var rf []*ResultFive
  10337. json.Unmarshal([]byte(infoStr), &rf)
  10338. var insuplc_admdvs string
  10339. var insutype string
  10340. var is390 int = 0
  10341. var is310 int = 0
  10342. var insutypes []*ResultFive
  10343. for _, item := range rf {
  10344. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  10345. insutypes = append(insutypes, item)
  10346. }
  10347. }
  10348. if len(insutypes) == 1 {
  10349. insutype = insutypes[0].Insutype
  10350. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  10351. } else {
  10352. for _, i := range insutypes {
  10353. if i.Insutype == "390" {
  10354. is390 = 1
  10355. }
  10356. if i.Insutype == "310" {
  10357. is310 = 1
  10358. }
  10359. }
  10360. }
  10361. if is390 == 1 {
  10362. insutype = "390"
  10363. }
  10364. if is310 == 1 {
  10365. insutype = "310"
  10366. }
  10367. if len(insutypes) == 0 {
  10368. insutype = "310"
  10369. }
  10370. insutype = psn_record.Insutype
  10371. for _, item := range rf {
  10372. if item.Insutype == insutype {
  10373. insuplc_admdvs = item.InsuplcAdmdvs
  10374. }
  10375. }
  10376. if config.IsOpen == 1 {
  10377. result := service.Gdyb2504(psn_record.PsnNo, miConfig.OrgName, role.UserName, miConfig.Code, insuplc_admdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, psn_record.TrtDclaDetlSn)
  10378. var dat map[string]interface{}
  10379. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  10380. fmt.Println(dat)
  10381. } else {
  10382. fmt.Println(err)
  10383. }
  10384. userJSONBytes, _ := json.Marshal(dat)
  10385. var res ResultFourteen
  10386. var res10265 ResultFourteen10265
  10387. if miConfig.Code == "H15049901371" {
  10388. if err := json.Unmarshal(userJSONBytes, &res10265); err != nil {
  10389. utils.ErrorLog("解析失败:%v", err)
  10390. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10391. return
  10392. }
  10393. res.ErrMsg = res10265.ErrMsg
  10394. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  10395. res.Infcode = infocode
  10396. res.Output = res10265.Output
  10397. res.InfRefmsgid = res10265.InfRefmsgid
  10398. } else {
  10399. if err := json.Unmarshal([]byte(result), &res); err != nil {
  10400. utils.ErrorLog("解析失败:%v", err)
  10401. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10402. return
  10403. }
  10404. }
  10405. //if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  10406. // utils.ErrorLog("解析失败:%v", err)
  10407. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10408. // return
  10409. //}
  10410. if res.Infcode == 0 {
  10411. psn_record.IsCancel = 2
  10412. service.CreatePsnNCDSRecord(&psn_record)
  10413. c.ServeSuccessJSON(map[string]interface{}{
  10414. "failed_code": 0,
  10415. "msg": "撤销备案成功",
  10416. })
  10417. } else {
  10418. c.ServeSuccessJSON(map[string]interface{}{
  10419. "failed_code": -10,
  10420. "msg": res.ErrMsg,
  10421. })
  10422. return
  10423. }
  10424. }
  10425. }
  10426. func (c *HisApiController) TestTest() {
  10427. patient, _ := service.GetHisPatientInfo(4, 456, 1619712000)
  10428. fmt.Println(patient.Iinfo)
  10429. }
  10430. type CustomData struct {
  10431. MsgId string
  10432. PsnNo string
  10433. Info string
  10434. }
  10435. func (c *HisApiController) ReversalData() {
  10436. var customData []*CustomData
  10437. custom := &CustomData{
  10438. MsgId: "H44022900158202103301714472004",
  10439. PsnNo: "44020000001101329945",
  10440. Info: "2207",
  10441. }
  10442. customData = append(customData, custom)
  10443. custom1 := &CustomData{
  10444. MsgId: "H4402290015820210330172057803",
  10445. PsnNo: "44020000001101161813",
  10446. Info: "2207",
  10447. }
  10448. customData = append(customData, custom1)
  10449. custom2 := &CustomData{
  10450. MsgId: "H44022900158202103301705198813",
  10451. PsnNo: "44190000133097375417",
  10452. Info: "2207",
  10453. }
  10454. customData = append(customData, custom2)
  10455. custom3 := &CustomData{
  10456. MsgId: "H44022900158202103301715524756",
  10457. PsnNo: "44020000001100187221",
  10458. Info: "2207",
  10459. }
  10460. customData = append(customData, custom3)
  10461. custom4 := &CustomData{
  10462. MsgId: "H44022900158202103301730376224",
  10463. PsnNo: "44020000001101959155",
  10464. Info: "2207",
  10465. }
  10466. customData = append(customData, custom4)
  10467. custom5 := &CustomData{
  10468. MsgId: "H44022900158202103301748008725",
  10469. PsnNo: "44020000001104246641",
  10470. Info: "2207",
  10471. }
  10472. customData = append(customData, custom5)
  10473. custom6 := &CustomData{
  10474. MsgId: "H44022900158202103301718096755",
  10475. PsnNo: "44020000001102211860",
  10476. Info: "2207",
  10477. }
  10478. customData = append(customData, custom6)
  10479. custom7 := &CustomData{
  10480. MsgId: "H44022900158202103301736551640",
  10481. PsnNo: "44020000001102687718",
  10482. Info: "2207",
  10483. }
  10484. customData = append(customData, custom7)
  10485. custom8 := &CustomData{
  10486. MsgId: "H44022900158202103301743097676",
  10487. PsnNo: "44020000001102127785",
  10488. Info: "2207",
  10489. }
  10490. customData = append(customData, custom8)
  10491. custom9 := &CustomData{
  10492. MsgId: "H44022900158202103301712304203",
  10493. PsnNo: "44020000001101518097",
  10494. Info: "2207",
  10495. }
  10496. customData = append(customData, custom9)
  10497. custom10 := &CustomData{
  10498. MsgId: "H44022900158202103301738448785",
  10499. PsnNo: "44020000001100500813",
  10500. Info: "2207",
  10501. }
  10502. customData = append(customData, custom10)
  10503. custom11 := &CustomData{
  10504. MsgId: "H44022900158202103301732455843",
  10505. PsnNo: "44020000001102690557",
  10506. Info: "2207",
  10507. }
  10508. customData = append(customData, custom11)
  10509. custom12 := &CustomData{
  10510. MsgId: "H44022900158202103301745421708",
  10511. PsnNo: "44020000001102211928",
  10512. Info: "2207",
  10513. }
  10514. customData = append(customData, custom12)
  10515. custom1212 := &CustomData{
  10516. MsgId: "H440229001582021033017351627",
  10517. PsnNo: "44020000001102481733",
  10518. Info: "2207",
  10519. }
  10520. customData = append(customData, custom1212)
  10521. custom13 := &CustomData{
  10522. MsgId: "H44022900158202103301740327951",
  10523. PsnNo: "44020000001103174866",
  10524. Info: "2207",
  10525. }
  10526. customData = append(customData, custom13)
  10527. custom14 := &CustomData{
  10528. MsgId: "H4402290015820210330174922668",
  10529. PsnNo: "44020000001102927272",
  10530. Info: "2207",
  10531. }
  10532. customData = append(customData, custom14)
  10533. custom15 := &CustomData{
  10534. MsgId: "H44022900158202103301752362273",
  10535. PsnNo: "44020000001102942890",
  10536. Info: "2207",
  10537. }
  10538. customData = append(customData, custom15)
  10539. custom16 := &CustomData{
  10540. MsgId: "H44022900158202103301751082917",
  10541. PsnNo: "44020000001101662162",
  10542. Info: "2207",
  10543. }
  10544. customData = append(customData, custom16)
  10545. custom17 := &CustomData{
  10546. MsgId: "H44022900158202103301754147728",
  10547. PsnNo: "44020000000229014511",
  10548. Info: "2207",
  10549. }
  10550. customData = append(customData, custom17)
  10551. adminUser := c.GetAdminUserInfo()
  10552. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  10553. for _, item := range customData {
  10554. result := service.Gdyb2601(item.PsnNo, item.MsgId, item.Info, miConfig.OrgName, "张俊杰", miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey)
  10555. fmt.Println(result)
  10556. }
  10557. }
  10558. //func (c *HisApiController) GetAllopatry() {
  10559. // year := c.GetString("year")
  10560. // month := c.GetString("month")
  10561. // admin_user_id, _ := c.GetInt64("admin_user_id")
  10562. // adminUser := c.GetAdminUserInfo()
  10563. // miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  10564. // roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  10565. // result, _ := service.Gdyb9001(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, 1669)
  10566. //
  10567. // var dat map[string]interface{}
  10568. // if err := json.Unmarshal([]byte(result), &dat); err == nil {
  10569. // fmt.Println(dat)
  10570. // } else {
  10571. // fmt.Println(err)
  10572. // }
  10573. // userJSONBytes, _ := json.Marshal(dat)
  10574. // var res models.Result9001
  10575. // if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  10576. // utils.ErrorLog("解析失败:%v", err)
  10577. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10578. // return
  10579. // }
  10580. //
  10581. // result2, _ := service.Gdyb3260(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, year, month, res.Output.Signinoutb.SignNo)
  10582. // var dat2 map[string]interface{}
  10583. // if err := json.Unmarshal([]byte(result2), &dat2); err == nil {
  10584. // fmt.Println(dat)
  10585. // } else {
  10586. // fmt.Println(err)
  10587. // }
  10588. // userJSONBytes2, _ := json.Marshal(dat2)
  10589. // var res2 models.Result3260
  10590. // if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  10591. // utils.ErrorLog("解析失败:%v", err)
  10592. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10593. // return
  10594. // }
  10595. // if res2.Infcode == 0 {
  10596. // c.ServeSuccessJSON(map[string]interface{}{
  10597. // "list": res2.Output.Data,
  10598. // })
  10599. // return
  10600. // } else {
  10601. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10602. // return
  10603. // }
  10604. //
  10605. //}
  10606. //func (c *HisApiController) ComfirmAllopatry() {
  10607. // year := c.GetString("year")
  10608. // month := c.GetString("month")
  10609. // admin_user_id, _ := c.GetInt64("admin_user_id")
  10610. // adminUser := c.GetAdminUserInfo()
  10611. // miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  10612. // roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  10613. // result, _ := service.Gdyb9001(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, 1669)
  10614. // var dat map[string]interface{}
  10615. // if err := json.Unmarshal([]byte(result), &dat); err == nil {
  10616. // fmt.Println(dat)
  10617. // } else {
  10618. // fmt.Println(err)
  10619. // }
  10620. // userJSONBytes, _ := json.Marshal(dat)
  10621. // var res models.Result9001
  10622. // if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  10623. // utils.ErrorLog("解析失败:%v", err)
  10624. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10625. // return
  10626. // }
  10627. //
  10628. // result2, _ := service.Gdyb3260(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, year, month, res.Output.Signinoutb.SignNo)
  10629. // var dat2 map[string]interface{}
  10630. // if err := json.Unmarshal([]byte(result2), &dat2); err == nil {
  10631. // fmt.Println(dat)
  10632. // } else {
  10633. // fmt.Println(err)
  10634. // }
  10635. // userJSONBytes2, _ := json.Marshal(dat2)
  10636. // var res2 models.Result3260
  10637. // if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  10638. // utils.ErrorLog("解析失败:%v", err)
  10639. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10640. // return
  10641. // }
  10642. //
  10643. // if res2.Infcode == 0 {
  10644. // result, _, msgId := service.Gdyb3261(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, year, month, res2)
  10645. // var dat map[string]interface{}
  10646. // if err := json.Unmarshal([]byte(result), &dat); err == nil {
  10647. // fmt.Println(dat)
  10648. // } else {
  10649. // fmt.Println(err)
  10650. // }
  10651. // userJSONBytes, _ := json.Marshal(dat)
  10652. // var res3 models.Result3261
  10653. // if err := json.Unmarshal(userJSONBytes, &res3); err != nil {
  10654. // utils.ErrorLog("解析失败:%v", err)
  10655. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10656. // return
  10657. // }
  10658. //
  10659. // if res3.Infcode == 0 {
  10660. // record := &models.HisYidiClearRecord{
  10661. // UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  10662. // Ctime: time.Now().Unix(),
  10663. // Mtime: time.Now().Unix(),
  10664. // Status: 1,
  10665. // MsgId: msgId,
  10666. // }
  10667. // service.SaveClearRecord(record)
  10668. // c.ServeSuccessJSON(map[string]interface{}{
  10669. // "msg": "提取成功",
  10670. // })
  10671. // }
  10672. // }
  10673. //}
  10674. func (c *HisApiController) RefundAllopatry() {
  10675. year := c.GetString("year")
  10676. month := c.GetString("month")
  10677. id, _ := c.GetInt64("id")
  10678. admin_user_id, _ := c.GetInt64("admin_user_id")
  10679. adminUser := c.GetAdminUserInfo()
  10680. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  10681. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  10682. record, _ := service.GetClearRecordById(id)
  10683. result, _ := service.Gdyb3262(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, year, month, record.MsgId)
  10684. var dat map[string]interface{}
  10685. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  10686. fmt.Println(dat)
  10687. } else {
  10688. fmt.Println(err)
  10689. }
  10690. userJSONBytes, _ := json.Marshal(dat)
  10691. var empty ResultFourteen
  10692. if err := json.Unmarshal(userJSONBytes, &empty); err != nil {
  10693. utils.ErrorLog("解析失败:%v", err)
  10694. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10695. return
  10696. }
  10697. if empty.Infcode == 0 {
  10698. c.ServeSuccessJSON(map[string]interface{}{
  10699. "msg": "撤销成功",
  10700. })
  10701. return
  10702. }
  10703. }
  10704. func (c *HisApiController) ReversalOtherData() {
  10705. var customData []*CustomData
  10706. custom := &CustomData{
  10707. MsgId: "H44022900158202103301714472004",
  10708. PsnNo: "44020000001101329945",
  10709. Info: "2208",
  10710. }
  10711. customData = append(customData, custom)
  10712. custom1 := &CustomData{
  10713. MsgId: "H4402290015820210330172057803",
  10714. PsnNo: "44020000001101161813",
  10715. Info: "2208",
  10716. }
  10717. customData = append(customData, custom1)
  10718. custom2 := &CustomData{
  10719. MsgId: "H44022900158202103301705198813",
  10720. PsnNo: "44190000133097375417",
  10721. Info: "2208",
  10722. }
  10723. customData = append(customData, custom2)
  10724. custom3 := &CustomData{
  10725. MsgId: "H44022900158202103301715524756",
  10726. PsnNo: "44020000001100187221",
  10727. Info: "2208",
  10728. }
  10729. customData = append(customData, custom3)
  10730. custom4 := &CustomData{
  10731. MsgId: "H44022900158202103301730376224",
  10732. PsnNo: "44020000001101959155",
  10733. Info: "2208",
  10734. }
  10735. customData = append(customData, custom4)
  10736. custom5 := &CustomData{
  10737. MsgId: "H44022900158202103301748008725",
  10738. PsnNo: "44020000001104246641",
  10739. Info: "2208",
  10740. }
  10741. customData = append(customData, custom5)
  10742. custom6 := &CustomData{
  10743. MsgId: "H44022900158202103301718096755",
  10744. PsnNo: "44020000001102211860",
  10745. Info: "2208",
  10746. }
  10747. customData = append(customData, custom6)
  10748. custom7 := &CustomData{
  10749. MsgId: "H44022900158202103301736551640",
  10750. PsnNo: "44020000001102687718",
  10751. Info: "2208",
  10752. }
  10753. customData = append(customData, custom7)
  10754. custom8 := &CustomData{
  10755. MsgId: "H44022900158202103301743097676",
  10756. PsnNo: "44020000001102127785",
  10757. Info: "2208",
  10758. }
  10759. customData = append(customData, custom8)
  10760. custom9 := &CustomData{
  10761. MsgId: "H44022900158202103301712304203",
  10762. PsnNo: "44020000001101518097",
  10763. Info: "2208",
  10764. }
  10765. customData = append(customData, custom9)
  10766. custom10 := &CustomData{
  10767. MsgId: "H44022900158202103301738448785",
  10768. PsnNo: "44020000001100500813",
  10769. Info: "2208",
  10770. }
  10771. customData = append(customData, custom10)
  10772. custom11 := &CustomData{
  10773. MsgId: "H44022900158202103301732455843",
  10774. PsnNo: "44020000001102690557",
  10775. Info: "2208",
  10776. }
  10777. customData = append(customData, custom11)
  10778. custom12 := &CustomData{
  10779. MsgId: "H44022900158202103301745421708",
  10780. PsnNo: "44020000001102211928",
  10781. Info: "2208",
  10782. }
  10783. customData = append(customData, custom12)
  10784. custom1212 := &CustomData{
  10785. MsgId: "H440229001582021033017351627",
  10786. PsnNo: "44020000001102481733",
  10787. Info: "2208",
  10788. }
  10789. customData = append(customData, custom1212)
  10790. custom13 := &CustomData{
  10791. MsgId: "H44022900158202103301740327951",
  10792. PsnNo: "44020000001103174866",
  10793. Info: "2208",
  10794. }
  10795. customData = append(customData, custom13)
  10796. custom14 := &CustomData{
  10797. MsgId: "H4402290015820210330174922668",
  10798. PsnNo: "44020000001102927272",
  10799. Info: "2208",
  10800. }
  10801. customData = append(customData, custom14)
  10802. custom15 := &CustomData{
  10803. MsgId: "H44022900158202103301752362273",
  10804. PsnNo: "44020000001102942890",
  10805. Info: "2208",
  10806. }
  10807. customData = append(customData, custom15)
  10808. custom16 := &CustomData{
  10809. MsgId: "H44022900158202103301751082917",
  10810. PsnNo: "44020000001101662162",
  10811. Info: "2208",
  10812. }
  10813. customData = append(customData, custom16)
  10814. custom17 := &CustomData{
  10815. MsgId: "H44022900158202103301754147728",
  10816. PsnNo: "44020000000229014511",
  10817. Info: "2208",
  10818. }
  10819. customData = append(customData, custom17)
  10820. adminUser := c.GetAdminUserInfo()
  10821. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  10822. for _, item := range customData {
  10823. result := service.Gdyb2601(item.PsnNo, item.MsgId, item.Info, miConfig.OrgName, "张俊杰", miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey)
  10824. fmt.Println(result)
  10825. }
  10826. }
  10827. func PathExists(path string) (bool, error) {
  10828. _, err := os.Stat(path)
  10829. if err == nil {
  10830. return true, nil
  10831. }
  10832. if os.IsNotExist(err) {
  10833. return false, nil
  10834. }
  10835. return false, err
  10836. }
  10837. //创建文件夹
  10838. func Mkdir(dir string) {
  10839. // 创建文件夹
  10840. exist, err := PathExists(dir)
  10841. if err != nil {
  10842. fmt.Println(err.Error())
  10843. } else {
  10844. if exist {
  10845. fmt.Println(dir + "文件夹已存在!")
  10846. } else {
  10847. // 文件夹名称,权限
  10848. err := os.Mkdir(dir, os.ModePerm)
  10849. if err != nil {
  10850. fmt.Println(dir+"文件夹创建失败:", err.Error())
  10851. } else {
  10852. fmt.Println(dir + "文件夹创建成功!")
  10853. }
  10854. }
  10855. }
  10856. }
  10857. //压缩文件
  10858. func Zip(srcFile string, destZip string) error {
  10859. zipfile, err := os.Create(destZip)
  10860. if err != nil {
  10861. return err
  10862. }
  10863. defer zipfile.Close()
  10864. archive := zip.NewWriter(zipfile)
  10865. defer archive.Close()
  10866. filepath.Walk(srcFile, func(path string, info os.FileInfo, err error) error {
  10867. if err != nil {
  10868. return err
  10869. }
  10870. header, err := zip.FileInfoHeader(info)
  10871. if err != nil {
  10872. return err
  10873. }
  10874. header.Name = strings.TrimPrefix(path, filepath.Dir(srcFile)+"/")
  10875. // header.Name = path
  10876. if info.IsDir() {
  10877. header.Name += "/"
  10878. } else {
  10879. header.Method = zip.Deflate
  10880. }
  10881. writer, err := archive.CreateHeader(header)
  10882. if err != nil {
  10883. return err
  10884. }
  10885. if !info.IsDir() {
  10886. file, err := os.Open(path)
  10887. if err != nil {
  10888. return err
  10889. }
  10890. defer file.Close()
  10891. _, err = io.Copy(writer, file)
  10892. }
  10893. return err
  10894. })
  10895. return err
  10896. }
  10897. func ReadFile(filePath string) []byte {
  10898. f, err := os.Open(filePath)
  10899. if err != nil {
  10900. fmt.Println("read file fail", err)
  10901. return nil
  10902. }
  10903. defer f.Close()
  10904. fd, err := ioutil.ReadAll(f)
  10905. if err != nil {
  10906. fmt.Println("read to fd fail", err)
  10907. return nil
  10908. }
  10909. return fd
  10910. }
  10911. func saveLog(result string, request string, infno string, desc string) {
  10912. org_id, _ := beego.AppConfig.Int64("org_id")
  10913. miConfig, _ := service.FindMedicalInsuranceInfo(org_id)
  10914. dir := miConfig.OrgName + "日志"
  10915. utils.Mkdir(dir)
  10916. month := time.Unix(1557042972, 0).Format("1")
  10917. year := time.Now().Format("2006")
  10918. month = time.Now().Format("01")
  10919. day := time.Now().Format("02")
  10920. hour := time.Now().Format("15")
  10921. min := time.Now().Format("04")
  10922. sec := time.Now().Format("05")
  10923. result_time := year + "-" + month + "-" + day + " " + hour + ":" + min + ":" + sec
  10924. file := strconv.FormatInt(org_id, 10) + "_" + year + month + day + "_log"
  10925. file_name := file + ".txt"
  10926. file_path := miConfig.OrgName + "日志" + "/" + file_name
  10927. exist, _ := utils.PathExists(file_path)
  10928. if exist { //存在
  10929. fmt.Println("存在")
  10930. f, err := os.OpenFile(file_path, os.O_WRONLY, 0644)
  10931. if err != nil {
  10932. fmt.Println("read fail")
  10933. }
  10934. content := "\r\n" + "\r\n" + "\r\n" + result_time + " " + "【 " + desc + infno + "入参" + " 】:" + "\r\n" + request + "\r\n" + result_time + " " + "【 " + desc + infno + "出参" + " 】:" + "\r\n" + result
  10935. n, _ := f.Seek(0, 2)
  10936. _, err = f.WriteAt([]byte(content), n)
  10937. } else { //不存在
  10938. fmt.Println("文件不存在,创建文件")
  10939. f, err := os.Create(miConfig.OrgName + "日志" + "/" + file_name)
  10940. defer f.Close()
  10941. if err != nil {
  10942. } else {
  10943. _, err = f.Write([]byte("记录日志"))
  10944. }
  10945. }
  10946. }
  10947. type Charset string
  10948. const (
  10949. UTF8 = Charset("UTF-8")
  10950. GB18030 = Charset("GB18030")
  10951. )
  10952. func ConvertToString(src string, srcCode string, tagCode string) string {
  10953. srcCoder := mahonia.NewDecoder(srcCode)
  10954. srcResult := srcCoder.ConvertString(src)
  10955. tagCoder := mahonia.NewDecoder(tagCode)
  10956. _, cdata, _ := tagCoder.Translate([]byte(srcResult), true)
  10957. result := string(cdata)
  10958. return result
  10959. }
  10960. func (c *HisApiController) ReadEleCard() {
  10961. id_card_type, _ := c.GetInt64("id_card_type")
  10962. admin_user_id, _ := c.GetInt64("admin_user_id")
  10963. fmt.Println(c.GetAdminUserInfo().CurrentOrgId)
  10964. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  10965. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  10966. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  10967. var api string
  10968. if miConfig.MdtrtareaAdmvs == "320921" {
  10969. api = "http://192.168.2.110:9532/" + "jsyb/readcard?" + "fixmedins_code=" + miConfig.Code + "&secret_key=" + miConfig.SecretKey + "&ak=" + miConfig.AccessKey + "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName +
  10970. "&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
  10971. fmt.Println(api)
  10972. } else {
  10973. 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 +
  10974. "&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)
  10975. }
  10976. resp, requestErr := http.Get(api)
  10977. if requestErr != nil {
  10978. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10979. return
  10980. }
  10981. body, ioErr := ioutil.ReadAll(resp.Body)
  10982. if ioErr != nil {
  10983. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  10984. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10985. return
  10986. }
  10987. var respJSON map[string]interface{}
  10988. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  10989. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  10990. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10991. return
  10992. }
  10993. var status string
  10994. status = respJSON["data"].(map[string]interface{})["status"].(string)
  10995. //card_type := respJSON["data"].(map[string]interface{})["type"].(string)
  10996. var token string
  10997. var res ResultTwo //1101结果
  10998. var res10265 ResultTwo10265 //1101结果
  10999. if status == "0" { //读卡成功
  11000. var card_info string //卡信息
  11001. var busi_card_info string
  11002. token = respJSON["data"].(map[string]interface{})["token"].(string)
  11003. busi_card_info = respJSON["data"].(map[string]interface{})["busi_card_info"].(string)
  11004. card_info = respJSON["data"].(map[string]interface{})["card_info"].(string)
  11005. fmt.Println(card_info)
  11006. fmt.Println(busi_card_info)
  11007. respJSON = respJSON["data"].(map[string]interface{})["result"].(map[string]interface{})
  11008. result, _ := json.Marshal(respJSON)
  11009. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  11010. utils.ErrorLog("解析失败:%v", err)
  11011. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11012. return
  11013. }
  11014. res.ErrMsg = res10265.ErrMsg
  11015. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  11016. res.Infcode = infocode
  11017. res.Output = res10265.Output
  11018. res.InfRefmsgid = res10265.InfRefmsgid
  11019. if res.Infcode == 0 {
  11020. c.ServeSuccessJSON(map[string]interface{}{
  11021. "number": token,
  11022. })
  11023. }
  11024. } else {
  11025. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  11026. return
  11027. }
  11028. } else { //读卡失败
  11029. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  11030. return
  11031. }
  11032. }
  11033. func DeleteExtraSpaceTwo(s string) string {
  11034. //删除字符串中的多余空格,有多个空格时,仅保留一个空格
  11035. s1 := strings.Replace(s, " ", " ", -1) //替换tab为空格
  11036. regstr := "\\s{2,}" //两个及两个以上空格的正则表达式
  11037. reg, _ := regexp.Compile(regstr) //编译正则表达式
  11038. s2 := make([]byte, len(s1)) //定义字符数组切片
  11039. copy(s2, s1) //将字符串复制到切片
  11040. spc_index := reg.FindStringIndex(string(s2)) //在字符串中搜索
  11041. for len(spc_index) > 0 { //找到适配项
  11042. s2 = append(s2[:spc_index[0]+1], s2[spc_index[1]:]...) //删除多余空格
  11043. spc_index = reg.FindStringIndex(string(s2)) //继续在字符串中搜索
  11044. }
  11045. return string(s2)
  11046. }
  11047. func Remove0000(s string) string {
  11048. str := make([]rune, 0, len(s))
  11049. for _, v := range []rune(s) {
  11050. if v == 0 {
  11051. continue
  11052. }
  11053. str = append(str, v)
  11054. }
  11055. return string(str)
  11056. }
  11057. func (c *HisApiController) GetELeCertInfo(code string, operator_id string, operator_name string) (string, string) {
  11058. DllDef := syscall.MustLoadDLL("HeaSecReadInfo.dll")
  11059. readCard := DllDef.MustFindProc("EcQuery")
  11060. pCardInfo := make([]byte, 8192)
  11061. pBusiCardInfo := make([]byte, 8192)
  11062. data := make(map[string]interface{})
  11063. //pData := make(map[string]interface{})
  11064. inputData := make(map[string]interface{})
  11065. inputData["orgId"] = code
  11066. inputData["businessType"] = "01101"
  11067. inputData["operatorId"] = operator_id
  11068. inputData["operatorName"] = operator_name
  11069. inputData["officeId"] = "001"
  11070. inputData["officeName"] = "血透室"
  11071. //
  11072. data["data"] = inputData
  11073. data["transType"] = "ec.query"
  11074. data["orgId"] = code
  11075. bytesData, _ := json.Marshal(data)
  11076. pCardInfo = bytesData
  11077. ret2, _, _ := readCard.Call((uintptr)(unsafe.Pointer(&pCardInfo[0])), (uintptr)(unsafe.Pointer(&pBusiCardInfo[0])))
  11078. fmt.Println(ret2)
  11079. //fmt.Println(DeleteExtraSpace(string(bytesData)))
  11080. //fmt.Println(DeleteExtraSpace(string(pBusiCardInfo)))
  11081. fmt.Println(":", ConvertToString(DeleteExtraSpace(string(bytesData)), "gbk", "utf-8"))
  11082. fmt.Println(":", ConvertToString(DeleteExtraSpace(string(pBusiCardInfo)), "gbk", "utf-8"))
  11083. if ret2 != 0 {
  11084. return "", ""
  11085. }
  11086. return DeleteExtraSpace(string(bytesData)), DeleteExtraSpace(string(pBusiCardInfo))
  11087. }
  11088. func DeleteExtraSpace(s string) string {
  11089. //删除字符串中的多余空格,有多个空格时,仅保留一个空格
  11090. s1 := strings.Replace(s, " ", " ", -1) //替换tab为空格
  11091. regstr := "\\s{2,}" //两个及两个以上空格的正则表达式
  11092. reg, _ := regexp.Compile(regstr) //编译正则表达式
  11093. s2 := make([]byte, len(s1)) //定义字符数组切片
  11094. copy(s2, s1) //将字符串复制到切片
  11095. spc_index := reg.FindStringIndex(string(s2)) //在字符串中搜索
  11096. for len(spc_index) > 0 { //找到适配项
  11097. s2 = append(s2[:spc_index[0]+1], s2[spc_index[1]:]...) //删除多余空格
  11098. spc_index = reg.FindStringIndex(string(s2)) //继续在字符串中搜索
  11099. }
  11100. return string(s2)
  11101. }