his_api_controller.go 455KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504250525062507250825092510251125122513251425152516251725182519252025212522252325242525252625272528252925302531253225332534253525362537253825392540254125422543254425452546254725482549255025512552255325542555255625572558255925602561256225632564256525662567256825692570257125722573257425752576257725782579258025812582258325842585258625872588258925902591259225932594259525962597259825992600260126022603260426052606260726082609261026112612261326142615261626172618261926202621262226232624262526262627262826292630263126322633263426352636263726382639264026412642264326442645264626472648264926502651265226532654265526562657265826592660266126622663266426652666266726682669267026712672267326742675267626772678267926802681268226832684268526862687268826892690269126922693269426952696269726982699270027012702270327042705270627072708270927102711271227132714271527162717271827192720272127222723272427252726272727282729273027312732273327342735273627372738273927402741274227432744274527462747274827492750275127522753275427552756275727582759276027612762276327642765276627672768276927702771277227732774277527762777277827792780278127822783278427852786278727882789279027912792279327942795279627972798279928002801280228032804280528062807280828092810281128122813281428152816281728182819282028212822282328242825282628272828282928302831283228332834283528362837283828392840284128422843284428452846284728482849285028512852285328542855285628572858285928602861286228632864286528662867286828692870287128722873287428752876287728782879288028812882288328842885288628872888288928902891289228932894289528962897289828992900290129022903290429052906290729082909291029112912291329142915291629172918291929202921292229232924292529262927292829292930293129322933293429352936293729382939294029412942294329442945294629472948294929502951295229532954295529562957295829592960296129622963296429652966296729682969297029712972297329742975297629772978297929802981298229832984298529862987298829892990299129922993299429952996299729982999300030013002300330043005300630073008300930103011301230133014301530163017301830193020302130223023302430253026302730283029303030313032303330343035303630373038303930403041304230433044304530463047304830493050305130523053305430553056305730583059306030613062306330643065306630673068306930703071307230733074307530763077307830793080308130823083308430853086308730883089309030913092309330943095309630973098309931003101310231033104310531063107310831093110311131123113311431153116311731183119312031213122312331243125312631273128312931303131313231333134313531363137313831393140314131423143314431453146314731483149315031513152315331543155315631573158315931603161316231633164316531663167316831693170317131723173317431753176317731783179318031813182318331843185318631873188318931903191319231933194319531963197319831993200320132023203320432053206320732083209321032113212321332143215321632173218321932203221322232233224322532263227322832293230323132323233323432353236323732383239324032413242324332443245324632473248324932503251325232533254325532563257325832593260326132623263326432653266326732683269327032713272327332743275327632773278327932803281328232833284328532863287328832893290329132923293329432953296329732983299330033013302330333043305330633073308330933103311331233133314331533163317331833193320332133223323332433253326332733283329333033313332333333343335333633373338333933403341334233433344334533463347334833493350335133523353335433553356335733583359336033613362336333643365336633673368336933703371337233733374337533763377337833793380338133823383338433853386338733883389339033913392339333943395339633973398339934003401340234033404340534063407340834093410341134123413341434153416341734183419342034213422342334243425342634273428342934303431343234333434343534363437343834393440344134423443344434453446344734483449345034513452345334543455345634573458345934603461346234633464346534663467346834693470347134723473347434753476347734783479348034813482348334843485348634873488348934903491349234933494349534963497349834993500350135023503350435053506350735083509351035113512351335143515351635173518351935203521352235233524352535263527352835293530353135323533353435353536353735383539354035413542354335443545354635473548354935503551355235533554355535563557355835593560356135623563356435653566356735683569357035713572357335743575357635773578357935803581358235833584358535863587358835893590359135923593359435953596359735983599360036013602360336043605360636073608360936103611361236133614361536163617361836193620362136223623362436253626362736283629363036313632363336343635363636373638363936403641364236433644364536463647364836493650365136523653365436553656365736583659366036613662366336643665366636673668366936703671367236733674367536763677367836793680368136823683368436853686368736883689369036913692369336943695369636973698369937003701370237033704370537063707370837093710371137123713371437153716371737183719372037213722372337243725372637273728372937303731373237333734373537363737373837393740374137423743374437453746374737483749375037513752375337543755375637573758375937603761376237633764376537663767376837693770377137723773377437753776377737783779378037813782378337843785378637873788378937903791379237933794379537963797379837993800380138023803380438053806380738083809381038113812381338143815381638173818381938203821382238233824382538263827382838293830383138323833383438353836383738383839384038413842384338443845384638473848384938503851385238533854385538563857385838593860386138623863386438653866386738683869387038713872387338743875387638773878387938803881388238833884388538863887388838893890389138923893389438953896389738983899390039013902390339043905390639073908390939103911391239133914391539163917391839193920392139223923392439253926392739283929393039313932393339343935393639373938393939403941394239433944394539463947394839493950395139523953395439553956395739583959396039613962396339643965396639673968396939703971397239733974397539763977397839793980398139823983398439853986398739883989399039913992399339943995399639973998399940004001400240034004400540064007400840094010401140124013401440154016401740184019402040214022402340244025402640274028402940304031403240334034403540364037403840394040404140424043404440454046404740484049405040514052405340544055405640574058405940604061406240634064406540664067406840694070407140724073407440754076407740784079408040814082408340844085408640874088408940904091409240934094409540964097409840994100410141024103410441054106410741084109411041114112411341144115411641174118411941204121412241234124412541264127412841294130413141324133413441354136413741384139414041414142414341444145414641474148414941504151415241534154415541564157415841594160416141624163416441654166416741684169417041714172417341744175417641774178417941804181418241834184418541864187418841894190419141924193419441954196419741984199420042014202420342044205420642074208420942104211421242134214421542164217421842194220422142224223422442254226422742284229423042314232423342344235423642374238423942404241424242434244424542464247424842494250425142524253425442554256425742584259426042614262426342644265426642674268426942704271427242734274427542764277427842794280428142824283428442854286428742884289429042914292429342944295429642974298429943004301430243034304430543064307430843094310431143124313431443154316431743184319432043214322432343244325432643274328432943304331433243334334433543364337433843394340434143424343434443454346434743484349435043514352435343544355435643574358435943604361436243634364436543664367436843694370437143724373437443754376437743784379438043814382438343844385438643874388438943904391439243934394439543964397439843994400440144024403440444054406440744084409441044114412441344144415441644174418441944204421442244234424442544264427442844294430443144324433443444354436443744384439444044414442444344444445444644474448444944504451445244534454445544564457445844594460446144624463446444654466446744684469447044714472447344744475447644774478447944804481448244834484448544864487448844894490449144924493449444954496449744984499450045014502450345044505450645074508450945104511451245134514451545164517451845194520452145224523452445254526452745284529453045314532453345344535453645374538453945404541454245434544454545464547454845494550455145524553455445554556455745584559456045614562456345644565456645674568456945704571457245734574457545764577457845794580458145824583458445854586458745884589459045914592459345944595459645974598459946004601460246034604460546064607460846094610461146124613461446154616461746184619462046214622462346244625462646274628462946304631463246334634463546364637463846394640464146424643464446454646464746484649465046514652465346544655465646574658465946604661466246634664466546664667466846694670467146724673467446754676467746784679468046814682468346844685468646874688468946904691469246934694469546964697469846994700470147024703470447054706470747084709471047114712471347144715471647174718471947204721472247234724472547264727472847294730473147324733473447354736473747384739474047414742474347444745474647474748474947504751475247534754475547564757475847594760476147624763476447654766476747684769477047714772477347744775477647774778477947804781478247834784478547864787478847894790479147924793479447954796479747984799480048014802480348044805480648074808480948104811481248134814481548164817481848194820482148224823482448254826482748284829483048314832483348344835483648374838483948404841484248434844484548464847484848494850485148524853485448554856485748584859486048614862486348644865486648674868486948704871487248734874487548764877487848794880488148824883488448854886488748884889489048914892489348944895489648974898489949004901490249034904490549064907490849094910491149124913491449154916491749184919492049214922492349244925492649274928492949304931493249334934493549364937493849394940494149424943494449454946494749484949495049514952495349544955495649574958495949604961496249634964496549664967496849694970497149724973497449754976497749784979498049814982498349844985498649874988498949904991499249934994499549964997499849995000500150025003500450055006500750085009501050115012501350145015501650175018501950205021502250235024502550265027502850295030503150325033503450355036503750385039504050415042504350445045504650475048504950505051505250535054505550565057505850595060506150625063506450655066506750685069507050715072507350745075507650775078507950805081508250835084508550865087508850895090509150925093509450955096509750985099510051015102510351045105510651075108510951105111511251135114511551165117511851195120512151225123512451255126512751285129513051315132513351345135513651375138513951405141514251435144514551465147514851495150515151525153515451555156515751585159516051615162516351645165516651675168516951705171517251735174517551765177517851795180518151825183518451855186518751885189519051915192519351945195519651975198519952005201520252035204520552065207520852095210521152125213521452155216521752185219522052215222522352245225522652275228522952305231523252335234523552365237523852395240524152425243524452455246524752485249525052515252525352545255525652575258525952605261526252635264526552665267526852695270527152725273527452755276527752785279528052815282528352845285528652875288528952905291529252935294529552965297529852995300530153025303530453055306530753085309531053115312531353145315531653175318531953205321532253235324532553265327532853295330533153325333533453355336533753385339534053415342534353445345534653475348534953505351535253535354535553565357535853595360536153625363536453655366536753685369537053715372537353745375537653775378537953805381538253835384538553865387538853895390539153925393539453955396539753985399540054015402540354045405540654075408540954105411541254135414541554165417541854195420542154225423542454255426542754285429543054315432543354345435543654375438543954405441544254435444544554465447544854495450545154525453545454555456545754585459546054615462546354645465546654675468546954705471547254735474547554765477547854795480548154825483548454855486548754885489549054915492549354945495549654975498549955005501550255035504550555065507550855095510551155125513551455155516551755185519552055215522552355245525552655275528552955305531553255335534553555365537553855395540554155425543554455455546554755485549555055515552555355545555555655575558555955605561556255635564556555665567556855695570557155725573557455755576557755785579558055815582558355845585558655875588558955905591559255935594559555965597559855995600560156025603560456055606560756085609561056115612561356145615561656175618561956205621562256235624562556265627562856295630563156325633563456355636563756385639564056415642564356445645564656475648564956505651565256535654565556565657565856595660566156625663566456655666566756685669567056715672567356745675567656775678567956805681568256835684568556865687568856895690569156925693569456955696569756985699570057015702570357045705570657075708570957105711571257135714571557165717571857195720572157225723572457255726572757285729573057315732573357345735573657375738573957405741574257435744574557465747574857495750575157525753575457555756575757585759576057615762576357645765576657675768576957705771577257735774577557765777577857795780578157825783578457855786578757885789579057915792579357945795579657975798579958005801580258035804580558065807580858095810581158125813581458155816581758185819582058215822582358245825582658275828582958305831583258335834583558365837583858395840584158425843584458455846584758485849585058515852585358545855585658575858585958605861586258635864586558665867586858695870587158725873587458755876587758785879588058815882588358845885588658875888588958905891589258935894589558965897589858995900590159025903590459055906590759085909591059115912591359145915591659175918591959205921592259235924592559265927592859295930593159325933593459355936593759385939594059415942594359445945594659475948594959505951595259535954595559565957595859595960596159625963596459655966596759685969597059715972597359745975597659775978597959805981598259835984598559865987598859895990599159925993599459955996599759985999600060016002600360046005600660076008600960106011601260136014601560166017601860196020602160226023602460256026602760286029603060316032603360346035603660376038603960406041604260436044604560466047604860496050605160526053605460556056605760586059606060616062606360646065606660676068606960706071607260736074607560766077607860796080608160826083608460856086608760886089609060916092609360946095609660976098609961006101610261036104610561066107610861096110611161126113611461156116611761186119612061216122612361246125612661276128612961306131613261336134613561366137613861396140614161426143614461456146614761486149615061516152615361546155615661576158615961606161616261636164616561666167616861696170617161726173617461756176617761786179618061816182618361846185618661876188618961906191619261936194619561966197619861996200620162026203620462056206620762086209621062116212621362146215621662176218621962206221622262236224622562266227622862296230623162326233623462356236623762386239624062416242624362446245624662476248624962506251625262536254625562566257625862596260626162626263626462656266626762686269627062716272627362746275627662776278627962806281628262836284628562866287628862896290629162926293629462956296629762986299630063016302630363046305630663076308630963106311631263136314631563166317631863196320632163226323632463256326632763286329633063316332633363346335633663376338633963406341634263436344634563466347634863496350635163526353635463556356635763586359636063616362636363646365636663676368636963706371637263736374637563766377637863796380638163826383638463856386638763886389639063916392639363946395639663976398639964006401640264036404640564066407640864096410641164126413641464156416641764186419642064216422642364246425642664276428642964306431643264336434643564366437643864396440644164426443644464456446644764486449645064516452645364546455645664576458645964606461646264636464646564666467646864696470647164726473647464756476647764786479648064816482648364846485648664876488648964906491649264936494649564966497649864996500650165026503650465056506650765086509651065116512651365146515651665176518651965206521652265236524652565266527652865296530653165326533653465356536653765386539654065416542654365446545654665476548654965506551655265536554655565566557655865596560656165626563656465656566656765686569657065716572657365746575657665776578657965806581658265836584658565866587658865896590659165926593659465956596659765986599660066016602660366046605660666076608660966106611661266136614661566166617661866196620662166226623662466256626662766286629663066316632663366346635663666376638663966406641664266436644664566466647664866496650665166526653665466556656665766586659666066616662666366646665666666676668666966706671667266736674667566766677667866796680668166826683668466856686668766886689669066916692669366946695669666976698669967006701670267036704670567066707670867096710671167126713671467156716671767186719672067216722672367246725672667276728672967306731673267336734673567366737673867396740674167426743674467456746674767486749675067516752675367546755675667576758675967606761676267636764676567666767676867696770677167726773677467756776677767786779678067816782678367846785678667876788678967906791679267936794679567966797679867996800680168026803680468056806680768086809681068116812681368146815681668176818681968206821682268236824682568266827682868296830683168326833683468356836683768386839684068416842684368446845684668476848684968506851685268536854685568566857685868596860686168626863686468656866686768686869687068716872687368746875687668776878687968806881688268836884688568866887688868896890689168926893689468956896689768986899690069016902690369046905690669076908690969106911691269136914691569166917691869196920692169226923692469256926692769286929693069316932693369346935693669376938693969406941694269436944694569466947694869496950695169526953695469556956695769586959696069616962696369646965696669676968696969706971697269736974697569766977697869796980698169826983698469856986698769886989699069916992699369946995699669976998699970007001700270037004700570067007700870097010701170127013701470157016701770187019702070217022702370247025702670277028702970307031703270337034703570367037703870397040704170427043704470457046704770487049705070517052705370547055705670577058705970607061706270637064706570667067706870697070707170727073707470757076707770787079708070817082708370847085708670877088708970907091709270937094709570967097709870997100710171027103710471057106710771087109711071117112711371147115711671177118711971207121712271237124712571267127712871297130713171327133713471357136713771387139714071417142714371447145714671477148714971507151715271537154715571567157715871597160716171627163716471657166716771687169717071717172717371747175717671777178717971807181718271837184718571867187718871897190719171927193719471957196719771987199720072017202720372047205720672077208720972107211721272137214721572167217721872197220722172227223722472257226722772287229723072317232723372347235723672377238723972407241724272437244724572467247724872497250725172527253725472557256725772587259726072617262726372647265726672677268726972707271727272737274727572767277727872797280728172827283728472857286728772887289729072917292729372947295729672977298729973007301730273037304730573067307730873097310731173127313731473157316731773187319732073217322732373247325732673277328732973307331733273337334733573367337733873397340734173427343734473457346734773487349735073517352735373547355735673577358735973607361736273637364736573667367736873697370737173727373737473757376737773787379738073817382738373847385738673877388738973907391739273937394739573967397739873997400740174027403740474057406740774087409741074117412741374147415741674177418741974207421742274237424742574267427742874297430743174327433743474357436743774387439744074417442744374447445744674477448744974507451745274537454745574567457745874597460746174627463746474657466746774687469747074717472747374747475747674777478747974807481748274837484748574867487748874897490749174927493749474957496749774987499750075017502750375047505750675077508750975107511751275137514751575167517751875197520752175227523752475257526752775287529753075317532753375347535753675377538753975407541754275437544754575467547754875497550755175527553755475557556755775587559756075617562756375647565756675677568756975707571757275737574757575767577757875797580758175827583758475857586758775887589759075917592759375947595759675977598759976007601760276037604760576067607760876097610761176127613761476157616761776187619762076217622762376247625762676277628762976307631763276337634763576367637763876397640764176427643764476457646764776487649765076517652765376547655765676577658765976607661766276637664766576667667766876697670767176727673767476757676767776787679768076817682768376847685768676877688768976907691769276937694769576967697769876997700770177027703770477057706770777087709771077117712771377147715771677177718771977207721772277237724772577267727772877297730773177327733773477357736773777387739774077417742774377447745774677477748774977507751775277537754775577567757775877597760776177627763776477657766776777687769777077717772777377747775777677777778777977807781778277837784778577867787778877897790779177927793779477957796779777987799780078017802780378047805780678077808780978107811781278137814781578167817781878197820782178227823782478257826782778287829783078317832783378347835783678377838783978407841784278437844784578467847784878497850785178527853785478557856785778587859786078617862786378647865786678677868786978707871787278737874787578767877787878797880788178827883788478857886788778887889789078917892789378947895789678977898789979007901790279037904790579067907790879097910791179127913791479157916791779187919792079217922792379247925792679277928792979307931793279337934793579367937793879397940794179427943794479457946794779487949795079517952795379547955795679577958795979607961796279637964796579667967796879697970797179727973797479757976797779787979798079817982798379847985798679877988798979907991799279937994799579967997799879998000800180028003800480058006800780088009801080118012801380148015801680178018801980208021802280238024802580268027802880298030803180328033803480358036803780388039804080418042804380448045804680478048804980508051805280538054805580568057805880598060806180628063806480658066806780688069807080718072807380748075807680778078807980808081808280838084808580868087808880898090809180928093809480958096809780988099810081018102810381048105810681078108810981108111811281138114811581168117811881198120812181228123812481258126812781288129813081318132813381348135813681378138813981408141814281438144814581468147814881498150815181528153815481558156815781588159816081618162816381648165816681678168816981708171817281738174817581768177817881798180818181828183818481858186818781888189819081918192819381948195819681978198819982008201820282038204820582068207820882098210821182128213821482158216821782188219822082218222822382248225822682278228822982308231823282338234823582368237823882398240824182428243824482458246824782488249825082518252825382548255825682578258825982608261826282638264826582668267826882698270827182728273827482758276827782788279828082818282828382848285828682878288828982908291829282938294829582968297829882998300830183028303830483058306830783088309831083118312831383148315831683178318831983208321832283238324832583268327832883298330833183328333833483358336833783388339834083418342834383448345834683478348834983508351835283538354835583568357835883598360836183628363836483658366836783688369837083718372837383748375837683778378837983808381838283838384838583868387838883898390839183928393839483958396839783988399840084018402840384048405840684078408840984108411841284138414841584168417841884198420842184228423842484258426842784288429843084318432843384348435843684378438843984408441844284438444844584468447844884498450845184528453845484558456845784588459846084618462846384648465846684678468846984708471847284738474847584768477847884798480848184828483848484858486848784888489849084918492849384948495849684978498849985008501850285038504850585068507850885098510851185128513851485158516851785188519852085218522852385248525852685278528852985308531853285338534853585368537853885398540854185428543854485458546854785488549855085518552855385548555855685578558855985608561856285638564856585668567856885698570857185728573857485758576857785788579858085818582858385848585858685878588858985908591859285938594859585968597859885998600860186028603860486058606860786088609861086118612861386148615861686178618861986208621862286238624862586268627862886298630863186328633863486358636863786388639864086418642864386448645864686478648864986508651865286538654865586568657865886598660866186628663866486658666866786688669867086718672867386748675867686778678867986808681868286838684868586868687868886898690869186928693869486958696869786988699870087018702870387048705870687078708870987108711871287138714871587168717871887198720872187228723872487258726872787288729873087318732873387348735873687378738873987408741874287438744874587468747874887498750875187528753875487558756875787588759876087618762876387648765876687678768876987708771877287738774877587768777877887798780878187828783878487858786878787888789879087918792879387948795879687978798879988008801880288038804880588068807880888098810881188128813881488158816881788188819882088218822882388248825882688278828882988308831883288338834883588368837883888398840884188428843884488458846884788488849885088518852885388548855885688578858885988608861886288638864886588668867886888698870887188728873887488758876887788788879888088818882888388848885888688878888888988908891889288938894889588968897889888998900890189028903890489058906890789088909891089118912891389148915891689178918891989208921892289238924892589268927892889298930893189328933893489358936893789388939894089418942894389448945894689478948894989508951895289538954895589568957895889598960896189628963896489658966896789688969897089718972897389748975897689778978897989808981898289838984898589868987898889898990899189928993899489958996899789988999900090019002900390049005900690079008900990109011901290139014901590169017901890199020902190229023902490259026902790289029903090319032903390349035903690379038903990409041904290439044904590469047904890499050905190529053905490559056905790589059906090619062906390649065906690679068906990709071907290739074907590769077907890799080908190829083908490859086908790889089909090919092909390949095909690979098909991009101910291039104910591069107910891099110911191129113911491159116911791189119912091219122912391249125912691279128912991309131913291339134913591369137913891399140914191429143914491459146914791489149915091519152915391549155915691579158915991609161916291639164916591669167916891699170917191729173917491759176917791789179918091819182918391849185918691879188918991909191919291939194919591969197919891999200920192029203920492059206920792089209921092119212921392149215921692179218921992209221922292239224922592269227922892299230923192329233923492359236923792389239924092419242924392449245924692479248924992509251925292539254925592569257925892599260926192629263926492659266926792689269927092719272927392749275927692779278927992809281928292839284928592869287928892899290929192929293929492959296929792989299930093019302930393049305930693079308930993109311931293139314931593169317931893199320932193229323932493259326932793289329933093319332933393349335933693379338933993409341934293439344934593469347934893499350935193529353935493559356935793589359936093619362936393649365936693679368936993709371937293739374937593769377937893799380938193829383938493859386938793889389939093919392939393949395939693979398939994009401940294039404940594069407940894099410941194129413941494159416941794189419942094219422942394249425942694279428942994309431943294339434943594369437943894399440944194429443944494459446944794489449945094519452945394549455945694579458945994609461946294639464946594669467946894699470947194729473947494759476947794789479948094819482948394849485948694879488948994909491949294939494949594969497949894999500950195029503950495059506950795089509951095119512951395149515951695179518951995209521952295239524952595269527952895299530953195329533953495359536953795389539954095419542954395449545954695479548954995509551955295539554955595569557955895599560956195629563956495659566956795689569957095719572957395749575957695779578957995809581958295839584958595869587958895899590959195929593959495959596959795989599960096019602960396049605960696079608960996109611961296139614961596169617961896199620962196229623962496259626962796289629963096319632963396349635963696379638963996409641964296439644964596469647964896499650965196529653965496559656965796589659966096619662966396649665966696679668966996709671967296739674967596769677967896799680968196829683968496859686968796889689969096919692969396949695969696979698969997009701970297039704970597069707970897099710971197129713971497159716971797189719972097219722972397249725972697279728972997309731973297339734973597369737973897399740974197429743974497459746974797489749975097519752975397549755975697579758975997609761976297639764976597669767976897699770977197729773977497759776977797789779978097819782978397849785978697879788978997909791979297939794979597969797979897999800980198029803980498059806980798089809981098119812981398149815981698179818981998209821982298239824982598269827982898299830983198329833983498359836983798389839984098419842984398449845984698479848984998509851985298539854985598569857985898599860986198629863986498659866986798689869987098719872987398749875987698779878987998809881988298839884988598869887988898899890989198929893989498959896989798989899990099019902990399049905990699079908990999109911991299139914991599169917991899199920992199229923992499259926992799289929993099319932993399349935993699379938993999409941994299439944994599469947994899499950995199529953995499559956995799589959996099619962996399649965996699679968996999709971997299739974997599769977997899799980998199829983998499859986998799889989999099919992999399949995999699979998999910000100011000210003100041000510006100071000810009100101001110012100131001410015100161001710018100191002010021100221002310024100251002610027100281002910030100311003210033100341003510036100371003810039100401004110042100431004410045100461004710048100491005010051100521005310054100551005610057100581005910060100611006210063100641006510066100671006810069100701007110072100731007410075100761007710078100791008010081100821008310084100851008610087100881008910090100911009210093100941009510096100971009810099101001010110102101031010410105101061010710108101091011010111101121011310114101151011610117101181011910120101211012210123101241012510126101271012810129101301013110132101331013410135101361013710138101391014010141101421014310144101451014610147101481014910150101511015210153101541015510156101571015810159101601016110162101631016410165101661016710168101691017010171101721017310174101751017610177101781017910180101811018210183101841018510186101871018810189101901019110192101931019410195101961019710198101991020010201102021020310204102051020610207102081020910210102111021210213102141021510216102171021810219102201022110222102231022410225102261022710228102291023010231102321023310234102351023610237102381023910240102411024210243102441024510246102471024810249102501025110252102531025410255102561025710258102591026010261102621026310264102651026610267102681026910270102711027210273102741027510276102771027810279102801028110282102831028410285102861028710288102891029010291102921029310294102951029610297102981029910300103011030210303103041030510306103071030810309103101031110312103131031410315103161031710318103191032010321103221032310324103251032610327103281032910330103311033210333103341033510336103371033810339103401034110342103431034410345103461034710348103491035010351103521035310354103551035610357103581035910360103611036210363103641036510366103671036810369103701037110372103731037410375103761037710378103791038010381103821038310384103851038610387103881038910390103911039210393103941039510396103971039810399104001040110402104031040410405104061040710408104091041010411104121041310414104151041610417104181041910420104211042210423104241042510426104271042810429104301043110432104331043410435104361043710438104391044010441104421044310444104451044610447104481044910450104511045210453104541045510456104571045810459104601046110462104631046410465104661046710468104691047010471104721047310474104751047610477104781047910480104811048210483104841048510486104871048810489104901049110492104931049410495104961049710498104991050010501105021050310504105051050610507105081050910510105111051210513105141051510516105171051810519105201052110522105231052410525105261052710528105291053010531105321053310534105351053610537105381053910540105411054210543105441054510546105471054810549105501055110552105531055410555105561055710558105591056010561105621056310564105651056610567105681056910570105711057210573105741057510576105771057810579105801058110582105831058410585105861058710588105891059010591105921059310594105951059610597105981059910600106011060210603106041060510606106071060810609106101061110612106131061410615106161061710618106191062010621106221062310624106251062610627106281062910630106311063210633106341063510636106371063810639106401064110642106431064410645106461064710648106491065010651106521065310654106551065610657106581065910660106611066210663106641066510666106671066810669106701067110672106731067410675106761067710678106791068010681106821068310684106851068610687106881068910690106911069210693106941069510696106971069810699107001070110702107031070410705107061070710708107091071010711107121071310714107151071610717107181071910720107211072210723107241072510726107271072810729107301073110732107331073410735107361073710738107391074010741107421074310744107451074610747107481074910750107511075210753107541075510756107571075810759107601076110762107631076410765107661076710768107691077010771107721077310774107751077610777107781077910780107811078210783107841078510786107871078810789107901079110792107931079410795107961079710798107991080010801108021080310804108051080610807108081080910810108111081210813108141081510816108171081810819108201082110822108231082410825108261082710828108291083010831108321083310834108351083610837108381083910840108411084210843108441084510846108471084810849108501085110852108531085410855108561085710858108591086010861108621086310864108651086610867108681086910870108711087210873108741087510876108771087810879108801088110882108831088410885108861088710888108891089010891108921089310894108951089610897108981089910900109011090210903109041090510906109071090810909109101091110912109131091410915109161091710918109191092010921109221092310924109251092610927109281092910930109311093210933109341093510936109371093810939109401094110942109431094410945109461094710948109491095010951109521095310954109551095610957109581095910960109611096210963109641096510966109671096810969109701097110972109731097410975109761097710978109791098010981109821098310984109851098610987109881098910990109911099210993109941099510996109971099810999110001100111002110031100411005110061100711008110091101011011110121101311014110151101611017110181101911020110211102211023110241102511026110271102811029110301103111032110331103411035110361103711038110391104011041110421104311044110451104611047110481104911050110511105211053110541105511056110571105811059110601106111062110631106411065110661106711068110691107011071110721107311074110751107611077110781107911080110811108211083110841108511086110871108811089110901109111092110931109411095110961109711098110991110011101111021110311104111051110611107111081110911110111111111211113111141111511116111171111811119111201112111122111231112411125111261112711128111291113011131111321113311134111351113611137111381113911140111411114211143111441114511146111471114811149111501115111152111531115411155111561115711158111591116011161111621116311164111651116611167111681116911170111711117211173111741117511176111771117811179111801118111182111831118411185111861118711188111891119011191111921119311194111951119611197111981119911200112011120211203112041120511206112071120811209112101121111212112131121411215112161121711218112191122011221112221122311224112251122611227112281122911230112311123211233112341123511236112371123811239112401124111242112431124411245112461124711248112491125011251112521125311254112551125611257112581125911260112611126211263112641126511266112671126811269112701127111272112731127411275112761127711278112791128011281112821128311284112851128611287112881128911290112911129211293112941129511296112971129811299113001130111302113031130411305113061130711308113091131011311113121131311314113151131611317113181131911320113211132211323113241132511326113271132811329113301133111332113331133411335113361133711338113391134011341113421134311344113451134611347113481134911350113511135211353113541135511356113571135811359113601136111362113631136411365113661136711368113691137011371113721137311374113751137611377113781137911380113811138211383113841138511386113871138811389113901139111392113931139411395113961139711398113991140011401114021140311404114051140611407114081140911410114111141211413114141141511416114171141811419114201142111422114231142411425114261142711428114291143011431114321143311434114351143611437114381143911440114411144211443114441144511446114471144811449114501145111452114531145411455114561145711458114591146011461114621146311464114651146611467114681146911470114711147211473114741147511476114771147811479114801148111482114831148411485114861148711488114891149011491114921149311494114951149611497114981149911500115011150211503115041150511506115071150811509115101151111512115131151411515115161151711518115191152011521115221152311524115251152611527115281152911530115311153211533115341153511536115371153811539115401154111542115431154411545115461154711548115491155011551115521155311554115551155611557115581155911560115611156211563115641156511566115671156811569115701157111572115731157411575115761157711578115791158011581115821158311584115851158611587115881158911590115911159211593115941159511596115971159811599116001160111602116031160411605116061160711608116091161011611116121161311614116151161611617116181161911620116211162211623116241162511626116271162811629116301163111632116331163411635116361163711638116391164011641116421164311644116451164611647116481164911650116511165211653116541165511656116571165811659116601166111662116631166411665116661166711668116691167011671116721167311674116751167611677116781167911680116811168211683116841168511686116871168811689116901169111692116931169411695116961169711698116991170011701117021170311704117051170611707117081170911710117111171211713117141171511716117171171811719117201172111722117231172411725117261172711728117291173011731117321173311734117351173611737117381173911740117411174211743117441174511746117471174811749117501175111752117531175411755117561175711758117591176011761117621176311764117651176611767117681176911770117711177211773117741177511776117771177811779117801178111782117831178411785117861178711788117891179011791117921179311794117951179611797117981179911800118011180211803118041180511806118071180811809118101181111812118131181411815118161181711818118191182011821118221182311824118251182611827118281182911830118311183211833118341183511836118371183811839118401184111842118431184411845118461184711848118491185011851118521185311854118551185611857118581185911860118611186211863118641186511866118671186811869118701187111872118731187411875118761187711878118791188011881118821188311884118851188611887118881188911890118911189211893118941189511896118971189811899119001190111902119031190411905119061190711908119091191011911119121191311914119151191611917119181191911920119211192211923119241192511926119271192811929119301193111932119331193411935119361193711938119391194011941119421194311944119451194611947119481194911950119511195211953119541195511956119571195811959119601196111962119631196411965119661196711968119691197011971119721197311974119751197611977119781197911980119811198211983119841198511986119871198811989119901199111992119931199411995119961199711998119991200012001120021200312004120051200612007120081200912010120111201212013120141201512016120171201812019120201202112022120231202412025120261202712028120291203012031120321203312034120351203612037120381203912040120411204212043120441204512046120471204812049120501205112052120531205412055120561205712058120591206012061120621206312064120651206612067120681206912070120711207212073120741207512076120771207812079120801208112082120831208412085120861208712088120891209012091120921209312094120951209612097120981209912100121011210212103121041210512106121071210812109121101211112112121131211412115121161211712118121191212012121121221212312124121251212612127121281212912130121311213212133121341213512136121371213812139121401214112142121431214412145121461214712148121491215012151121521215312154121551215612157121581215912160121611216212163121641216512166121671216812169121701217112172121731217412175121761217712178121791218012181121821218312184121851218612187121881218912190121911219212193121941219512196121971219812199122001220112202122031220412205122061220712208122091221012211122121221312214122151221612217122181221912220122211222212223122241222512226122271222812229122301223112232122331223412235122361223712238122391224012241122421224312244122451224612247122481224912250122511225212253122541225512256122571225812259122601226112262122631226412265122661226712268122691227012271122721227312274122751227612277122781227912280122811228212283122841228512286122871228812289122901229112292122931229412295122961229712298122991230012301123021230312304123051230612307123081230912310123111231212313123141231512316123171231812319123201232112322123231232412325123261232712328123291233012331123321233312334123351233612337123381233912340123411234212343123441234512346123471234812349123501235112352123531235412355123561235712358123591236012361123621236312364123651236612367123681236912370123711237212373123741237512376123771237812379123801238112382123831238412385123861238712388123891239012391123921239312394
  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. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  5705. var cert_no string
  5706. if his.IdCardType == 1 {
  5707. cert_no = strings.Split(psn_info.CardInfo, "|")[0]
  5708. }
  5709. fmt.Println(cert_no)
  5710. 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)
  5711. //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)
  5712. var dat map[string]interface{}
  5713. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  5714. fmt.Println(dat)
  5715. } else {
  5716. fmt.Println(err)
  5717. }
  5718. saveLog(result2, src_resquest, "2207", "结算")
  5719. userJSONBytes, _ := json.Marshal(dat)
  5720. if err := json.Unmarshal(userJSONBytes, &resSeven10265); err != nil {
  5721. utils.ErrorLog("解析失败:%v", err)
  5722. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5723. return
  5724. }
  5725. res.InfRefmsgid = resSeven10265.InfRefmsgid
  5726. res.Output = resSeven10265.Output
  5727. res.ErrMsg = resSeven10265.ErrMsg
  5728. res.Cainfo = resSeven10265.Cainfo
  5729. res.WarnMsg = resSeven10265.WarnMsg
  5730. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  5731. res.Infcode = infocode
  5732. } else {
  5733. if miConfig.Code == "H15049901371" {
  5734. //赤峰地区国家医保医疗类别
  5735. //职工透析:医疗类别选特殊情况门诊990502
  5736. //居民定额血透门慢: 医疗类别选门诊慢病140104
  5737. var med_type string
  5738. if his.Insutype == "390" {
  5739. if reg_type == 14 {
  5740. med_type = "9933"
  5741. } else if reg_type == 11 {
  5742. med_type = "11"
  5743. }
  5744. } else if his.Insutype == "310" {
  5745. if reg_type == 14 {
  5746. med_type = "990502"
  5747. } else if reg_type == 11 {
  5748. med_type = "11"
  5749. }
  5750. }
  5751. 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)
  5752. } else {
  5753. 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)
  5754. }
  5755. //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)
  5756. var dat map[string]interface{}
  5757. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  5758. fmt.Println(dat)
  5759. } else {
  5760. fmt.Println(err)
  5761. }
  5762. saveLog(result2, src_resquest, "2207", "结算")
  5763. userJSONBytes, _ := json.Marshal(dat)
  5764. if miConfig.Code == "H15049901371" {
  5765. if err := json.Unmarshal(userJSONBytes, &resSeven10265); err != nil {
  5766. utils.ErrorLog("解析失败:%v", err)
  5767. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5768. return
  5769. }
  5770. res.InfRefmsgid = resSeven10265.InfRefmsgid
  5771. res.Output = resSeven10265.Output
  5772. res.ErrMsg = resSeven10265.ErrMsg
  5773. res.Cainfo = resSeven10265.Cainfo
  5774. res.WarnMsg = resSeven10265.WarnMsg
  5775. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  5776. res.Infcode = infocode
  5777. } else {
  5778. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  5779. utils.ErrorLog("解析失败:%v", err)
  5780. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5781. return
  5782. }
  5783. }
  5784. }
  5785. if res.Infcode != 0 {
  5786. errlog := &models.HisOrderError{
  5787. UserOrgId: adminUser.CurrentOrgId,
  5788. Ctime: time.Now().Unix(),
  5789. Mtime: time.Now().Unix(),
  5790. Number: chrg_bchno,
  5791. ErrMsg: res.ErrMsg,
  5792. Status: 1,
  5793. PatientId: id,
  5794. RecordTime: recordDateTime,
  5795. Stage: 6,
  5796. }
  5797. service.CreateErrMsgLog(errlog)
  5798. c.ServeSuccessJSON(map[string]interface{}{
  5799. "failed_code": -10,
  5800. "msg": res.ErrMsg,
  5801. })
  5802. return
  5803. } else {
  5804. order, _ := service.GetHisOrderTwo(adminUser.CurrentOrgId, chrg_bchno, id)
  5805. order.OrderStatus = 2
  5806. order.Status = 1
  5807. order.MdtrtId = res.Output.Setlinfo.MdtrtID
  5808. order.SetlId = res.Output.Setlinfo.SetlID
  5809. order.PsnNo = res.Output.Setlinfo.PsnNo
  5810. order.PsnName = res.Output.Setlinfo.PsnName
  5811. order.PsnCertType = res.Output.Setlinfo.PsnCertType
  5812. order.Certno = res.Output.Setlinfo.Certno
  5813. order.Gend = res.Output.Setlinfo.Gend
  5814. order.Naty = res.Output.Setlinfo.Naty
  5815. order.Age = res.Output.Setlinfo.Age
  5816. order.Insutype = res.Output.Setlinfo.Insutype
  5817. order.PsnType = res.Output.Setlinfo.PsnType
  5818. order.CvlservFlag = res.Output.Setlinfo.CvlservFlag
  5819. order.SetlTime = res.Output.Setlinfo.SetlTime
  5820. order.MdtrtCertType = res.Output.Setlinfo.MdtrtCertType
  5821. if res.Output.Setlinfo.MedType == "140101" {
  5822. order.MedType = "14"
  5823. } else {
  5824. order.MedType = res.Output.Setlinfo.MedType
  5825. }
  5826. if reg_type == 1112 {
  5827. order.MedType = "1112"
  5828. }
  5829. if reg_type == 1111 {
  5830. order.MedType = "1111"
  5831. }
  5832. order.MedfeeSumamt = res.Output.Setlinfo.MedfeeSumamt
  5833. order.FulamtOwnpayAmt = res.Output.Setlinfo.FulamtOwnpayAmt
  5834. order.OverlmtSelfPay = res.Output.Setlinfo.OverlmtSelfpay
  5835. order.PreselfpayAmt = res.Output.Setlinfo.PreselfpayAmt
  5836. order.InscpScpAmt = res.Output.Setlinfo.InscpScpAmt
  5837. order.ActPayDedc = res.Output.Setlinfo.ActPayDedc
  5838. order.HifpPay = res.Output.Setlinfo.HifpPay
  5839. order.CvlservPay = res.Output.Setlinfo.CvlservPay
  5840. order.PoolPropSelfpay = res.Output.Setlinfo.PoolPropSelfpay
  5841. order.HifesPay = res.Output.Setlinfo.HifesPay
  5842. order.HifobPay = res.Output.Setlinfo.HifobPay
  5843. order.MafPay = res.Output.Setlinfo.MafPay
  5844. order.HifmiPay = res.Output.Setlinfo.HifmiPay
  5845. order.OthPay = res.Output.Setlinfo.OthPay
  5846. order.FundPaySumamt = res.Output.Setlinfo.FundPaySumamt
  5847. order.PsnPartAmt = res.Output.Setlinfo.PsnPartAmt
  5848. order.AcctPay = res.Output.Setlinfo.AcctPay
  5849. order.PsnCashPay = res.Output.Setlinfo.PsnCashPay
  5850. order.HospPartAmt = res.Output.Setlinfo.HospPartAmt
  5851. order.Balc = res.Output.Setlinfo.Balc
  5852. order.AcctMulaidPay = res.Output.Setlinfo.AcctMulaidPay
  5853. order.MedinsSetlId = res.Output.Setlinfo.MedinsSetlID
  5854. order.ClrOptins = res.Output.Setlinfo.ClrOptins
  5855. order.ClrType = res.Output.Setlinfo.ClrType
  5856. order.ClrWay = res.Output.Setlinfo.ClrWay
  5857. order.Creator = order.Creator
  5858. order.Modify = roles.AdminUserId
  5859. order.RequestLog = src_resquest
  5860. setlDetail, _ := json.Marshal(res.Output.Setldetail)
  5861. detailStr := string(setlDetail)
  5862. order.SetlDetail = detailStr
  5863. err := service.UpdataOrderStatusTwo(chrg_bchno, adminUser.CurrentOrgId)
  5864. err = service.UpDateOrder(order)
  5865. if err == nil {
  5866. //判断是否使用了押金
  5867. if dec_way == "true" {
  5868. tmpstring := strconv.FormatInt(order.ID, 10)
  5869. order.Decimal = decimal
  5870. service.UpDateOrder(order)
  5871. //扣押金
  5872. errmsg = service.SpendDeposit(c.GetAdminUserInfo().CurrentOrgId, id, c.GetAdminUserInfo().AdminUser.Id, tmpstring, decimal)
  5873. if errmsg != nil {
  5874. c.ServeFailJsonSend(enums.ErrorCodeParamWrong, errmsg.Error())
  5875. return
  5876. }
  5877. }
  5878. c.ServeSuccessJSON(map[string]interface{}{
  5879. "msg": "结算成功",
  5880. })
  5881. } else {
  5882. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeAmountAccountException)
  5883. return
  5884. }
  5885. }
  5886. } else {
  5887. adminUser := c.GetAdminUserInfo()
  5888. errlog := &models.HisOrderError{
  5889. UserOrgId: adminUser.CurrentOrgId,
  5890. Ctime: time.Now().Unix(),
  5891. Mtime: time.Now().Unix(),
  5892. ErrMsg: res.ErrMsg,
  5893. Status: 1,
  5894. PatientId: id,
  5895. RecordTime: recordDateTime,
  5896. Stage: 4,
  5897. }
  5898. service.CreateErrMsgLog(errlog)
  5899. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeRegisterRepeatException)
  5900. return
  5901. }
  5902. } else {
  5903. adminUser := c.GetAdminUserInfo()
  5904. errlog := &models.HisOrderError{
  5905. UserOrgId: adminUser.CurrentOrgId,
  5906. Ctime: time.Now().Unix(),
  5907. Mtime: time.Now().Unix(),
  5908. ErrMsg: res.ErrMsg,
  5909. Status: 1,
  5910. PatientId: id,
  5911. RecordTime: recordDateTime,
  5912. Stage: 4,
  5913. }
  5914. service.CreateErrMsgLog(errlog)
  5915. c.ServeSuccessJSON(map[string]interface{}{
  5916. "failed_code": -10,
  5917. "msg": res.ErrMsg,
  5918. })
  5919. return
  5920. //c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCalOrderException)
  5921. //return
  5922. }
  5923. }
  5924. }
  5925. } else if tempOrder.ID > 0 {
  5926. if tempOrder.IsPre == 1 {
  5927. allTotal := fmt.Sprintf("%.4f", tempOrder.MedfeeSumamt)
  5928. var rf []*ResultFive
  5929. json.Unmarshal([]byte(his.Iinfo), &rf)
  5930. chrg_bchno := tempOrder.Number
  5931. cert_no := his.Certno
  5932. var insutypes []string
  5933. var insutype string
  5934. var is390 int = 0
  5935. var is310 int = 0
  5936. for _, item := range rf {
  5937. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  5938. insutypes = append(insutypes, item.Insutype)
  5939. }
  5940. }
  5941. if len(insutypes) == 1 {
  5942. insutype = insutypes[0]
  5943. } else {
  5944. for _, i := range insutypes {
  5945. if i == "390" {
  5946. is390 = 1
  5947. }
  5948. if i == "310" {
  5949. is310 = 1
  5950. }
  5951. }
  5952. }
  5953. if is390 == 1 {
  5954. insutype = "390"
  5955. }
  5956. if is310 == 1 {
  5957. insutype = "310"
  5958. }
  5959. if len(insutypes) == 0 {
  5960. insutype = "310"
  5961. }
  5962. if len(insutypes) == 2 {
  5963. insutype = strconv.FormatInt(his.SocialType, 64)
  5964. }
  5965. //insutype = "390"
  5966. if his.IdCardType == 1 {
  5967. // cert_no = his.MedicalInsuranceNumber
  5968. cert_no = his.Certno
  5969. } else {
  5970. cert_no = his.Certno
  5971. }
  5972. var res ResultSeven
  5973. var resSeven10265 ResultSeven10265
  5974. var src_resquest string
  5975. var result2 string
  5976. var acct_used_flag string
  5977. fmt.Println("pay_way")
  5978. fmt.Println(pay_way)
  5979. fmt.Println("pay_way")
  5980. if pay_way == 4 {
  5981. acct_used_flag = "1"
  5982. } else {
  5983. acct_used_flag = "0"
  5984. }
  5985. if miConfig.MdtrtareaAdmvs == "421300" {
  5986. api := "http://192.168.124.4:9532/" + "hbyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  5987. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  5988. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  5989. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  5990. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  5991. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  5992. "&insutype=" + insutype + "&total=" + allTotal + "&med_type=" + strconv.FormatInt(reg_type, 10) + "&acct_used_flag=" + acct_used_flag
  5993. resp, requestErr := http.Get(api)
  5994. if requestErr != nil {
  5995. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5996. return
  5997. }
  5998. body, ioErr := ioutil.ReadAll(resp.Body)
  5999. if ioErr != nil {
  6000. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  6001. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6002. return
  6003. }
  6004. var respJSON map[string]interface{}
  6005. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  6006. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  6007. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6008. return
  6009. }
  6010. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  6011. result, _ := json.Marshal(respJSON)
  6012. fmt.Println("log")
  6013. fmt.Println(string(result))
  6014. if err := json.Unmarshal([]byte(result), &res); err != nil {
  6015. utils.ErrorLog("解析失败:%v", err)
  6016. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6017. return
  6018. }
  6019. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  6020. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  6021. psn_info.VerifyNumber = strings.Replace(psn_info.VerifyNumber, "+", "%2B", -1)
  6022. //psn_info, _ := service.GetPsnByPatientId(id)
  6023. bas := strings.Split(psn_info.CardInfo, "|")
  6024. if his.IdCardType == 1 {
  6025. cert_no = bas[2]
  6026. } else {
  6027. cert_no = bas[1]
  6028. }
  6029. //江苏地区国家医保医疗类别
  6030. //职工透析:医疗类别选特殊情况门诊9933
  6031. //居民血透门慢: 医疗类别选门诊慢病1402
  6032. //var med_type string
  6033. //if his.Insutype == "310" {
  6034. // if reg_type == 14 {
  6035. // med_type = "9933"
  6036. // } else if reg_type == 11 {
  6037. // med_type = "11"
  6038. //
  6039. // }
  6040. //} else if his.Insutype == "390" {
  6041. // if reg_type == 14 {
  6042. // med_type = "1402"
  6043. // } else if reg_type == 11 {
  6044. // med_type = "11"
  6045. // }
  6046. //}
  6047. var api string
  6048. if miConfig.MdtrtareaAdmvs == "320921" {
  6049. api = "http://192.168.2.110:9532/" + "jsyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  6050. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  6051. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  6052. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  6053. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  6054. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  6055. "&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
  6056. //req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  6057. } else {
  6058. //req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  6059. api = "http://192.168.5.251:9532/" + "jsyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  6060. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  6061. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  6062. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  6063. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  6064. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  6065. "&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
  6066. }
  6067. resp, requestErr := http.Get(api)
  6068. if requestErr != nil {
  6069. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6070. return
  6071. }
  6072. body, ioErr := ioutil.ReadAll(resp.Body)
  6073. if ioErr != nil {
  6074. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  6075. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6076. return
  6077. }
  6078. var respJSON map[string]interface{}
  6079. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  6080. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  6081. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6082. return
  6083. }
  6084. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  6085. result, _ := json.Marshal(respJSON)
  6086. fmt.Println("log")
  6087. fmt.Println(string(result))
  6088. if err := json.Unmarshal([]byte(result), &resSeven10265); err != nil {
  6089. utils.ErrorLog("解析失败:%v", err)
  6090. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6091. return
  6092. }
  6093. res.InfRefmsgid = resSeven10265.InfRefmsgid
  6094. res.Output = resSeven10265.Output
  6095. res.ErrMsg = resSeven10265.ErrMsg
  6096. res.Cainfo = resSeven10265.Cainfo
  6097. res.WarnMsg = resSeven10265.WarnMsg
  6098. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  6099. res.Infcode = infocode
  6100. } else if miConfig.MdtrtareaAdmvs == "350500" {
  6101. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  6102. var cert_no string
  6103. if his.IdCardType == 1 {
  6104. cert_no = strings.Split(psn_info.CardInfo, "|")[0]
  6105. }
  6106. fmt.Println(cert_no)
  6107. 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)
  6108. var dat map[string]interface{}
  6109. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  6110. fmt.Println(dat)
  6111. } else {
  6112. fmt.Println(err)
  6113. }
  6114. saveLog(result2, src_resquest, "2207", "结算")
  6115. userJSONBytes, _ := json.Marshal(dat)
  6116. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  6117. utils.ErrorLog("解析失败:%v", err)
  6118. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6119. return
  6120. }
  6121. } else {
  6122. var src_resquest string
  6123. if miConfig.Code == "H15049901371" {
  6124. //赤峰地区国家医保医疗类别
  6125. //职工透析:医疗类别选特殊情况门诊990502
  6126. //居民定额血透门慢: 医疗类别选门诊慢病140104
  6127. var med_type string
  6128. if his.Insutype == "390" {
  6129. if reg_type == 14 {
  6130. med_type = "9933"
  6131. } else if reg_type == 11 {
  6132. med_type = "11"
  6133. }
  6134. } else if his.Insutype == "310" {
  6135. if reg_type == 14 {
  6136. med_type = "990502"
  6137. } else if reg_type == 11 {
  6138. med_type = "11"
  6139. }
  6140. }
  6141. 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)
  6142. } else {
  6143. 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)
  6144. }
  6145. var dat map[string]interface{}
  6146. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  6147. fmt.Println(dat)
  6148. } else {
  6149. fmt.Println(err)
  6150. }
  6151. saveLog(result2, src_resquest, "2207", "结算")
  6152. userJSONBytes, _ := json.Marshal(dat)
  6153. if miConfig.Code == "H15049901371" {
  6154. if err := json.Unmarshal(userJSONBytes, &resSeven10265); err != nil {
  6155. utils.ErrorLog("解析失败:%v", err)
  6156. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6157. return
  6158. }
  6159. res.InfRefmsgid = resSeven10265.InfRefmsgid
  6160. res.Output = resSeven10265.Output
  6161. res.ErrMsg = resSeven10265.ErrMsg
  6162. res.Cainfo = resSeven10265.Cainfo
  6163. res.WarnMsg = resSeven10265.WarnMsg
  6164. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  6165. res.Infcode = infocode
  6166. } else {
  6167. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  6168. utils.ErrorLog("解析失败:%v", err)
  6169. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6170. return
  6171. }
  6172. }
  6173. }
  6174. if res.Infcode != 0 {
  6175. errlog := &models.HisOrderError{
  6176. UserOrgId: adminUser.CurrentOrgId,
  6177. Ctime: time.Now().Unix(),
  6178. Mtime: time.Now().Unix(),
  6179. Number: chrg_bchno,
  6180. ErrMsg: res.ErrMsg,
  6181. Status: 1,
  6182. PatientId: id,
  6183. RecordTime: recordDateTime,
  6184. Stage: 6,
  6185. }
  6186. service.CreateErrMsgLog(errlog)
  6187. c.ServeSuccessJSON(map[string]interface{}{
  6188. "failed_code": -10,
  6189. "msg": res.ErrMsg,
  6190. })
  6191. return
  6192. } else {
  6193. order, _ := service.GetHisOrderTwo(adminUser.CurrentOrgId, chrg_bchno, id)
  6194. order.OrderStatus = 2
  6195. order.MdtrtId = res.Output.Setlinfo.MdtrtID
  6196. order.SetlId = res.Output.Setlinfo.SetlID
  6197. order.PsnNo = res.Output.Setlinfo.PsnNo
  6198. order.PsnName = res.Output.Setlinfo.PsnName
  6199. order.PsnCertType = res.Output.Setlinfo.PsnCertType
  6200. order.Certno = res.Output.Setlinfo.Certno
  6201. order.Gend = res.Output.Setlinfo.Gend
  6202. order.Naty = res.Output.Setlinfo.Naty
  6203. order.Age = res.Output.Setlinfo.Age
  6204. order.Insutype = res.Output.Setlinfo.Insutype
  6205. order.PsnType = res.Output.Setlinfo.PsnType
  6206. order.CvlservFlag = res.Output.Setlinfo.CvlservFlag
  6207. order.SetlTime = res.Output.Setlinfo.SetlTime
  6208. order.MdtrtCertType = res.Output.Setlinfo.MdtrtCertType
  6209. //order.MedType = res.Output.Setlinfo.MedType
  6210. if reg_type == 1112 {
  6211. order.MedType = "1112"
  6212. }
  6213. if reg_type == 1111 {
  6214. order.MedType = "1111"
  6215. }
  6216. order.MedfeeSumamt = res.Output.Setlinfo.MedfeeSumamt
  6217. order.FulamtOwnpayAmt = res.Output.Setlinfo.FulamtOwnpayAmt
  6218. order.OverlmtSelfPay = res.Output.Setlinfo.OverlmtSelfpay
  6219. order.PreselfpayAmt = res.Output.Setlinfo.PreselfpayAmt
  6220. order.InscpScpAmt = res.Output.Setlinfo.InscpScpAmt
  6221. order.ActPayDedc = res.Output.Setlinfo.ActPayDedc
  6222. order.HifpPay = res.Output.Setlinfo.HifpPay
  6223. order.CvlservPay = res.Output.Setlinfo.CvlservPay
  6224. order.PoolPropSelfpay = res.Output.Setlinfo.PoolPropSelfpay
  6225. order.HifesPay = res.Output.Setlinfo.HifesPay
  6226. order.HifobPay = res.Output.Setlinfo.HifobPay
  6227. order.MafPay = res.Output.Setlinfo.MafPay
  6228. order.HifmiPay = res.Output.Setlinfo.HifmiPay
  6229. order.OthPay = res.Output.Setlinfo.OthPay
  6230. order.FundPaySumamt = res.Output.Setlinfo.FundPaySumamt
  6231. order.PsnPartAmt = res.Output.Setlinfo.PsnPartAmt
  6232. order.AcctPay = res.Output.Setlinfo.AcctPay
  6233. order.PsnCashPay = res.Output.Setlinfo.PsnCashPay
  6234. order.HospPartAmt = res.Output.Setlinfo.HospPartAmt
  6235. order.Balc = res.Output.Setlinfo.Balc
  6236. order.AcctMulaidPay = res.Output.Setlinfo.AcctMulaidPay
  6237. order.MedinsSetlId = res.Output.Setlinfo.MedinsSetlID
  6238. order.ClrOptins = res.Output.Setlinfo.ClrOptins
  6239. order.ClrWay = res.Output.Setlinfo.ClrWay
  6240. order.Creator = order.Creator
  6241. order.Modify = roles.AdminUserId
  6242. order.RequestLog = src_resquest
  6243. order.Diagnosis = diagnosis_id
  6244. setlDetail, _ := json.Marshal(res.Output.Setldetail)
  6245. detailStr := string(setlDetail)
  6246. order.SetlDetail = detailStr
  6247. err := service.UpdataOrderStatusTwo(chrg_bchno, adminUser.CurrentOrgId)
  6248. err = service.UpDateOrder(order)
  6249. if err == nil {
  6250. //判断是否使用了押金
  6251. if dec_way == "true" {
  6252. tmpstring := strconv.FormatInt(order.ID, 10)
  6253. //扣押金
  6254. order.Decimal = decimal
  6255. service.UpDateOrder(order)
  6256. errmsg = service.SpendDeposit(c.GetAdminUserInfo().CurrentOrgId, id, c.GetAdminUserInfo().AdminUser.Id, tmpstring, decimal)
  6257. if errmsg != nil {
  6258. c.ServeFailJsonSend(enums.ErrorCodeParamWrong, errmsg.Error())
  6259. return
  6260. }
  6261. }
  6262. c.ServeSuccessJSON(map[string]interface{}{
  6263. "msg": "结算成功",
  6264. })
  6265. } else {
  6266. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeAmountAccountException)
  6267. return
  6268. }
  6269. }
  6270. }
  6271. }
  6272. }
  6273. //func (c *HisApiController) GetPreUploadInfo() {
  6274. // id, _ := c.GetInt64("id")
  6275. // record_time := c.GetString("record_time")
  6276. // settle_accounts_type, _ := c.GetInt64("settle_accounts_type")
  6277. // admin_user_id, _ := c.GetInt64("admin_user_id")
  6278. //
  6279. // timeLayout := "2006-01-02"
  6280. // loc, _ := time.LoadLocation("Local")
  6281. // theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  6282. // if err != nil {
  6283. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  6284. // return
  6285. // }
  6286. // recordDateTime := theTime.Unix()
  6287. // adminUser := c.GetAdminUserInfo()
  6288. //
  6289. // var prescriptions []*models.HisPrescription
  6290. //
  6291. // var start_time int64
  6292. // var end_time int64
  6293. //
  6294. // data := make(map[string]interface{})
  6295. // if settle_accounts_type == 1 { //日结
  6296. // prescriptions, _ = service.GetHisPrescription(adminUser.CurrentOrgId, id, recordDateTime)
  6297. // data["pre"] = prescriptions
  6298. //
  6299. // } else { //月结
  6300. // start_time_str := c.GetString("start_time")
  6301. // end_time_str := c.GetString("end_time")
  6302. // timeLayout := "2006-01-02"
  6303. // loc, _ := time.LoadLocation("Local")
  6304. // theStartTime, err := time.ParseInLocation(timeLayout+" 15:04:05", start_time_str+" 00:00:00", loc)
  6305. // if err != nil {
  6306. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  6307. // return
  6308. // }
  6309. // recordStartTime := theStartTime.Unix()
  6310. // start_time = recordStartTime
  6311. // theEndTime, err := time.ParseInLocation(timeLayout+" 15:04:05", end_time_str+" 00:00:00", loc)
  6312. // if err != nil {
  6313. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  6314. // return
  6315. // }
  6316. // recordEndTime := theEndTime.Unix()
  6317. // end_time = recordEndTime
  6318. // prescriptions, _ = service.GetMonthHisPrescription(adminUser.CurrentOrgId, id, recordStartTime, recordEndTime)
  6319. // data["pre"] = prescriptions
  6320. //
  6321. // }
  6322. //
  6323. // roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  6324. //
  6325. // his, _ := service.GetVMHisPatientInfo(adminUser.CurrentOrgId, id, recordDateTime)
  6326. // timestamp := time.Now().Unix()
  6327. // tempTime := time.Unix(timestamp, 0)
  6328. // timeFormat := tempTime.Format("20060102150405")
  6329. // chrgBchno := rand.Intn(100000) + 10000
  6330. // chrg_bchno := timeFormat + strconv.FormatInt(int64(chrgBchno), 10) + strconv.FormatInt(his.PatientId, 10)
  6331. // miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  6332. // patientPrescription, _ := service.FindPatientPrescriptionInfo(adminUser.CurrentOrgId, id, recordDateTime)
  6333. // department, _ := service.GetDepartMentDetail(patientPrescription.Departments)
  6334. // strconv.FormatInt(his.PatientId, 10)
  6335. // client := &http.Client{}
  6336. // data["psn_no"] = his.PsnNo
  6337. // data["mdtrt_id"] = his.Number
  6338. // data["chrg_bchno"] = chrg_bchno
  6339. // data["org_name"] = miConfig.OrgName
  6340. // data["doctor"] = roles.UserName
  6341. // data["doctor_id"] = strconv.FormatInt(roles.AdminUserId, 10)
  6342. // data["dept"] = strconv.FormatInt(patientPrescription.Departments, 10)
  6343. // data["fixmedins_code"] = miConfig.Code
  6344. // data["dept_code"] = department.Number
  6345. // data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  6346. // data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  6347. // data["secret_key"] = miConfig.SecretKey
  6348. // var ids []int64
  6349. //
  6350. // for _, item := range prescriptions {
  6351. // ids = append(ids, item.ID)
  6352. // }
  6353. // config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  6354. // if config.IsOpen == 1 { //对接了医保,走医保流程
  6355. // bytesData, _ := json.Marshal(data)
  6356. // req, _ := http.NewRequest("POST", "http://127.0.0.1:9532/"+"gdyb/five", bytes.NewReader(bytesData))
  6357. // resp, _ := client.Do(req)
  6358. // defer resp.Body.Close()
  6359. // body, ioErr := ioutil.ReadAll(resp.Body)
  6360. // if ioErr != nil {
  6361. // utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  6362. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6363. // return
  6364. // }
  6365. // var respJSON map[string]interface{}
  6366. // if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  6367. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  6368. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6369. // return
  6370. // }
  6371. //
  6372. // respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  6373. // userJSONBytes, _ := json.Marshal(respJSON)
  6374. // var res ResultFour
  6375. // if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  6376. // utils.ErrorLog("解析失败:%v", err)
  6377. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6378. // return
  6379. // }
  6380. //
  6381. // if res.Infcode == 0 {
  6382. // order := &models.HisOrder{
  6383. // UserOrgId: adminUser.CurrentOrgId,
  6384. // HisPatientId: his.ID,
  6385. // PatientId: his.PatientId,
  6386. // SettleAccountsDate: recordDateTime,
  6387. // Ctime: time.Now().Unix(),
  6388. // Mtime: time.Now().Unix(),
  6389. // Status: 1,
  6390. // Number: chrg_bchno,
  6391. // Infcode: res.Infcode,
  6392. // WarnMsg: res.WarnMsg,
  6393. // Cainfo: res.Cainfo,
  6394. // ErrMsg: res.ErrMsg,
  6395. // RespondTime: res.RefmsgTime,
  6396. // InfRefmsgid: res.InfRefmsgid,
  6397. // OrderStatus: 1,
  6398. // IsMedicineInsurance: 1,
  6399. // SettleType: settle_accounts_type,
  6400. // SettleStartTime: start_time,
  6401. // SettleEndTime: end_time,
  6402. // Creator: roles.ID,
  6403. // Modify: roles.ID,
  6404. // PType: 2,
  6405. // }
  6406. // err = service.CreateOrder(order)
  6407. // if err != nil {
  6408. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCreatePreOrderException)
  6409. // return
  6410. // }
  6411. //
  6412. // for _, item := range res.Output.Result {
  6413. // temp := strings.Split(item.FeedetlSn, "-")
  6414. // var advice_id int64 = 0
  6415. // var project_id int64 = 0
  6416. // var types int64 = 0
  6417. //
  6418. // id, _ := strconv.ParseInt(temp[2], 10, 64)
  6419. // types, _ = strconv.ParseInt(temp[1], 10, 64)
  6420. //
  6421. // if temp[1] == "1" {
  6422. // advice_id = id
  6423. // project_id = 0
  6424. // } else if temp[1] == "2" {
  6425. // advice_id = 0
  6426. // project_id = id
  6427. // }
  6428. //
  6429. // info := &models.HisOrderInfo{
  6430. // OrderNumber: order.Number,
  6431. // FeedetlSn: item.FeedetlSn,
  6432. // UploadDate: time.Now().Unix(),
  6433. // AdviceId: advice_id,
  6434. // DetItemFeeSumamt: item.DetItemFeeSumamt,
  6435. // Cnt: item.Cnt,
  6436. // Pric: float64(item.Pric),
  6437. // PatientId: his.PatientId,
  6438. // PricUplmtAmt: item.PricUplmtAmt,
  6439. // SelfpayProp: item.SelfpayProp,
  6440. // FulamtOwnpayAmt: item.FulamtOwnpayAmt,
  6441. // OverlmtAmt: item.OverlmtAmt,
  6442. // PreselfpayAmt: item.PreselfpayAmt,
  6443. // BasMednFlag: item.BasMednFlag,
  6444. // MedChrgitmType: item.MedChrgitmType,
  6445. // HiNegoDrugFlag: item.HiNegoDrugFlag,
  6446. // Status: 1,
  6447. // Memo: item.Memo,
  6448. // Mtime: time.Now().Unix(),
  6449. // InscpScpAmt: item.InscpScpAmt,
  6450. // DrtReimFlag: item.DrtReimFlag,
  6451. // Ctime: time.Now().Unix(),
  6452. // ListSpItemFlag: item.ListSpItemFlag,
  6453. // ChldMedcFlag: item.ChldMedcFlag,
  6454. // LmtUsedFlag: item.LmtUsedFlag,
  6455. // ChrgitmLv: item.ChrgitmLv,
  6456. // UserOrgId: adminUser.CurrentOrgId,
  6457. // HisPatientId: his.ID,
  6458. // OrderId: order.ID,
  6459. // ProjectId: project_id,
  6460. // Type: types,
  6461. // }
  6462. // service.CreateOrderInfo(info)
  6463. //
  6464. // }
  6465. // service.UpDatePrescriptionNumber(adminUser.CurrentOrgId, ids, chrg_bchno)
  6466. // service.UpDatePrescriptionInfoNumber(adminUser.CurrentOrgId, patientPrescription.PatientId, chrg_bchno, recordDateTime)
  6467. //
  6468. // var total float64
  6469. // for _, item := range prescriptions {
  6470. // if item.Type == 1 { //药品
  6471. // for _, subItem := range item.HisDoctorAdviceInfo {
  6472. // total = total + (subItem.Price * subItem.PrescribingNumber)
  6473. // }
  6474. // }
  6475. // if item.Type == 2 { //项目
  6476. // for _, subItem := range item.HisPrescriptionProject {
  6477. // total = total + (subItem.Price * float64(subItem.Count))
  6478. // }
  6479. // }
  6480. // }
  6481. //
  6482. // for _, item := range prescriptions {
  6483. // for _, subItem := range item.HisAdditionalCharge {
  6484. // total = total + (subItem.Price * float64(subItem.Count))
  6485. // }
  6486. // }
  6487. //
  6488. // allTotal := fmt.Sprintf("%.2f", total)
  6489. // if res.Infcode == 0 {
  6490. // var rf []*ResultFive
  6491. // json.Unmarshal([]byte(his.Iinfo), &rf)
  6492. // psn_no := his.PsnNo
  6493. // mdtrt_id := his.Number
  6494. // chrg_bchno := chrg_bchno
  6495. // cert_no := his.Certno
  6496. // insutype := rf[0].Insutype
  6497. //
  6498. // if his.IdCardType == 1 {
  6499. // cert_no = his.MedicalInsuranceNumber
  6500. //
  6501. // } else {
  6502. //
  6503. // cert_no = his.Certno
  6504. //
  6505. // }
  6506. //
  6507. // api := "http://127.0.0.1:9532/" + "gdyb/seven?cert_no=" + cert_no + "&insutype=" +
  6508. // insutype + "&psn_no=" + psn_no + "&chrg_bchno=" + chrg_bchno + "&mdtrt_id=" + mdtrt_id +
  6509. // "&total=" + allTotal + "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code + "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" +
  6510. // miConfig.SecretKey + "&med_type=" + strconv.FormatInt(patientPrescription.RegisterType, 10) + "&id_card_type=" + strconv.FormatInt(int64(his.IdCardType), 10)
  6511. // resp, requestErr := http.Get(api)
  6512. // if requestErr != nil {
  6513. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6514. // return
  6515. // }
  6516. // defer resp.Body.Close()
  6517. // body, ioErr := ioutil.ReadAll(resp.Body)
  6518. // if ioErr != nil {
  6519. // utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  6520. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6521. // return
  6522. // }
  6523. // var respJSON map[string]interface{}
  6524. // if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  6525. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  6526. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6527. // return
  6528. // }
  6529. // fmt.Println(respJSON)
  6530. // respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  6531. // userJSONBytes, _ := json.Marshal(respJSON)
  6532. // var res ResultSeven
  6533. // if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  6534. // utils.ErrorLog("解析失败:%v", err)
  6535. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6536. // return
  6537. // }
  6538. // if res.Infcode != 0 {
  6539. // errlog := &models.HisOrderError{
  6540. // UserOrgId: adminUser.CurrentOrgId,
  6541. // Ctime: time.Now().Unix(),
  6542. // Mtime: time.Now().Unix(),
  6543. // Number: chrg_bchno,
  6544. // ErrMsg: res.ErrMsg,
  6545. // Status: 1,
  6546. // PatientId: id,
  6547. // RecordTime: recordDateTime,
  6548. // Stage: 7,
  6549. // }
  6550. // service.CreateErrMsgLog(errlog)
  6551. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeRegisterRepeatException)
  6552. // return
  6553. // } else {
  6554. // order, _ := service.GetHisOrderTwo(adminUser.CurrentOrgId, chrg_bchno, id)
  6555. // order.OrderStatus = 1
  6556. // order.MdtrtId = res.Output.Setlinfo.MdtrtID
  6557. // order.SetlId = res.Output.Setlinfo.SetlID
  6558. // order.PsnNo = res.Output.Setlinfo.PsnNo
  6559. // order.PsnName = res.Output.Setlinfo.PsnName
  6560. // order.PsnCertType = res.Output.Setlinfo.PsnCertType
  6561. // order.Certno = res.Output.Setlinfo.Certno
  6562. // order.Gend = res.Output.Setlinfo.Gend
  6563. // order.Naty = res.Output.Setlinfo.Naty
  6564. // order.Age = res.Output.Setlinfo.Age
  6565. // order.Insutype = res.Output.Setlinfo.Insutype
  6566. // order.PsnType = res.Output.Setlinfo.PsnType
  6567. // order.CvlservFlag = res.Output.Setlinfo.CvlservFlag
  6568. // order.SetlTime = res.Output.Setlinfo.SetlTime
  6569. // order.MdtrtCertType = res.Output.Setlinfo.MdtrtCertType
  6570. // order.MedType = res.Output.Setlinfo.MedType
  6571. // order.MedfeeSumamt = res.Output.Setlinfo.MedfeeSumamt
  6572. // order.FulamtOwnpayAmt = res.Output.Setlinfo.FulamtOwnpayAmt
  6573. // order.OverlmtSelfPay = res.Output.Setlinfo.OverlmtSelfpay
  6574. // order.PreselfpayAmt = res.Output.Setlinfo.PreselfpayAmt
  6575. // order.InscpScpAmt = res.Output.Setlinfo.InscpScpAmt
  6576. // order.ActPayDedc = res.Output.Setlinfo.ActPayDedc
  6577. // order.HifpPay = res.Output.Setlinfo.HifpPay
  6578. // order.CvlservPay = res.Output.Setlinfo.CvlservPay
  6579. // order.PoolPropSelfpay = res.Output.Setlinfo.PoolPropSelfpay
  6580. // order.HifesPay = res.Output.Setlinfo.HifesPay
  6581. // order.HifobPay = res.Output.Setlinfo.HifobPay
  6582. // order.MafPay = res.Output.Setlinfo.MafPay
  6583. // order.OthPay = res.Output.Setlinfo.OthPay
  6584. // order.FundPaySumamt = res.Output.Setlinfo.FundPaySumamt
  6585. // order.PsnPartAmt = res.Output.Setlinfo.PsnPartAmt
  6586. // order.AcctPay = res.Output.Setlinfo.AcctPay
  6587. // order.PsnCashPay = res.Output.Setlinfo.PsnCashPay
  6588. // order.HospPartAmt = res.Output.Setlinfo.HospPartAmt
  6589. // order.Balc = res.Output.Setlinfo.Balc
  6590. // order.AcctMulaidPay = res.Output.Setlinfo.AcctMulaidPay
  6591. // order.MedinsSetlId = res.Output.Setlinfo.MedinsSetlID
  6592. // order.ClrOptins = res.Output.Setlinfo.ClrOptins
  6593. // order.ClrWay = res.Output.Setlinfo.ClrWay
  6594. // order.Creator = order.Creator
  6595. // order.Modify = roles.ID
  6596. // setlDetail, _ := json.Marshal(res.Output.Setldetail)
  6597. // detailStr := string(setlDetail)
  6598. // order.SetlDetail = detailStr
  6599. // //err := service.UpdataOrderStatusTwo(chrg_bchno, adminUser.CurrentOrgId)
  6600. // err = service.UpDateOrder(order)
  6601. // if err == nil {
  6602. // c.ServeSuccessJSON(map[string]interface{}{
  6603. // "msg": "预结算成功",
  6604. // })
  6605. // } else {
  6606. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeAmountAccountException)
  6607. // return
  6608. // }
  6609. // }
  6610. // } else {
  6611. // adminUser := c.GetAdminUserInfo()
  6612. // errlog := &models.HisOrderError{
  6613. // UserOrgId: adminUser.CurrentOrgId,
  6614. // Ctime: time.Now().Unix(),
  6615. // Mtime: time.Now().Unix(),
  6616. // ErrMsg: res.ErrMsg,
  6617. // Status: 1,
  6618. // PatientId: id,
  6619. // RecordTime: recordDateTime,
  6620. // Stage: 4,
  6621. // }
  6622. // service.CreateErrMsgLog(errlog)
  6623. //
  6624. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeRegisterRepeatException)
  6625. // return
  6626. // }
  6627. // } else {
  6628. // adminUser := c.GetAdminUserInfo()
  6629. // errlog := &models.HisOrderError{
  6630. // UserOrgId: adminUser.CurrentOrgId,
  6631. // Ctime: time.Now().Unix(),
  6632. // Mtime: time.Now().Unix(),
  6633. // ErrMsg: res.ErrMsg,
  6634. // Status: 1,
  6635. // PatientId: id,
  6636. // RecordTime: recordDateTime,
  6637. // Stage: 4,
  6638. // }
  6639. // service.CreateErrMsgLog(errlog)
  6640. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCalOrderException)
  6641. // return
  6642. // }
  6643. //
  6644. // } else {
  6645. // var total float64
  6646. // for _, item := range prescriptions {
  6647. // if item.Type == 1 { //药品
  6648. // for _, subItem := range item.HisDoctorAdviceInfo {
  6649. // total = total + (subItem.Price * subItem.PrescribingNumber)
  6650. // }
  6651. // }
  6652. // if item.Type == 2 { //项目
  6653. // for _, subItem := range item.HisPrescriptionProject {
  6654. // total = total + (subItem.Price * float64(subItem.Count))
  6655. // }
  6656. // }
  6657. //
  6658. // for _, subItem := range item.HisAdditionalCharge {
  6659. // total = total + (subItem.Price * float64(subItem.Count))
  6660. // }
  6661. // }
  6662. //
  6663. // allTotal := fmt.Sprintf("%.2f", total)
  6664. // totals, _ := strconv.ParseFloat(allTotal, 64)
  6665. // order := &models.HisOrder{
  6666. // UserOrgId: adminUser.CurrentOrgId,
  6667. // HisPatientId: his.ID,
  6668. // PatientId: id,
  6669. // SettleAccountsDate: recordDateTime,
  6670. // Ctime: time.Now().Unix(),
  6671. // Mtime: time.Now().Unix(),
  6672. // Status: 1,
  6673. // OrderStatus: 2,
  6674. // Number: chrg_bchno,
  6675. // MedfeeSumamt: totals,
  6676. // }
  6677. // err = service.CreateOrder(order)
  6678. // if err != nil {
  6679. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCreatePreOrderException)
  6680. // return
  6681. // }
  6682. //
  6683. // var customs []*Custom
  6684. // for _, item := range prescriptions {
  6685. //
  6686. // if item.Type == 1 { //药品
  6687. // for _, subItem := range item.HisDoctorAdviceInfo {
  6688. // cus := &Custom{
  6689. // AdviceId: subItem.ID,
  6690. // ProjectId: 0,
  6691. // DetItemFeeSumamt: fmt.Sprintf("%.2f", subItem.Price*subItem.PrescribingNumber),
  6692. // Cut: fmt.Sprintf("%.2f", subItem.PrescribingNumber),
  6693. // FeedetlSn: subItem.FeedetlSn,
  6694. // Price: fmt.Sprintf("%.2f", subItem.Price),
  6695. // MedListCodg: subItem.MedListCodg,
  6696. // Type: 1,
  6697. // }
  6698. // customs = append(customs, cus)
  6699. // }
  6700. // }
  6701. //
  6702. // if item.Type == 2 { //项目
  6703. // for _, subItem := range item.HisPrescriptionProject {
  6704. //
  6705. // cus := &Custom{
  6706. // AdviceId: 0,
  6707. // ProjectId: subItem.ID,
  6708. // DetItemFeeSumamt: fmt.Sprintf("%.2f", subItem.Price*float64(subItem.Count)),
  6709. // Cut: fmt.Sprintf("%.2f", float64(subItem.Count)),
  6710. // FeedetlSn: subItem.FeedetlSn,
  6711. // Price: fmt.Sprintf("%.2f", float64(subItem.Price)),
  6712. // MedListCodg: subItem.MedListCodg,
  6713. // Type: 2,
  6714. // }
  6715. //
  6716. // customs = append(customs, cus)
  6717. // }
  6718. // }
  6719. //
  6720. // for _, item := range item.HisAdditionalCharge {
  6721. // cus := &Custom{
  6722. // ItemId: item.ID,
  6723. // AdviceId: 0,
  6724. // ProjectId: 0,
  6725. // DetItemFeeSumamt: fmt.Sprintf("%.2f", item.Price),
  6726. // Cut: fmt.Sprintf("%.2f", float64(item.Count)),
  6727. // FeedetlSn: item.FeedetlSn,
  6728. // Price: fmt.Sprintf("%.2f", float64(item.Price)),
  6729. // MedListCodg: item.XtHisAddtionConfig.Code,
  6730. // Type: 3,
  6731. // }
  6732. //
  6733. // customs = append(customs, cus)
  6734. // }
  6735. //
  6736. // }
  6737. //
  6738. // for _, item := range customs {
  6739. // var advice_id int64 = 0
  6740. // var project_id int64 = 0
  6741. // var item_id int64 = 0
  6742. //
  6743. // var types int64 = 0
  6744. //
  6745. // if item.Type == 1 {
  6746. // advice_id = item.AdviceId
  6747. // project_id = 0
  6748. // item_id = 0
  6749. // } else if item.Type == 2 {
  6750. // advice_id = 0
  6751. // item_id = 0
  6752. //
  6753. // project_id = item.ProjectId
  6754. // } else if item.Type == 3 {
  6755. // advice_id = 0
  6756. // item_id = item.ItemId
  6757. // project_id = 0
  6758. // }
  6759. //
  6760. // detItemFeeSumamt, _ := strconv.ParseFloat(item.DetItemFeeSumamt, 32)
  6761. // cut, _ := strconv.ParseFloat(item.Cut, 32)
  6762. // pric, _ := strconv.ParseFloat(item.Price, 32)
  6763. //
  6764. // info := &models.HisOrderInfo{
  6765. // OrderNumber: order.Number,
  6766. // UploadDate: time.Now().Unix(),
  6767. // AdviceId: advice_id,
  6768. // DetItemFeeSumamt: detItemFeeSumamt,
  6769. // Cnt: cut,
  6770. // Pric: pric,
  6771. // PatientId: id,
  6772. // Status: 1,
  6773. // Mtime: time.Now().Unix(),
  6774. // Ctime: time.Now().Unix(),
  6775. // UserOrgId: adminUser.CurrentOrgId,
  6776. // HisPatientId: his.ID,
  6777. // OrderId: order.ID,
  6778. // ProjectId: project_id,
  6779. // Type: types,
  6780. // ItemId: item_id,
  6781. // }
  6782. // service.CreateOrderInfo(info)
  6783. // }
  6784. // //err := service.UpDateAddtionNumber(adminUser.CurrentOrgId, ids, chrg_bchno)
  6785. // err = service.UpDatePrescriptionNumber(adminUser.CurrentOrgId, ids, chrg_bchno)
  6786. // err = service.UpDatePrescriptionInfoNumber(adminUser.CurrentOrgId, id, chrg_bchno, recordDateTime)
  6787. // err = service.UpdataOrderStatusTwo(chrg_bchno, adminUser.CurrentOrgId)
  6788. // if err == nil {
  6789. // c.ServeSuccessJSON(map[string]interface{}{
  6790. // "msg": "结算成功",
  6791. // })
  6792. // } else {
  6793. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeAmountAccountException)
  6794. // return
  6795. // }
  6796. // }
  6797. //}
  6798. //上传明细-预结算-
  6799. func (c *HisApiController) GetPreUploadInfo() {
  6800. id, _ := c.GetInt64("id")
  6801. record_time := c.GetString("record_time")
  6802. his_patient_id, _ := c.GetInt64("his_patient_id")
  6803. settle_accounts_type, _ := c.GetInt64("settle_accounts_type")
  6804. admin_user_id, _ := c.GetInt64("admin_user_id")
  6805. diagnosis_id := c.GetString("diagnosis")
  6806. sick_type, _ := c.GetInt64("sick_type")
  6807. reg_type, _ := c.GetInt64("p_type")
  6808. begin_time := c.GetString("begin_time")
  6809. id_str := c.GetString("ids")
  6810. ids_arr := strings.Split(id_str, ",")
  6811. timeLayout := "2006-01-02"
  6812. loc, _ := time.LoadLocation("Local")
  6813. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  6814. if err != nil {
  6815. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  6816. return
  6817. }
  6818. recordDateTime := theTime.Unix()
  6819. adminUser := c.GetAdminUserInfo()
  6820. diagnosis_ids := strings.Split(diagnosis_id, ",")
  6821. var config []*models.HisXtDiagnoseConfig
  6822. for _, item := range diagnosis_ids {
  6823. id, _ := strconv.ParseInt(item, 10, 64)
  6824. diagnosisConfig, _ := service.FindDiagnoseById(id)
  6825. config = append(config, &diagnosisConfig)
  6826. }
  6827. //diagnosisConfig, _ := service.FindDiagnoseById(diagnosis_id)
  6828. sickConfig, _ := service.FindSickById(sick_type)
  6829. var prescriptions []*models.HisPrescription
  6830. var start_time int64
  6831. var end_time int64
  6832. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  6833. fmt.Println(his_patient_id)
  6834. his, _ := service.GetNewHisPatientInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  6835. timestamp := time.Now().Unix()
  6836. tempTime := time.Unix(timestamp, 0)
  6837. timeFormat := tempTime.Format("20060102150405")
  6838. chrgBchno := rand.Intn(100000) + 10000
  6839. chrg_bchno := timeFormat + strconv.FormatInt(int64(chrgBchno), 10) + strconv.FormatInt(his.PatientId, 10)
  6840. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  6841. var patientPrescription models.HisPrescriptionInfo
  6842. patientPrescription, _ = service.FindHisPatientPrescriptionInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  6843. if patientPrescription.ID == 0 {
  6844. patientPrescription, _ = service.FindLastPatientPrescriptionInfo(adminUser.CurrentOrgId, id, recordDateTime)
  6845. }
  6846. //miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  6847. department, _ := service.GetDepartMentDetail(patientPrescription.Departments)
  6848. doctor_info, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, patientPrescription.DoctorId)
  6849. strconv.FormatInt(his.PatientId, 10)
  6850. var res2 ResultSix
  6851. var resSix10265 ResultSix10265
  6852. var time_stamp string
  6853. if miConfig.MdtrtareaAdmvs == "421300" {
  6854. data := make(map[string]interface{})
  6855. client := &http.Client{}
  6856. data["psn_no"] = his.PsnNo
  6857. data["mdtrt_id"] = his.Number
  6858. data["department"] = department.Name
  6859. data["org_name"] = miConfig.OrgName
  6860. data["med_type"] = strconv.FormatInt(reg_type, 10)
  6861. data["doctor_id"] = doctor_info.DoctorNumber
  6862. data["doctor_name"] = roles.UserName
  6863. data["fixmedins_code"] = miConfig.Code
  6864. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  6865. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  6866. data["secret_key"] = miConfig.SecretKey
  6867. data["sick_code"] = sickConfig.CountryCode
  6868. data["sick_name"] = sickConfig.ClassName
  6869. data["begin_time"] = begin_time
  6870. data["dept"] = strconv.FormatInt(department.ID, 10)
  6871. data["config"] = config
  6872. data["opter"] = roles.UserName
  6873. fmt.Println(data)
  6874. bytesData, _ := json.Marshal(data)
  6875. req, _ := http.NewRequest("POST", "http://192.168.124.4:9532/"+"hbyb/2203", bytes.NewReader(bytesData))
  6876. resp, _ := client.Do(req)
  6877. defer resp.Body.Close()
  6878. body, ioErr := ioutil.ReadAll(resp.Body)
  6879. if ioErr != nil {
  6880. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  6881. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6882. return
  6883. }
  6884. var respJSON map[string]interface{}
  6885. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  6886. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  6887. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6888. return
  6889. }
  6890. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  6891. userJSONBytes, _ := json.Marshal(respJSON)
  6892. fmt.Println("log")
  6893. fmt.Println(string(userJSONBytes))
  6894. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  6895. utils.ErrorLog("解析失败:%v", err)
  6896. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6897. return
  6898. }
  6899. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  6900. data := make(map[string]interface{})
  6901. client := &http.Client{}
  6902. data["psn_no"] = his.PsnNo
  6903. data["mdtrt_id"] = his.Number
  6904. data["doctor"] = roles.UserName
  6905. data["department"] = department.Name
  6906. data["org_name"] = miConfig.OrgName
  6907. data["med_type"] = strconv.FormatInt(reg_type, 10)
  6908. data["doctor_id"] = strconv.FormatInt(doctor_info.AdminUserId, 10)
  6909. data["fixmedins_code"] = miConfig.Code
  6910. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  6911. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  6912. data["secret_key"] = miConfig.SecretKey
  6913. data["sick_code"] = sickConfig.CountryCode
  6914. data["sick_name"] = sickConfig.ClassName
  6915. data["begin_time"] = begin_time
  6916. data["dept"] = strconv.FormatInt(department.ID, 10)
  6917. data["config"] = config
  6918. data["url"] = miConfig.Url
  6919. data["ak"] = miConfig.AccessKey
  6920. data["cainfo"] = miConfig.Cainfo
  6921. bytesData, _ := json.Marshal(data)
  6922. var req *http.Request
  6923. if miConfig.MdtrtareaAdmvs == "320921" {
  6924. req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/2203", bytes.NewReader(bytesData))
  6925. //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 +
  6926. // "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&cainfo=" + miConfig.Cainfo
  6927. } else {
  6928. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2203", bytes.NewReader(bytesData))
  6929. }
  6930. resp, _ := client.Do(req)
  6931. defer resp.Body.Close()
  6932. body, ioErr := ioutil.ReadAll(resp.Body)
  6933. if ioErr != nil {
  6934. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  6935. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6936. return
  6937. }
  6938. var respJSON map[string]interface{}
  6939. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  6940. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  6941. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6942. return
  6943. }
  6944. time_stamp = strconv.FormatInt(int64(respJSON["data"].(map[string]interface{})["time_stamp"].(float64)), 10)
  6945. //fmt.Println(respJSON["data"].(map[string]interface{})["time_stamp"].(string))
  6946. //time_stamp = respJSON["data"].(map[string]interface{})["time_stamp"].(string)
  6947. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  6948. userJSONBytes, _ := json.Marshal(respJSON)
  6949. fmt.Println("log")
  6950. fmt.Println(string(userJSONBytes))
  6951. if err := json.Unmarshal(userJSONBytes, &resSix10265); err != nil {
  6952. utils.ErrorLog("解析失败:%v", err)
  6953. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6954. return
  6955. }
  6956. res2.InfRefmsgid = resSix10265.InfRefmsgid
  6957. res2.Output = resSix10265.Output
  6958. res2.ErrMsg = resSix10265.ErrMsg
  6959. res2.Cainfo = resSix10265.Cainfo
  6960. res2.WarnMsg = resSix10265.WarnMsg
  6961. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  6962. res2.Infcode = infocode
  6963. } else if miConfig.MdtrtareaAdmvs == "350500" {
  6964. 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)
  6965. saveLog(result, requestLog, "2203", "上传就诊信息")
  6966. var respJSON2 map[string]interface{}
  6967. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  6968. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  6969. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6970. return
  6971. }
  6972. userJSONBytes2, _ := json.Marshal(respJSON2)
  6973. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  6974. utils.ErrorLog("解析失败:%v", err)
  6975. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6976. return
  6977. }
  6978. } else {
  6979. var result string
  6980. var requestLog string
  6981. if miConfig.MdtrtareaAdmvs == "440781" { //
  6982. 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)
  6983. } else {
  6984. if miConfig.Code == "H15049901371" {
  6985. //赤峰地区国家医保医疗类别
  6986. //职工透析:医疗类别选特殊情况门诊990502
  6987. //居民定额血透门慢: 医疗类别选门诊慢病140104
  6988. var med_type string
  6989. if his.Insutype == "390" {
  6990. if reg_type == 14 {
  6991. med_type = "9933"
  6992. } else if reg_type == 11 {
  6993. med_type = "11"
  6994. }
  6995. } else if his.Insutype == "310" {
  6996. if reg_type == 14 {
  6997. med_type = "990502"
  6998. } else if reg_type == 11 {
  6999. med_type = "11"
  7000. }
  7001. }
  7002. 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)
  7003. } else {
  7004. 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)
  7005. }
  7006. saveLog(result, requestLog, "2203", "上传就诊信息")
  7007. var respJSON2 map[string]interface{}
  7008. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  7009. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  7010. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7011. return
  7012. }
  7013. userJSONBytes2, _ := json.Marshal(respJSON2)
  7014. if miConfig.Code == "H15049901371" {
  7015. if err := json.Unmarshal(userJSONBytes2, &resSix10265); err != nil {
  7016. utils.ErrorLog("解析失败:%v", err)
  7017. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7018. return
  7019. }
  7020. res2.InfRefmsgid = resSix10265.InfRefmsgid
  7021. res2.Output = resSix10265.Output
  7022. res2.ErrMsg = resSix10265.ErrMsg
  7023. res2.Cainfo = resSix10265.Cainfo
  7024. res2.WarnMsg = resSix10265.WarnMsg
  7025. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  7026. res2.Infcode = infocode
  7027. } else {
  7028. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  7029. utils.ErrorLog("解析失败:%v", err)
  7030. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7031. return
  7032. }
  7033. }
  7034. }
  7035. }
  7036. if res2.Infcode != 0 {
  7037. adminUser := c.GetAdminUserInfo()
  7038. errlog := &models.HisOrderError{
  7039. UserOrgId: adminUser.CurrentOrgId,
  7040. Ctime: time.Now().Unix(),
  7041. Mtime: time.Now().Unix(),
  7042. ErrMsg: res2.ErrMsg,
  7043. Status: 1,
  7044. PatientId: id,
  7045. RecordTime: recordDateTime,
  7046. Stage: 3,
  7047. }
  7048. service.CreateErrMsgLog(errlog)
  7049. c.ServeSuccessJSON(map[string]interface{}{
  7050. "failed_code": -10,
  7051. "msg": res2.ErrMsg,
  7052. })
  7053. return
  7054. } else {
  7055. his.Diagnosis = diagnosis_id
  7056. his.SickType = sickConfig.ID
  7057. his.PType = fmt.Sprintf("%d", reg_type)
  7058. service.UpdateHisPatientThree(&his)
  7059. data := make(map[string]interface{})
  7060. if settle_accounts_type == 1 { //日结
  7061. if reg_type == 11 || reg_type == 1111 || reg_type == 1112 {
  7062. prescriptions, _ = service.GetPrescriptionByIds(ids_arr, adminUser.CurrentOrgId)
  7063. } else {
  7064. prescriptions, _ = service.GetNewHisPrescription(adminUser.CurrentOrgId, his_patient_id, recordDateTime, strconv.Itoa(int(reg_type)))
  7065. }
  7066. data["pre"] = prescriptions
  7067. } else { //月结
  7068. start_time_str := c.GetString("start_time")
  7069. end_time_str := c.GetString("end_time")
  7070. timeLayout := "2006-01-02"
  7071. loc, _ := time.LoadLocation("Local")
  7072. theStartTime, err := time.ParseInLocation(timeLayout+" 15:04:05", start_time_str+" 00:00:00", loc)
  7073. if err != nil {
  7074. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  7075. return
  7076. }
  7077. recordStartTime := theStartTime.Unix()
  7078. start_time = recordStartTime
  7079. theEndTime, err := time.ParseInLocation(timeLayout+" 15:04:05", end_time_str+" 00:00:00", loc)
  7080. if err != nil {
  7081. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  7082. return
  7083. }
  7084. recordEndTime := theEndTime.Unix()
  7085. end_time = recordEndTime
  7086. prescriptions, _ = service.GetMonthHisPrescriptionTwo(adminUser.CurrentOrgId, id, recordStartTime, recordEndTime, reg_type)
  7087. data["pre"] = prescriptions
  7088. }
  7089. client := &http.Client{}
  7090. data["psn_no"] = his.PsnNo
  7091. data["mdtrt_id"] = his.Number
  7092. data["chrg_bchno"] = chrg_bchno
  7093. data["org_name"] = miConfig.OrgName
  7094. data["doctor"] = roles.UserName
  7095. data["doctor_id"] = strconv.FormatInt(roles.AdminUserId, 10)
  7096. data["dept"] = strconv.FormatInt(patientPrescription.Departments, 10)
  7097. data["fixmedins_code"] = miConfig.Code
  7098. data["balance_accounts_type"] = strconv.FormatInt(his.BalanceAccountsType, 10)
  7099. if (department.ID == 0 && adminUser.CurrentOrgId == 9919) || (department.ID == 0 && adminUser.CurrentOrgId == 10106) {
  7100. data["dept_code"] = "15"
  7101. } else {
  7102. data["dept_code"] = department.Number
  7103. }
  7104. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  7105. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  7106. data["secret_key"] = miConfig.SecretKey
  7107. data["url"] = miConfig.Url
  7108. data["ak"] = miConfig.AccessKey
  7109. data["new_doctor_name"] = patientPrescription.Doctor
  7110. data["diag_code"] = sickConfig.CountryCode
  7111. data["time_stamp"] = time_stamp
  7112. data["cainfo"] = miConfig.Cainfo
  7113. var ids []int64
  7114. for _, item := range prescriptions {
  7115. ids = append(ids, item.ID)
  7116. }
  7117. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  7118. if config.IsOpen == 1 { //对接了医保,走医保流程
  7119. var res ResultFour
  7120. var resFour10265 ResultFour10265
  7121. if miConfig.MdtrtareaAdmvs == "421300" {
  7122. bytesData, _ := json.Marshal(data)
  7123. req, _ := http.NewRequest("POST", "http://192.168.124.4:9532/"+"hbyb/2204", bytes.NewReader(bytesData))
  7124. resp, _ := client.Do(req)
  7125. defer resp.Body.Close()
  7126. body, ioErr := ioutil.ReadAll(resp.Body)
  7127. if ioErr != nil {
  7128. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  7129. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7130. return
  7131. }
  7132. var respJSON map[string]interface{}
  7133. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  7134. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  7135. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7136. return
  7137. }
  7138. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  7139. userJSONBytes, _ := json.Marshal(respJSON)
  7140. fmt.Println("log")
  7141. fmt.Println(string(userJSONBytes))
  7142. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  7143. utils.ErrorLog("解析失败:%v", err)
  7144. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7145. return
  7146. }
  7147. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  7148. bytesData, _ := json.Marshal(data)
  7149. var req *http.Request
  7150. if miConfig.MdtrtareaAdmvs == "320921" {
  7151. req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  7152. } else {
  7153. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  7154. }
  7155. resp, _ := client.Do(req)
  7156. defer resp.Body.Close()
  7157. body, ioErr := ioutil.ReadAll(resp.Body)
  7158. if ioErr != nil {
  7159. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  7160. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7161. return
  7162. }
  7163. var respJSON map[string]interface{}
  7164. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  7165. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  7166. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7167. return
  7168. }
  7169. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  7170. userJSONBytes, _ := json.Marshal(respJSON)
  7171. fmt.Println("log")
  7172. fmt.Println(string(userJSONBytes))
  7173. if err := json.Unmarshal(userJSONBytes, &resFour10265); err != nil {
  7174. utils.ErrorLog("解析失败:%v", err)
  7175. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7176. return
  7177. }
  7178. res.InfRefmsgid = resFour10265.InfRefmsgid
  7179. res.Output = resFour10265.Output
  7180. res.ErrMsg = resFour10265.ErrMsg
  7181. res.Cainfo = resFour10265.Cainfo
  7182. res.WarnMsg = resFour10265.WarnMsg
  7183. infocode, _ := strconv.ParseInt(resFour10265.Infcode, 10, 64)
  7184. res.Infcode = infocode
  7185. } else if miConfig.MdtrtareaAdmvs == "350500" {
  7186. 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)
  7187. var dat map[string]interface{}
  7188. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  7189. fmt.Println(dat)
  7190. } else {
  7191. fmt.Println(err)
  7192. }
  7193. saveLog(result, request_log, "2204", "上传费用明细")
  7194. userJSONBytes, _ := json.Marshal(dat)
  7195. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  7196. utils.ErrorLog("解析失败:%v", err)
  7197. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7198. return
  7199. }
  7200. } else {
  7201. if miConfig.Code == "H15049901371" {
  7202. 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)
  7203. var dat map[string]interface{}
  7204. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  7205. fmt.Println(dat)
  7206. } else {
  7207. fmt.Println(err)
  7208. }
  7209. saveLog(result, request_log, "2204", "上传费用明细")
  7210. userJSONBytes, _ := json.Marshal(dat)
  7211. if err := json.Unmarshal(userJSONBytes, &resFour10265); err != nil {
  7212. utils.ErrorLog("解析失败:%v", err)
  7213. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7214. return
  7215. }
  7216. res.InfRefmsgid = resFour10265.InfRefmsgid
  7217. res.Output = resFour10265.Output
  7218. res.ErrMsg = resFour10265.ErrMsg
  7219. res.Cainfo = resFour10265.Cainfo
  7220. res.WarnMsg = resFour10265.WarnMsg
  7221. infocode, _ := strconv.ParseInt(resFour10265.Infcode, 10, 64)
  7222. res.Infcode = infocode
  7223. } else {
  7224. 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)
  7225. var dat map[string]interface{}
  7226. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  7227. fmt.Println(dat)
  7228. } else {
  7229. fmt.Println(err)
  7230. }
  7231. saveLog(result, request_log, "2204", "上传费用明细")
  7232. userJSONBytes, _ := json.Marshal(dat)
  7233. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  7234. utils.ErrorLog("解析失败:%v", err)
  7235. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7236. return
  7237. }
  7238. }
  7239. }
  7240. if res.Infcode == 0 {
  7241. order := &models.HisOrder{
  7242. UserOrgId: adminUser.CurrentOrgId,
  7243. HisPatientId: his.ID,
  7244. PatientId: his.PatientId,
  7245. SettleAccountsDate: recordDateTime,
  7246. Ctime: time.Now().Unix(),
  7247. Mtime: time.Now().Unix(),
  7248. MdtrtId: his.Number,
  7249. PsnNo: his.PsnNo,
  7250. MedType: strconv.FormatInt(reg_type, 10),
  7251. Status: 1,
  7252. Number: chrg_bchno,
  7253. Infcode: res.Infcode,
  7254. WarnMsg: res.WarnMsg,
  7255. Cainfo: res.Cainfo,
  7256. ErrMsg: res.ErrMsg,
  7257. RespondTime: res.RefmsgTime,
  7258. InfRefmsgid: res.InfRefmsgid,
  7259. OrderStatus: 1,
  7260. IsMedicineInsurance: 1,
  7261. SettleType: settle_accounts_type,
  7262. SettleStartTime: start_time,
  7263. SettleEndTime: end_time,
  7264. Creator: roles.AdminUserId,
  7265. Modify: roles.AdminUserId,
  7266. PType: 2,
  7267. Diagnosis: diagnosis_id,
  7268. }
  7269. err = service.CreateOrder(order)
  7270. if err != nil {
  7271. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCreatePreOrderException)
  7272. return
  7273. }
  7274. for _, item := range res.Output.Result {
  7275. temp := strings.Split(item.FeedetlSn, "-")
  7276. var advice_id int64 = 0
  7277. var project_id int64 = 0
  7278. var types int64 = 0
  7279. id, _ := strconv.ParseInt(temp[2], 10, 64)
  7280. types, _ = strconv.ParseInt(temp[1], 10, 64)
  7281. if temp[1] == "1" {
  7282. advice_id = id
  7283. project_id = 0
  7284. } else if temp[1] == "2" {
  7285. advice_id = 0
  7286. project_id = id
  7287. }
  7288. info := &models.HisOrderInfo{
  7289. OrderNumber: order.Number,
  7290. FeedetlSn: item.FeedetlSn,
  7291. UploadDate: time.Now().Unix(),
  7292. AdviceId: advice_id,
  7293. DetItemFeeSumamt: item.DetItemFeeSumamt,
  7294. Cnt: item.Cnt,
  7295. Pric: float64(item.Pric),
  7296. PatientId: his.PatientId,
  7297. PricUplmtAmt: item.PricUplmtAmt,
  7298. SelfpayProp: item.SelfpayProp,
  7299. FulamtOwnpayAmt: item.FulamtOwnpayAmt,
  7300. OverlmtAmt: item.OverlmtAmt,
  7301. PreselfpayAmt: item.PreselfpayAmt,
  7302. BasMednFlag: item.BasMednFlag,
  7303. MedChrgitmType: item.MedChrgitmType,
  7304. HiNegoDrugFlag: item.HiNegoDrugFlag,
  7305. Status: 1,
  7306. Memo: item.Memo,
  7307. Mtime: time.Now().Unix(),
  7308. InscpScpAmt: item.InscpScpAmt,
  7309. DrtReimFlag: item.DrtReimFlag,
  7310. Ctime: time.Now().Unix(),
  7311. ListSpItemFlag: item.ListSpItemFlag,
  7312. ChldMedcFlag: item.ChldMedcFlag,
  7313. LmtUsedFlag: item.LmtUsedFlag,
  7314. ChrgitmLv: item.ChrgitmLv,
  7315. UserOrgId: adminUser.CurrentOrgId,
  7316. HisPatientId: his.ID,
  7317. OrderId: order.ID,
  7318. ProjectId: project_id,
  7319. Type: types,
  7320. }
  7321. service.CreateOrderInfo(info)
  7322. }
  7323. service.UpDatePrescriptionNumber(adminUser.CurrentOrgId, ids, chrg_bchno)
  7324. service.UpDateHisPrescriptionInfoNumber(adminUser.CurrentOrgId, his_patient_id, chrg_bchno, recordDateTime)
  7325. var total float64
  7326. for _, item := range prescriptions {
  7327. if item.Type == 1 { //药品
  7328. for _, subItem := range item.HisDoctorAdviceInfo {
  7329. total = total + (subItem.Price * subItem.PrescribingNumber)
  7330. }
  7331. }
  7332. if item.Type == 2 { //项目
  7333. for _, subItem := range item.HisPrescriptionProject {
  7334. cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  7335. total = total + (subItem.Price * cnt)
  7336. }
  7337. }
  7338. }
  7339. for _, item := range prescriptions {
  7340. for _, subItem := range item.HisAdditionalCharge {
  7341. total = total + (subItem.Price * float64(subItem.Count))
  7342. }
  7343. }
  7344. allTotal := fmt.Sprintf("%.4f", total)
  7345. if res.Infcode == 0 {
  7346. var rf []*ResultFive
  7347. json.Unmarshal([]byte(his.Iinfo), &rf)
  7348. chrg_bchno := chrg_bchno
  7349. cert_no := his.Certno
  7350. var insutypes []string
  7351. var insutype string
  7352. var is390 int = 0
  7353. var is310 int = 0
  7354. for _, item := range rf {
  7355. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  7356. insutypes = append(insutypes, item.Insutype)
  7357. }
  7358. }
  7359. if len(insutypes) == 1 {
  7360. insutype = insutypes[0]
  7361. } else {
  7362. for _, i := range insutypes {
  7363. if i == "390" {
  7364. is390 = 1
  7365. }
  7366. if i == "310" {
  7367. is310 = 1
  7368. }
  7369. }
  7370. }
  7371. if is390 == 1 {
  7372. insutype = "390"
  7373. }
  7374. if is310 == 1 {
  7375. insutype = "310"
  7376. }
  7377. if len(insutypes) == 0 {
  7378. insutype = "310"
  7379. }
  7380. if len(insutypes) == 2 {
  7381. insutype = strconv.FormatInt(his.SocialType, 64)
  7382. }
  7383. //insutype = "390"
  7384. if his.IdCardType == 1 {
  7385. cert_no = his.MedicalInsuranceNumber
  7386. } else {
  7387. cert_no = his.Certno
  7388. }
  7389. var res ResultSeven
  7390. var resSeven10265 ResultSeven10265
  7391. if miConfig.MdtrtareaAdmvs == "421300" {
  7392. api := "http://192.168.124.4:9532/" + "hbyb/2206?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  7393. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  7394. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  7395. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  7396. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  7397. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  7398. "&insutype=" + insutype + "&total=" + allTotal + "&med_type=" + strconv.FormatInt(reg_type, 10)
  7399. resp, requestErr := http.Get(api)
  7400. if requestErr != nil {
  7401. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7402. return
  7403. }
  7404. body, ioErr := ioutil.ReadAll(resp.Body)
  7405. if ioErr != nil {
  7406. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  7407. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7408. return
  7409. }
  7410. var respJSON map[string]interface{}
  7411. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  7412. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  7413. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7414. return
  7415. }
  7416. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  7417. result, _ := json.Marshal(respJSON)
  7418. fmt.Println("log")
  7419. fmt.Println(string(result))
  7420. if err := json.Unmarshal([]byte(result), &res); err != nil {
  7421. utils.ErrorLog("解析失败:%v", err)
  7422. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7423. return
  7424. }
  7425. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  7426. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  7427. psn_info.VerifyNumber = strings.Replace(psn_info.VerifyNumber, "+", "%2B", -1)
  7428. bas := strings.Split(psn_info.CardInfo, "|")
  7429. if his.IdCardType == 1 {
  7430. cert_no = bas[2]
  7431. } else {
  7432. cert_no = bas[1]
  7433. }
  7434. //江苏地区国家医保医疗类别
  7435. //职工透析:医疗类别选特殊情况门诊9933
  7436. //居民血透门慢: 医疗类别选门诊慢病1402
  7437. //var med_type string
  7438. //if his.Insutype == "310" {
  7439. // if reg_type == 14 {
  7440. // med_type = "9933"
  7441. // } else if reg_type == 11 {
  7442. // med_type = "11"
  7443. //
  7444. // }
  7445. //} else if his.Insutype == "390" {
  7446. // if reg_type == 14 {
  7447. // med_type = "1402"
  7448. // } else if reg_type == 11 {
  7449. // med_type = "11"
  7450. // }
  7451. //}
  7452. var api string
  7453. if miConfig.MdtrtareaAdmvs == "320921" {
  7454. api = "http://192.168.2.110:9532/" + "jsyb/2206?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  7455. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  7456. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  7457. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  7458. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  7459. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  7460. "&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
  7461. //req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  7462. } else {
  7463. //req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  7464. api = "http://192.168.5.251:9532/" + "jsyb/2206?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  7465. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  7466. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  7467. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  7468. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  7469. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  7470. "&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
  7471. }
  7472. resp, requestErr := http.Get(api)
  7473. if requestErr != nil {
  7474. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7475. return
  7476. }
  7477. body, ioErr := ioutil.ReadAll(resp.Body)
  7478. if ioErr != nil {
  7479. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  7480. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7481. return
  7482. }
  7483. var respJSON map[string]interface{}
  7484. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  7485. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  7486. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7487. return
  7488. }
  7489. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  7490. result, _ := json.Marshal(respJSON)
  7491. fmt.Println("log")
  7492. fmt.Println(string(result))
  7493. if err := json.Unmarshal([]byte(result), &resSeven10265); err != nil {
  7494. utils.ErrorLog("解析失败:%v", err)
  7495. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7496. return
  7497. }
  7498. res.InfRefmsgid = resSeven10265.InfRefmsgid
  7499. res.Output = resSeven10265.Output
  7500. res.ErrMsg = resSeven10265.ErrMsg
  7501. res.Cainfo = resSeven10265.Cainfo
  7502. res.WarnMsg = resSeven10265.WarnMsg
  7503. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  7504. res.Infcode = infocode
  7505. } else if miConfig.MdtrtareaAdmvs == "350500" {
  7506. 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)
  7507. var dat map[string]interface{}
  7508. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  7509. fmt.Println(dat)
  7510. } else {
  7511. fmt.Println(err)
  7512. }
  7513. saveLog(result, request_log, "2206", "预结算")
  7514. userJSONBytes, _ := json.Marshal(dat)
  7515. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  7516. utils.ErrorLog("解析失败:%v", err)
  7517. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7518. return
  7519. }
  7520. } else {
  7521. var result string
  7522. var request_log string
  7523. if miConfig.Code == "H15049901371" {
  7524. //赤峰地区国家医保医疗类别
  7525. //职工透析:医疗类别选特殊情况门诊990502
  7526. //居民定额血透门慢: 医疗类别选门诊慢病140104
  7527. var med_type string
  7528. if his.Insutype == "390" {
  7529. if reg_type == 14 {
  7530. med_type = "9933"
  7531. } else if reg_type == 11 {
  7532. med_type = "11"
  7533. }
  7534. } else if his.Insutype == "310" {
  7535. if reg_type == 14 {
  7536. med_type = "990502"
  7537. } else if reg_type == 11 {
  7538. med_type = "11"
  7539. }
  7540. }
  7541. 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)
  7542. } else {
  7543. 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)
  7544. }
  7545. var dat map[string]interface{}
  7546. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  7547. fmt.Println(dat)
  7548. } else {
  7549. fmt.Println(err)
  7550. }
  7551. saveLog(result, request_log, "2206", "预结算")
  7552. //userJSONBytes, _ := json.Marshal(dat)
  7553. //
  7554. //if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  7555. // utils.ErrorLog("解析失败:%v", err)
  7556. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7557. // return
  7558. //}
  7559. userJSONBytes, _ := json.Marshal(dat)
  7560. if miConfig.Code == "H15049901371" {
  7561. if err := json.Unmarshal(userJSONBytes, &resSeven10265); err != nil {
  7562. utils.ErrorLog("解析失败:%v", err)
  7563. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7564. return
  7565. }
  7566. res.InfRefmsgid = resSeven10265.InfRefmsgid
  7567. res.Output = resSeven10265.Output
  7568. res.ErrMsg = resSeven10265.ErrMsg
  7569. res.Cainfo = resSeven10265.Cainfo
  7570. res.WarnMsg = resSeven10265.WarnMsg
  7571. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  7572. res.Infcode = infocode
  7573. } else {
  7574. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  7575. utils.ErrorLog("解析失败:%v", err)
  7576. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7577. return
  7578. }
  7579. }
  7580. }
  7581. if res.Infcode != 0 {
  7582. errlog := &models.HisOrderError{
  7583. UserOrgId: adminUser.CurrentOrgId,
  7584. Ctime: time.Now().Unix(),
  7585. Mtime: time.Now().Unix(),
  7586. Number: chrg_bchno,
  7587. ErrMsg: res.ErrMsg,
  7588. Status: 1,
  7589. PatientId: id,
  7590. RecordTime: recordDateTime,
  7591. Stage: 20,
  7592. }
  7593. service.CreateErrMsgLog(errlog)
  7594. c.ServeSuccessJSON(map[string]interface{}{
  7595. "failed_code": -10,
  7596. "msg": res.ErrMsg,
  7597. })
  7598. return
  7599. } else {
  7600. order, _ := service.GetHisOrderTwo(adminUser.CurrentOrgId, chrg_bchno, id)
  7601. order.OrderStatus = 1
  7602. order.IsPre = 1
  7603. order.Status = 1
  7604. order.MdtrtId = res.Output.Setlinfo.MdtrtID
  7605. order.SetlId = res.Output.Setlinfo.SetlID
  7606. order.PsnNo = res.Output.Setlinfo.PsnNo
  7607. order.PsnName = res.Output.Setlinfo.PsnName
  7608. order.PsnCertType = res.Output.Setlinfo.PsnCertType
  7609. order.Certno = res.Output.Setlinfo.Certno
  7610. order.Gend = res.Output.Setlinfo.Gend
  7611. order.Naty = res.Output.Setlinfo.Naty
  7612. order.Age = res.Output.Setlinfo.Age
  7613. order.Insutype = res.Output.Setlinfo.Insutype
  7614. order.PsnType = res.Output.Setlinfo.PsnType
  7615. order.CvlservFlag = res.Output.Setlinfo.CvlservFlag
  7616. order.SetlTime = res.Output.Setlinfo.SetlTime
  7617. order.MdtrtCertType = res.Output.Setlinfo.MdtrtCertType
  7618. if res.Output.Setlinfo.MedType == "140101" {
  7619. order.MedType = "14"
  7620. } else {
  7621. order.MedType = res.Output.Setlinfo.MedType
  7622. }
  7623. if reg_type == 1112 {
  7624. order.MedType = "1112"
  7625. }
  7626. if reg_type == 1111 {
  7627. order.MedType = "1111"
  7628. }
  7629. order.MedfeeSumamt = res.Output.Setlinfo.MedfeeSumamt
  7630. order.FulamtOwnpayAmt = res.Output.Setlinfo.FulamtOwnpayAmt
  7631. order.OverlmtSelfPay = res.Output.Setlinfo.OverlmtSelfpay
  7632. order.PreselfpayAmt = res.Output.Setlinfo.PreselfpayAmt
  7633. order.InscpScpAmt = res.Output.Setlinfo.InscpScpAmt
  7634. order.ActPayDedc = res.Output.Setlinfo.ActPayDedc
  7635. order.HifpPay = res.Output.Setlinfo.HifpPay
  7636. order.CvlservPay = res.Output.Setlinfo.CvlservPay
  7637. order.PoolPropSelfpay = res.Output.Setlinfo.PoolPropSelfpay
  7638. order.HifesPay = res.Output.Setlinfo.HifesPay
  7639. order.HifobPay = res.Output.Setlinfo.HifobPay
  7640. order.MafPay = res.Output.Setlinfo.MafPay
  7641. order.HifmiPay = res.Output.Setlinfo.HifmiPay
  7642. order.OthPay = res.Output.Setlinfo.OthPay
  7643. order.FundPaySumamt = res.Output.Setlinfo.FundPaySumamt
  7644. order.PsnPartAmt = res.Output.Setlinfo.PsnPartAmt
  7645. order.AcctPay = res.Output.Setlinfo.AcctPay
  7646. order.PsnCashPay = res.Output.Setlinfo.PsnCashPay
  7647. order.HospPartAmt = res.Output.Setlinfo.HospPartAmt
  7648. order.Balc = res.Output.Setlinfo.Balc
  7649. order.AcctMulaidPay = res.Output.Setlinfo.AcctMulaidPay
  7650. order.MedinsSetlId = res.Output.Setlinfo.MedinsSetlID
  7651. order.ClrOptins = res.Output.Setlinfo.ClrOptins
  7652. order.ClrWay = res.Output.Setlinfo.ClrWay
  7653. order.Creator = order.Creator
  7654. order.Modify = roles.AdminUserId
  7655. setlDetail, _ := json.Marshal(res.Output.Setldetail)
  7656. detailStr := string(setlDetail)
  7657. order.SetlDetail = detailStr
  7658. //err := service.UpdataOrderStatusTwo(chrg_bchno, adminUser.CurrentOrgId)
  7659. err = service.UpDateOrder(order)
  7660. if err == nil {
  7661. c.ServeSuccessJSON(map[string]interface{}{
  7662. "msg": "预结算成功",
  7663. })
  7664. } else {
  7665. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeAmountAccountException)
  7666. return
  7667. }
  7668. }
  7669. } else {
  7670. adminUser := c.GetAdminUserInfo()
  7671. errlog := &models.HisOrderError{
  7672. UserOrgId: adminUser.CurrentOrgId,
  7673. Ctime: time.Now().Unix(),
  7674. Mtime: time.Now().Unix(),
  7675. ErrMsg: res.ErrMsg,
  7676. Status: 1,
  7677. PatientId: id,
  7678. RecordTime: recordDateTime,
  7679. Stage: 4,
  7680. }
  7681. service.CreateErrMsgLog(errlog)
  7682. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeRegisterRepeatException)
  7683. return
  7684. }
  7685. } else {
  7686. adminUser := c.GetAdminUserInfo()
  7687. errlog := &models.HisOrderError{
  7688. UserOrgId: adminUser.CurrentOrgId,
  7689. Ctime: time.Now().Unix(),
  7690. Mtime: time.Now().Unix(),
  7691. ErrMsg: res.ErrMsg,
  7692. Status: 1,
  7693. PatientId: id,
  7694. RecordTime: recordDateTime,
  7695. Stage: 4,
  7696. }
  7697. service.CreateErrMsgLog(errlog)
  7698. c.ServeSuccessJSON(map[string]interface{}{
  7699. "failed_code": -10,
  7700. "msg": res.ErrMsg,
  7701. })
  7702. return
  7703. }
  7704. }
  7705. }
  7706. }
  7707. //退款
  7708. func (c *HisApiController) Refund() {
  7709. order_id, _ := c.GetInt64("order_id")
  7710. admin_user_id, _ := c.GetInt64("admin_user_id")
  7711. adminUser := c.GetAdminUserInfo()
  7712. var order models.HisOrder
  7713. order, _ = service.GetHisOrderByID(order_id)
  7714. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  7715. if order.ID == 0 {
  7716. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  7717. return
  7718. }
  7719. his, _ := service.GetHisPatientByNumber(order.MdtrtId)
  7720. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  7721. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  7722. if config.IsOpen == 1 { //对接了医保,走医保流程
  7723. var res ResultSixteen
  7724. var resSixteen10265 ResultSixteen10265
  7725. var src_resquest string
  7726. var result string
  7727. if miConfig.MdtrtareaAdmvs == "421300" {
  7728. api3 := "http://192.168.124.4:9532/" + "hbyb/2208?psn_no=" + order.PsnNo +
  7729. "&mdtrt_id=" + order.MdtrtId + "&setl_id=" + order.SetlId + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  7730. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  7731. resp3, requestErr3 := http.Get(api3)
  7732. if requestErr3 != nil {
  7733. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7734. return
  7735. }
  7736. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  7737. if ioErr3 != nil {
  7738. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  7739. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7740. return
  7741. }
  7742. var respJSON3 map[string]interface{}
  7743. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  7744. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  7745. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7746. return
  7747. }
  7748. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  7749. userJSONBytes3, _ := json.Marshal(respJSON3)
  7750. fmt.Println("log")
  7751. fmt.Println(string(userJSONBytes3))
  7752. if err := json.Unmarshal(userJSONBytes3, &res); err != nil {
  7753. utils.ErrorLog("解析失败:%v", err)
  7754. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7755. return
  7756. }
  7757. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  7758. var api3 string
  7759. if miConfig.MdtrtareaAdmvs == "320921" {
  7760. api3 = "http://192.168.2.110:9532/" + "jsyb/2208?psn_no=" + order.PsnNo +
  7761. "&mdtrt_id=" + order.MdtrtId + "&setl_id=" + order.SetlId + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  7762. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  7763. //req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  7764. } else {
  7765. //req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  7766. api3 = "http://192.168.5.251:9532/" + "jsyb/2208?psn_no=" + order.PsnNo +
  7767. "&mdtrt_id=" + order.MdtrtId + "&setl_id=" + order.SetlId + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  7768. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  7769. }
  7770. resp3, requestErr3 := http.Get(api3)
  7771. if requestErr3 != nil {
  7772. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7773. return
  7774. }
  7775. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  7776. if ioErr3 != nil {
  7777. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  7778. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7779. return
  7780. }
  7781. var respJSON3 map[string]interface{}
  7782. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  7783. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  7784. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7785. return
  7786. }
  7787. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  7788. userJSONBytes3, _ := json.Marshal(respJSON3)
  7789. if err := json.Unmarshal(userJSONBytes3, &resSixteen10265); err != nil {
  7790. utils.ErrorLog("解析失败:%v", err)
  7791. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7792. return
  7793. }
  7794. res.InfRefmsgid = resSixteen10265.InfRefmsgid
  7795. res.Output = resSixteen10265.Output
  7796. res.ErrMsg = resSixteen10265.ErrMsg
  7797. res.Cainfo = resSixteen10265.Cainfo
  7798. res.WarnMsg = resSixteen10265.WarnMsg
  7799. infocode, _ := strconv.ParseInt(resSixteen10265.Infcode, 10, 64)
  7800. res.Infcode = infocode
  7801. } else if miConfig.MdtrtareaAdmvs == "350500" {
  7802. 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)
  7803. var dat map[string]interface{}
  7804. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  7805. fmt.Println(dat)
  7806. } else {
  7807. fmt.Println(err)
  7808. }
  7809. saveLog(result, src_resquest, "2208", "退费")
  7810. userJSONBytes, _ := json.Marshal(dat)
  7811. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  7812. utils.ErrorLog("解析失败:%v", err)
  7813. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7814. return
  7815. }
  7816. } else {
  7817. if miConfig.Code == "H15049901371" {
  7818. result, src_resquest = service.Gdyb2208(order.PsnNo, order.MdtrtId, order.SetlId, miConfig.OrgName, roles.UserName, miConfig.SecretKey, miConfig.Code, his.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs)
  7819. var dat map[string]interface{}
  7820. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  7821. fmt.Println(dat)
  7822. } else {
  7823. fmt.Println(err)
  7824. }
  7825. saveLog(result, src_resquest, "2208", "退费")
  7826. userJSONBytes, _ := json.Marshal(dat)
  7827. if err := json.Unmarshal(userJSONBytes, &resSixteen10265); err != nil {
  7828. utils.ErrorLog("解析失败:%v", err)
  7829. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7830. return
  7831. }
  7832. res.InfRefmsgid = resSixteen10265.InfRefmsgid
  7833. res.Output = resSixteen10265.Output
  7834. res.ErrMsg = resSixteen10265.ErrMsg
  7835. res.Cainfo = resSixteen10265.Cainfo
  7836. res.WarnMsg = resSixteen10265.WarnMsg
  7837. infocode, _ := strconv.ParseInt(resSixteen10265.Infcode, 10, 64)
  7838. res.Infcode = infocode
  7839. } else {
  7840. result, src_resquest = service.Gdyb2208(order.PsnNo, order.MdtrtId, order.SetlId, miConfig.OrgName, roles.UserName, miConfig.SecretKey, miConfig.Code, his.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs)
  7841. var dat map[string]interface{}
  7842. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  7843. fmt.Println(dat)
  7844. } else {
  7845. fmt.Println(err)
  7846. }
  7847. saveLog(result, src_resquest, "2208", "退费")
  7848. userJSONBytes, _ := json.Marshal(dat)
  7849. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  7850. utils.ErrorLog("解析失败:%v", err)
  7851. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7852. return
  7853. }
  7854. }
  7855. }
  7856. if res.Infcode == 0 {
  7857. var res2 ResultSix
  7858. var resSix10265 ResultSix10265
  7859. if miConfig.MdtrtareaAdmvs == "421300" {
  7860. api3 := "http://192.168.124.4:9532/" + "hbyb/2205?psn_no=" + order.PsnNo +
  7861. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  7862. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  7863. resp3, requestErr3 := http.Get(api3)
  7864. if requestErr3 != nil {
  7865. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7866. return
  7867. }
  7868. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  7869. if ioErr3 != nil {
  7870. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  7871. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7872. return
  7873. }
  7874. var respJSON3 map[string]interface{}
  7875. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  7876. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  7877. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7878. return
  7879. }
  7880. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  7881. userJSONBytes3, _ := json.Marshal(respJSON3)
  7882. fmt.Println("log")
  7883. fmt.Println(string(userJSONBytes3))
  7884. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  7885. utils.ErrorLog("解析失败:%v", err)
  7886. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7887. return
  7888. }
  7889. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  7890. var api3 string
  7891. if miConfig.MdtrtareaAdmvs == "320921" {
  7892. api3 = "http://192.168.2.110:9532/" + "jsyb/2205?psn_no=" + order.PsnNo +
  7893. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  7894. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  7895. //req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  7896. } else {
  7897. //req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  7898. api3 = "http://192.168.5.251:9532/" + "jsyb/2205?psn_no=" + order.PsnNo +
  7899. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  7900. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  7901. }
  7902. resp3, requestErr3 := http.Get(api3)
  7903. if requestErr3 != nil {
  7904. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7905. return
  7906. }
  7907. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  7908. if ioErr3 != nil {
  7909. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  7910. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7911. return
  7912. }
  7913. var respJSON3 map[string]interface{}
  7914. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  7915. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  7916. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7917. return
  7918. }
  7919. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  7920. userJSONBytes3, _ := json.Marshal(respJSON3)
  7921. fmt.Println("log")
  7922. fmt.Println(string(userJSONBytes3))
  7923. if err := json.Unmarshal(userJSONBytes3, &resSix10265); err != nil {
  7924. utils.ErrorLog("解析失败:%v", err)
  7925. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7926. return
  7927. }
  7928. res2.InfRefmsgid = resSix10265.InfRefmsgid
  7929. res2.Output = resSix10265.Output
  7930. res2.ErrMsg = resSix10265.ErrMsg
  7931. res2.Cainfo = resSix10265.Cainfo
  7932. res2.WarnMsg = resSix10265.WarnMsg
  7933. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  7934. res2.Infcode = infocode
  7935. } else if miConfig.MdtrtareaAdmvs == "350500" {
  7936. 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)
  7937. var dat map[string]interface{}
  7938. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  7939. fmt.Println(dat)
  7940. } else {
  7941. fmt.Println(err)
  7942. }
  7943. saveLog(result2, src_request, "2205", "撤销明细")
  7944. userJSONBytes, _ := json.Marshal(dat)
  7945. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  7946. utils.ErrorLog("解析失败:%v", err)
  7947. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7948. return
  7949. }
  7950. } else {
  7951. if miConfig.Code == "H15049901371" {
  7952. result2, src_request := service.Gdyb2205(order.PsnNo, order.MdtrtId, order.Number, miConfig.OrgName, roles.UserName, his.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, miConfig.Code)
  7953. var dat map[string]interface{}
  7954. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  7955. fmt.Println(dat)
  7956. } else {
  7957. fmt.Println(err)
  7958. }
  7959. saveLog(result2, src_request, "2205", "撤销明细")
  7960. userJSONBytes, _ := json.Marshal(dat)
  7961. if err := json.Unmarshal(userJSONBytes, &resSix10265); err != nil {
  7962. utils.ErrorLog("解析失败:%v", err)
  7963. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7964. return
  7965. }
  7966. res2.InfRefmsgid = resSix10265.InfRefmsgid
  7967. res2.Output = resSix10265.Output
  7968. res2.ErrMsg = resSix10265.ErrMsg
  7969. res2.Cainfo = resSix10265.Cainfo
  7970. res2.WarnMsg = resSix10265.WarnMsg
  7971. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  7972. res2.Infcode = infocode
  7973. } else {
  7974. result2, src_request := service.Gdyb2205(order.PsnNo, order.MdtrtId, order.Number, miConfig.OrgName, roles.UserName, his.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, miConfig.Code)
  7975. var dat map[string]interface{}
  7976. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  7977. fmt.Println(dat)
  7978. } else {
  7979. fmt.Println(err)
  7980. }
  7981. saveLog(result2, src_request, "2205", "撤销明细")
  7982. userJSONBytes, _ := json.Marshal(dat)
  7983. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  7984. utils.ErrorLog("解析失败:%v", err)
  7985. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7986. return
  7987. }
  7988. }
  7989. }
  7990. if res2.Infcode == 0 {
  7991. err := service.UpdataOrderStatus(order_id, order.Number, adminUser.CurrentOrgId, src_resquest, result)
  7992. if err == nil {
  7993. //当押金不为零时产生退费记录
  7994. if order.Decimal != 0 {
  7995. tmp := strconv.FormatInt(order.ID, 10)
  7996. err = service.MoneyIncrease(adminUser.CurrentOrgId, order.PatientId, tmp, order.Decimal)
  7997. if err != nil {
  7998. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7999. return
  8000. }
  8001. }
  8002. c.ServeSuccessJSON(map[string]interface{}{
  8003. "msg": "退费成功",
  8004. })
  8005. } else {
  8006. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8007. return
  8008. }
  8009. } else {
  8010. c.ServeSuccessJSON(map[string]interface{}{
  8011. "code": -10,
  8012. "msg": res2.ErrMsg,
  8013. })
  8014. }
  8015. } else {
  8016. c.ServeSuccessJSON(map[string]interface{}{
  8017. "code": -10,
  8018. "msg": res.ErrMsg,
  8019. })
  8020. }
  8021. }
  8022. }
  8023. func (c *HisApiController) RefundNumber() {
  8024. record_time := c.GetString("record_time")
  8025. //patient_id, _ := c.GetInt64("patient_id")
  8026. admin_user_id, _ := c.GetInt64("admin_user_id")
  8027. his_patient_id, _ := c.GetInt64("id")
  8028. timeLayout := "2006-01-02"
  8029. loc, _ := time.LoadLocation("Local")
  8030. adminUser := c.GetAdminUserInfo()
  8031. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  8032. fmt.Println(err)
  8033. if err != nil {
  8034. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  8035. return
  8036. }
  8037. recordDateTime := theTime.Unix()
  8038. //his, _ := service.GetVMHisPatientInfo(adminUser.CurrentOrgId, patient_id, recordDateTime)
  8039. his, _ := service.GetHisPatientRecord(adminUser.CurrentOrgId, his_patient_id)
  8040. //patientPrescription, _ := service.FindPatientPrescriptionInfo(adminUser.CurrentOrgId, patient_id, recordDateTime)
  8041. //order, _ := service.GetHisOrderByID(order_id)
  8042. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  8043. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  8044. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  8045. count, _ := service.GetOrderCountByNumber(adminUser.CurrentOrgId, his.PatientId, recordDateTime, his.Number)
  8046. if count > 0 {
  8047. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeOrderParamWrong)
  8048. return
  8049. }
  8050. if config.IsOpen == 1 { //对接了医保,走医保流程
  8051. var res2 ResultSix
  8052. var resSix10265 ResultSix10265
  8053. if miConfig.MdtrtareaAdmvs == "421300" {
  8054. api3 := "http://192.168.124.4:9532/" + "hbyb/2202?psn_no=" + his.PsnNo +
  8055. "&mdtrt_id=" + his.Number + "&ipt_otp_no=" + his.IptOtpNo + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  8056. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  8057. resp3, requestErr3 := http.Get(api3)
  8058. if requestErr3 != nil {
  8059. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8060. return
  8061. }
  8062. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  8063. if ioErr3 != nil {
  8064. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  8065. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8066. return
  8067. }
  8068. var respJSON3 map[string]interface{}
  8069. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  8070. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  8071. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8072. return
  8073. }
  8074. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  8075. userJSONBytes3, _ := json.Marshal(respJSON3)
  8076. fmt.Println("log")
  8077. fmt.Println(string(userJSONBytes3))
  8078. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  8079. utils.ErrorLog("解析失败:%v", err)
  8080. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8081. return
  8082. }
  8083. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  8084. var api3 string
  8085. if miConfig.MdtrtareaAdmvs == "320921" {
  8086. api3 = "http://192.168.2.110:9532/" + "jsyb/2202?psn_no=" + his.PsnNo +
  8087. "&mdtrt_id=" + his.Number + "&ipt_otp_no=" + his.IptOtpNo + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  8088. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  8089. //req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  8090. } else {
  8091. //req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  8092. api3 = "http://192.168.5.251:9532/" + "jsyb/2202?psn_no=" + his.PsnNo +
  8093. "&mdtrt_id=" + his.Number + "&ipt_otp_no=" + his.IptOtpNo + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  8094. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  8095. }
  8096. resp3, requestErr3 := http.Get(api3)
  8097. if requestErr3 != nil {
  8098. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8099. return
  8100. }
  8101. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  8102. if ioErr3 != nil {
  8103. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  8104. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8105. return
  8106. }
  8107. var respJSON3 map[string]interface{}
  8108. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  8109. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  8110. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8111. return
  8112. }
  8113. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  8114. userJSONBytes3, _ := json.Marshal(respJSON3)
  8115. if err := json.Unmarshal(userJSONBytes3, &resSix10265); err != nil {
  8116. utils.ErrorLog("解析失败:%v", err)
  8117. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8118. return
  8119. }
  8120. res2.InfRefmsgid = resSix10265.InfRefmsgid
  8121. res2.Output = resSix10265.Output
  8122. res2.ErrMsg = resSix10265.ErrMsg
  8123. res2.Cainfo = resSix10265.Cainfo
  8124. res2.WarnMsg = resSix10265.WarnMsg
  8125. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  8126. res2.Infcode = infocode
  8127. } else if miConfig.MdtrtareaAdmvs == "350500" {
  8128. 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)
  8129. var dat map[string]interface{}
  8130. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  8131. fmt.Println(dat)
  8132. } else {
  8133. fmt.Println(err)
  8134. }
  8135. saveLog(result, request, "2202", "退号")
  8136. userJSONBytes, _ := json.Marshal(dat)
  8137. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  8138. utils.ErrorLog("解析失败:%v", err)
  8139. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8140. return
  8141. }
  8142. } else {
  8143. var api3 string
  8144. if miConfig.Code == "H15049901371" {
  8145. api3 = "http://127.0.0.1:9532/" + "gdyb/three?psn_no=" + his.PsnNo +
  8146. "&mdtrt_id=" + his.Number + "&ipt_otp_no=" + his.IptOtpNo + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  8147. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  8148. } else {
  8149. api3 = "http://127.0.0.1:9532/" + "gdyb/three?psn_no=" + his.PsnNo +
  8150. "&mdtrt_id=" + his.Number + "&ipt_otp_no=" + his.IptOtpNo + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  8151. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  8152. }
  8153. resp3, requestErr3 := http.Get(api3)
  8154. if requestErr3 != nil {
  8155. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8156. return
  8157. }
  8158. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  8159. if ioErr3 != nil {
  8160. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  8161. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8162. return
  8163. }
  8164. var respJSON3 map[string]interface{}
  8165. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  8166. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  8167. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8168. return
  8169. }
  8170. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  8171. userJSONBytes3, _ := json.Marshal(respJSON3)
  8172. if miConfig.Code == "H15049901371" {
  8173. if err := json.Unmarshal(userJSONBytes3, &resSix10265); err != nil {
  8174. utils.ErrorLog("解析失败:%v", err)
  8175. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8176. return
  8177. }
  8178. res2.InfRefmsgid = resSix10265.InfRefmsgid
  8179. res2.Output = resSix10265.Output
  8180. res2.ErrMsg = resSix10265.ErrMsg
  8181. res2.Cainfo = resSix10265.Cainfo
  8182. res2.WarnMsg = resSix10265.WarnMsg
  8183. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  8184. res2.Infcode = infocode
  8185. } else {
  8186. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  8187. utils.ErrorLog("解析失败:%v", err)
  8188. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8189. return
  8190. }
  8191. }
  8192. }
  8193. if res2.Infcode == 0 {
  8194. if err == nil {
  8195. c.ServeSuccessJSON(map[string]interface{}{
  8196. "msg": "退号成功",
  8197. })
  8198. service.UpdataRegStatusTwo(his_patient_id, recordDateTime, adminUser.CurrentOrgId)
  8199. } else {
  8200. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8201. return
  8202. }
  8203. } else {
  8204. c.ServeSuccessJSON(map[string]interface{}{
  8205. "code": -10,
  8206. "msg": res2.ErrMsg,
  8207. })
  8208. }
  8209. } else {
  8210. //err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId)
  8211. //if err == nil {
  8212. // c.ServeSuccessJSON(map[string]interface{}{
  8213. // "msg": "退费成功",
  8214. // })
  8215. //} else {
  8216. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8217. // return
  8218. //}
  8219. }
  8220. }
  8221. func (c *HisApiController) RefundDetail() {
  8222. order_id, _ := c.GetInt64("order_id")
  8223. admin_user_id, _ := c.GetInt64("admin_user_id")
  8224. //his_patient_id, _ := c.GetInt64("his_patient_id")
  8225. number := c.GetString("number")
  8226. record_time := c.GetString("record_time")
  8227. patient_id, _ := c.GetInt64("patient_id")
  8228. //med_type, _ := c.GetInt64("med_type")
  8229. timeLayout := "2006-01-02"
  8230. loc, _ := time.LoadLocation("Local")
  8231. adminUser := c.GetAdminUserInfo()
  8232. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  8233. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  8234. fmt.Println(err)
  8235. if err != nil {
  8236. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  8237. return
  8238. }
  8239. recordDateTime := theTime.Unix()
  8240. //his, _ := service.GetNewVMHisPatientInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  8241. patientPrescription, _ := service.FindPatientPrescriptionInfo(adminUser.CurrentOrgId, patient_id, recordDateTime)
  8242. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  8243. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  8244. var order models.HisOrder
  8245. order, _ = service.GetHisOrderByID(order_id)
  8246. his, _ := service.GetHisPatientByNumber(order.MdtrtId)
  8247. if config.IsOpen == 1 { //对接了医保,走医保流程
  8248. var res2 ResultSix
  8249. if miConfig.MdtrtareaAdmvs == "421300" {
  8250. api3 := "http://192.168.124.4:9532/" + "hbyb/2205?psn_no=" + order.PsnNo +
  8251. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + patientPrescription.Doctor + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  8252. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  8253. resp3, requestErr3 := http.Get(api3)
  8254. if requestErr3 != nil {
  8255. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8256. return
  8257. }
  8258. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  8259. if ioErr3 != nil {
  8260. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  8261. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8262. return
  8263. }
  8264. var respJSON3 map[string]interface{}
  8265. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  8266. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  8267. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8268. return
  8269. }
  8270. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  8271. userJSONBytes3, _ := json.Marshal(respJSON3)
  8272. fmt.Println("log")
  8273. fmt.Println(string(userJSONBytes3))
  8274. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  8275. utils.ErrorLog("解析失败:%v", err)
  8276. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8277. return
  8278. }
  8279. err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId, "", "")
  8280. if err == nil {
  8281. c.ServeSuccessJSON(map[string]interface{}{
  8282. "msg": "撤销明细成功",
  8283. })
  8284. return
  8285. } else {
  8286. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8287. return
  8288. }
  8289. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  8290. var resSix10265 ResultSix10265
  8291. var api3 string
  8292. if miConfig.MdtrtareaAdmvs == "320921" {
  8293. api3 = "http://192.168.2.110:9532/" + "jsyb/2205?psn_no=" + order.PsnNo +
  8294. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + patientPrescription.Doctor + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  8295. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  8296. //req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  8297. } else {
  8298. //req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  8299. api3 = "http://192.168.5.251:9532/" + "jsyb/2205?psn_no=" + order.PsnNo +
  8300. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + patientPrescription.Doctor + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  8301. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  8302. }
  8303. resp3, requestErr3 := http.Get(api3)
  8304. if requestErr3 != nil {
  8305. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8306. return
  8307. }
  8308. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  8309. if ioErr3 != nil {
  8310. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  8311. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8312. return
  8313. }
  8314. var respJSON3 map[string]interface{}
  8315. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  8316. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  8317. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8318. return
  8319. }
  8320. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  8321. userJSONBytes3, _ := json.Marshal(respJSON3)
  8322. fmt.Println("log")
  8323. fmt.Println(string(userJSONBytes3))
  8324. if err := json.Unmarshal(userJSONBytes3, &resSix10265); err != nil {
  8325. utils.ErrorLog("解析失败:%v", err)
  8326. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8327. return
  8328. }
  8329. res2.InfRefmsgid = resSix10265.InfRefmsgid
  8330. res2.Output = resSix10265.Output
  8331. res2.ErrMsg = resSix10265.ErrMsg
  8332. res2.Cainfo = resSix10265.Cainfo
  8333. res2.WarnMsg = resSix10265.WarnMsg
  8334. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  8335. res2.Infcode = infocode
  8336. err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId, "", "")
  8337. if err == nil {
  8338. c.ServeSuccessJSON(map[string]interface{}{
  8339. "msg": "撤销明细成功",
  8340. })
  8341. return
  8342. } else {
  8343. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8344. return
  8345. }
  8346. } else if miConfig.MdtrtareaAdmvs == "350500" {
  8347. 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)
  8348. var dat map[string]interface{}
  8349. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  8350. fmt.Println(dat)
  8351. } else {
  8352. fmt.Println(err)
  8353. }
  8354. saveLog(result2, src_request, "2205", "撤销明细")
  8355. userJSONBytes, _ := json.Marshal(dat)
  8356. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  8357. utils.ErrorLog("解析失败:%v", err)
  8358. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8359. return
  8360. }
  8361. if res2.Infcode == 0 {
  8362. err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId, "", "")
  8363. if err == nil {
  8364. c.ServeSuccessJSON(map[string]interface{}{
  8365. "msg": "撤销明细成功",
  8366. })
  8367. return
  8368. } else {
  8369. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8370. return
  8371. }
  8372. } else {
  8373. c.ServeSuccessJSON(map[string]interface{}{
  8374. "code": -10,
  8375. "msg": res2.ErrMsg,
  8376. })
  8377. }
  8378. } else {
  8379. api2 := "http://127.0.0.1:9532/" + "gdyb/six?psn_no=" + his.PsnNo +
  8380. "&mdtrt_id=" + his.Number + "&chrg_bchno=" + order.Number + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  8381. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  8382. resp2, requestErr2 := http.Get(api2)
  8383. if requestErr2 != nil {
  8384. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8385. return
  8386. }
  8387. body2, ioErr2 := ioutil.ReadAll(resp2.Body)
  8388. if ioErr2 != nil {
  8389. utils.ErrorLog("接口返回数据读取失败: %v", ioErr2)
  8390. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8391. return
  8392. }
  8393. var respJSON2 map[string]interface{}
  8394. if err := json.Unmarshal([]byte(string(body2)), &respJSON2); err != nil {
  8395. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  8396. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8397. return
  8398. }
  8399. err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId, "", "")
  8400. if err == nil {
  8401. c.ServeSuccessJSON(map[string]interface{}{
  8402. "msg": "撤销明细成功",
  8403. })
  8404. return
  8405. } else {
  8406. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8407. return
  8408. }
  8409. }
  8410. } else {
  8411. err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId, "", "")
  8412. if err == nil {
  8413. c.ServeSuccessJSON(map[string]interface{}{
  8414. "msg": "退费成功",
  8415. })
  8416. } else {
  8417. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8418. return
  8419. }
  8420. }
  8421. }
  8422. //对账
  8423. func (c *HisApiController) GetCheckAccount() {
  8424. start_time := c.GetString("start_time")
  8425. end_time := c.GetString("end_time")
  8426. insutype := c.GetString("insutype")
  8427. clr_type := c.GetString("clr_type")
  8428. clr_org := c.GetString("clr_optins")
  8429. admin_user_id, _ := c.GetInt64("admin_user_id")
  8430. adminUser := c.GetAdminUserInfo()
  8431. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  8432. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  8433. if len(clr_org) == 0 {
  8434. clr_org = miConfig.MdtrtareaAdmvs
  8435. }
  8436. timeLayout := "2006-01-02"
  8437. loc, _ := time.LoadLocation("Local")
  8438. startime, _ := time.ParseInLocation(timeLayout+" 15:04:05", start_time+" 00:00:00", loc)
  8439. endtime, _ := time.ParseInLocation(timeLayout+" 15:04:05", end_time+" 23:59:59", loc)
  8440. orders, _ := service.GetOrderByTime(startime.Unix(), endtime.Unix(), adminUser.CurrentOrgId, insutype, "", clr_type)
  8441. fixmedins_setl_cnt := int64(len(orders))
  8442. var medfee_sumamt float64
  8443. var acct_pay float64
  8444. var fund_pay_sumamt float64
  8445. for _, item := range orders {
  8446. medfee_sumamt = medfee_sumamt + item.MedfeeSumamt
  8447. acct_pay = acct_pay + item.AcctPay
  8448. fund_pay_sumamt = fund_pay_sumamt + item.FundPaySumamt
  8449. }
  8450. var user_name string
  8451. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  8452. if role.ID == 0 {
  8453. user_name = "xxx"
  8454. } else {
  8455. user_name = role.UserName
  8456. }
  8457. var res ResultEight
  8458. var res10188 ResultEightFor10188
  8459. if config.IsOpen == 1 {
  8460. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  8461. api := "http://192.168.2.110:9532/" + "jsyb/3201?" +
  8462. "insutype=" + insutype +
  8463. "&clr_type=" + clr_type +
  8464. "&setl_optins=" + clr_org +
  8465. "&stmt_begndate=" + start_time +
  8466. "&stm_enddate=" + end_time +
  8467. "&medfee_sumamt=" + fmt.Sprintf("%.4f", medfee_sumamt) +
  8468. "&fund_pay_sumamt=" + fmt.Sprintf("%.4f", fund_pay_sumamt) +
  8469. "&acct_pay=" + fmt.Sprintf("%.4f", acct_pay) +
  8470. "&fixmedins_setl_cnt=" + strconv.FormatInt(fixmedins_setl_cnt, 10) +
  8471. "&fixmedins_code=" + miConfig.Code +
  8472. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs +
  8473. "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  8474. "&secret_key=" + miConfig.SecretKey +
  8475. "&org_name=" + miConfig.OrgName +
  8476. "&doctor=" + user_name +
  8477. "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  8478. fmt.Println(api)
  8479. resp, requestErr := http.Get(api)
  8480. if requestErr != nil {
  8481. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8482. return
  8483. }
  8484. body, ioErr := ioutil.ReadAll(resp.Body)
  8485. fmt.Println(body)
  8486. if ioErr != nil {
  8487. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  8488. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8489. return
  8490. }
  8491. var respJSON map[string]interface{}
  8492. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  8493. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  8494. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8495. return
  8496. }
  8497. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  8498. userJSONBytes, _ := json.Marshal(respJSON)
  8499. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  8500. utils.ErrorLog("解析失败:%v", err)
  8501. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8502. return
  8503. }
  8504. res.InfRefmsgid = res10188.InfRefmsgid
  8505. res.Output = res10188.Output
  8506. res.ErrMsg = res10188.ErrMsg
  8507. res.Cainfo = res10188.Cainfo
  8508. res.WarnMsg = res10188.WarnMsg
  8509. infocode, _ := strconv.ParseInt(res10188.Infcode, 10, 64)
  8510. res.Infcode = infocode
  8511. } else if miConfig.MdtrtareaAdmvs == "150499" {
  8512. api := "http://172.16.13.254:9532/" + "nmyb/3201?" +
  8513. "insutype=" + insutype +
  8514. "&clr_type=" + clr_type +
  8515. "&setl_optins=" + clr_org +
  8516. "&stmt_begndate=" + start_time +
  8517. "&stm_enddate=" + end_time +
  8518. "&medfee_sumamt=" + fmt.Sprintf("%.4f", medfee_sumamt) +
  8519. "&fund_pay_sumamt=" + fmt.Sprintf("%.4f", fund_pay_sumamt) +
  8520. "&acct_pay=" + fmt.Sprintf("%.4f", acct_pay) +
  8521. "&fixmedins_setl_cnt=" + strconv.FormatInt(fixmedins_setl_cnt, 10) +
  8522. "&fixmedins_code=" + miConfig.Code +
  8523. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs +
  8524. "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  8525. "&secret_key=" + miConfig.SecretKey +
  8526. "&org_name=" + miConfig.OrgName +
  8527. "&doctor=" + user_name
  8528. resp, requestErr := http.Get(api)
  8529. if requestErr != nil {
  8530. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8531. return
  8532. }
  8533. body, ioErr := ioutil.ReadAll(resp.Body)
  8534. if ioErr != nil {
  8535. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  8536. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8537. return
  8538. }
  8539. var respJSON map[string]interface{}
  8540. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  8541. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  8542. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8543. return
  8544. }
  8545. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  8546. result, _ := json.Marshal(respJSON)
  8547. fmt.Println("log")
  8548. fmt.Println(string(result))
  8549. if err := json.Unmarshal([]byte(result), &res10188); err != nil {
  8550. utils.ErrorLog("解析失败:%v", err)
  8551. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8552. return
  8553. }
  8554. res.InfRefmsgid = res10188.InfRefmsgid
  8555. res.Output = res10188.Output
  8556. res.ErrMsg = res10188.ErrMsg
  8557. res.Cainfo = res10188.Cainfo
  8558. res.WarnMsg = res10188.WarnMsg
  8559. infocode, _ := strconv.ParseInt(res10188.Infcode, 10, 64)
  8560. res.Infcode = infocode
  8561. } else {
  8562. api := "http://127.0.0.1:9532/" + "gdyb/ten?" +
  8563. "insutype=" + insutype +
  8564. "&clr_type=" + clr_type +
  8565. "&setl_optins=" + clr_org +
  8566. "&stmt_begndate=" + start_time +
  8567. "&stm_enddate=" + end_time +
  8568. "&medfee_sumamt=" + fmt.Sprintf("%.4f", medfee_sumamt) +
  8569. "&fund_pay_sumamt=" + fmt.Sprintf("%.4f", fund_pay_sumamt) +
  8570. "&acct_pay=" + fmt.Sprintf("%.4f", acct_pay) +
  8571. "&fixmedins_setl_cnt=" + strconv.FormatInt(fixmedins_setl_cnt, 10) +
  8572. "&fixmedins_code=" + miConfig.Code +
  8573. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs +
  8574. "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  8575. "&secret_key=" + miConfig.SecretKey +
  8576. "&org_name=" + miConfig.OrgName +
  8577. "&doctor=" + user_name
  8578. fmt.Println(api)
  8579. resp, requestErr := http.Get(api)
  8580. if requestErr != nil {
  8581. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8582. return
  8583. }
  8584. body, ioErr := ioutil.ReadAll(resp.Body)
  8585. fmt.Println(body)
  8586. if ioErr != nil {
  8587. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  8588. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8589. return
  8590. }
  8591. var respJSON map[string]interface{}
  8592. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  8593. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  8594. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8595. return
  8596. }
  8597. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  8598. userJSONBytes, _ := json.Marshal(respJSON)
  8599. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  8600. utils.ErrorLog("解析失败:%v", err)
  8601. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8602. return
  8603. }
  8604. }
  8605. if res.Infcode == 0 {
  8606. if res.Output.Stmtinfo.StmtRslt == "0" {
  8607. micc := &models.MedicalInsuranceCostCompare{
  8608. StartTime: startime.Unix(),
  8609. EndTime: endtime.Unix(),
  8610. Insutype: insutype,
  8611. CheckType: 1,
  8612. Num: fixmedins_setl_cnt,
  8613. Mtime: time.Now().Unix(),
  8614. Status: 1,
  8615. UserOrgId: adminUser.CurrentOrgId,
  8616. CostTotal: medfee_sumamt,
  8617. FuncTotal: fund_pay_sumamt,
  8618. PsnPay: acct_pay,
  8619. Creator: admin_user_id,
  8620. Ctime: time.Now().Unix(),
  8621. ClrType: clr_type,
  8622. }
  8623. err := service.CreateMedicalInsuranceCostCompareRecord(micc)
  8624. if err == nil {
  8625. c.ServeSuccessJSON(map[string]interface{}{
  8626. "stmt_rslt": res.Output.Stmtinfo.StmtRslt,
  8627. "stmt_rslt_dscr": res.Output.Stmtinfo.StmtRsltDscr,
  8628. })
  8629. } else {
  8630. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8631. }
  8632. } else {
  8633. c.ServeSuccessJSON(map[string]interface{}{
  8634. "stmt_rslt": res.Output.Stmtinfo.StmtRslt,
  8635. "stmt_rslt_dscr": res.Output.Stmtinfo.StmtRsltDscr,
  8636. })
  8637. }
  8638. } else {
  8639. c.ServeSuccessJSON(map[string]interface{}{
  8640. "code": -10,
  8641. "msg": res.ErrMsg,
  8642. })
  8643. }
  8644. }
  8645. }
  8646. func (c *HisApiController) Check310() {
  8647. adminUser := c.GetAdminUserInfo()
  8648. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  8649. var user_name string
  8650. user_name = "高慧裕"
  8651. api := "http://127.0.0.1:9532/" + "gdyb/ten?" +
  8652. "insutype=" + "310" +
  8653. "&clr_type=" + "" +
  8654. "&setl_optins=" + "441202" +
  8655. "&stmt_begndate=" + "2022-03-01" +
  8656. "&stm_enddate=" + "2022-03-31" +
  8657. "&medfee_sumamt=" + "194930.12" +
  8658. "&fund_pay_sumamt=" + "188741.46" +
  8659. "&acct_pay=" + "0" +
  8660. "&fixmedins_setl_cnt=" + "452" +
  8661. "&fixmedins_code=" + miConfig.Code +
  8662. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs +
  8663. "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  8664. "&secret_key=" + miConfig.SecretKey +
  8665. "&org_name=" + miConfig.OrgName +
  8666. "&doctor=" + user_name
  8667. fmt.Println(api)
  8668. resp, requestErr := http.Get(api)
  8669. if requestErr != nil {
  8670. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8671. return
  8672. }
  8673. body, ioErr := ioutil.ReadAll(resp.Body)
  8674. fmt.Println(body)
  8675. if ioErr != nil {
  8676. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  8677. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8678. return
  8679. }
  8680. var respJSON map[string]interface{}
  8681. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  8682. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  8683. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8684. return
  8685. }
  8686. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  8687. userJSONBytes, _ := json.Marshal(respJSON)
  8688. var res ResultEight
  8689. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  8690. utils.ErrorLog("解析失败:%v", err)
  8691. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8692. return
  8693. }
  8694. }
  8695. func (c *HisApiController) Check390() {
  8696. adminUser := c.GetAdminUserInfo()
  8697. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  8698. var user_name string
  8699. user_name = "高慧裕"
  8700. api := "http://127.0.0.1:9532/" + "gdyb/ten?" +
  8701. "insutype=" + "390" +
  8702. "&clr_type=" + "" +
  8703. "&setl_optins=" + "441202" +
  8704. "&stmt_begndate=" + "2022-03-01" +
  8705. "&stm_enddate=" + "2022-03-31" +
  8706. "&medfee_sumamt=" + "1068448.89" +
  8707. "&fund_pay_sumamt=" + "1014677.62" +
  8708. "&acct_pay=" + "0" +
  8709. "&fixmedins_setl_cnt=" + "1950" +
  8710. "&fixmedins_code=" + miConfig.Code +
  8711. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs +
  8712. "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  8713. "&secret_key=" + miConfig.SecretKey +
  8714. "&org_name=" + miConfig.OrgName +
  8715. "&doctor=" + user_name
  8716. fmt.Println(api)
  8717. resp, requestErr := http.Get(api)
  8718. if requestErr != nil {
  8719. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8720. return
  8721. }
  8722. body, ioErr := ioutil.ReadAll(resp.Body)
  8723. fmt.Println(body)
  8724. if ioErr != nil {
  8725. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  8726. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8727. return
  8728. }
  8729. var respJSON map[string]interface{}
  8730. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  8731. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  8732. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8733. return
  8734. }
  8735. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  8736. userJSONBytes, _ := json.Marshal(respJSON)
  8737. var res ResultEight
  8738. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  8739. utils.ErrorLog("解析失败:%v", err)
  8740. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8741. return
  8742. }
  8743. }
  8744. //对账明细
  8745. func (c *HisApiController) GetCheckDetailAccount() {
  8746. start_time := c.GetString("start_time")
  8747. end_time := c.GetString("end_time")
  8748. admin_user_id, _ := c.GetInt64("admin_user_id")
  8749. adminUser := c.GetAdminUserInfo()
  8750. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  8751. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  8752. timeLayout := "2006-01-02"
  8753. loc, _ := time.LoadLocation("Local")
  8754. startime, _ := time.ParseInLocation(timeLayout+" 15:04:05", start_time+" 00:00:00", loc)
  8755. endtime, _ := time.ParseInLocation(timeLayout+" 15:04:05", end_time+" 23:59:59", loc)
  8756. orders, _ := service.GetOrderByTimeTwo(startime.Unix(), endtime.Unix(), adminUser.CurrentOrgId)
  8757. rand.Seed(time.Now().UnixNano())
  8758. num := rand.Intn(30000)
  8759. Mkdir(miConfig.OrgName)
  8760. file := strconv.FormatInt(int64(num), 10)
  8761. file_name := file + ".txt"
  8762. zip_name := file + ".zip"
  8763. zip_path := miConfig.OrgName + "/" + zip_name
  8764. file_path := miConfig.OrgName + "/" + file_name
  8765. decimal.DivisionPrecision = 2
  8766. var medfee_sumamt float64
  8767. var psn_cash_pay float64
  8768. var fund_pay_sumamt float64
  8769. fixmedins_setl_cnt := int64(len(orders))
  8770. for _, item := range orders {
  8771. medfee_sumamt = medfee_sumamt + item.MedfeeSumamt
  8772. psn_cash_pay = psn_cash_pay + item.PsnCashPay
  8773. fund_pay_sumamt = fund_pay_sumamt + item.FundPaySumamt
  8774. }
  8775. f, err := os.Create(miConfig.OrgName + "/" + file_name)
  8776. defer f.Close()
  8777. if err != nil {
  8778. fmt.Println(err.Error())
  8779. } else {
  8780. for _, item := range orders {
  8781. var refd_setl_flag string
  8782. if item.OrderStatus == 2 {
  8783. refd_setl_flag = "0"
  8784. var str string
  8785. str = item.SetlId + " " +
  8786. item.MdtrtId + " " +
  8787. item.PsnNo + " " +
  8788. fmt.Sprintf("%.4f", item.MedfeeSumamt) + " " +
  8789. fmt.Sprintf("%.4f", item.FundPaySumamt) + " " +
  8790. fmt.Sprintf("%.4f", item.AcctPay) + " " + refd_setl_flag + "\r\n"
  8791. _, err = f.Write([]byte(str))
  8792. }
  8793. if item.OrderStatus == 3 {
  8794. var str string
  8795. str = item.SetlId + " " +
  8796. item.MdtrtId + " " +
  8797. item.PsnNo + " " +
  8798. fmt.Sprintf("%.4f", item.MedfeeSumamt) + " " +
  8799. fmt.Sprintf("%.4f", item.FundPaySumamt) + " " +
  8800. fmt.Sprintf("%.4f", item.AcctPay) + " " + "1" + "\r\n"
  8801. _, err = f.Write([]byte(str))
  8802. var str2 string
  8803. str2 = item.SetlId + " " +
  8804. item.MdtrtId + " " +
  8805. item.PsnNo + " " +
  8806. fmt.Sprintf("%.4f", 0-item.MedfeeSumamt) + " " +
  8807. fmt.Sprintf("%.4f", 0-item.FundPaySumamt) + " " +
  8808. fmt.Sprintf("%.4f", 0-item.AcctPay) + " " + "1" + "\r\n"
  8809. _, err = f.Write([]byte(str2))
  8810. }
  8811. }
  8812. }
  8813. Zip(file_path, zip_path)
  8814. fmt.Println(ReadFile(zip_path))
  8815. fmt.Println(string(ReadFile(zip_path)))
  8816. if config.IsOpen == 1 {
  8817. var user_name string
  8818. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  8819. if role.ID == 0 {
  8820. user_name = "管理员"
  8821. } else {
  8822. user_name = role.UserName
  8823. }
  8824. baseParams := models.BaseParams{
  8825. SecretKey: miConfig.SecretKey,
  8826. FixmedinsCode: miConfig.Code,
  8827. InsuplcAdmdvs: miConfig.InsuplcAdmdvs,
  8828. MdtrtareaAdmvs: miConfig.MdtrtareaAdmvs,
  8829. OrgName: miConfig.OrgName,
  8830. Doctor: user_name,
  8831. }
  8832. result := service.Gdyb9101(baseParams, file_name, ReadFile(file_path))
  8833. var dat map[string]interface{}
  8834. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  8835. fmt.Println(dat)
  8836. } else {
  8837. fmt.Println(err)
  8838. }
  8839. userJSONBytes, _ := json.Marshal(dat)
  8840. var res ResultNine
  8841. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  8842. utils.ErrorLog("解析失败:%v", err)
  8843. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8844. return
  8845. }
  8846. if res.Infcode == 0 {
  8847. fileNo := res.Output.FileQuryNo
  8848. api := "http://127.0.0.1:9532/" + "gdyb/twelve?" +
  8849. "file_qury_no=" + fileNo +
  8850. "&setl_optins=" + "定点医保中心" +
  8851. "&stmt_begndate=" + start_time +
  8852. "&stm_enddate=" + end_time +
  8853. "&medfee_sumamt=" + fmt.Sprintf("%.4f", medfee_sumamt) +
  8854. "&fund_pay_sumamt=" + fmt.Sprintf("%.4f", fund_pay_sumamt) +
  8855. "&cash_payamt=" + fmt.Sprintf("%.4f", psn_cash_pay) +
  8856. "&fixmedins_setl_cnt=" + strconv.FormatInt(fixmedins_setl_cnt, 10) +
  8857. "&fixmedins_code=" + miConfig.Code +
  8858. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs +
  8859. "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  8860. "&secret_key=" + miConfig.SecretKey +
  8861. "&org_name=" + miConfig.OrgName +
  8862. "&doctor=" + user_name
  8863. resp, requestErr := http.Get(api)
  8864. if requestErr != nil {
  8865. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8866. return
  8867. }
  8868. body, ioErr := ioutil.ReadAll(resp.Body)
  8869. if ioErr != nil {
  8870. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  8871. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8872. return
  8873. }
  8874. var respJSON map[string]interface{}
  8875. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  8876. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  8877. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8878. return
  8879. }
  8880. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  8881. userJSONBytes, _ := json.Marshal(respJSON)
  8882. var res ResultTen
  8883. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  8884. utils.ErrorLog("解析失败:%v", err)
  8885. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8886. return
  8887. }
  8888. if res.Infcode == 0 {
  8889. service.Gdyb9102(baseParams, zip_name, fileNo)
  8890. micc := &models.MedicalInsuranceCostCompare{
  8891. StartTime: startime.Unix(),
  8892. EndTime: endtime.Unix(),
  8893. Insutype: "0",
  8894. CheckType: 2,
  8895. Num: fixmedins_setl_cnt,
  8896. Mtime: time.Now().Unix(),
  8897. Status: 1,
  8898. UserOrgId: adminUser.CurrentOrgId,
  8899. CostTotal: medfee_sumamt,
  8900. FuncTotal: fund_pay_sumamt,
  8901. PsnPay: psn_cash_pay,
  8902. Creator: admin_user_id,
  8903. Ctime: time.Now().Unix(),
  8904. }
  8905. service.CreateMedicalInsuranceCostCompareRecord(micc)
  8906. c.ServeSuccessJSON(map[string]interface{}{
  8907. "msg": "明细对账成功",
  8908. })
  8909. }
  8910. } else {
  8911. }
  8912. }
  8913. }
  8914. type CustomOrderInfo struct {
  8915. Name string
  8916. Spec string
  8917. Unit string
  8918. Count float64
  8919. Price float64
  8920. Total float64
  8921. }
  8922. func (c *HisApiController) GetSettleAccounts() {
  8923. //id, _ := c.GetInt64("id")
  8924. //record_time := c.GetString("record_time")
  8925. order_id, _ := c.GetInt64("order_id")
  8926. admin_user_id, _ := c.GetInt64("admin_user_id")
  8927. //timeLayout := "2006-01-02"
  8928. //loc, _ := time.LoadLocation("Local")
  8929. //
  8930. //theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  8931. //if err != nil {
  8932. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  8933. // return
  8934. //}
  8935. //recordDateTime := theTime.Unix()
  8936. adminUser := c.GetAdminUserInfo()
  8937. order, _ := service.GetHisOrderByID(order_id)
  8938. his, _ := service.GetHisPatientByNumber(order.MdtrtId)
  8939. orderInfos, _ := service.GetHisOrderInfoByNumber(order.Number)
  8940. orderInfos_two, _ := service.GetHisOrderInfoByNumberTwo(order.Number)
  8941. orderInfos = append(orderInfos, orderInfos_two...)
  8942. his_hospital, _ := service.GetInHospitalRecordByNumber(order.MdtrtId)
  8943. //diagnosisConfig, _ := service.FindDiagnoseById(his.Diagnosis)
  8944. var diagnosis_ids []string
  8945. if his.ID > 0 {
  8946. diagnosis_ids = strings.Split(his.Diagnosis, ",")
  8947. } else {
  8948. diagnosis_ids = strings.Split(his_hospital.Diagnosis, ",")
  8949. }
  8950. patient, _ := service.GetPatientByIDTwo(adminUser.CurrentOrgId, order.PatientId)
  8951. var dia_config []*models.HisXtDiagnoseConfig
  8952. var name string
  8953. for _, item := range diagnosis_ids {
  8954. id, _ := strconv.ParseInt(item, 10, 64)
  8955. diagnosisConfig, _ := service.FindDiagnoseById(id)
  8956. dia_config = append(dia_config, &diagnosisConfig)
  8957. if len(name) == 0 {
  8958. name = diagnosisConfig.ClassName
  8959. } else {
  8960. name = name + "," + diagnosisConfig.ClassName
  8961. }
  8962. }
  8963. var bedCostTotal float64 = 0 //床位总费
  8964. var bedCostSelfTotal float64 = 0 //床位自费
  8965. var bedCostPartSelfTotal float64 = 0 //床位部分项目自费
  8966. var operationCostTotal float64 = 0 //手术费
  8967. var operationCostSelfTotal float64 = 0 //手术费
  8968. var operationCostPartSelfTotal float64 = 0 //手术费
  8969. var otherCostTotal float64 = 0 //其他费用
  8970. var otherCostSelfTotal float64 = 0 //其他费用
  8971. var otherCostPartSelfTotal float64 = 0 //其他费用
  8972. var materialCostTotal float64 = 0 //材料费
  8973. var materialCostSelfTotal float64 = 0 //材料费
  8974. var materialCostPartSelfTotal float64 = 0 //材料费
  8975. var westernMedicineCostTotal float64 = 0 //西药费
  8976. var westernMedicineCostSelfTotal float64 = 0 //西药费
  8977. var westernMedicineCostPartSelfTotal float64 = 0 //西药费
  8978. var chineseTraditionalMedicineCostTotal float64 = 0 //中成药
  8979. var chineseTraditionalMedicineCostSelfTotal float64 = 0 //中成药
  8980. var chineseTraditionalMedicineCostPartSelfTotal float64 = 0 //中成药
  8981. var checkCostTotal float64 = 0 //检查费
  8982. var checkCostSelfTotal float64 = 0 //检查费
  8983. var checkCostPartSelfTotal float64 = 0 //检查费
  8984. var laboratoryCostTotal float64 = 0 //化验费
  8985. var laboratoryCostSelfTotal float64 = 0 //化验费
  8986. var laboratoryCostPartSelfTotal float64 = 0 //化验费
  8987. var treatCostTotal float64 = 0 //治疗费用
  8988. var treatCostSelfTotal float64 = 0 //治疗费用
  8989. var treatCostPartSelfTotal float64 = 0 //治疗费用
  8990. decimal.DivisionPrecision = 2
  8991. for _, item := range orderInfos {
  8992. if item.MedChrgitmType == "01" { //床位费
  8993. bedCostTotal, _ = decimal.NewFromFloat(bedCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  8994. bedCostSelfTotal, _ = decimal.NewFromFloat(bedCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  8995. bedCostPartSelfTotal, _ = decimal.NewFromFloat(bedCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  8996. }
  8997. if c.GetAdminUserInfo().CurrentOrgId == 10188 || c.GetAdminUserInfo().CurrentOrgId == 10217 {
  8998. if item.MedChrgitmType == "03" { //检查费
  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. } else {
  9004. if item.MedChrgitmType == "03" { //检查费
  9005. checkCostTotal, _ = decimal.NewFromFloat(checkCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  9006. checkCostSelfTotal, _ = decimal.NewFromFloat(checkCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  9007. checkCostPartSelfTotal, _ = decimal.NewFromFloat(checkCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  9008. }
  9009. }
  9010. if item.MedChrgitmType == "04" { //化验费
  9011. laboratoryCostTotal, _ = decimal.NewFromFloat(laboratoryCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  9012. laboratoryCostSelfTotal, _ = decimal.NewFromFloat(laboratoryCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  9013. laboratoryCostPartSelfTotal, _ = decimal.NewFromFloat(laboratoryCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  9014. }
  9015. if item.MedChrgitmType == "05" || item.MedChrgitmType == "1402" || item.MedChrgitmType == "1403" { //治疗费
  9016. treatCostTotal, _ = decimal.NewFromFloat(treatCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  9017. treatCostSelfTotal, _ = decimal.NewFromFloat(treatCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  9018. treatCostPartSelfTotal, _ = decimal.NewFromFloat(treatCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  9019. }
  9020. if item.MedChrgitmType == "06" { //手术费
  9021. operationCostTotal, _ = decimal.NewFromFloat(operationCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  9022. operationCostSelfTotal, _ = decimal.NewFromFloat(operationCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  9023. operationCostPartSelfTotal, _ = decimal.NewFromFloat(operationCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  9024. }
  9025. if item.MedChrgitmType == "08" { //材料费
  9026. materialCostTotal, _ = decimal.NewFromFloat(materialCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  9027. materialCostSelfTotal, _ = decimal.NewFromFloat(materialCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  9028. materialCostPartSelfTotal, _ = decimal.NewFromFloat(materialCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  9029. }
  9030. if item.MedChrgitmType == "09" { //西药费
  9031. westernMedicineCostTotal, _ = decimal.NewFromFloat(westernMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  9032. westernMedicineCostSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  9033. westernMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  9034. }
  9035. if item.MedChrgitmType == "11" { //中成费
  9036. chineseTraditionalMedicineCostTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  9037. chineseTraditionalMedicineCostSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  9038. chineseTraditionalMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  9039. }
  9040. if item.MedChrgitmType == "14" || item.MedChrgitmType == "0" || item.MedChrgitmType == "12" || item.MedChrgitmType == "02" { //其他费
  9041. otherCostTotal, _ = decimal.NewFromFloat(otherCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  9042. otherCostSelfTotal, _ = decimal.NewFromFloat(otherCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  9043. otherCostPartSelfTotal, _ = decimal.NewFromFloat(otherCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  9044. }
  9045. }
  9046. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  9047. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  9048. var user_name string
  9049. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  9050. if role.ID == 0 {
  9051. user_name = "管理员"
  9052. } else {
  9053. user_name = role.UserName
  9054. }
  9055. baseParams := models.BaseParams{
  9056. SecretKey: miConfig.SecretKey,
  9057. FixmedinsCode: miConfig.Code,
  9058. InsuplcAdmdvs: miConfig.InsuplcAdmdvs,
  9059. MdtrtareaAdmvs: miConfig.MdtrtareaAdmvs,
  9060. OrgName: miConfig.OrgName,
  9061. Doctor: user_name,
  9062. }
  9063. businessParams := models.BusinessParams{
  9064. PsnNo: order.PsnNo,
  9065. MdtrtId: order.MdtrtId,
  9066. SetlId: order.SetlId,
  9067. }
  9068. var res ResultEleven
  9069. var resEleven10265 ResultEleven10265
  9070. if config.IsOpen == 1 {
  9071. if miConfig.MdtrtareaAdmvs == "421300" {
  9072. api := "http://192.168.124.4:9532/" + "hbyb/5203?psn_no=" + businessParams.PsnNo + "&mdtrt_id=" + businessParams.MdtrtId + "&setl_id=" + businessParams.SetlId +
  9073. "&org_name=" + miConfig.OrgName + "&doctor=" + baseParams.Doctor + "&fixmedins_code=" + miConfig.Code +
  9074. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  9075. resp, requestErr := http.Get(api)
  9076. if requestErr != nil {
  9077. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9078. return
  9079. }
  9080. body, ioErr := ioutil.ReadAll(resp.Body)
  9081. if ioErr != nil {
  9082. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  9083. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9084. return
  9085. }
  9086. var respJSON map[string]interface{}
  9087. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  9088. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  9089. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9090. return
  9091. }
  9092. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  9093. result, _ := json.Marshal(respJSON)
  9094. fmt.Println("log")
  9095. fmt.Println(string(result))
  9096. if err := json.Unmarshal([]byte(result), &res); err != nil {
  9097. utils.ErrorLog("解析失败:%v", err)
  9098. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9099. return
  9100. }
  9101. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  9102. var api string
  9103. if miConfig.MdtrtareaAdmvs == "320921" {
  9104. api = "http://192.168.2.110:9532/" + "jsyb/5203?psn_no=" + businessParams.PsnNo + "&mdtrt_id=" + businessParams.MdtrtId + "&setl_id=" + businessParams.SetlId +
  9105. "&org_name=" + miConfig.OrgName + "&doctor=" + baseParams.Doctor + "&fixmedins_code=" + miConfig.Code +
  9106. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  9107. //req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  9108. } else {
  9109. //req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  9110. api = "http://192.168.5.251:9532/" + "jsyb/5203?psn_no=" + businessParams.PsnNo + "&mdtrt_id=" + businessParams.MdtrtId + "&setl_id=" + businessParams.SetlId +
  9111. "&org_name=" + miConfig.OrgName + "&doctor=" + baseParams.Doctor + "&fixmedins_code=" + miConfig.Code +
  9112. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  9113. }
  9114. resp, requestErr := http.Get(api)
  9115. if requestErr != nil {
  9116. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9117. return
  9118. }
  9119. body, ioErr := ioutil.ReadAll(resp.Body)
  9120. if ioErr != nil {
  9121. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  9122. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9123. return
  9124. }
  9125. var respJSON map[string]interface{}
  9126. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  9127. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  9128. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9129. return
  9130. }
  9131. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  9132. result, _ := json.Marshal(respJSON)
  9133. fmt.Println("log")
  9134. fmt.Println(string(result))
  9135. if err := json.Unmarshal([]byte(result), &resEleven10265); err != nil {
  9136. utils.ErrorLog("解析失败:%v", err)
  9137. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9138. return
  9139. }
  9140. res.InfRefmsgid = resEleven10265.InfRefmsgid
  9141. res.Output = resEleven10265.Output
  9142. res.ErrMsg = resEleven10265.ErrMsg
  9143. res.Cainfo = resEleven10265.Cainfo
  9144. res.WarnMsg = resEleven10265.WarnMsg
  9145. infocode, _ := strconv.ParseInt(resEleven10265.Infcode, 10, 64)
  9146. res.Infcode = infocode
  9147. } else if miConfig.MdtrtareaAdmvs == "350500" {
  9148. result := service.FJyb5203(baseParams, businessParams, miConfig.Url, miConfig.Code, miConfig.AppSecret, miConfig.SignKey, miConfig.EncKey)
  9149. var dat map[string]interface{}
  9150. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  9151. fmt.Println(dat)
  9152. } else {
  9153. fmt.Println(err)
  9154. }
  9155. userJSONBytes, _ := json.Marshal(dat)
  9156. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  9157. utils.ErrorLog("解析失败:%v", err)
  9158. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9159. return
  9160. }
  9161. } else if miConfig.MdtrtareaAdmvs == "150499" {
  9162. fmt.Println("~~~~~~~")
  9163. api := "http://172.16.13.254:9532/" + "nmyb/5203?psn_no=" + businessParams.PsnNo + "&mdtrt_id=" + businessParams.MdtrtId + "&setl_id=" + businessParams.SetlId +
  9164. "&org_name=" + miConfig.OrgName + "&doctor=" + baseParams.Doctor + "&fixmedins_code=" + miConfig.Code +
  9165. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  9166. resp, requestErr := http.Get(api)
  9167. if requestErr != nil {
  9168. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9169. return
  9170. }
  9171. body, ioErr := ioutil.ReadAll(resp.Body)
  9172. if ioErr != nil {
  9173. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  9174. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9175. return
  9176. }
  9177. var respJSON map[string]interface{}
  9178. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  9179. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  9180. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9181. return
  9182. }
  9183. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  9184. result, _ := json.Marshal(respJSON)
  9185. fmt.Println("log")
  9186. fmt.Println(string(result))
  9187. if err := json.Unmarshal([]byte(result), &resEleven10265); err != nil {
  9188. utils.ErrorLog("解析失败:%v", err)
  9189. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9190. return
  9191. }
  9192. res.InfRefmsgid = resEleven10265.InfRefmsgid
  9193. res.Output = resEleven10265.Output
  9194. res.ErrMsg = resEleven10265.ErrMsg
  9195. res.Cainfo = resEleven10265.Cainfo
  9196. res.WarnMsg = resEleven10265.WarnMsg
  9197. infocode, _ := strconv.ParseInt(resEleven10265.Infcode, 10, 64)
  9198. res.Infcode = infocode
  9199. } else {
  9200. result := service.Gdyb5203(baseParams, businessParams)
  9201. //service.Gdyb5204(baseParams, businessParams)
  9202. //service.Gdyb5302(businessParams.PsnNo, baseParams.OrgName, baseParams.Doctor, baseParams.FixmedinsCode, baseParams.InsuplcAdmdvs, baseParams.MdtrtareaAdmvs, baseParams.SecretKey)
  9203. var dat map[string]interface{}
  9204. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  9205. fmt.Println(dat)
  9206. } else {
  9207. fmt.Println(err)
  9208. }
  9209. userJSONBytes, _ := json.Marshal(dat)
  9210. if miConfig.Code == "H15049901371" {
  9211. if err := json.Unmarshal(userJSONBytes, &resEleven10265); err != nil {
  9212. utils.ErrorLog("解析失败:%v", err)
  9213. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9214. return
  9215. }
  9216. res.InfRefmsgid = resEleven10265.InfRefmsgid
  9217. res.Output = resEleven10265.Output
  9218. res.ErrMsg = resEleven10265.ErrMsg
  9219. res.Cainfo = resEleven10265.Cainfo
  9220. res.WarnMsg = resEleven10265.WarnMsg
  9221. infocode, _ := strconv.ParseInt(resEleven10265.Infcode, 10, 64)
  9222. res.Infcode = infocode
  9223. } else {
  9224. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  9225. utils.ErrorLog("解析失败:%v", err)
  9226. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9227. return
  9228. }
  9229. }
  9230. }
  9231. printor_admin, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  9232. charge_admin, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, order.Creator)
  9233. patientPrescription, _ := service.FindPatientPrescriptionInfo(adminUser.CurrentOrgId, order.PatientId, order.SettleAccountsDate)
  9234. adminRole_two, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, patientPrescription.DoctorId)
  9235. doctor_info, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, his_hospital.Doctor)
  9236. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  9237. var doctor_name string
  9238. if roles.ID == 0 {
  9239. doctor_name = "管理员"
  9240. } else {
  9241. doctor_name = roles.UserName
  9242. }
  9243. yiliao_leibie := ""
  9244. switch order.MedType {
  9245. case "11":
  9246. yiliao_leibie = "普通门诊"
  9247. break
  9248. case "12":
  9249. yiliao_leibie = "门诊挂号"
  9250. break
  9251. case "13":
  9252. yiliao_leibie = "急诊"
  9253. break
  9254. case "14":
  9255. yiliao_leibie = "门诊特殊病"
  9256. break
  9257. case "15":
  9258. yiliao_leibie = "门诊统筹"
  9259. break
  9260. case "16":
  9261. yiliao_leibie = "门诊慢性病"
  9262. break
  9263. case "21":
  9264. yiliao_leibie = "普通住院"
  9265. break
  9266. }
  9267. departments, _ := service.GetDepartMentDetail(patientPrescription.Departments)
  9268. if res.Infcode == 0 {
  9269. c.ServeSuccessJSON(map[string]interface{}{
  9270. "diagnosis": name,
  9271. "order_infos": orderInfos,
  9272. "number": order.MdtrtId,
  9273. "date": order.SettleAccountsDate,
  9274. "charge_admin": charge_admin,
  9275. "printor_admin": printor_admin,
  9276. "info": res.Output.Setlinfo,
  9277. "order": order,
  9278. "bedCostTotal": bedCostTotal,
  9279. "bedCostSelfTotal": bedCostSelfTotal,
  9280. "bedCostPartSelfTotal": bedCostPartSelfTotal,
  9281. "operationCostTotal": operationCostTotal,
  9282. "operationCostSelfTotal": operationCostSelfTotal,
  9283. "operationCostPartSelfTotal": operationCostPartSelfTotal,
  9284. "otherCostTotal": otherCostTotal,
  9285. "otherCostSelfTotal": otherCostSelfTotal,
  9286. "otherCostPartSelfTotal": otherCostPartSelfTotal,
  9287. "materialCostTotal": materialCostTotal,
  9288. "materialCostSelfTotal": materialCostSelfTotal,
  9289. "materialCostPartSelfTotal": materialCostPartSelfTotal,
  9290. "westernMedicineCostTotal": westernMedicineCostTotal,
  9291. "westernMedicineCostSelfTotal": westernMedicineCostSelfTotal,
  9292. "westernMedicineCostPartSelfTotal": westernMedicineCostPartSelfTotal,
  9293. "chineseTraditionalMedicineCostTotal": chineseTraditionalMedicineCostTotal,
  9294. "chineseTraditionalMedicineCostSelfTotal": chineseTraditionalMedicineCostSelfTotal,
  9295. "chineseTraditionalMedicineCostPartSelfTotal": chineseTraditionalMedicineCostPartSelfTotal,
  9296. "checkCostTotal": checkCostTotal,
  9297. "checkCostSelfTotal": checkCostSelfTotal,
  9298. "checkCostPartSelfTotal": checkCostPartSelfTotal,
  9299. "laboratoryCostTotal": laboratoryCostTotal,
  9300. "laboratoryCostSelfTotal": laboratoryCostSelfTotal,
  9301. "laboratoryCostPartSelfTotal": laboratoryCostPartSelfTotal,
  9302. "treatCostTotal": treatCostTotal,
  9303. "treatCostSelfTotal": treatCostSelfTotal,
  9304. "treatCostPartSelfTotal": treatCostPartSelfTotal,
  9305. "doctor_info": doctor_info,
  9306. "doctor_code": adminRole_two.DoctorCode,
  9307. "doctor_name": doctor_name,
  9308. "health_card_no": order.PsnNo,
  9309. "department": departments.Name,
  9310. "yiliao_leibie": yiliao_leibie,
  9311. "after_money": order.AccountPrice,
  9312. "patient": patient,
  9313. "org_name": miConfig.OrgName,
  9314. "org_code": miConfig.Code,
  9315. "order_number": order.Number,
  9316. "his_hospital": his_hospital,
  9317. "his": his,
  9318. "dia_config": dia_config,
  9319. //"check_order_info": cus_slice,
  9320. })
  9321. }
  9322. }
  9323. }
  9324. func (c *HisApiController) CheckTreatment() {
  9325. patient_id, _ := c.GetInt64("patient_id")
  9326. id_card_no := c.GetString("id_card_no")
  9327. insutype := c.GetString("insutype")
  9328. med_type := c.GetString("med_type")
  9329. admin_user_id, _ := c.GetInt64("admin_user_id")
  9330. adminUser := c.GetAdminUserInfo()
  9331. patient, _ := service.GetPatientByID(adminUser.CurrentOrgId, patient_id)
  9332. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  9333. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  9334. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  9335. if miConfig.MdtrtareaAdmvs == "421300" {
  9336. var res ResultTwo
  9337. api := "http://192.168.124.4:9532/" + "hbyb/1101?cert_no=" + "" +
  9338. "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  9339. "&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)
  9340. resp, requestErr := http.Get(api)
  9341. if requestErr != nil {
  9342. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9343. return
  9344. }
  9345. body, ioErr := ioutil.ReadAll(resp.Body)
  9346. if ioErr != nil {
  9347. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  9348. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9349. return
  9350. }
  9351. var respJSON map[string]interface{}
  9352. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  9353. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  9354. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9355. return
  9356. }
  9357. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  9358. result, _ := json.Marshal(respJSON)
  9359. if err := json.Unmarshal([]byte(result), &res); err != nil {
  9360. utils.ErrorLog("解析失败:%v", err)
  9361. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9362. return
  9363. }
  9364. if res.Infcode == 0 {
  9365. api := "http://192.168.124.4:9532/" + "hbyb/2001?cert_no=" + "" +
  9366. "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  9367. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&psn_no=" + res.Output.Baseinfo.PsnNo + "&insutype=" + insutype + "&med_type=" + med_type
  9368. resp, requestErr := http.Get(api)
  9369. if requestErr != nil {
  9370. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9371. return
  9372. }
  9373. body, ioErr := ioutil.ReadAll(resp.Body)
  9374. if ioErr != nil {
  9375. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  9376. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9377. return
  9378. }
  9379. var respJSON map[string]interface{}
  9380. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  9381. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  9382. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9383. return
  9384. }
  9385. var res Result2001
  9386. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  9387. result2, _ := json.Marshal(respJSON)
  9388. if err := json.Unmarshal([]byte(result2), &res); err != nil {
  9389. utils.ErrorLog("解析失败:%v", err)
  9390. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9391. return
  9392. }
  9393. if res.Infcode == 0 {
  9394. c.ServeSuccessJSON(map[string]interface{}{
  9395. "msg": res.Output.Trtinfo,
  9396. })
  9397. }
  9398. } else {
  9399. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  9400. return
  9401. }
  9402. } else {
  9403. result := service.Gdyb1101A(id_card_no, miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, patient.Name)
  9404. var dat map[string]interface{}
  9405. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  9406. fmt.Println(dat)
  9407. } else {
  9408. fmt.Println(err)
  9409. }
  9410. userJSONBytes, _ := json.Marshal(dat)
  9411. var res ResultTwo
  9412. var res10265 ResultTwo10265
  9413. if miConfig.Code == "H15049901371" {
  9414. if err := json.Unmarshal(userJSONBytes, &res10265); err != nil {
  9415. utils.ErrorLog("解析失败:%v", err)
  9416. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9417. return
  9418. }
  9419. res.ErrMsg = res10265.ErrMsg
  9420. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  9421. res.Infcode = infocode
  9422. res.Output = res10265.Output
  9423. res.InfRefmsgid = res10265.InfRefmsgid
  9424. } else {
  9425. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  9426. utils.ErrorLog("解析失败:%v", err)
  9427. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9428. return
  9429. }
  9430. }
  9431. var user_name string
  9432. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, adminUser.AdminUser.Id)
  9433. if role.ID == 0 {
  9434. user_name = "xxx"
  9435. } else {
  9436. user_name = role.UserName
  9437. }
  9438. baseParams := models.BaseParams{
  9439. SecretKey: miConfig.SecretKey,
  9440. FixmedinsCode: miConfig.Code,
  9441. InsuplcAdmdvs: miConfig.InsuplcAdmdvs,
  9442. MdtrtareaAdmvs: miConfig.MdtrtareaAdmvs,
  9443. OrgName: miConfig.OrgName,
  9444. Doctor: user_name,
  9445. }
  9446. if config.IsOpen == 1 {
  9447. if miConfig.Code == "H15049901371" {
  9448. if med_type == "14" {
  9449. if insutype == "390" {
  9450. med_type = "9933"
  9451. } else if insutype == "310" {
  9452. med_type = "990502"
  9453. }
  9454. } else if med_type == "11" {
  9455. med_type = "11"
  9456. }
  9457. }
  9458. result := service.Gdyb2001(baseParams, res.Output.Baseinfo.PsnNo, insutype, med_type)
  9459. var dat map[string]interface{}
  9460. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  9461. fmt.Println(dat)
  9462. } else {
  9463. fmt.Println(err)
  9464. }
  9465. var res Result2001
  9466. var res10265 Result2001Org10265
  9467. if miConfig.Code == "H15049901371" {
  9468. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  9469. utils.ErrorLog("解析失败:%v", err)
  9470. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9471. return
  9472. }
  9473. res.ErrMsg = res10265.ErrMsg
  9474. res.Output = res10265.Output
  9475. res.InfRefmsgid = res10265.InfRefmsgid
  9476. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  9477. res.Infcode = infocode
  9478. } else {
  9479. if err := json.Unmarshal([]byte(result), &res); err != nil {
  9480. utils.ErrorLog("解析失败:%v", err)
  9481. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9482. return
  9483. }
  9484. }
  9485. if res.Infcode == 0 {
  9486. c.ServeSuccessJSON(map[string]interface{}{
  9487. "msg": res.Output.Trtinfo,
  9488. })
  9489. }
  9490. }
  9491. }
  9492. }
  9493. //func (c *HisApiController) PutRecord() {
  9494. // id, _ := c.GetInt64("id")
  9495. // record_time := c.GetString("record_time")
  9496. // timeLayout := "2006-01-02"
  9497. // loc, _ := time.LoadLocation("Local")
  9498. // theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  9499. // if err != nil {
  9500. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  9501. // return
  9502. // }
  9503. // recordDateTime := theTime.Unix()
  9504. //
  9505. // adminInfo := c.GetAdminUserInfo()
  9506. // patient, _ := service.GetPatientByID(adminInfo.CurrentOrgId, id)
  9507. // patientPrescription, _ := service.FindPatientPrescriptionInfo(adminInfo.CurrentOrgId, id, recordDateTime)
  9508. //
  9509. // miConfig, _ := service.FindMedicalInsuranceInfo(adminInfo.CurrentOrgId)
  9510. //
  9511. // fmt.Println(miConfig.SecretKey)
  9512. //
  9513. // if patient == nil {
  9514. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodePatientNoExist)
  9515. // return
  9516. // }
  9517. // if len(patient.IdCardNo) == 0 {
  9518. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeIDCartNo)
  9519. // return
  9520. // }
  9521. // config, _ := service.GetMedicalInsuranceConfig(adminInfo.CurrentOrgId)
  9522. // if config.IsOpen == 1 {
  9523. // 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
  9524. // resp, requestErr := http.Get(api)
  9525. // if requestErr != nil {
  9526. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9527. // return
  9528. // }
  9529. // defer resp.Body.Close()
  9530. // body, ioErr := ioutil.ReadAll(resp.Body)
  9531. // if ioErr != nil {
  9532. // utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  9533. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9534. // return
  9535. // }
  9536. // var respJSON map[string]interface{}
  9537. //
  9538. // if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  9539. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  9540. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9541. // return
  9542. // }
  9543. //
  9544. // userJSON := respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  9545. // userJSONBytes, _ := json.Marshal(userJSON)
  9546. // var res ResultTwo
  9547. // if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  9548. // utils.ErrorLog("解析失败:%v", err)
  9549. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9550. // return
  9551. // }
  9552. // Iinfos, _ := json.Marshal(res.Output.Iinfo)
  9553. // Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  9554. // infoStr := string(Iinfos)
  9555. // idetinfoStr := string(Idetinfos)
  9556. //
  9557. // if res.Infcode == 0 {
  9558. // his := models.VMHisPatient{
  9559. // Status: 1,
  9560. // Ctime: time.Now().Unix(),
  9561. // Mtime: time.Now().Unix(),
  9562. // PsnNo: res.Output.Baseinfo.PsnNo,
  9563. // PsnCertType: res.Output.Baseinfo.PsnCertType,
  9564. // Certno: res.Output.Baseinfo.Certno,
  9565. // PsnName: res.Output.Baseinfo.PsnName,
  9566. // Gend: res.Output.Baseinfo.Gend,
  9567. // Naty: res.Output.Baseinfo.Naty,
  9568. // Brdy: res.Output.Baseinfo.Brdy,
  9569. // Age: res.Output.Baseinfo.Age,
  9570. // Iinfo: infoStr,
  9571. // Idetinfo: idetinfoStr,
  9572. // PatientId: patient.ID,
  9573. // RecordDate: theTime.Unix(),
  9574. // UserOrgId: adminInfo.CurrentOrgId,
  9575. // AdminUserId: adminInfo.AdminUser.Id,
  9576. // IsReturn: 1,
  9577. // }
  9578. //
  9579. // //doctor_id := strconv.FormatInt(patientPrescription.DoctorId, 10)
  9580. // //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")
  9581. // //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")
  9582. //
  9583. // //var dat map[string]interface{}
  9584. // //if err := json.Unmarshal([]byte(result), &dat); err == nil {
  9585. // // fmt.Println(dat)
  9586. // //} else {
  9587. // // fmt.Println(err)
  9588. // //}
  9589. //
  9590. // var dat2 map[string]interface{}
  9591. // if err := json.Unmarshal([]byte(result2), &dat2); err == nil {
  9592. // fmt.Println(dat2)
  9593. // } else {
  9594. // fmt.Println(err)
  9595. // }
  9596. //
  9597. // } else {
  9598. // adminUser := c.GetAdminUserInfo()
  9599. // errlog := &models.HisOrderError{
  9600. // UserOrgId: adminUser.CurrentOrgId,
  9601. // Ctime: time.Now().Unix(),
  9602. // Mtime: time.Now().Unix(),
  9603. // ErrMsg: res.ErrMsg,
  9604. // Status: 1,
  9605. // PatientId: id,
  9606. // RecordTime: recordDateTime,
  9607. // Stage: 1,
  9608. // }
  9609. // service.CreateErrMsgLog(errlog)
  9610. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeGdybOneException)
  9611. // return
  9612. // }
  9613. // }
  9614. //
  9615. //}
  9616. //func (c *HisApiController) GetUploadDiag() {
  9617. // id, _ := c.GetInt64("id")
  9618. // record_time := c.GetString("record_time")
  9619. //
  9620. // diagnosis_id, _ := c.GetInt64("diagnosis")
  9621. // sick_type, _ := c.GetInt64("sick_type")
  9622. // reg_type, _ := c.GetInt64("reg_type")
  9623. //
  9624. // timeLayout := "2006-01-02"
  9625. // loc, _ := time.LoadLocation("Local")
  9626. // theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  9627. // if err != nil {
  9628. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  9629. // return
  9630. // }
  9631. //
  9632. // var patientPrescription models.HisPrescriptionInfo
  9633. // recordDateTime := theTime.Unix()
  9634. // adminInfo := c.GetAdminUserInfo()
  9635. // patientPrescription, _ = service.FindPatientPrescriptionInfo(adminInfo.CurrentOrgId, id, recordDateTime)
  9636. //
  9637. // if patientPrescription.ID == 0 {
  9638. // patientPrescription, _ = service.FindLastPatientPrescriptionInfo(adminInfo.CurrentOrgId, id, recordDateTime)
  9639. // }
  9640. //
  9641. // miConfig, _ := service.FindMedicalInsuranceInfo(adminInfo.CurrentOrgId)
  9642. // diagnosisConfig, _ := service.FindDiagnoseById(diagnosis_id)
  9643. // his, _ := service.GetVMHisPatientInfo(adminInfo.CurrentOrgId, id, recordDateTime)
  9644. // sickConfig, _ := service.FindSickById(sick_type)
  9645. // department, _ := service.GetDepartMentDetail(patientPrescription.Departments)
  9646. //
  9647. // api2 := "http://127.0.0.1:9532/" + "gdyb/four?psn_no=" + his.PsnNo +
  9648. // "&mdtrt_id=" + his.Number + "&doctor=" + patientPrescription.Doctor + "&department=" + department.Name +
  9649. // "&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 +
  9650. // "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&sick_code=" + sickConfig.ContentCode + "&sick_name=" + sickConfig.ClassName
  9651. // resp2, requestErr2 := http.Get(api2)
  9652. // if requestErr2 != nil {
  9653. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9654. // return
  9655. // }
  9656. // body2, ioErr2 := ioutil.ReadAll(resp2.Body)
  9657. // if ioErr2 != nil {
  9658. // utils.ErrorLog("接口返回数据读取失败: %v", ioErr2)
  9659. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9660. // return
  9661. // }
  9662. // var respJSON2 map[string]interface{}
  9663. // if err := json.Unmarshal([]byte(string(body2)), &respJSON2); err != nil {
  9664. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  9665. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9666. // return
  9667. // }
  9668. // respJSON2 = respJSON2["data"].(map[string]interface{})["pre"].(map[string]interface{})
  9669. // userJSONBytes2, _ := json.Marshal(respJSON2)
  9670. //
  9671. // var res2 ResultSix
  9672. // if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  9673. // utils.ErrorLog("解析失败:%v", err)
  9674. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9675. // return
  9676. // }
  9677. // if res2.Infcode != 0 {
  9678. // adminUser := c.GetAdminUserInfo()
  9679. // errlog := &models.HisOrderError{
  9680. // UserOrgId: adminUser.CurrentOrgId,
  9681. // Ctime: time.Now().Unix(),
  9682. // Mtime: time.Now().Unix(),
  9683. // ErrMsg: res2.ErrMsg,
  9684. // Status: 1,
  9685. // PatientId: id,
  9686. // RecordTime: recordDateTime,
  9687. // Stage: 3,
  9688. // }
  9689. // service.CreateErrMsgLog(errlog)
  9690. //
  9691. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeRegisterThreeException)
  9692. // return
  9693. // }
  9694. //
  9695. // c.ServeSuccessJSON(map[string]interface{}{
  9696. // "msg": "上传成功",
  9697. // })
  9698. //
  9699. //}
  9700. type QueryResult struct {
  9701. ID int64
  9702. Name string
  9703. Code string
  9704. List_type_code string
  9705. }
  9706. func (c *HisApiController) GetCheckCode() {
  9707. ids_str := c.GetString("ids")
  9708. record_type, _ := c.GetInt64("record_type") //1.药品 2.耗材 3.项目
  9709. ids_arr := strings.Split(ids_str, ",")
  9710. var queryResult []QueryResult
  9711. ids := make([]int64, 0)
  9712. for _, item := range ids_arr {
  9713. id, _ := strconv.ParseInt(item, 10, 64)
  9714. ids = append(ids, id)
  9715. }
  9716. if record_type == 1 {
  9717. drugs, _ := service.GetBatchDrugList(ids)
  9718. for _, item := range drugs {
  9719. result := QueryResult{
  9720. ID: item.ID,
  9721. Name: item.DrugName,
  9722. Code: item.MedicalInsuranceNumber,
  9723. List_type_code: "101",
  9724. }
  9725. queryResult = append(queryResult, result)
  9726. }
  9727. } else if record_type == 2 {
  9728. goods, _ := service.GetBatchGoodInformationList(ids)
  9729. for _, item := range goods {
  9730. result := QueryResult{
  9731. ID: item.ID,
  9732. Name: item.GoodName,
  9733. Code: item.MedicalInsuranceNumber,
  9734. List_type_code: "301",
  9735. }
  9736. queryResult = append(queryResult, result)
  9737. }
  9738. } else if record_type == 3 {
  9739. projects, _ := service.GetBathchMyPorjecgList(ids)
  9740. for _, item := range projects {
  9741. result := QueryResult{
  9742. ID: item.ID,
  9743. Name: item.ProjectName,
  9744. Code: item.MedicalCode,
  9745. List_type_code: "201",
  9746. }
  9747. queryResult = append(queryResult, result)
  9748. }
  9749. }
  9750. admin_user_id, _ := c.GetInt64("admin_user_id")
  9751. adminUser := c.GetAdminUserInfo()
  9752. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  9753. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  9754. var user_name string
  9755. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  9756. if role.ID == 0 {
  9757. user_name = "xxx"
  9758. } else {
  9759. user_name = role.UserName
  9760. }
  9761. baseParams := &models.BaseParams{
  9762. SecretKey: miConfig.SecretKey,
  9763. FixmedinsCode: miConfig.Code,
  9764. InsuplcAdmdvs: miConfig.InsuplcAdmdvs,
  9765. MdtrtareaAdmvs: miConfig.MdtrtareaAdmvs,
  9766. OrgName: miConfig.OrgName,
  9767. Doctor: user_name,
  9768. }
  9769. if config.IsOpen == 1 {
  9770. for _, item := range queryResult {
  9771. var result string
  9772. if record_type == 1 {
  9773. result = service.Gdyb3301(baseParams, item.Name, item.Code, item.List_type_code, "2021-04-26", "", item.List_type_code)
  9774. } else if record_type == 2 {
  9775. result = service.Gdyb3301(baseParams, item.Name, item.Code, item.List_type_code, "2021-04-26", "", item.List_type_code)
  9776. } else if record_type == 3 {
  9777. result = service.Gdyb3301(baseParams, item.Name, item.Code, item.List_type_code, "2021-04-26", "", item.List_type_code)
  9778. }
  9779. var dat map[string]interface{}
  9780. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  9781. fmt.Println(dat)
  9782. } else {
  9783. fmt.Println(err)
  9784. }
  9785. userJSONBytes, _ := json.Marshal(dat)
  9786. var res ResultSix
  9787. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  9788. utils.ErrorLog("解析失败:%v", err)
  9789. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9790. return
  9791. }
  9792. if res.Infcode == 0 {
  9793. if record_type == 1 {
  9794. service.UpdateBaseDrugById(item.ID)
  9795. } else if record_type == 2 {
  9796. service.UpdateGoodInformaitonByDetail(item.ID)
  9797. } else if record_type == 3 {
  9798. service.UpdateProjectById(item.ID)
  9799. }
  9800. c.ServeSuccessJSON(map[string]interface{}{
  9801. "failed_code": 0,
  9802. "msg": "目录对照成功",
  9803. })
  9804. } else {
  9805. c.ServeSuccessJSON(map[string]interface{}{
  9806. "failed_code": -10,
  9807. "msg": res.ErrMsg,
  9808. })
  9809. }
  9810. }
  9811. }
  9812. }
  9813. func (c *HisApiController) UnCheckCode() {
  9814. ids_str := c.GetString("ids")
  9815. record_type, _ := c.GetInt64("record_type") //1.药品 2.耗材 3.项目
  9816. admin_user_id, _ := c.GetInt64("admin_user_id")
  9817. ids_arr := strings.Split(ids_str, ",")
  9818. var queryResult []QueryResult
  9819. ids := make([]int64, 0)
  9820. for _, item := range ids_arr {
  9821. id, _ := strconv.ParseInt(item, 10, 64)
  9822. ids = append(ids, id)
  9823. }
  9824. if record_type == 1 {
  9825. drugs, _ := service.GetBatchDrugList(ids)
  9826. for _, item := range drugs {
  9827. result := QueryResult{
  9828. ID: item.ID,
  9829. Name: item.DrugName,
  9830. Code: item.MedicalInsuranceNumber,
  9831. List_type_code: "101",
  9832. }
  9833. queryResult = append(queryResult, result)
  9834. }
  9835. } else if record_type == 2 {
  9836. goods, _ := service.GetBatchGoodInformationList(ids)
  9837. for _, item := range goods {
  9838. result := QueryResult{
  9839. ID: item.ID,
  9840. Name: item.GoodName,
  9841. Code: item.MedicalInsuranceNumber,
  9842. List_type_code: "301",
  9843. }
  9844. queryResult = append(queryResult, result)
  9845. }
  9846. } else if record_type == 3 {
  9847. projects, _ := service.GetBathchMyPorjecgList(ids)
  9848. for _, item := range projects {
  9849. result := QueryResult{
  9850. ID: item.ID,
  9851. Name: item.ProjectName,
  9852. Code: item.MedicalCode,
  9853. List_type_code: "201",
  9854. }
  9855. queryResult = append(queryResult, result)
  9856. }
  9857. }
  9858. adminUser := c.GetAdminUserInfo()
  9859. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  9860. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  9861. var user_name string
  9862. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  9863. if role.ID == 0 {
  9864. user_name = "xxx"
  9865. } else {
  9866. user_name = role.UserName
  9867. }
  9868. baseParams := &models.BaseParams{
  9869. SecretKey: miConfig.SecretKey,
  9870. FixmedinsCode: miConfig.Code,
  9871. InsuplcAdmdvs: miConfig.InsuplcAdmdvs,
  9872. MdtrtareaAdmvs: miConfig.MdtrtareaAdmvs,
  9873. OrgName: miConfig.OrgName,
  9874. Doctor: user_name,
  9875. }
  9876. if config.IsOpen == 1 {
  9877. for _, item := range queryResult {
  9878. var result string
  9879. if record_type == 1 {
  9880. result = service.Gdyb3302(baseParams, item.Name, item.Code, item.List_type_code)
  9881. } else if record_type == 2 {
  9882. result = service.Gdyb3302(baseParams, item.Name, item.Code, item.List_type_code)
  9883. } else if record_type == 3 {
  9884. result = service.Gdyb3302(baseParams, item.Name, item.Code, item.List_type_code)
  9885. }
  9886. var dat2 map[string]interface{}
  9887. if err := json.Unmarshal([]byte(result), &dat2); err == nil {
  9888. fmt.Println(dat2)
  9889. } else {
  9890. fmt.Println(err)
  9891. }
  9892. userJSONBytes, _ := json.Marshal(dat2)
  9893. var res ResultSix
  9894. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  9895. utils.ErrorLog("解析失败:%v", err)
  9896. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9897. return
  9898. }
  9899. if res.Infcode == 0 {
  9900. if record_type == 1 {
  9901. service.UpdateDrugByIdDetail(item.ID)
  9902. } else if record_type == 2 {
  9903. service.UpdateGoodInfoById(item.ID)
  9904. } else if record_type == 3 {
  9905. service.UpdateMyProjectById(item.ID)
  9906. }
  9907. c.ServeSuccessJSON(map[string]interface{}{
  9908. "failed_code": 0,
  9909. "msg": "撤销目录对照成功",
  9910. })
  9911. } else {
  9912. c.ServeSuccessJSON(map[string]interface{}{
  9913. "failed_code": -10,
  9914. "msg": res.ErrMsg,
  9915. })
  9916. }
  9917. }
  9918. }
  9919. }
  9920. func (c *HisApiController) GetPatientInfo() {
  9921. id_card_no := c.GetString("id_card_no")
  9922. admin_user_id, _ := c.GetInt64("admin_user_id")
  9923. patient, _ := service.GetPatientByIDCard(id_card_no, c.GetAdminUserInfo().CurrentOrgId)
  9924. if patient.ID == 0 {
  9925. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodePatientNoExist)
  9926. return
  9927. }
  9928. role, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  9929. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  9930. config, _ := service.GetMedicalInsuranceConfig(c.GetAdminUserInfo().CurrentOrgId)
  9931. if config.IsOpen == 1 {
  9932. result := service.Gdyb1101A(id_card_no, miConfig.OrgName, role.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, patient.Name)
  9933. var dat map[string]interface{}
  9934. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  9935. fmt.Println(dat)
  9936. } else {
  9937. fmt.Println(err)
  9938. }
  9939. userJSONBytes, _ := json.Marshal(dat)
  9940. var res ResultTwo
  9941. var res10265 ResultTwo10265
  9942. if miConfig.Code == "H15049901371" {
  9943. if err := json.Unmarshal(userJSONBytes, &res10265); err != nil {
  9944. utils.ErrorLog("解析失败:%v", err)
  9945. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9946. return
  9947. }
  9948. res.ErrMsg = res10265.ErrMsg
  9949. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  9950. res.Infcode = infocode
  9951. res.Output = res10265.Output
  9952. res.InfRefmsgid = res10265.InfRefmsgid
  9953. } else {
  9954. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  9955. utils.ErrorLog("解析失败:%v", err)
  9956. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9957. return
  9958. }
  9959. }
  9960. //if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  9961. // utils.ErrorLog("解析失败:%v", err)
  9962. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9963. // return
  9964. //}
  9965. if res.Infcode != 0 {
  9966. c.ServeSuccessJSON(map[string]interface{}{
  9967. "failed_code": -10,
  9968. "msg": res.ErrMsg,
  9969. })
  9970. } else {
  9971. c.ServeSuccessJSON(map[string]interface{}{
  9972. "failed_code": 0,
  9973. "info": res,
  9974. })
  9975. }
  9976. }
  9977. }
  9978. func (c *HisApiController) PsnPutOnRecord() {
  9979. record_type, _ := c.GetInt64("type")
  9980. patient_id, _ := c.GetInt64("patient_id")
  9981. admin_user_id, _ := c.GetInt64("admin_user_id")
  9982. start_time := c.GetString("start_time")
  9983. end_time := c.GetString("end_time")
  9984. adminUser := c.GetAdminUserInfo()
  9985. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  9986. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  9987. var patients []*models.Patients
  9988. if record_type == 1 { //全部备案
  9989. patient, _ := service.GetAllPatient(adminUser.CurrentOrgId)
  9990. patients = append(patients, patient...)
  9991. } else { //单个备案
  9992. patient, _ := service.GetPatientByID(adminUser.CurrentOrgId, patient_id)
  9993. patients = append(patients, patient)
  9994. }
  9995. var user_name string
  9996. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  9997. if role.ID == 0 {
  9998. user_name = "xxx"
  9999. } else {
  10000. user_name = role.UserName
  10001. }
  10002. if config.IsOpen == 1 {
  10003. for _, item := range patients {
  10004. 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
  10005. resp, requestErr := http.Get(api)
  10006. if requestErr != nil {
  10007. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10008. return
  10009. }
  10010. defer resp.Body.Close()
  10011. body, ioErr := ioutil.ReadAll(resp.Body)
  10012. if ioErr != nil {
  10013. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  10014. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10015. return
  10016. }
  10017. var respJSON map[string]interface{}
  10018. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  10019. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  10020. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10021. return
  10022. }
  10023. userJSON := respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  10024. userJSONBytes, _ := json.Marshal(userJSON)
  10025. var res ResultTwo
  10026. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  10027. utils.ErrorLog("解析失败:%v", err)
  10028. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10029. return
  10030. }
  10031. if res.Infcode == 0 {
  10032. result := service.Gdyb2505(res.Output.Baseinfo.PsnNo, user_name, miConfig.OrgName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, start_time, end_time)
  10033. var dat map[string]interface{}
  10034. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  10035. fmt.Println(dat)
  10036. } else {
  10037. fmt.Println(err)
  10038. }
  10039. userJSONBytes, _ := json.Marshal(dat)
  10040. var res2 ResultThirteen
  10041. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  10042. utils.ErrorLog("解析失败:%v", err)
  10043. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10044. return
  10045. }
  10046. if res2.Infcode == 0 {
  10047. psnResult := &models.GdybPsnRecord{
  10048. UserOrgId: adminUser.CurrentOrgId,
  10049. PatientId: item.ID,
  10050. PsnNo: res.Output.Baseinfo.PsnNo,
  10051. Ctime: time.Now().Unix(),
  10052. Mtime: time.Now().Unix(),
  10053. Status: 1,
  10054. IsCancel: 1,
  10055. TrtDclaDetlSn: res2.Output.Result.TrtDclaDetlSn,
  10056. }
  10057. service.CreatePsnRecord(psnResult)
  10058. } else {
  10059. c.ServeSuccessJSON(map[string]interface{}{
  10060. "failed_code": -10,
  10061. "msg": res2.ErrMsg,
  10062. })
  10063. return
  10064. }
  10065. }
  10066. }
  10067. }
  10068. }
  10069. func (c *HisApiController) PsnUnPutOnRecord() {
  10070. id, _ := c.GetInt64("id")
  10071. //record_type, _ := c.GetInt64("type")
  10072. admin_user_id, _ := c.GetInt64("admin_user_id")
  10073. adminUser := c.GetAdminUserInfo()
  10074. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  10075. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  10076. var user_name string
  10077. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  10078. if role.ID == 0 {
  10079. user_name = "xxx"
  10080. } else {
  10081. user_name = role.UserName
  10082. }
  10083. psn_record, _ := service.GetPsnRecordById(id)
  10084. if psn_record.ID == 0 {
  10085. c.ServeFailJSONWithSGJErrorCode(enums.ErrorPsnRecordNoExistWrong)
  10086. return
  10087. }
  10088. if config.IsOpen == 1 {
  10089. result := service.Gdyb2506(psn_record.PsnNo, user_name, miConfig.OrgName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, psn_record.TrtDclaDetlSn)
  10090. var dat map[string]interface{}
  10091. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  10092. fmt.Println(dat)
  10093. } else {
  10094. fmt.Println(err)
  10095. }
  10096. userJSONBytes, _ := json.Marshal(dat)
  10097. var res ResultFourteen
  10098. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  10099. utils.ErrorLog("解析失败:%v", err)
  10100. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10101. return
  10102. }
  10103. if res.Infcode == 0 {
  10104. psn_record.IsCancel = 2
  10105. service.CreatePsnRecord(&psn_record)
  10106. } else {
  10107. c.ServeSuccessJSON(map[string]interface{}{
  10108. "failed_code": -10,
  10109. "msg": res.ErrMsg,
  10110. })
  10111. return
  10112. }
  10113. }
  10114. }
  10115. func (c *HisApiController) PsnPutNCDSOnRecord() {
  10116. patient_id, _ := c.GetInt64("patient_id")
  10117. insutype_two := c.GetString("insutype")
  10118. psn_no := c.GetString("psn_no")
  10119. doctor_id, _ := c.GetInt64("doctor_id")
  10120. sick_id, _ := c.GetInt64("sick_id")
  10121. department_id, _ := c.GetInt64("department_id")
  10122. start_time := c.GetString("start_time")
  10123. end_time := c.GetString("end_time")
  10124. check_time := c.GetString("check_time")
  10125. adminUser := c.GetAdminUserInfo()
  10126. patient, _ := service.GetPatientByID(adminUser.CurrentOrgId, patient_id)
  10127. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  10128. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  10129. sick, _ := service.FindSickById(sick_id)
  10130. doctor, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, doctor_id)
  10131. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, doctor_id)
  10132. var res ResultTwo
  10133. var res10265 ResultTwo10265
  10134. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  10135. psn_info, _ := service.GetPsnByPatientId(patient.ID)
  10136. api := "http://192.168.2.110:9532/" + "hbyb/1101?cert_no=" + "" +
  10137. "&org_name=" + miConfig.OrgName + "&doctor=" + role.UserName + "&fixmedins_code=" + miConfig.Code +
  10138. "&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
  10139. resp, requestErr := http.Get(api)
  10140. if requestErr != nil {
  10141. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10142. return
  10143. }
  10144. body, ioErr := ioutil.ReadAll(resp.Body)
  10145. if ioErr != nil {
  10146. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  10147. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10148. return
  10149. }
  10150. var respJSON map[string]interface{}
  10151. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  10152. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  10153. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10154. return
  10155. }
  10156. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  10157. result, _ := json.Marshal(respJSON)
  10158. fmt.Println("log")
  10159. fmt.Println(string(result))
  10160. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  10161. utils.ErrorLog("解析失败:%v", err)
  10162. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10163. return
  10164. }
  10165. res.ErrMsg = res10265.ErrMsg
  10166. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  10167. res.Infcode = infocode
  10168. res.Output = res10265.Output
  10169. res.InfRefmsgid = res10265.InfRefmsgid
  10170. } else {
  10171. result, _ := service.Gdyb1101(patient.IdCardNo, miConfig.OrgName, role.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, 2, "", "0", patient.Name)
  10172. if miConfig.Code == "H15049901371" {
  10173. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  10174. utils.ErrorLog("解析失败:%v", err)
  10175. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10176. return
  10177. }
  10178. res.ErrMsg = res10265.ErrMsg
  10179. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  10180. res.Infcode = infocode
  10181. res.Output = res10265.Output
  10182. res.InfRefmsgid = res10265.InfRefmsgid
  10183. } else {
  10184. if err := json.Unmarshal([]byte(result), &res); err != nil {
  10185. utils.ErrorLog("解析失败:%v", err)
  10186. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10187. return
  10188. }
  10189. }
  10190. }
  10191. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  10192. infoStr := string(Iinfos)
  10193. var rf []*ResultFive
  10194. json.Unmarshal([]byte(infoStr), &rf)
  10195. var insuplc_admdvs string
  10196. var insutype string
  10197. var is390 int = 0
  10198. var is310 int = 0
  10199. var insutypes []*ResultFive
  10200. for _, item := range rf {
  10201. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  10202. insutypes = append(insutypes, item)
  10203. }
  10204. }
  10205. if len(insutypes) == 1 {
  10206. insutype = insutypes[0].Insutype
  10207. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  10208. } else {
  10209. for _, i := range insutypes {
  10210. if i.Insutype == "390" {
  10211. is390 = 1
  10212. }
  10213. if i.Insutype == "310" {
  10214. is310 = 1
  10215. }
  10216. }
  10217. }
  10218. if is390 == 1 {
  10219. insutype = "390"
  10220. }
  10221. if is310 == 1 {
  10222. insutype = "310"
  10223. }
  10224. if len(insutypes) == 2 {
  10225. insutype = insutype_two
  10226. }
  10227. if len(insutypes) == 0 {
  10228. insutype = "310"
  10229. }
  10230. insutype = insutype_two
  10231. fmt.Println(insutype)
  10232. for _, item := range rf {
  10233. fmt.Println(item.Insutype)
  10234. fmt.Println(insutype)
  10235. if item.Insutype == insutype {
  10236. fmt.Println(item.Insutype)
  10237. fmt.Println(insutype)
  10238. insuplc_admdvs = item.InsuplcAdmdvs
  10239. }
  10240. }
  10241. fmt.Println(insuplc_admdvs)
  10242. var res2 ResultThirteen
  10243. var res10265_2 ResultThirteen10265
  10244. if config.IsOpen == 1 {
  10245. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  10246. } else {
  10247. 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)
  10248. var dat map[string]interface{}
  10249. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  10250. fmt.Println(dat)
  10251. } else {
  10252. fmt.Println(err)
  10253. }
  10254. userJSONBytes, _ := json.Marshal(dat)
  10255. if miConfig.Code == "H15049901371" {
  10256. if err := json.Unmarshal(userJSONBytes, &res10265_2); err != nil {
  10257. utils.ErrorLog("解析失败:%v", err)
  10258. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10259. return
  10260. }
  10261. res2.ErrMsg = res10265_2.ErrMsg
  10262. infocode, _ := strconv.ParseInt(res10265_2.Infcode, 10, 64)
  10263. res2.Infcode = infocode
  10264. res2.Output = res10265_2.Output
  10265. res2.InfRefmsgid = res10265_2.InfRefmsgid
  10266. } else {
  10267. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  10268. utils.ErrorLog("解析失败:%v", err)
  10269. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10270. return
  10271. }
  10272. }
  10273. }
  10274. if res2.Infcode == 0 {
  10275. psnResult := &models.GdybPsnNcdsRecord{
  10276. UserOrgId: adminUser.CurrentOrgId,
  10277. PatientId: patient.ID,
  10278. PsnNo: psn_no,
  10279. DoctorId: doctor.AdminUserId,
  10280. DepartmentId: department_id,
  10281. SickType: sick_id,
  10282. Insutype: insutype,
  10283. Ctime: time.Now().Unix(),
  10284. Mtime: time.Now().Unix(),
  10285. Status: 1,
  10286. IsCancel: 1,
  10287. TrtDclaDetlSn: res2.Output.Result.TrtDclaDetlSn,
  10288. }
  10289. service.CreatePsnNCDSRecord(psnResult)
  10290. c.ServeSuccessJSON(map[string]interface{}{
  10291. "failed_code": 0,
  10292. "msg": "备案成功",
  10293. "result": psnResult,
  10294. })
  10295. } else {
  10296. c.ServeSuccessJSON(map[string]interface{}{
  10297. "failed_code": -10,
  10298. "msg": res2.ErrMsg,
  10299. })
  10300. return
  10301. }
  10302. }
  10303. }
  10304. func (c *HisApiController) PsnPutUnNCDSOnRecord() {
  10305. id, _ := c.GetInt64("id")
  10306. admin_user_id, _ := c.GetInt64("admin_user_id")
  10307. adminUser := c.GetAdminUserInfo()
  10308. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  10309. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  10310. //config, _ := service.Ge(adminUser.CurrentOrgId)
  10311. patient, _ := service.GetPatientByID(c.GetAdminUserInfo().CurrentOrgId, id)
  10312. //role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  10313. //var user_name string
  10314. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  10315. //if role.ID == 0 {
  10316. // user_name = "xxx"
  10317. //} else {
  10318. // user_name = role.UserName
  10319. //}
  10320. psn_record, _ := service.GetPsnNCDSRecordById(id)
  10321. if psn_record.ID == 0 {
  10322. c.ServeFailJSONWithSGJErrorCode(enums.ErrorPsnRecordNoExistWrong)
  10323. return
  10324. }
  10325. result, _ := service.Gdyb1101(patient.IdCardNo, miConfig.OrgName, role.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, 2, "", "0", patient.Name)
  10326. var res ResultTwo
  10327. var res10265 ResultTwo10265
  10328. if miConfig.Code == "H15049901371" {
  10329. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  10330. utils.ErrorLog("解析失败:%v", err)
  10331. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10332. return
  10333. }
  10334. res.ErrMsg = res10265.ErrMsg
  10335. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  10336. res.Infcode = infocode
  10337. res.Output = res10265.Output
  10338. res.InfRefmsgid = res10265.InfRefmsgid
  10339. } else {
  10340. if err := json.Unmarshal([]byte(result), &res); err != nil {
  10341. utils.ErrorLog("解析失败:%v", err)
  10342. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10343. return
  10344. }
  10345. }
  10346. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  10347. infoStr := string(Iinfos)
  10348. var rf []*ResultFive
  10349. json.Unmarshal([]byte(infoStr), &rf)
  10350. var insuplc_admdvs string
  10351. var insutype string
  10352. var is390 int = 0
  10353. var is310 int = 0
  10354. var insutypes []*ResultFive
  10355. for _, item := range rf {
  10356. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  10357. insutypes = append(insutypes, item)
  10358. }
  10359. }
  10360. if len(insutypes) == 1 {
  10361. insutype = insutypes[0].Insutype
  10362. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  10363. } else {
  10364. for _, i := range insutypes {
  10365. if i.Insutype == "390" {
  10366. is390 = 1
  10367. }
  10368. if i.Insutype == "310" {
  10369. is310 = 1
  10370. }
  10371. }
  10372. }
  10373. if is390 == 1 {
  10374. insutype = "390"
  10375. }
  10376. if is310 == 1 {
  10377. insutype = "310"
  10378. }
  10379. if len(insutypes) == 0 {
  10380. insutype = "310"
  10381. }
  10382. insutype = psn_record.Insutype
  10383. for _, item := range rf {
  10384. if item.Insutype == insutype {
  10385. insuplc_admdvs = item.InsuplcAdmdvs
  10386. }
  10387. }
  10388. if config.IsOpen == 1 {
  10389. result := service.Gdyb2504(psn_record.PsnNo, miConfig.OrgName, role.UserName, miConfig.Code, insuplc_admdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, psn_record.TrtDclaDetlSn)
  10390. var dat map[string]interface{}
  10391. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  10392. fmt.Println(dat)
  10393. } else {
  10394. fmt.Println(err)
  10395. }
  10396. userJSONBytes, _ := json.Marshal(dat)
  10397. var res ResultFourteen
  10398. var res10265 ResultFourteen10265
  10399. if miConfig.Code == "H15049901371" {
  10400. if err := json.Unmarshal(userJSONBytes, &res10265); err != nil {
  10401. utils.ErrorLog("解析失败:%v", err)
  10402. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10403. return
  10404. }
  10405. res.ErrMsg = res10265.ErrMsg
  10406. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  10407. res.Infcode = infocode
  10408. res.Output = res10265.Output
  10409. res.InfRefmsgid = res10265.InfRefmsgid
  10410. } else {
  10411. if err := json.Unmarshal([]byte(result), &res); err != nil {
  10412. utils.ErrorLog("解析失败:%v", err)
  10413. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10414. return
  10415. }
  10416. }
  10417. //if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  10418. // utils.ErrorLog("解析失败:%v", err)
  10419. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10420. // return
  10421. //}
  10422. if res.Infcode == 0 {
  10423. psn_record.IsCancel = 2
  10424. service.CreatePsnNCDSRecord(&psn_record)
  10425. c.ServeSuccessJSON(map[string]interface{}{
  10426. "failed_code": 0,
  10427. "msg": "撤销备案成功",
  10428. })
  10429. } else {
  10430. c.ServeSuccessJSON(map[string]interface{}{
  10431. "failed_code": -10,
  10432. "msg": res.ErrMsg,
  10433. })
  10434. return
  10435. }
  10436. }
  10437. }
  10438. func (c *HisApiController) TestTest() {
  10439. patient, _ := service.GetHisPatientInfo(4, 456, 1619712000)
  10440. fmt.Println(patient.Iinfo)
  10441. }
  10442. type CustomData struct {
  10443. MsgId string
  10444. PsnNo string
  10445. Info string
  10446. }
  10447. func (c *HisApiController) ReversalData() {
  10448. var customData []*CustomData
  10449. custom := &CustomData{
  10450. MsgId: "H44022900158202103301714472004",
  10451. PsnNo: "44020000001101329945",
  10452. Info: "2207",
  10453. }
  10454. customData = append(customData, custom)
  10455. custom1 := &CustomData{
  10456. MsgId: "H4402290015820210330172057803",
  10457. PsnNo: "44020000001101161813",
  10458. Info: "2207",
  10459. }
  10460. customData = append(customData, custom1)
  10461. custom2 := &CustomData{
  10462. MsgId: "H44022900158202103301705198813",
  10463. PsnNo: "44190000133097375417",
  10464. Info: "2207",
  10465. }
  10466. customData = append(customData, custom2)
  10467. custom3 := &CustomData{
  10468. MsgId: "H44022900158202103301715524756",
  10469. PsnNo: "44020000001100187221",
  10470. Info: "2207",
  10471. }
  10472. customData = append(customData, custom3)
  10473. custom4 := &CustomData{
  10474. MsgId: "H44022900158202103301730376224",
  10475. PsnNo: "44020000001101959155",
  10476. Info: "2207",
  10477. }
  10478. customData = append(customData, custom4)
  10479. custom5 := &CustomData{
  10480. MsgId: "H44022900158202103301748008725",
  10481. PsnNo: "44020000001104246641",
  10482. Info: "2207",
  10483. }
  10484. customData = append(customData, custom5)
  10485. custom6 := &CustomData{
  10486. MsgId: "H44022900158202103301718096755",
  10487. PsnNo: "44020000001102211860",
  10488. Info: "2207",
  10489. }
  10490. customData = append(customData, custom6)
  10491. custom7 := &CustomData{
  10492. MsgId: "H44022900158202103301736551640",
  10493. PsnNo: "44020000001102687718",
  10494. Info: "2207",
  10495. }
  10496. customData = append(customData, custom7)
  10497. custom8 := &CustomData{
  10498. MsgId: "H44022900158202103301743097676",
  10499. PsnNo: "44020000001102127785",
  10500. Info: "2207",
  10501. }
  10502. customData = append(customData, custom8)
  10503. custom9 := &CustomData{
  10504. MsgId: "H44022900158202103301712304203",
  10505. PsnNo: "44020000001101518097",
  10506. Info: "2207",
  10507. }
  10508. customData = append(customData, custom9)
  10509. custom10 := &CustomData{
  10510. MsgId: "H44022900158202103301738448785",
  10511. PsnNo: "44020000001100500813",
  10512. Info: "2207",
  10513. }
  10514. customData = append(customData, custom10)
  10515. custom11 := &CustomData{
  10516. MsgId: "H44022900158202103301732455843",
  10517. PsnNo: "44020000001102690557",
  10518. Info: "2207",
  10519. }
  10520. customData = append(customData, custom11)
  10521. custom12 := &CustomData{
  10522. MsgId: "H44022900158202103301745421708",
  10523. PsnNo: "44020000001102211928",
  10524. Info: "2207",
  10525. }
  10526. customData = append(customData, custom12)
  10527. custom1212 := &CustomData{
  10528. MsgId: "H440229001582021033017351627",
  10529. PsnNo: "44020000001102481733",
  10530. Info: "2207",
  10531. }
  10532. customData = append(customData, custom1212)
  10533. custom13 := &CustomData{
  10534. MsgId: "H44022900158202103301740327951",
  10535. PsnNo: "44020000001103174866",
  10536. Info: "2207",
  10537. }
  10538. customData = append(customData, custom13)
  10539. custom14 := &CustomData{
  10540. MsgId: "H4402290015820210330174922668",
  10541. PsnNo: "44020000001102927272",
  10542. Info: "2207",
  10543. }
  10544. customData = append(customData, custom14)
  10545. custom15 := &CustomData{
  10546. MsgId: "H44022900158202103301752362273",
  10547. PsnNo: "44020000001102942890",
  10548. Info: "2207",
  10549. }
  10550. customData = append(customData, custom15)
  10551. custom16 := &CustomData{
  10552. MsgId: "H44022900158202103301751082917",
  10553. PsnNo: "44020000001101662162",
  10554. Info: "2207",
  10555. }
  10556. customData = append(customData, custom16)
  10557. custom17 := &CustomData{
  10558. MsgId: "H44022900158202103301754147728",
  10559. PsnNo: "44020000000229014511",
  10560. Info: "2207",
  10561. }
  10562. customData = append(customData, custom17)
  10563. adminUser := c.GetAdminUserInfo()
  10564. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  10565. for _, item := range customData {
  10566. result := service.Gdyb2601(item.PsnNo, item.MsgId, item.Info, miConfig.OrgName, "张俊杰", miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey)
  10567. fmt.Println(result)
  10568. }
  10569. }
  10570. //func (c *HisApiController) GetAllopatry() {
  10571. // year := c.GetString("year")
  10572. // month := c.GetString("month")
  10573. // admin_user_id, _ := c.GetInt64("admin_user_id")
  10574. // adminUser := c.GetAdminUserInfo()
  10575. // miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  10576. // roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  10577. // result, _ := service.Gdyb9001(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, 1669)
  10578. //
  10579. // var dat map[string]interface{}
  10580. // if err := json.Unmarshal([]byte(result), &dat); err == nil {
  10581. // fmt.Println(dat)
  10582. // } else {
  10583. // fmt.Println(err)
  10584. // }
  10585. // userJSONBytes, _ := json.Marshal(dat)
  10586. // var res models.Result9001
  10587. // if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  10588. // utils.ErrorLog("解析失败:%v", err)
  10589. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10590. // return
  10591. // }
  10592. //
  10593. // result2, _ := service.Gdyb3260(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, year, month, res.Output.Signinoutb.SignNo)
  10594. // var dat2 map[string]interface{}
  10595. // if err := json.Unmarshal([]byte(result2), &dat2); err == nil {
  10596. // fmt.Println(dat)
  10597. // } else {
  10598. // fmt.Println(err)
  10599. // }
  10600. // userJSONBytes2, _ := json.Marshal(dat2)
  10601. // var res2 models.Result3260
  10602. // if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  10603. // utils.ErrorLog("解析失败:%v", err)
  10604. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10605. // return
  10606. // }
  10607. // if res2.Infcode == 0 {
  10608. // c.ServeSuccessJSON(map[string]interface{}{
  10609. // "list": res2.Output.Data,
  10610. // })
  10611. // return
  10612. // } else {
  10613. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10614. // return
  10615. // }
  10616. //
  10617. //}
  10618. //func (c *HisApiController) ComfirmAllopatry() {
  10619. // year := c.GetString("year")
  10620. // month := c.GetString("month")
  10621. // admin_user_id, _ := c.GetInt64("admin_user_id")
  10622. // adminUser := c.GetAdminUserInfo()
  10623. // miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  10624. // roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  10625. // result, _ := service.Gdyb9001(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, 1669)
  10626. // var dat map[string]interface{}
  10627. // if err := json.Unmarshal([]byte(result), &dat); err == nil {
  10628. // fmt.Println(dat)
  10629. // } else {
  10630. // fmt.Println(err)
  10631. // }
  10632. // userJSONBytes, _ := json.Marshal(dat)
  10633. // var res models.Result9001
  10634. // if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  10635. // utils.ErrorLog("解析失败:%v", err)
  10636. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10637. // return
  10638. // }
  10639. //
  10640. // result2, _ := service.Gdyb3260(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, year, month, res.Output.Signinoutb.SignNo)
  10641. // var dat2 map[string]interface{}
  10642. // if err := json.Unmarshal([]byte(result2), &dat2); err == nil {
  10643. // fmt.Println(dat)
  10644. // } else {
  10645. // fmt.Println(err)
  10646. // }
  10647. // userJSONBytes2, _ := json.Marshal(dat2)
  10648. // var res2 models.Result3260
  10649. // if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  10650. // utils.ErrorLog("解析失败:%v", err)
  10651. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10652. // return
  10653. // }
  10654. //
  10655. // if res2.Infcode == 0 {
  10656. // result, _, msgId := service.Gdyb3261(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, year, month, res2)
  10657. // var dat map[string]interface{}
  10658. // if err := json.Unmarshal([]byte(result), &dat); err == nil {
  10659. // fmt.Println(dat)
  10660. // } else {
  10661. // fmt.Println(err)
  10662. // }
  10663. // userJSONBytes, _ := json.Marshal(dat)
  10664. // var res3 models.Result3261
  10665. // if err := json.Unmarshal(userJSONBytes, &res3); err != nil {
  10666. // utils.ErrorLog("解析失败:%v", err)
  10667. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10668. // return
  10669. // }
  10670. //
  10671. // if res3.Infcode == 0 {
  10672. // record := &models.HisYidiClearRecord{
  10673. // UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  10674. // Ctime: time.Now().Unix(),
  10675. // Mtime: time.Now().Unix(),
  10676. // Status: 1,
  10677. // MsgId: msgId,
  10678. // }
  10679. // service.SaveClearRecord(record)
  10680. // c.ServeSuccessJSON(map[string]interface{}{
  10681. // "msg": "提取成功",
  10682. // })
  10683. // }
  10684. // }
  10685. //}
  10686. func (c *HisApiController) RefundAllopatry() {
  10687. year := c.GetString("year")
  10688. month := c.GetString("month")
  10689. id, _ := c.GetInt64("id")
  10690. admin_user_id, _ := c.GetInt64("admin_user_id")
  10691. adminUser := c.GetAdminUserInfo()
  10692. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  10693. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  10694. record, _ := service.GetClearRecordById(id)
  10695. result, _ := service.Gdyb3262(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, year, month, record.MsgId)
  10696. var dat map[string]interface{}
  10697. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  10698. fmt.Println(dat)
  10699. } else {
  10700. fmt.Println(err)
  10701. }
  10702. userJSONBytes, _ := json.Marshal(dat)
  10703. var empty ResultFourteen
  10704. if err := json.Unmarshal(userJSONBytes, &empty); err != nil {
  10705. utils.ErrorLog("解析失败:%v", err)
  10706. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10707. return
  10708. }
  10709. if empty.Infcode == 0 {
  10710. c.ServeSuccessJSON(map[string]interface{}{
  10711. "msg": "撤销成功",
  10712. })
  10713. return
  10714. }
  10715. }
  10716. func (c *HisApiController) ReversalOtherData() {
  10717. var customData []*CustomData
  10718. custom := &CustomData{
  10719. MsgId: "H44022900158202103301714472004",
  10720. PsnNo: "44020000001101329945",
  10721. Info: "2208",
  10722. }
  10723. customData = append(customData, custom)
  10724. custom1 := &CustomData{
  10725. MsgId: "H4402290015820210330172057803",
  10726. PsnNo: "44020000001101161813",
  10727. Info: "2208",
  10728. }
  10729. customData = append(customData, custom1)
  10730. custom2 := &CustomData{
  10731. MsgId: "H44022900158202103301705198813",
  10732. PsnNo: "44190000133097375417",
  10733. Info: "2208",
  10734. }
  10735. customData = append(customData, custom2)
  10736. custom3 := &CustomData{
  10737. MsgId: "H44022900158202103301715524756",
  10738. PsnNo: "44020000001100187221",
  10739. Info: "2208",
  10740. }
  10741. customData = append(customData, custom3)
  10742. custom4 := &CustomData{
  10743. MsgId: "H44022900158202103301730376224",
  10744. PsnNo: "44020000001101959155",
  10745. Info: "2208",
  10746. }
  10747. customData = append(customData, custom4)
  10748. custom5 := &CustomData{
  10749. MsgId: "H44022900158202103301748008725",
  10750. PsnNo: "44020000001104246641",
  10751. Info: "2208",
  10752. }
  10753. customData = append(customData, custom5)
  10754. custom6 := &CustomData{
  10755. MsgId: "H44022900158202103301718096755",
  10756. PsnNo: "44020000001102211860",
  10757. Info: "2208",
  10758. }
  10759. customData = append(customData, custom6)
  10760. custom7 := &CustomData{
  10761. MsgId: "H44022900158202103301736551640",
  10762. PsnNo: "44020000001102687718",
  10763. Info: "2208",
  10764. }
  10765. customData = append(customData, custom7)
  10766. custom8 := &CustomData{
  10767. MsgId: "H44022900158202103301743097676",
  10768. PsnNo: "44020000001102127785",
  10769. Info: "2208",
  10770. }
  10771. customData = append(customData, custom8)
  10772. custom9 := &CustomData{
  10773. MsgId: "H44022900158202103301712304203",
  10774. PsnNo: "44020000001101518097",
  10775. Info: "2208",
  10776. }
  10777. customData = append(customData, custom9)
  10778. custom10 := &CustomData{
  10779. MsgId: "H44022900158202103301738448785",
  10780. PsnNo: "44020000001100500813",
  10781. Info: "2208",
  10782. }
  10783. customData = append(customData, custom10)
  10784. custom11 := &CustomData{
  10785. MsgId: "H44022900158202103301732455843",
  10786. PsnNo: "44020000001102690557",
  10787. Info: "2208",
  10788. }
  10789. customData = append(customData, custom11)
  10790. custom12 := &CustomData{
  10791. MsgId: "H44022900158202103301745421708",
  10792. PsnNo: "44020000001102211928",
  10793. Info: "2208",
  10794. }
  10795. customData = append(customData, custom12)
  10796. custom1212 := &CustomData{
  10797. MsgId: "H440229001582021033017351627",
  10798. PsnNo: "44020000001102481733",
  10799. Info: "2208",
  10800. }
  10801. customData = append(customData, custom1212)
  10802. custom13 := &CustomData{
  10803. MsgId: "H44022900158202103301740327951",
  10804. PsnNo: "44020000001103174866",
  10805. Info: "2208",
  10806. }
  10807. customData = append(customData, custom13)
  10808. custom14 := &CustomData{
  10809. MsgId: "H4402290015820210330174922668",
  10810. PsnNo: "44020000001102927272",
  10811. Info: "2208",
  10812. }
  10813. customData = append(customData, custom14)
  10814. custom15 := &CustomData{
  10815. MsgId: "H44022900158202103301752362273",
  10816. PsnNo: "44020000001102942890",
  10817. Info: "2208",
  10818. }
  10819. customData = append(customData, custom15)
  10820. custom16 := &CustomData{
  10821. MsgId: "H44022900158202103301751082917",
  10822. PsnNo: "44020000001101662162",
  10823. Info: "2208",
  10824. }
  10825. customData = append(customData, custom16)
  10826. custom17 := &CustomData{
  10827. MsgId: "H44022900158202103301754147728",
  10828. PsnNo: "44020000000229014511",
  10829. Info: "2208",
  10830. }
  10831. customData = append(customData, custom17)
  10832. adminUser := c.GetAdminUserInfo()
  10833. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  10834. for _, item := range customData {
  10835. result := service.Gdyb2601(item.PsnNo, item.MsgId, item.Info, miConfig.OrgName, "张俊杰", miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey)
  10836. fmt.Println(result)
  10837. }
  10838. }
  10839. func PathExists(path string) (bool, error) {
  10840. _, err := os.Stat(path)
  10841. if err == nil {
  10842. return true, nil
  10843. }
  10844. if os.IsNotExist(err) {
  10845. return false, nil
  10846. }
  10847. return false, err
  10848. }
  10849. //创建文件夹
  10850. func Mkdir(dir string) {
  10851. // 创建文件夹
  10852. exist, err := PathExists(dir)
  10853. if err != nil {
  10854. fmt.Println(err.Error())
  10855. } else {
  10856. if exist {
  10857. fmt.Println(dir + "文件夹已存在!")
  10858. } else {
  10859. // 文件夹名称,权限
  10860. err := os.Mkdir(dir, os.ModePerm)
  10861. if err != nil {
  10862. fmt.Println(dir+"文件夹创建失败:", err.Error())
  10863. } else {
  10864. fmt.Println(dir + "文件夹创建成功!")
  10865. }
  10866. }
  10867. }
  10868. }
  10869. //压缩文件
  10870. func Zip(srcFile string, destZip string) error {
  10871. zipfile, err := os.Create(destZip)
  10872. if err != nil {
  10873. return err
  10874. }
  10875. defer zipfile.Close()
  10876. archive := zip.NewWriter(zipfile)
  10877. defer archive.Close()
  10878. filepath.Walk(srcFile, func(path string, info os.FileInfo, err error) error {
  10879. if err != nil {
  10880. return err
  10881. }
  10882. header, err := zip.FileInfoHeader(info)
  10883. if err != nil {
  10884. return err
  10885. }
  10886. header.Name = strings.TrimPrefix(path, filepath.Dir(srcFile)+"/")
  10887. // header.Name = path
  10888. if info.IsDir() {
  10889. header.Name += "/"
  10890. } else {
  10891. header.Method = zip.Deflate
  10892. }
  10893. writer, err := archive.CreateHeader(header)
  10894. if err != nil {
  10895. return err
  10896. }
  10897. if !info.IsDir() {
  10898. file, err := os.Open(path)
  10899. if err != nil {
  10900. return err
  10901. }
  10902. defer file.Close()
  10903. _, err = io.Copy(writer, file)
  10904. }
  10905. return err
  10906. })
  10907. return err
  10908. }
  10909. func ReadFile(filePath string) []byte {
  10910. f, err := os.Open(filePath)
  10911. if err != nil {
  10912. fmt.Println("read file fail", err)
  10913. return nil
  10914. }
  10915. defer f.Close()
  10916. fd, err := ioutil.ReadAll(f)
  10917. if err != nil {
  10918. fmt.Println("read to fd fail", err)
  10919. return nil
  10920. }
  10921. return fd
  10922. }
  10923. func saveLog(result string, request string, infno string, desc string) {
  10924. org_id, _ := beego.AppConfig.Int64("org_id")
  10925. miConfig, _ := service.FindMedicalInsuranceInfo(org_id)
  10926. dir := miConfig.OrgName + "日志"
  10927. utils.Mkdir(dir)
  10928. month := time.Unix(1557042972, 0).Format("1")
  10929. year := time.Now().Format("2006")
  10930. month = time.Now().Format("01")
  10931. day := time.Now().Format("02")
  10932. hour := time.Now().Format("15")
  10933. min := time.Now().Format("04")
  10934. sec := time.Now().Format("05")
  10935. result_time := year + "-" + month + "-" + day + " " + hour + ":" + min + ":" + sec
  10936. file := strconv.FormatInt(org_id, 10) + "_" + year + month + day + "_log"
  10937. file_name := file + ".txt"
  10938. file_path := miConfig.OrgName + "日志" + "/" + file_name
  10939. exist, _ := utils.PathExists(file_path)
  10940. if exist { //存在
  10941. fmt.Println("存在")
  10942. f, err := os.OpenFile(file_path, os.O_WRONLY, 0644)
  10943. if err != nil {
  10944. fmt.Println("read fail")
  10945. }
  10946. content := "\r\n" + "\r\n" + "\r\n" + result_time + " " + "【 " + desc + infno + "入参" + " 】:" + "\r\n" + request + "\r\n" + result_time + " " + "【 " + desc + infno + "出参" + " 】:" + "\r\n" + result
  10947. n, _ := f.Seek(0, 2)
  10948. _, err = f.WriteAt([]byte(content), n)
  10949. } else { //不存在
  10950. fmt.Println("文件不存在,创建文件")
  10951. f, err := os.Create(miConfig.OrgName + "日志" + "/" + file_name)
  10952. defer f.Close()
  10953. if err != nil {
  10954. } else {
  10955. _, err = f.Write([]byte("记录日志"))
  10956. }
  10957. }
  10958. }
  10959. type Charset string
  10960. const (
  10961. UTF8 = Charset("UTF-8")
  10962. GB18030 = Charset("GB18030")
  10963. )
  10964. func ConvertToString(src string, srcCode string, tagCode string) string {
  10965. srcCoder := mahonia.NewDecoder(srcCode)
  10966. srcResult := srcCoder.ConvertString(src)
  10967. tagCoder := mahonia.NewDecoder(tagCode)
  10968. _, cdata, _ := tagCoder.Translate([]byte(srcResult), true)
  10969. result := string(cdata)
  10970. return result
  10971. }
  10972. func (c *HisApiController) ReadEleCard() {
  10973. id_card_type, _ := c.GetInt64("id_card_type")
  10974. admin_user_id, _ := c.GetInt64("admin_user_id")
  10975. fmt.Println(c.GetAdminUserInfo().CurrentOrgId)
  10976. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  10977. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  10978. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  10979. var api string
  10980. if miConfig.MdtrtareaAdmvs == "320921" {
  10981. 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 +
  10982. "&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
  10983. fmt.Println(api)
  10984. } else {
  10985. 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 +
  10986. "&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)
  10987. }
  10988. resp, requestErr := http.Get(api)
  10989. if requestErr != nil {
  10990. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10991. return
  10992. }
  10993. body, ioErr := ioutil.ReadAll(resp.Body)
  10994. if ioErr != nil {
  10995. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  10996. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10997. return
  10998. }
  10999. var respJSON map[string]interface{}
  11000. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  11001. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  11002. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11003. return
  11004. }
  11005. var status string
  11006. status = respJSON["data"].(map[string]interface{})["status"].(string)
  11007. //card_type := respJSON["data"].(map[string]interface{})["type"].(string)
  11008. var token string
  11009. var res ResultTwo //1101结果
  11010. var res10265 ResultTwo10265 //1101结果
  11011. if status == "0" { //读卡成功
  11012. var card_info string //卡信息
  11013. var busi_card_info string
  11014. token = respJSON["data"].(map[string]interface{})["token"].(string)
  11015. busi_card_info = respJSON["data"].(map[string]interface{})["busi_card_info"].(string)
  11016. card_info = respJSON["data"].(map[string]interface{})["card_info"].(string)
  11017. fmt.Println(card_info)
  11018. fmt.Println(busi_card_info)
  11019. respJSON = respJSON["data"].(map[string]interface{})["result"].(map[string]interface{})
  11020. result, _ := json.Marshal(respJSON)
  11021. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  11022. utils.ErrorLog("解析失败:%v", err)
  11023. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11024. return
  11025. }
  11026. res.ErrMsg = res10265.ErrMsg
  11027. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  11028. res.Infcode = infocode
  11029. res.Output = res10265.Output
  11030. res.InfRefmsgid = res10265.InfRefmsgid
  11031. if res.Infcode == 0 {
  11032. c.ServeSuccessJSON(map[string]interface{}{
  11033. "number": token,
  11034. })
  11035. }
  11036. } else {
  11037. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  11038. return
  11039. }
  11040. } else { //读卡失败
  11041. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  11042. return
  11043. }
  11044. }
  11045. func DeleteExtraSpaceTwo(s string) string {
  11046. //删除字符串中的多余空格,有多个空格时,仅保留一个空格
  11047. s1 := strings.Replace(s, " ", " ", -1) //替换tab为空格
  11048. regstr := "\\s{2,}" //两个及两个以上空格的正则表达式
  11049. reg, _ := regexp.Compile(regstr) //编译正则表达式
  11050. s2 := make([]byte, len(s1)) //定义字符数组切片
  11051. copy(s2, s1) //将字符串复制到切片
  11052. spc_index := reg.FindStringIndex(string(s2)) //在字符串中搜索
  11053. for len(spc_index) > 0 { //找到适配项
  11054. s2 = append(s2[:spc_index[0]+1], s2[spc_index[1]:]...) //删除多余空格
  11055. spc_index = reg.FindStringIndex(string(s2)) //继续在字符串中搜索
  11056. }
  11057. return string(s2)
  11058. }
  11059. func Remove0000(s string) string {
  11060. str := make([]rune, 0, len(s))
  11061. for _, v := range []rune(s) {
  11062. if v == 0 {
  11063. continue
  11064. }
  11065. str = append(str, v)
  11066. }
  11067. return string(str)
  11068. }
  11069. func (c *HisApiController) GetELeCertInfo(code string, operator_id string, operator_name string) (string, string) {
  11070. DllDef := syscall.MustLoadDLL("HeaSecReadInfo.dll")
  11071. readCard := DllDef.MustFindProc("EcQuery")
  11072. pCardInfo := make([]byte, 8192)
  11073. pBusiCardInfo := make([]byte, 8192)
  11074. data := make(map[string]interface{})
  11075. //pData := make(map[string]interface{})
  11076. inputData := make(map[string]interface{})
  11077. inputData["orgId"] = code
  11078. inputData["businessType"] = "01101"
  11079. inputData["operatorId"] = operator_id
  11080. inputData["operatorName"] = operator_name
  11081. inputData["officeId"] = "001"
  11082. inputData["officeName"] = "血透室"
  11083. //
  11084. data["data"] = inputData
  11085. data["transType"] = "ec.query"
  11086. data["orgId"] = code
  11087. bytesData, _ := json.Marshal(data)
  11088. pCardInfo = bytesData
  11089. ret2, _, _ := readCard.Call((uintptr)(unsafe.Pointer(&pCardInfo[0])), (uintptr)(unsafe.Pointer(&pBusiCardInfo[0])))
  11090. fmt.Println(ret2)
  11091. //fmt.Println(DeleteExtraSpace(string(bytesData)))
  11092. //fmt.Println(DeleteExtraSpace(string(pBusiCardInfo)))
  11093. fmt.Println(":", ConvertToString(DeleteExtraSpace(string(bytesData)), "gbk", "utf-8"))
  11094. fmt.Println(":", ConvertToString(DeleteExtraSpace(string(pBusiCardInfo)), "gbk", "utf-8"))
  11095. if ret2 != 0 {
  11096. return "", ""
  11097. }
  11098. return DeleteExtraSpace(string(bytesData)), DeleteExtraSpace(string(pBusiCardInfo))
  11099. }
  11100. func DeleteExtraSpace(s string) string {
  11101. //删除字符串中的多余空格,有多个空格时,仅保留一个空格
  11102. s1 := strings.Replace(s, " ", " ", -1) //替换tab为空格
  11103. regstr := "\\s{2,}" //两个及两个以上空格的正则表达式
  11104. reg, _ := regexp.Compile(regstr) //编译正则表达式
  11105. s2 := make([]byte, len(s1)) //定义字符数组切片
  11106. copy(s2, s1) //将字符串复制到切片
  11107. spc_index := reg.FindStringIndex(string(s2)) //在字符串中搜索
  11108. for len(spc_index) > 0 { //找到适配项
  11109. s2 = append(s2[:spc_index[0]+1], s2[spc_index[1]:]...) //删除多余空格
  11110. spc_index = reg.FindStringIndex(string(s2)) //继续在字符串中搜索
  11111. }
  11112. return string(s2)
  11113. }