his_api_controller.go 447KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504250525062507250825092510251125122513251425152516251725182519252025212522252325242525252625272528252925302531253225332534253525362537253825392540254125422543254425452546254725482549255025512552255325542555255625572558255925602561256225632564256525662567256825692570257125722573257425752576257725782579258025812582258325842585258625872588258925902591259225932594259525962597259825992600260126022603260426052606260726082609261026112612261326142615261626172618261926202621262226232624262526262627262826292630263126322633263426352636263726382639264026412642264326442645264626472648264926502651265226532654265526562657265826592660266126622663266426652666266726682669267026712672267326742675267626772678267926802681268226832684268526862687268826892690269126922693269426952696269726982699270027012702270327042705270627072708270927102711271227132714271527162717271827192720272127222723272427252726272727282729273027312732273327342735273627372738273927402741274227432744274527462747274827492750275127522753275427552756275727582759276027612762276327642765276627672768276927702771277227732774277527762777277827792780278127822783278427852786278727882789279027912792279327942795279627972798279928002801280228032804280528062807280828092810281128122813281428152816281728182819282028212822282328242825282628272828282928302831283228332834283528362837283828392840284128422843284428452846284728482849285028512852285328542855285628572858285928602861286228632864286528662867286828692870287128722873287428752876287728782879288028812882288328842885288628872888288928902891289228932894289528962897289828992900290129022903290429052906290729082909291029112912291329142915291629172918291929202921292229232924292529262927292829292930293129322933293429352936293729382939294029412942294329442945294629472948294929502951295229532954295529562957295829592960296129622963296429652966296729682969297029712972297329742975297629772978297929802981298229832984298529862987298829892990299129922993299429952996299729982999300030013002300330043005300630073008300930103011301230133014301530163017301830193020302130223023302430253026302730283029303030313032303330343035303630373038303930403041304230433044304530463047304830493050305130523053305430553056305730583059306030613062306330643065306630673068306930703071307230733074307530763077307830793080308130823083308430853086308730883089309030913092309330943095309630973098309931003101310231033104310531063107310831093110311131123113311431153116311731183119312031213122312331243125312631273128312931303131313231333134313531363137313831393140314131423143314431453146314731483149315031513152315331543155315631573158315931603161316231633164316531663167316831693170317131723173317431753176317731783179318031813182318331843185318631873188318931903191319231933194319531963197319831993200320132023203320432053206320732083209321032113212321332143215321632173218321932203221322232233224322532263227322832293230323132323233323432353236323732383239324032413242324332443245324632473248324932503251325232533254325532563257325832593260326132623263326432653266326732683269327032713272327332743275327632773278327932803281328232833284328532863287328832893290329132923293329432953296329732983299330033013302330333043305330633073308330933103311331233133314331533163317331833193320332133223323332433253326332733283329333033313332333333343335333633373338333933403341334233433344334533463347334833493350335133523353335433553356335733583359336033613362336333643365336633673368336933703371337233733374337533763377337833793380338133823383338433853386338733883389339033913392339333943395339633973398339934003401340234033404340534063407340834093410341134123413341434153416341734183419342034213422342334243425342634273428342934303431343234333434343534363437343834393440344134423443344434453446344734483449345034513452345334543455345634573458345934603461346234633464346534663467346834693470347134723473347434753476347734783479348034813482348334843485348634873488348934903491349234933494349534963497349834993500350135023503350435053506350735083509351035113512351335143515351635173518351935203521352235233524352535263527352835293530353135323533353435353536353735383539354035413542354335443545354635473548354935503551355235533554355535563557355835593560356135623563356435653566356735683569357035713572357335743575357635773578357935803581358235833584358535863587358835893590359135923593359435953596359735983599360036013602360336043605360636073608360936103611361236133614361536163617361836193620362136223623362436253626362736283629363036313632363336343635363636373638363936403641364236433644364536463647364836493650365136523653365436553656365736583659366036613662366336643665366636673668366936703671367236733674367536763677367836793680368136823683368436853686368736883689369036913692369336943695369636973698369937003701370237033704370537063707370837093710371137123713371437153716371737183719372037213722372337243725372637273728372937303731373237333734373537363737373837393740374137423743374437453746374737483749375037513752375337543755375637573758375937603761376237633764376537663767376837693770377137723773377437753776377737783779378037813782378337843785378637873788378937903791379237933794379537963797379837993800380138023803380438053806380738083809381038113812381338143815381638173818381938203821382238233824382538263827382838293830383138323833383438353836383738383839384038413842384338443845384638473848384938503851385238533854385538563857385838593860386138623863386438653866386738683869387038713872387338743875387638773878387938803881388238833884388538863887388838893890389138923893389438953896389738983899390039013902390339043905390639073908390939103911391239133914391539163917391839193920392139223923392439253926392739283929393039313932393339343935393639373938393939403941394239433944394539463947394839493950395139523953395439553956395739583959396039613962396339643965396639673968396939703971397239733974397539763977397839793980398139823983398439853986398739883989399039913992399339943995399639973998399940004001400240034004400540064007400840094010401140124013401440154016401740184019402040214022402340244025402640274028402940304031403240334034403540364037403840394040404140424043404440454046404740484049405040514052405340544055405640574058405940604061406240634064406540664067406840694070407140724073407440754076407740784079408040814082408340844085408640874088408940904091409240934094409540964097409840994100410141024103410441054106410741084109411041114112411341144115411641174118411941204121412241234124412541264127412841294130413141324133413441354136413741384139414041414142414341444145414641474148414941504151415241534154415541564157415841594160416141624163416441654166416741684169417041714172417341744175417641774178417941804181418241834184418541864187418841894190419141924193419441954196419741984199420042014202420342044205420642074208420942104211421242134214421542164217421842194220422142224223422442254226422742284229423042314232423342344235423642374238423942404241424242434244424542464247424842494250425142524253425442554256425742584259426042614262426342644265426642674268426942704271427242734274427542764277427842794280428142824283428442854286428742884289429042914292429342944295429642974298429943004301430243034304430543064307430843094310431143124313431443154316431743184319432043214322432343244325432643274328432943304331433243334334433543364337433843394340434143424343434443454346434743484349435043514352435343544355435643574358435943604361436243634364436543664367436843694370437143724373437443754376437743784379438043814382438343844385438643874388438943904391439243934394439543964397439843994400440144024403440444054406440744084409441044114412441344144415441644174418441944204421442244234424442544264427442844294430443144324433443444354436443744384439444044414442444344444445444644474448444944504451445244534454445544564457445844594460446144624463446444654466446744684469447044714472447344744475447644774478447944804481448244834484448544864487448844894490449144924493449444954496449744984499450045014502450345044505450645074508450945104511451245134514451545164517451845194520452145224523452445254526452745284529453045314532453345344535453645374538453945404541454245434544454545464547454845494550455145524553455445554556455745584559456045614562456345644565456645674568456945704571457245734574457545764577457845794580458145824583458445854586458745884589459045914592459345944595459645974598459946004601460246034604460546064607460846094610461146124613461446154616461746184619462046214622462346244625462646274628462946304631463246334634463546364637463846394640464146424643464446454646464746484649465046514652465346544655465646574658465946604661466246634664466546664667466846694670467146724673467446754676467746784679468046814682468346844685468646874688468946904691469246934694469546964697469846994700470147024703470447054706470747084709471047114712471347144715471647174718471947204721472247234724472547264727472847294730473147324733473447354736473747384739474047414742474347444745474647474748474947504751475247534754475547564757475847594760476147624763476447654766476747684769477047714772477347744775477647774778477947804781478247834784478547864787478847894790479147924793479447954796479747984799480048014802480348044805480648074808480948104811481248134814481548164817481848194820482148224823482448254826482748284829483048314832483348344835483648374838483948404841484248434844484548464847484848494850485148524853485448554856485748584859486048614862486348644865486648674868486948704871487248734874487548764877487848794880488148824883488448854886488748884889489048914892489348944895489648974898489949004901490249034904490549064907490849094910491149124913491449154916491749184919492049214922492349244925492649274928492949304931493249334934493549364937493849394940494149424943494449454946494749484949495049514952495349544955495649574958495949604961496249634964496549664967496849694970497149724973497449754976497749784979498049814982498349844985498649874988498949904991499249934994499549964997499849995000500150025003500450055006500750085009501050115012501350145015501650175018501950205021502250235024502550265027502850295030503150325033503450355036503750385039504050415042504350445045504650475048504950505051505250535054505550565057505850595060506150625063506450655066506750685069507050715072507350745075507650775078507950805081508250835084508550865087508850895090509150925093509450955096509750985099510051015102510351045105510651075108510951105111511251135114511551165117511851195120512151225123512451255126512751285129513051315132513351345135513651375138513951405141514251435144514551465147514851495150515151525153515451555156515751585159516051615162516351645165516651675168516951705171517251735174517551765177517851795180518151825183518451855186518751885189519051915192519351945195519651975198519952005201520252035204520552065207520852095210521152125213521452155216521752185219522052215222522352245225522652275228522952305231523252335234523552365237523852395240524152425243524452455246524752485249525052515252525352545255525652575258525952605261526252635264526552665267526852695270527152725273527452755276527752785279528052815282528352845285528652875288528952905291529252935294529552965297529852995300530153025303530453055306530753085309531053115312531353145315531653175318531953205321532253235324532553265327532853295330533153325333533453355336533753385339534053415342534353445345534653475348534953505351535253535354535553565357535853595360536153625363536453655366536753685369537053715372537353745375537653775378537953805381538253835384538553865387538853895390539153925393539453955396539753985399540054015402540354045405540654075408540954105411541254135414541554165417541854195420542154225423542454255426542754285429543054315432543354345435543654375438543954405441544254435444544554465447544854495450545154525453545454555456545754585459546054615462546354645465546654675468546954705471547254735474547554765477547854795480548154825483548454855486548754885489549054915492549354945495549654975498549955005501550255035504550555065507550855095510551155125513551455155516551755185519552055215522552355245525552655275528552955305531553255335534553555365537553855395540554155425543554455455546554755485549555055515552555355545555555655575558555955605561556255635564556555665567556855695570557155725573557455755576557755785579558055815582558355845585558655875588558955905591559255935594559555965597559855995600560156025603560456055606560756085609561056115612561356145615561656175618561956205621562256235624562556265627562856295630563156325633563456355636563756385639564056415642564356445645564656475648564956505651565256535654565556565657565856595660566156625663566456655666566756685669567056715672567356745675567656775678567956805681568256835684568556865687568856895690569156925693569456955696569756985699570057015702570357045705570657075708570957105711571257135714571557165717571857195720572157225723572457255726572757285729573057315732573357345735573657375738573957405741574257435744574557465747574857495750575157525753575457555756575757585759576057615762576357645765576657675768576957705771577257735774577557765777577857795780578157825783578457855786578757885789579057915792579357945795579657975798579958005801580258035804580558065807580858095810581158125813581458155816581758185819582058215822582358245825582658275828582958305831583258335834583558365837583858395840584158425843584458455846584758485849585058515852585358545855585658575858585958605861586258635864586558665867586858695870587158725873587458755876587758785879588058815882588358845885588658875888588958905891589258935894589558965897589858995900590159025903590459055906590759085909591059115912591359145915591659175918591959205921592259235924592559265927592859295930593159325933593459355936593759385939594059415942594359445945594659475948594959505951595259535954595559565957595859595960596159625963596459655966596759685969597059715972597359745975597659775978597959805981598259835984598559865987598859895990599159925993599459955996599759985999600060016002600360046005600660076008600960106011601260136014601560166017601860196020602160226023602460256026602760286029603060316032603360346035603660376038603960406041604260436044604560466047604860496050605160526053605460556056605760586059606060616062606360646065606660676068606960706071607260736074607560766077607860796080608160826083608460856086608760886089609060916092609360946095609660976098609961006101610261036104610561066107610861096110611161126113611461156116611761186119612061216122612361246125612661276128612961306131613261336134613561366137613861396140614161426143614461456146614761486149615061516152615361546155615661576158615961606161616261636164616561666167616861696170617161726173617461756176617761786179618061816182618361846185618661876188618961906191619261936194619561966197619861996200620162026203620462056206620762086209621062116212621362146215621662176218621962206221622262236224622562266227622862296230623162326233623462356236623762386239624062416242624362446245624662476248624962506251625262536254625562566257625862596260626162626263626462656266626762686269627062716272627362746275627662776278627962806281628262836284628562866287628862896290629162926293629462956296629762986299630063016302630363046305630663076308630963106311631263136314631563166317631863196320632163226323632463256326632763286329633063316332633363346335633663376338633963406341634263436344634563466347634863496350635163526353635463556356635763586359636063616362636363646365636663676368636963706371637263736374637563766377637863796380638163826383638463856386638763886389639063916392639363946395639663976398639964006401640264036404640564066407640864096410641164126413641464156416641764186419642064216422642364246425642664276428642964306431643264336434643564366437643864396440644164426443644464456446644764486449645064516452645364546455645664576458645964606461646264636464646564666467646864696470647164726473647464756476647764786479648064816482648364846485648664876488648964906491649264936494649564966497649864996500650165026503650465056506650765086509651065116512651365146515651665176518651965206521652265236524652565266527652865296530653165326533653465356536653765386539654065416542654365446545654665476548654965506551655265536554655565566557655865596560656165626563656465656566656765686569657065716572657365746575657665776578657965806581658265836584658565866587658865896590659165926593659465956596659765986599660066016602660366046605660666076608660966106611661266136614661566166617661866196620662166226623662466256626662766286629663066316632663366346635663666376638663966406641664266436644664566466647664866496650665166526653665466556656665766586659666066616662666366646665666666676668666966706671667266736674667566766677667866796680668166826683668466856686668766886689669066916692669366946695669666976698669967006701670267036704670567066707670867096710671167126713671467156716671767186719672067216722672367246725672667276728672967306731673267336734673567366737673867396740674167426743674467456746674767486749675067516752675367546755675667576758675967606761676267636764676567666767676867696770677167726773677467756776677767786779678067816782678367846785678667876788678967906791679267936794679567966797679867996800680168026803680468056806680768086809681068116812681368146815681668176818681968206821682268236824682568266827682868296830683168326833683468356836683768386839684068416842684368446845684668476848684968506851685268536854685568566857685868596860686168626863686468656866686768686869687068716872687368746875687668776878687968806881688268836884688568866887688868896890689168926893689468956896689768986899690069016902690369046905690669076908690969106911691269136914691569166917691869196920692169226923692469256926692769286929693069316932693369346935693669376938693969406941694269436944694569466947694869496950695169526953695469556956695769586959696069616962696369646965696669676968696969706971697269736974697569766977697869796980698169826983698469856986698769886989699069916992699369946995699669976998699970007001700270037004700570067007700870097010701170127013701470157016701770187019702070217022702370247025702670277028702970307031703270337034703570367037703870397040704170427043704470457046704770487049705070517052705370547055705670577058705970607061706270637064706570667067706870697070707170727073707470757076707770787079708070817082708370847085708670877088708970907091709270937094709570967097709870997100710171027103710471057106710771087109711071117112711371147115711671177118711971207121712271237124712571267127712871297130713171327133713471357136713771387139714071417142714371447145714671477148714971507151715271537154715571567157715871597160716171627163716471657166716771687169717071717172717371747175717671777178717971807181718271837184718571867187718871897190719171927193719471957196719771987199720072017202720372047205720672077208720972107211721272137214721572167217721872197220722172227223722472257226722772287229723072317232723372347235723672377238723972407241724272437244724572467247724872497250725172527253725472557256725772587259726072617262726372647265726672677268726972707271727272737274727572767277727872797280728172827283728472857286728772887289729072917292729372947295729672977298729973007301730273037304730573067307730873097310731173127313731473157316731773187319732073217322732373247325732673277328732973307331733273337334733573367337733873397340734173427343734473457346734773487349735073517352735373547355735673577358735973607361736273637364736573667367736873697370737173727373737473757376737773787379738073817382738373847385738673877388738973907391739273937394739573967397739873997400740174027403740474057406740774087409741074117412741374147415741674177418741974207421742274237424742574267427742874297430743174327433743474357436743774387439744074417442744374447445744674477448744974507451745274537454745574567457745874597460746174627463746474657466746774687469747074717472747374747475747674777478747974807481748274837484748574867487748874897490749174927493749474957496749774987499750075017502750375047505750675077508750975107511751275137514751575167517751875197520752175227523752475257526752775287529753075317532753375347535753675377538753975407541754275437544754575467547754875497550755175527553755475557556755775587559756075617562756375647565756675677568756975707571757275737574757575767577757875797580758175827583758475857586758775887589759075917592759375947595759675977598759976007601760276037604760576067607760876097610761176127613761476157616761776187619762076217622762376247625762676277628762976307631763276337634763576367637763876397640764176427643764476457646764776487649765076517652765376547655765676577658765976607661766276637664766576667667766876697670767176727673767476757676767776787679768076817682768376847685768676877688768976907691769276937694769576967697769876997700770177027703770477057706770777087709771077117712771377147715771677177718771977207721772277237724772577267727772877297730773177327733773477357736773777387739774077417742774377447745774677477748774977507751775277537754775577567757775877597760776177627763776477657766776777687769777077717772777377747775777677777778777977807781778277837784778577867787778877897790779177927793779477957796779777987799780078017802780378047805780678077808780978107811781278137814781578167817781878197820782178227823782478257826782778287829783078317832783378347835783678377838783978407841784278437844784578467847784878497850785178527853785478557856785778587859786078617862786378647865786678677868786978707871787278737874787578767877787878797880788178827883788478857886788778887889789078917892789378947895789678977898789979007901790279037904790579067907790879097910791179127913791479157916791779187919792079217922792379247925792679277928792979307931793279337934793579367937793879397940794179427943794479457946794779487949795079517952795379547955795679577958795979607961796279637964796579667967796879697970797179727973797479757976797779787979798079817982798379847985798679877988798979907991799279937994799579967997799879998000800180028003800480058006800780088009801080118012801380148015801680178018801980208021802280238024802580268027802880298030803180328033803480358036803780388039804080418042804380448045804680478048804980508051805280538054805580568057805880598060806180628063806480658066806780688069807080718072807380748075807680778078807980808081808280838084808580868087808880898090809180928093809480958096809780988099810081018102810381048105810681078108810981108111811281138114811581168117811881198120812181228123812481258126812781288129813081318132813381348135813681378138813981408141814281438144814581468147814881498150815181528153815481558156815781588159816081618162816381648165816681678168816981708171817281738174817581768177817881798180818181828183818481858186818781888189819081918192819381948195819681978198819982008201820282038204820582068207820882098210821182128213821482158216821782188219822082218222822382248225822682278228822982308231823282338234823582368237823882398240824182428243824482458246824782488249825082518252825382548255825682578258825982608261826282638264826582668267826882698270827182728273827482758276827782788279828082818282828382848285828682878288828982908291829282938294829582968297829882998300830183028303830483058306830783088309831083118312831383148315831683178318831983208321832283238324832583268327832883298330833183328333833483358336833783388339834083418342834383448345834683478348834983508351835283538354835583568357835883598360836183628363836483658366836783688369837083718372837383748375837683778378837983808381838283838384838583868387838883898390839183928393839483958396839783988399840084018402840384048405840684078408840984108411841284138414841584168417841884198420842184228423842484258426842784288429843084318432843384348435843684378438843984408441844284438444844584468447844884498450845184528453845484558456845784588459846084618462846384648465846684678468846984708471847284738474847584768477847884798480848184828483848484858486848784888489849084918492849384948495849684978498849985008501850285038504850585068507850885098510851185128513851485158516851785188519852085218522852385248525852685278528852985308531853285338534853585368537853885398540854185428543854485458546854785488549855085518552855385548555855685578558855985608561856285638564856585668567856885698570857185728573857485758576857785788579858085818582858385848585858685878588858985908591859285938594859585968597859885998600860186028603860486058606860786088609861086118612861386148615861686178618861986208621862286238624862586268627862886298630863186328633863486358636863786388639864086418642864386448645864686478648864986508651865286538654865586568657865886598660866186628663866486658666866786688669867086718672867386748675867686778678867986808681868286838684868586868687868886898690869186928693869486958696869786988699870087018702870387048705870687078708870987108711871287138714871587168717871887198720872187228723872487258726872787288729873087318732873387348735873687378738873987408741874287438744874587468747874887498750875187528753875487558756875787588759876087618762876387648765876687678768876987708771877287738774877587768777877887798780878187828783878487858786878787888789879087918792879387948795879687978798879988008801880288038804880588068807880888098810881188128813881488158816881788188819882088218822882388248825882688278828882988308831883288338834883588368837883888398840884188428843884488458846884788488849885088518852885388548855885688578858885988608861886288638864886588668867886888698870887188728873887488758876887788788879888088818882888388848885888688878888888988908891889288938894889588968897889888998900890189028903890489058906890789088909891089118912891389148915891689178918891989208921892289238924892589268927892889298930893189328933893489358936893789388939894089418942894389448945894689478948894989508951895289538954895589568957895889598960896189628963896489658966896789688969897089718972897389748975897689778978897989808981898289838984898589868987898889898990899189928993899489958996899789988999900090019002900390049005900690079008900990109011901290139014901590169017901890199020902190229023902490259026902790289029903090319032903390349035903690379038903990409041904290439044904590469047904890499050905190529053905490559056905790589059906090619062906390649065906690679068906990709071907290739074907590769077907890799080908190829083908490859086908790889089909090919092909390949095909690979098909991009101910291039104910591069107910891099110911191129113911491159116911791189119912091219122912391249125912691279128912991309131913291339134913591369137913891399140914191429143914491459146914791489149915091519152915391549155915691579158915991609161916291639164916591669167916891699170917191729173917491759176917791789179918091819182918391849185918691879188918991909191919291939194919591969197919891999200920192029203920492059206920792089209921092119212921392149215921692179218921992209221922292239224922592269227922892299230923192329233923492359236923792389239924092419242924392449245924692479248924992509251925292539254925592569257925892599260926192629263926492659266926792689269927092719272927392749275927692779278927992809281928292839284928592869287928892899290929192929293929492959296929792989299930093019302930393049305930693079308930993109311931293139314931593169317931893199320932193229323932493259326932793289329933093319332933393349335933693379338933993409341934293439344934593469347934893499350935193529353935493559356935793589359936093619362936393649365936693679368936993709371937293739374937593769377937893799380938193829383938493859386938793889389939093919392939393949395939693979398939994009401940294039404940594069407940894099410941194129413941494159416941794189419942094219422942394249425942694279428942994309431943294339434943594369437943894399440944194429443944494459446944794489449945094519452945394549455945694579458945994609461946294639464946594669467946894699470947194729473947494759476947794789479948094819482948394849485948694879488948994909491949294939494949594969497949894999500950195029503950495059506950795089509951095119512951395149515951695179518951995209521952295239524952595269527952895299530953195329533953495359536953795389539954095419542954395449545954695479548954995509551955295539554955595569557955895599560956195629563956495659566956795689569957095719572957395749575957695779578957995809581958295839584958595869587958895899590959195929593959495959596959795989599960096019602960396049605960696079608960996109611961296139614961596169617961896199620962196229623962496259626962796289629963096319632963396349635963696379638963996409641964296439644964596469647964896499650965196529653965496559656965796589659966096619662966396649665966696679668966996709671967296739674967596769677967896799680968196829683968496859686968796889689969096919692969396949695969696979698969997009701970297039704970597069707970897099710971197129713971497159716971797189719972097219722972397249725972697279728972997309731973297339734973597369737973897399740974197429743974497459746974797489749975097519752975397549755975697579758975997609761976297639764976597669767976897699770977197729773977497759776977797789779978097819782978397849785978697879788978997909791979297939794979597969797979897999800980198029803980498059806980798089809981098119812981398149815981698179818981998209821982298239824982598269827982898299830983198329833983498359836983798389839984098419842984398449845984698479848984998509851985298539854985598569857985898599860986198629863986498659866986798689869987098719872987398749875987698779878987998809881988298839884988598869887988898899890989198929893989498959896989798989899990099019902990399049905990699079908990999109911991299139914991599169917991899199920992199229923992499259926992799289929993099319932993399349935993699379938993999409941994299439944994599469947994899499950995199529953995499559956995799589959996099619962996399649965996699679968996999709971997299739974997599769977997899799980998199829983998499859986998799889989999099919992999399949995999699979998999910000100011000210003100041000510006100071000810009100101001110012100131001410015100161001710018100191002010021100221002310024100251002610027100281002910030100311003210033100341003510036100371003810039100401004110042100431004410045100461004710048100491005010051100521005310054100551005610057100581005910060100611006210063100641006510066100671006810069100701007110072100731007410075100761007710078100791008010081100821008310084100851008610087100881008910090100911009210093100941009510096100971009810099101001010110102101031010410105101061010710108101091011010111101121011310114101151011610117101181011910120101211012210123101241012510126101271012810129101301013110132101331013410135101361013710138101391014010141101421014310144101451014610147101481014910150101511015210153101541015510156101571015810159101601016110162101631016410165101661016710168101691017010171101721017310174101751017610177101781017910180101811018210183101841018510186101871018810189101901019110192101931019410195101961019710198101991020010201102021020310204102051020610207102081020910210102111021210213102141021510216102171021810219102201022110222102231022410225102261022710228102291023010231102321023310234102351023610237102381023910240102411024210243102441024510246102471024810249102501025110252102531025410255102561025710258102591026010261102621026310264102651026610267102681026910270102711027210273102741027510276102771027810279102801028110282102831028410285102861028710288102891029010291102921029310294102951029610297102981029910300103011030210303103041030510306103071030810309103101031110312103131031410315103161031710318103191032010321103221032310324103251032610327103281032910330103311033210333103341033510336103371033810339103401034110342103431034410345103461034710348103491035010351103521035310354103551035610357103581035910360103611036210363103641036510366103671036810369103701037110372103731037410375103761037710378103791038010381103821038310384103851038610387103881038910390103911039210393103941039510396103971039810399104001040110402104031040410405104061040710408104091041010411104121041310414104151041610417104181041910420104211042210423104241042510426104271042810429104301043110432104331043410435104361043710438104391044010441104421044310444104451044610447104481044910450104511045210453104541045510456104571045810459104601046110462104631046410465104661046710468104691047010471104721047310474104751047610477104781047910480104811048210483104841048510486104871048810489104901049110492104931049410495104961049710498104991050010501105021050310504105051050610507105081050910510105111051210513105141051510516105171051810519105201052110522105231052410525105261052710528105291053010531105321053310534105351053610537105381053910540105411054210543105441054510546105471054810549105501055110552105531055410555105561055710558105591056010561105621056310564105651056610567105681056910570105711057210573105741057510576105771057810579105801058110582105831058410585105861058710588105891059010591105921059310594105951059610597105981059910600106011060210603106041060510606106071060810609106101061110612106131061410615106161061710618106191062010621106221062310624106251062610627106281062910630106311063210633106341063510636106371063810639106401064110642106431064410645106461064710648106491065010651106521065310654106551065610657106581065910660106611066210663106641066510666106671066810669106701067110672106731067410675106761067710678106791068010681106821068310684106851068610687106881068910690106911069210693106941069510696106971069810699107001070110702107031070410705107061070710708107091071010711107121071310714107151071610717107181071910720107211072210723107241072510726107271072810729107301073110732107331073410735107361073710738107391074010741107421074310744107451074610747107481074910750107511075210753107541075510756107571075810759107601076110762107631076410765107661076710768107691077010771107721077310774107751077610777107781077910780107811078210783107841078510786107871078810789107901079110792107931079410795107961079710798107991080010801108021080310804108051080610807108081080910810108111081210813108141081510816108171081810819108201082110822108231082410825108261082710828108291083010831108321083310834108351083610837108381083910840108411084210843108441084510846108471084810849108501085110852108531085410855108561085710858108591086010861108621086310864108651086610867108681086910870108711087210873108741087510876108771087810879108801088110882108831088410885108861088710888108891089010891108921089310894108951089610897108981089910900109011090210903109041090510906109071090810909109101091110912109131091410915109161091710918109191092010921109221092310924109251092610927109281092910930109311093210933109341093510936109371093810939109401094110942109431094410945109461094710948109491095010951109521095310954109551095610957109581095910960109611096210963109641096510966109671096810969109701097110972109731097410975109761097710978109791098010981109821098310984109851098610987109881098910990109911099210993109941099510996109971099810999110001100111002110031100411005110061100711008110091101011011110121101311014110151101611017110181101911020110211102211023110241102511026110271102811029110301103111032110331103411035110361103711038110391104011041110421104311044110451104611047110481104911050110511105211053110541105511056110571105811059110601106111062110631106411065110661106711068110691107011071110721107311074110751107611077110781107911080110811108211083110841108511086110871108811089110901109111092110931109411095110961109711098110991110011101111021110311104111051110611107111081110911110111111111211113111141111511116111171111811119111201112111122111231112411125111261112711128111291113011131111321113311134111351113611137111381113911140111411114211143111441114511146111471114811149111501115111152111531115411155111561115711158111591116011161111621116311164111651116611167111681116911170111711117211173111741117511176111771117811179111801118111182111831118411185111861118711188111891119011191111921119311194111951119611197111981119911200112011120211203112041120511206112071120811209112101121111212112131121411215112161121711218112191122011221112221122311224112251122611227112281122911230112311123211233112341123511236112371123811239112401124111242112431124411245112461124711248112491125011251112521125311254112551125611257112581125911260112611126211263112641126511266112671126811269112701127111272112731127411275112761127711278112791128011281112821128311284112851128611287112881128911290112911129211293112941129511296112971129811299113001130111302113031130411305113061130711308113091131011311113121131311314113151131611317113181131911320113211132211323113241132511326113271132811329113301133111332113331133411335113361133711338113391134011341113421134311344113451134611347113481134911350113511135211353113541135511356113571135811359113601136111362113631136411365113661136711368113691137011371113721137311374113751137611377113781137911380113811138211383113841138511386113871138811389113901139111392113931139411395113961139711398113991140011401114021140311404114051140611407114081140911410114111141211413114141141511416114171141811419114201142111422114231142411425114261142711428114291143011431114321143311434114351143611437114381143911440114411144211443114441144511446114471144811449114501145111452114531145411455114561145711458114591146011461114621146311464114651146611467114681146911470114711147211473114741147511476114771147811479114801148111482114831148411485114861148711488114891149011491114921149311494114951149611497114981149911500115011150211503115041150511506115071150811509115101151111512115131151411515115161151711518115191152011521115221152311524115251152611527115281152911530115311153211533115341153511536115371153811539115401154111542115431154411545115461154711548115491155011551115521155311554115551155611557115581155911560115611156211563115641156511566115671156811569115701157111572115731157411575115761157711578115791158011581115821158311584115851158611587115881158911590115911159211593115941159511596115971159811599116001160111602116031160411605116061160711608116091161011611116121161311614116151161611617116181161911620116211162211623116241162511626116271162811629116301163111632116331163411635116361163711638116391164011641116421164311644116451164611647116481164911650116511165211653116541165511656116571165811659116601166111662116631166411665116661166711668116691167011671116721167311674116751167611677116781167911680116811168211683116841168511686116871168811689116901169111692116931169411695116961169711698116991170011701117021170311704117051170611707117081170911710117111171211713117141171511716117171171811719117201172111722117231172411725117261172711728117291173011731117321173311734117351173611737117381173911740117411174211743117441174511746117471174811749117501175111752117531175411755117561175711758117591176011761117621176311764117651176611767117681176911770117711177211773117741177511776117771177811779117801178111782117831178411785117861178711788117891179011791117921179311794117951179611797117981179911800118011180211803118041180511806118071180811809118101181111812118131181411815118161181711818118191182011821118221182311824118251182611827118281182911830118311183211833118341183511836118371183811839118401184111842118431184411845118461184711848118491185011851118521185311854118551185611857118581185911860118611186211863118641186511866118671186811869118701187111872118731187411875118761187711878118791188011881118821188311884118851188611887118881188911890118911189211893118941189511896118971189811899119001190111902119031190411905119061190711908119091191011911119121191311914119151191611917119181191911920119211192211923119241192511926119271192811929119301193111932119331193411935119361193711938119391194011941119421194311944119451194611947119481194911950119511195211953119541195511956119571195811959119601196111962119631196411965119661196711968119691197011971119721197311974119751197611977119781197911980119811198211983119841198511986119871198811989119901199111992119931199411995119961199711998119991200012001120021200312004120051200612007120081200912010120111201212013120141201512016120171201812019120201202112022120231202412025120261202712028120291203012031120321203312034120351203612037120381203912040120411204212043120441204512046120471204812049120501205112052120531205412055120561205712058120591206012061120621206312064120651206612067120681206912070120711207212073120741207512076120771207812079120801208112082120831208412085120861208712088120891209012091120921209312094120951209612097120981209912100121011210212103121041210512106121071210812109121101211112112121131211412115121161211712118121191212012121121221212312124121251212612127121281212912130121311213212133121341213512136121371213812139121401214112142121431214412145121461214712148121491215012151121521215312154121551215612157121581215912160121611216212163121641216512166121671216812169121701217112172121731217412175121761217712178121791218012181121821218312184121851218612187121881218912190121911219212193121941219512196121971219812199122001220112202122031220412205122061220712208122091221012211122121221312214122151221612217122181221912220122211222212223122241222512226122271222812229122301223112232122331223412235122361223712238122391224012241122421224312244122451224612247122481224912250122511225212253122541225512256122571225812259122601226112262122631226412265122661226712268122691227012271122721227312274
  1. package sg
  2. import (
  3. "archive/zip"
  4. "bytes"
  5. "encoding/json"
  6. "fmt"
  7. "gdyb/controllers"
  8. "gdyb/enums"
  9. "gdyb/models"
  10. "gdyb/service"
  11. "gdyb/utils"
  12. "github.com/astaxie/beego"
  13. "github.com/axgle/mahonia"
  14. "github.com/jinzhu/gorm"
  15. "github.com/shopspring/decimal"
  16. "io"
  17. "io/ioutil"
  18. "math/rand"
  19. "net/http"
  20. "os"
  21. "path/filepath"
  22. "strconv"
  23. "strings"
  24. "syscall"
  25. "time"
  26. "unsafe"
  27. )
  28. type HisApiController struct {
  29. controllers.BaseAuthAPIController
  30. }
  31. func HisManagerApiRegistRouters() {
  32. //挂号
  33. beego.Router("/api/register/get", &HisApiController{}, "get:GetRegisterInfo")
  34. //上传就诊信息-上传明细-结算
  35. beego.Router("/api/upload/get", &HisApiController{}, "get:GetUploadInfo")
  36. //查询
  37. beego.Router("/api/settle/query", &HisApiController{}, "get:GetSettleAccounts")
  38. //对总账
  39. beego.Router("/api/checkaccount/get", &HisApiController{}, "get:GetCheckAccount")
  40. //对明细
  41. beego.Router("/api/checkdetailaccount/get", &HisApiController{}, "get:GetCheckDetailAccount")
  42. //退费,退明细
  43. beego.Router("/api/refund/post", &HisApiController{}, "get:Refund")
  44. //退号
  45. beego.Router("/api/refundnumber/post", &HisApiController{}, "get:RefundNumber")
  46. //退明细
  47. beego.Router("/api/refunddetail/post", &HisApiController{}, "get:RefundDetail")
  48. beego.Router("/api/treatment/check", &HisApiController{}, "get:CheckTreatment")
  49. beego.Router("/api/org/info", &HisApiController{}, "get:GetOrgInfo")
  50. beego.Router("/api/readcard", &HisApiController{}, "get:ReadCard")
  51. beego.Router("/api/presettle/get", &HisApiController{}, "get:GetPreUploadInfo")
  52. beego.Router("/api/310", &HisApiController{}, "get:Check310")
  53. beego.Router("/api/390", &HisApiController{}, "get:Check390")
  54. beego.Router("/api/patient/info", &HisApiController{}, "get:GetPatientInfo")
  55. beego.Router("/api/checkcode/get", &HisApiController{}, "get:GetCheckCode")
  56. beego.Router("/api/uncheckcode/get", &HisApiController{}, "get:UnCheckCode")
  57. beego.Router("/api/psn/putonrecord", &HisApiController{}, "get:PsnPutOnRecord")
  58. beego.Router("/api/psn/unputonrecord", &HisApiController{}, "get:PsnUnPutOnRecord")
  59. beego.Router("/api/psn/ncds/putonrecord", &HisApiController{}, "get:PsnPutNCDSOnRecord")
  60. beego.Router("/api/psn/ncds/unputonrecord", &HisApiController{}, "get:PsnPutUnNCDSOnRecord")
  61. beego.Router("/api/reversal", &HisApiController{}, "get:ReversalData")
  62. beego.Router("/api/reversal/other", &HisApiController{}, "get:ReversalOtherData")
  63. beego.Router("/api/settlelist/get", &HisApiController{}, "get:GetSettleList")
  64. beego.Router("/api/settlelisthosptial/get", &HisApiController{}, "get:GetSettleListHospital")
  65. beego.Router("/api/pwd/check", &HisApiController{}, "get:CheckCardPWD")
  66. beego.Router("/api/insutype/check", &HisApiController{}, "get:CheckInsutype")
  67. beego.Router("/api/batchsettlelist/get", &HisApiController{}, "get:GetBatchSettleList")
  68. beego.Router("/api/psn/info", &HisApiController{}, "get:GetPsnNcdsInfo")
  69. //beego.Router("/api/allopatry/get", &HisApiController{}, "get:GetAllopatry")
  70. //beego.Router("/api/comfirmallopatry/post", &HisApiController{}, "post:ComfirmAllopatry")
  71. beego.Router("/api/allopatry/refund", &HisApiController{}, "post:RefundAllopatry")
  72. beego.Router("/api/check", &HisApiController{}, "get:Check")
  73. beego.Router("/api/check3101", &HisApiController{}, "get:Check3101")
  74. beego.Router("/api/check3102", &HisApiController{}, "get:Check3102")
  75. 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. result, _ := service.Gdyb9001(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, 1669)
  84. var dat map[string]interface{}
  85. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  86. fmt.Println(dat)
  87. } else {
  88. fmt.Println(err)
  89. }
  90. userJSONBytes, _ := json.Marshal(dat)
  91. var res models.Result9001
  92. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  93. utils.ErrorLog("解析失败:%v", err)
  94. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  95. return
  96. }
  97. }
  98. func (c *HisApiController) Check3101() {
  99. patient_id, _ := c.GetInt64("patient_id")
  100. his_patient_id, _ := c.GetInt64("his_patient_id")
  101. admin_user_id, _ := c.GetInt64("admin_user_id")
  102. adminUser := c.GetAdminUserInfo()
  103. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  104. his, _ := service.GetNewHisPatientInfoFour(c.GetAdminUserInfo().CurrentOrgId, his_patient_id)
  105. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  106. record_time := c.GetString("record_time")
  107. trig_scen := c.GetString("trig_scen")
  108. timeLayout := "2006-01-02"
  109. loc, _ := time.LoadLocation("Local")
  110. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  111. if err != nil {
  112. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  113. return
  114. }
  115. recordDateTime := theTime.Unix()
  116. var patientPrescription models.HisPrescriptionInfo
  117. patientPrescription, _ = service.FindHisPatientPrescriptionInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  118. if patientPrescription.ID == 0 {
  119. patientPrescription, _ = service.FindLastPatientPrescriptionInfo(adminUser.CurrentOrgId, patient_id, recordDateTime)
  120. }
  121. department, _ := service.GetDepartMentDetail(patientPrescription.Departments)
  122. doctor_info, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, patientPrescription.DoctorId)
  123. //
  124. diagnosis_ids := strings.Split(patientPrescription.Diagnosis, ",")
  125. prescriptions, _ := service.GetNewHisPrescriptionTen(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  126. var pp models.PublicParams
  127. pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  128. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  129. pp.FixmedinsName = miConfig.OrgName
  130. pp.FixmedinsCode = miConfig.Code
  131. pp.RequestUrl = miConfig.Url
  132. pp.Cainfo = miConfig.Cainfo
  133. pp.SecretKey = miConfig.SecretKey
  134. pp.AccessKey = miConfig.AccessKey
  135. pp.OpterName = roles.UserName
  136. var config []*models.HisXtDiagnoseConfig
  137. for _, item := range diagnosis_ids {
  138. id, _ := strconv.ParseInt(item, 10, 64)
  139. diagnosisConfig, _ := service.FindDiagnoseById(id)
  140. config = append(config, &diagnosisConfig)
  141. }
  142. var pd models.PatientDtos
  143. pd.PatnID = his.PsnNo
  144. pd.PatnName = his.Name
  145. pd.Gend = his.Gend
  146. pd.Brdy = his.Brdy
  147. pd.Poolarea = his.InsuplcAdmdvs
  148. pd.CurrMdtrtID = his.Number
  149. var fed models.FsiEncounterDtos
  150. fed.MdtrtID = his.Number
  151. fed.MedinsID = miConfig.Code
  152. fed.MedinsName = miConfig.OrgName
  153. fed.MedinsAdmdvs = miConfig.MdtrtareaAdmvs
  154. fed.MedMdtrtType = "1"
  155. fed.MedinsType = "1"
  156. fed.MedinsLv = "11"
  157. tm := time.Unix(his.RecordDate, 0)
  158. s_tm := tm.Format("2006-01-02 15:04:05")
  159. fed.AdmDate = s_tm
  160. fed.DscgDate = s_tm
  161. fed.DscgMainDiseCodg = config[0].CountryCode
  162. fed.DscgMainDiseName = config[0].CountryContentName
  163. //诊断信息
  164. var fdds []*models.FsiDiagnoseDtos
  165. for index, item := range config {
  166. if index == 0 {
  167. var fdd models.FsiDiagnoseDtos
  168. fdd.DiseID = strconv.FormatInt(item.ID, 10)
  169. fdd.InoutDiseType = "1"
  170. fdd.MaindiseFlag = "1"
  171. fdd.DiseDate = s_tm
  172. fdd.DiasSrtNo = "1"
  173. fdd.DiseName = item.CountryContentName
  174. fdd.DiseCodg = item.CountryCode
  175. fdds = append(fdds, &fdd)
  176. } else {
  177. var fdd models.FsiDiagnoseDtos
  178. fdd.DiseID = strconv.FormatInt(item.ID, 10)
  179. fdd.InoutDiseType = "1"
  180. fdd.MaindiseFlag = "1"
  181. fdd.DiseDate = s_tm
  182. fdd.DiasSrtNo = strconv.FormatInt(int64(index), 10)
  183. fdd.DiseName = item.CountryContentName
  184. fdd.DiseCodg = item.CountryCode
  185. fdds = append(fdds, &fdd)
  186. }
  187. }
  188. fed.DrCodg = strconv.FormatInt(doctor_info.ID, 10)
  189. fed.AdmDeptCodg = strconv.FormatInt(department.ID, 10)
  190. fed.AdmDeptName = department.Name
  191. fed.DscgDeptCodg = strconv.FormatInt(department.ID, 10)
  192. fed.DscgDeptName = department.Name
  193. fed.MedMdtrtType = "1"
  194. fed.MedType = "11"
  195. //if his.Insutype == "390" {
  196. // fed.MedType = "1402"
  197. //} else {
  198. // fed.MedType = "9933"
  199. //}
  200. var orders []*models.FsiOrderDtos
  201. if trig_scen == "2" {
  202. //处方医嘱信息
  203. for _, item := range prescriptions {
  204. for _, subItem := range item.HisDoctorAdviceInfo {
  205. var order models.FsiOrderDtos
  206. order.RxID = strconv.FormatInt(item.ID, 10)
  207. order.Rxno = strconv.FormatInt(item.ID, 10)
  208. order.LongDrordFlag = "0"
  209. order.HilistType = "1"
  210. order.ChrgType = "1"
  211. order.DrordBhvr = "-"
  212. order.HilistCode = subItem.BaseDrugLib.MedicalInsuranceNumber
  213. order.HosplistName = subItem.BaseDrugLib.DrugName
  214. order.HilistLv = "1"
  215. order.HilistPric = fmt.Sprintf("%.2f", subItem.Price)
  216. order.HosplistCode = subItem.BaseDrugLib.MedicalInsuranceNumber
  217. order.HosplistName = subItem.BaseDrugLib.DrugName
  218. order.Cnt = fmt.Sprintf("%.2f", subItem.PrescribingNumber)
  219. order.Pric = fmt.Sprintf("%.2f", subItem.Price)
  220. order.Sumamt = fmt.Sprintf("%.2f", (subItem.PrescribingNumber * subItem.Price))
  221. order.OwnpayAmt = ""
  222. order.SelfpayAmt = ""
  223. order.Spec = ""
  224. order.SpecUnt = ""
  225. order.DrordBegnDate = s_tm
  226. order.DrordStopDate = ""
  227. order.DrordDrCodg = "1"
  228. order.DrordDeptName = department.Name
  229. order.DrordDrCodg = "1"
  230. order.DrordDrName = doctor_info.UserName
  231. order.DrordDrProfttl = ""
  232. order.CurrDrordFlag = "1"
  233. orders = append(orders, &order)
  234. }
  235. for _, subItem := range item.HisPrescriptionProject {
  236. if subItem.Type == 2 {
  237. var order models.FsiOrderDtos
  238. order.RxID = strconv.FormatInt(item.ID, 10)
  239. order.Rxno = strconv.FormatInt(item.ID, 10)
  240. order.LongDrordFlag = "0"
  241. order.HilistType = "1"
  242. order.ChrgType = "1"
  243. order.DrordBhvr = "-"
  244. order.HilistCode = subItem.HisProject.MedicalCode
  245. order.HosplistName = subItem.HisProject.ProjectName
  246. order.HilistLv = "1"
  247. order.HilistPric = fmt.Sprintf("%.2f", subItem.Price)
  248. order.HosplistCode = subItem.HisProject.MedicalCode
  249. order.HosplistName = subItem.HisProject.ProjectName
  250. order.Cnt = subItem.Count
  251. cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  252. order.Pric = fmt.Sprintf("%.2f", subItem.Price)
  253. order.Sumamt = fmt.Sprintf("%.2f", subItem.Price*cnt)
  254. order.OwnpayAmt = ""
  255. order.SelfpayAmt = ""
  256. order.Spec = ""
  257. order.SpecUnt = ""
  258. order.DrordBegnDate = s_tm
  259. order.DrordStopDate = ""
  260. order.DrordDrCodg = "1"
  261. order.DrordDeptName = department.Name
  262. order.DrordDrCodg = "1"
  263. order.DrordDrName = doctor_info.UserName
  264. order.DrordDrProfttl = ""
  265. order.CurrDrordFlag = "1"
  266. orders = append(orders, &order)
  267. }
  268. if subItem.Type == 3 {
  269. var order models.FsiOrderDtos
  270. order.RxID = strconv.FormatInt(item.ID, 10)
  271. order.Rxno = strconv.FormatInt(item.ID, 10)
  272. order.LongDrordFlag = "0"
  273. order.HilistType = "1"
  274. order.ChrgType = "1"
  275. order.DrordBhvr = "-"
  276. order.HilistCode = subItem.GoodInfo.MedicalInsuranceNumber
  277. order.HosplistName = subItem.GoodInfo.GoodName
  278. order.HilistLv = "1"
  279. order.HilistPric = fmt.Sprintf("%.2f", subItem.Price)
  280. order.HosplistCode = subItem.GoodInfo.MedicalInsuranceNumber
  281. order.HosplistName = subItem.GoodInfo.GoodName
  282. order.Cnt = subItem.Count
  283. cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  284. order.Pric = fmt.Sprintf("%.2f", subItem.Price)
  285. order.Sumamt = fmt.Sprintf("%.2f", subItem.Price*cnt)
  286. order.OwnpayAmt = ""
  287. order.SelfpayAmt = ""
  288. order.Spec = ""
  289. order.SpecUnt = ""
  290. order.DrordBegnDate = s_tm
  291. order.DrordStopDate = ""
  292. order.DrordDrCodg = "1"
  293. order.DrordDeptName = department.Name
  294. order.DrordDrCodg = "1"
  295. order.DrordDrName = doctor_info.UserName
  296. order.DrordDrProfttl = ""
  297. order.CurrDrordFlag = "1"
  298. orders = append(orders, &order)
  299. }
  300. }
  301. }
  302. //处方医嘱信息
  303. }
  304. fed.MatnStas = "0"
  305. fed.MedfeeSumamt = "0"
  306. fed.OwnpayAmt = "0"
  307. fed.SelfpayAmt = "0"
  308. fed.AcctPayamt = "0"
  309. fed.MaAmt = "0"
  310. fed.HifpPayamt = "0"
  311. fed.SetlTotlnum = "1"
  312. fed.Insutype = his.Insutype
  313. fed.ReimFlag = "0"
  314. fed.OutSetlFlag = "0"
  315. var fopd []*models.FsiOperationDtosData
  316. data := make(map[string]interface{})
  317. data["fed"] = fed
  318. data["fdd"] = fdds
  319. data["fod"] = orders
  320. data["pd"] = pd
  321. data["pp"] = pp
  322. data["fopd"] = fopd
  323. data["trig_scen"] = trig_scen
  324. fmt.Println(data)
  325. fmt.Println(fed)
  326. fmt.Println(fdds)
  327. fmt.Println(orders)
  328. fmt.Println(pd)
  329. fmt.Println(pp)
  330. fmt.Println(fopd)
  331. client := &http.Client{}
  332. bytesData, _ := json.Marshal(data)
  333. var req *http.Request
  334. if miConfig.MdtrtareaAdmvs == "320921" {
  335. req, _ = http.NewRequest("POST", "http://192.168.3.111:9532/"+"jsyb/3101", bytes.NewReader(bytesData))
  336. } else {
  337. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3101", bytes.NewReader(bytesData))
  338. }
  339. resp, _ := client.Do(req)
  340. defer resp.Body.Close()
  341. body, ioErr := ioutil.ReadAll(resp.Body)
  342. if ioErr != nil {
  343. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  344. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  345. return
  346. }
  347. var respJSON map[string]interface{}
  348. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  349. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  350. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  351. return
  352. }
  353. //手术操作集合
  354. //手术操作集合
  355. }
  356. func (c *HisApiController) Check3102() {
  357. patient_id, _ := c.GetInt64("patient_id")
  358. order_id, _ := c.GetInt64("order_id")
  359. his_patient_id, _ := c.GetInt64("his_patient_id")
  360. admin_user_id, _ := c.GetInt64("admin_user_id")
  361. trig_scen := c.GetString("trig_scen")
  362. adminUser := c.GetAdminUserInfo()
  363. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  364. his, _ := service.GetNewHisPatientInfoFour(c.GetAdminUserInfo().CurrentOrgId, his_patient_id)
  365. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  366. record_time := c.GetString("record_time")
  367. order, _ := service.GetHisOrderByID(order_id)
  368. timeLayout := "2006-01-02"
  369. loc, _ := time.LoadLocation("Local")
  370. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  371. if err != nil {
  372. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  373. return
  374. }
  375. recordDateTime := theTime.Unix()
  376. var patientPrescription models.HisPrescriptionInfo
  377. patientPrescription, _ = service.FindHisPatientPrescriptionInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  378. if patientPrescription.ID == 0 {
  379. patientPrescription, _ = service.FindLastPatientPrescriptionInfo(adminUser.CurrentOrgId, patient_id, recordDateTime)
  380. }
  381. department, _ := service.GetDepartMentDetail(patientPrescription.Departments)
  382. doctor_info, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, patientPrescription.DoctorId)
  383. //
  384. diagnosis_ids := strings.Split(his.Diagnosis, ",")
  385. prescriptions, _ := service.GetNewHisPrescriptionTen(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  386. var pp models.PublicParams
  387. pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  388. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  389. pp.FixmedinsName = miConfig.OrgName
  390. pp.FixmedinsCode = miConfig.Code
  391. pp.RequestUrl = miConfig.Url
  392. pp.Cainfo = miConfig.Cainfo
  393. pp.SecretKey = miConfig.SecretKey
  394. pp.AccessKey = miConfig.AccessKey
  395. pp.OpterName = roles.UserName
  396. var config []*models.HisXtDiagnoseConfig
  397. for _, item := range diagnosis_ids {
  398. id, _ := strconv.ParseInt(item, 10, 64)
  399. diagnosisConfig, _ := service.FindDiagnoseById(id)
  400. config = append(config, &diagnosisConfig)
  401. }
  402. var pd models.PatientDtos
  403. pd.PatnID = his.PsnNo
  404. pd.PatnName = his.Name
  405. pd.Gend = his.Gend
  406. pd.Brdy = his.Brdy
  407. pd.Poolarea = his.InsuplcAdmdvs
  408. pd.CurrMdtrtID = his.Number
  409. var fed models.FsiEncounterDtos
  410. fed.MdtrtID = his.Number
  411. fed.MedinsID = miConfig.Code
  412. fed.MedinsName = miConfig.OrgName
  413. fed.MedinsAdmdvs = miConfig.MdtrtareaAdmvs
  414. fed.MedMdtrtType = "1"
  415. fed.MedinsType = "1"
  416. fed.MedinsLv = "11"
  417. tm := time.Unix(his.RecordDate, 0)
  418. s_tm := tm.Format("2006-01-02 15:04:05")
  419. fed.AdmDate = s_tm
  420. fed.DscgDate = s_tm
  421. fed.DscgMainDiseCodg = config[0].CountryCode
  422. fed.DscgMainDiseName = config[0].CountryContentName
  423. //诊断信息
  424. var fdds []*models.FsiDiagnoseDtos
  425. for index, item := range config {
  426. if index == 0 {
  427. var fdd models.FsiDiagnoseDtos
  428. fdd.DiseID = strconv.FormatInt(item.ID, 10)
  429. fdd.InoutDiseType = "1"
  430. fdd.MaindiseFlag = "1"
  431. fdd.DiseDate = s_tm
  432. fdd.DiasSrtNo = "1"
  433. fdd.DiseName = item.CountryContentName
  434. fdd.DiseCodg = item.CountryCode
  435. fdds = append(fdds, &fdd)
  436. } else {
  437. var fdd models.FsiDiagnoseDtos
  438. fdd.DiseID = strconv.FormatInt(item.ID, 10)
  439. fdd.InoutDiseType = "1"
  440. fdd.MaindiseFlag = "1"
  441. fdd.DiseDate = s_tm
  442. fdd.DiasSrtNo = strconv.FormatInt(int64(index), 10)
  443. fdd.DiseName = item.CountryContentName
  444. fdd.DiseCodg = item.CountryCode
  445. fdds = append(fdds, &fdd)
  446. }
  447. }
  448. fed.DrCodg = strconv.FormatInt(doctor_info.ID, 10)
  449. fed.AdmDeptCodg = strconv.FormatInt(department.ID, 10)
  450. fed.AdmDeptName = department.Name
  451. fed.DscgDeptCodg = strconv.FormatInt(department.ID, 10)
  452. fed.DscgDeptName = department.Name
  453. fed.MedType = order.MedType
  454. //处方医嘱信息
  455. var orders []*models.FsiOrderDtos
  456. //for _, item := range prescriptions {
  457. // for _, subItem := range item.HisDoctorAdviceInfo {
  458. // var order models.FsiOrderDtos
  459. // order.RxID = strconv.FormatInt(item.ID, 10)
  460. // order.Rxno = strconv.FormatInt(item.ID, 10)
  461. // order.LongDrordFlag = "0"
  462. // order.HilistType = "1"
  463. // order.ChrgType = "1"
  464. // order.DrordBhvr = "-"
  465. // order.HilistCode = subItem.BaseDrugLib.MedicalInsuranceNumber
  466. // order.HosplistName = subItem.BaseDrugLib.DrugName
  467. // order.HilistLv = "1"
  468. // order.HilistPric = strconv.FormatFloat(subItem.Price, 'E', -1, 64)
  469. // order.HosplistCode = subItem.BaseDrugLib.MedicalInsuranceNumber
  470. // order.HosplistName = subItem.BaseDrugLib.DrugName
  471. // order.Cnt = strconv.FormatFloat(subItem.PrescribingNumber, 'E', -1, 64)
  472. // order.Pric = strconv.FormatFloat(subItem.Price, 'E', -1, 64)
  473. // order.Sumamt = strconv.FormatFloat((subItem.Price * subItem.PrescribingNumber), 'E', -1, 64)
  474. // order.OwnpayAmt = ""
  475. // order.SelfpayAmt = ""
  476. // order.Spec = ""
  477. // order.SpecUnt = ""
  478. // order.DrordBegnDate = s_tm
  479. // order.DrordStopDate = ""
  480. // order.DrordDrCodg = "1"
  481. // order.DrordDeptName = department.Name
  482. // order.DrordDrCodg = "1"
  483. // order.DrordDrName = doctor_info.UserName
  484. // order.DrordDrProfttl = ""
  485. // order.CurrDrordFlag = "1"
  486. // orders = append(orders, &order)
  487. // }
  488. // for _, subItem := range item.HisPrescriptionProject {
  489. // if subItem.Type == 2 {
  490. // var order models.FsiOrderDtos
  491. // order.RxID = strconv.FormatInt(item.ID, 10)
  492. // order.Rxno = strconv.FormatInt(item.ID, 10)
  493. // order.LongDrordFlag = "0"
  494. // order.HilistType = "1"
  495. // order.ChrgType = "1"
  496. // order.DrordBhvr = "-"
  497. // order.HilistCode = subItem.HisProject.MedicalCode
  498. // order.HosplistName = subItem.HisProject.ProjectName
  499. // order.HilistLv = "1"
  500. // order.HilistPric = strconv.FormatFloat(subItem.Price, 'E', -1, 64)
  501. // order.HosplistCode = subItem.HisProject.MedicalCode
  502. // order.HosplistName = subItem.HisProject.ProjectName
  503. // order.Cnt = subItem.Count
  504. // cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  505. //
  506. // order.Pric = strconv.FormatFloat(subItem.Price, 'E', -1, 64)
  507. // order.Sumamt = strconv.FormatFloat((subItem.Price * cnt), 'E', -1, 64)
  508. // order.OwnpayAmt = ""
  509. // order.SelfpayAmt = ""
  510. // order.Spec = ""
  511. // order.SpecUnt = ""
  512. // order.DrordBegnDate = s_tm
  513. // order.DrordStopDate = ""
  514. // order.DrordDrCodg = "1"
  515. // order.DrordDeptName = department.Name
  516. // order.DrordDrCodg = "1"
  517. // order.DrordDrName = doctor_info.UserName
  518. // order.DrordDrProfttl = ""
  519. // order.CurrDrordFlag = "1"
  520. // orders = append(orders, &order)
  521. //
  522. // }
  523. // if subItem.Type == 3 {
  524. //
  525. // var order models.FsiOrderDtos
  526. // order.RxID = strconv.FormatInt(item.ID, 10)
  527. // order.Rxno = strconv.FormatInt(item.ID, 10)
  528. // order.LongDrordFlag = "0"
  529. // order.HilistType = "1"
  530. // order.ChrgType = "1"
  531. // order.DrordBhvr = "-"
  532. // order.HilistCode = subItem.GoodInfo.MedicalInsuranceNumber
  533. // order.HosplistName = subItem.GoodInfo.GoodName
  534. // order.HilistLv = "1"
  535. // order.HilistPric = strconv.FormatFloat(subItem.Price, 'E', -1, 64)
  536. // order.HosplistCode = subItem.GoodInfo.MedicalInsuranceNumber
  537. // order.HosplistName = subItem.GoodInfo.GoodName
  538. // order.Cnt = subItem.Count
  539. // cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  540. // order.Pric = strconv.FormatFloat(subItem.Price, 'E', -1, 64)
  541. // order.Sumamt = strconv.FormatFloat((subItem.Price * cnt), 'E', -1, 64)
  542. // order.OwnpayAmt = ""
  543. // order.SelfpayAmt = ""
  544. // order.Spec = ""
  545. // order.SpecUnt = ""
  546. // order.DrordBegnDate = s_tm
  547. // order.DrordStopDate = ""
  548. // order.DrordDrCodg = "1"
  549. // order.DrordDeptName = department.Name
  550. // order.DrordDrCodg = "1"
  551. // order.DrordDrName = doctor_info.UserName
  552. // order.DrordDrProfttl = ""
  553. // order.CurrDrordFlag = "1"
  554. // orders = append(orders, &order)
  555. //
  556. // }
  557. // }
  558. //}
  559. for _, item := range prescriptions {
  560. for _, subItem := range item.HisDoctorAdviceInfo {
  561. var order models.FsiOrderDtos
  562. order.RxID = strconv.FormatInt(item.ID, 10)
  563. order.Rxno = strconv.FormatInt(item.ID, 10)
  564. order.LongDrordFlag = "0"
  565. order.HilistType = "1"
  566. order.ChrgType = "1"
  567. order.DrordBhvr = "-"
  568. order.HilistCode = subItem.BaseDrugLib.MedicalInsuranceNumber
  569. order.HosplistName = subItem.BaseDrugLib.DrugName
  570. order.HilistLv = "1"
  571. order.HilistPric = fmt.Sprintf("%.2f", subItem.Price)
  572. order.HosplistCode = subItem.BaseDrugLib.MedicalInsuranceNumber
  573. order.HosplistName = subItem.BaseDrugLib.DrugName
  574. order.Cnt = fmt.Sprintf("%.2f", subItem.PrescribingNumber)
  575. order.Pric = fmt.Sprintf("%.2f", subItem.Price)
  576. order.Sumamt = fmt.Sprintf("%.2f", (subItem.PrescribingNumber * subItem.Price))
  577. order.OwnpayAmt = ""
  578. order.SelfpayAmt = ""
  579. order.Spec = ""
  580. order.SpecUnt = ""
  581. order.DrordBegnDate = s_tm
  582. order.DrordStopDate = ""
  583. order.DrordDrCodg = "1"
  584. order.DrordDeptName = department.Name
  585. order.DrordDrCodg = "1"
  586. order.DrordDrName = doctor_info.UserName
  587. order.DrordDrProfttl = ""
  588. order.CurrDrordFlag = "1"
  589. orders = append(orders, &order)
  590. }
  591. for _, subItem := range item.HisPrescriptionProject {
  592. if subItem.Type == 2 {
  593. var order models.FsiOrderDtos
  594. order.RxID = strconv.FormatInt(item.ID, 10)
  595. order.Rxno = strconv.FormatInt(item.ID, 10)
  596. order.LongDrordFlag = "0"
  597. order.HilistType = "1"
  598. order.ChrgType = "1"
  599. order.DrordBhvr = "-"
  600. order.HilistCode = subItem.HisProject.MedicalCode
  601. order.HosplistName = subItem.HisProject.ProjectName
  602. order.HilistLv = "1"
  603. order.HilistPric = fmt.Sprintf("%.2f", subItem.Price)
  604. order.HosplistCode = subItem.HisProject.MedicalCode
  605. order.HosplistName = subItem.HisProject.ProjectName
  606. order.Cnt = subItem.Count
  607. cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  608. order.Pric = fmt.Sprintf("%.2f", subItem.Price)
  609. order.Sumamt = fmt.Sprintf("%.2f", subItem.Price*cnt)
  610. order.OwnpayAmt = ""
  611. order.SelfpayAmt = ""
  612. order.Spec = ""
  613. order.SpecUnt = ""
  614. order.DrordBegnDate = s_tm
  615. order.DrordStopDate = ""
  616. order.DrordDrCodg = "1"
  617. order.DrordDeptName = department.Name
  618. order.DrordDrCodg = "1"
  619. order.DrordDrName = doctor_info.UserName
  620. order.DrordDrProfttl = ""
  621. order.CurrDrordFlag = "1"
  622. orders = append(orders, &order)
  623. }
  624. if subItem.Type == 3 {
  625. var order models.FsiOrderDtos
  626. order.RxID = strconv.FormatInt(item.ID, 10)
  627. order.Rxno = strconv.FormatInt(item.ID, 10)
  628. order.LongDrordFlag = "0"
  629. order.HilistType = "1"
  630. order.ChrgType = "1"
  631. order.DrordBhvr = "-"
  632. order.HilistCode = subItem.GoodInfo.MedicalInsuranceNumber
  633. order.HosplistName = subItem.GoodInfo.GoodName
  634. order.HilistLv = "1"
  635. order.HilistPric = fmt.Sprintf("%.2f", subItem.Price)
  636. order.HosplistCode = subItem.GoodInfo.MedicalInsuranceNumber
  637. order.HosplistName = subItem.GoodInfo.GoodName
  638. order.Cnt = subItem.Count
  639. cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  640. order.Pric = fmt.Sprintf("%.2f", subItem.Price)
  641. order.Sumamt = fmt.Sprintf("%.2f", subItem.Price*cnt)
  642. order.OwnpayAmt = ""
  643. order.SelfpayAmt = ""
  644. order.Spec = ""
  645. order.SpecUnt = ""
  646. order.DrordBegnDate = s_tm
  647. order.DrordStopDate = ""
  648. order.DrordDrCodg = "1"
  649. order.DrordDeptName = department.Name
  650. order.DrordDrCodg = "1"
  651. order.DrordDrName = doctor_info.UserName
  652. order.DrordDrProfttl = ""
  653. order.CurrDrordFlag = "1"
  654. orders = append(orders, &order)
  655. }
  656. }
  657. }
  658. //处方医嘱信息
  659. fed.MatnStas = "0"
  660. fed.MedfeeSumamt = fmt.Sprintf("%.2f", order.MedfeeSumamt)
  661. fed.OwnpayAmt = fmt.Sprintf("%.2f", order.FulamtOwnpayAmt)
  662. fed.SelfpayAmt = fmt.Sprintf("%.2f", order.PreselfpayAmt)
  663. fed.AcctPayamt = fmt.Sprintf("%.2f", order.AcctPay)
  664. fed.MaAmt = fmt.Sprintf("%.2f", order.MafPay)
  665. fed.HifpPayamt = fmt.Sprintf("%.2f", order.HifpPay)
  666. fed.SetlTotlnum = "1"
  667. fed.Insutype = his.Insutype
  668. fed.ReimFlag = "0"
  669. fed.OutSetlFlag = "0"
  670. var fopd []*models.FsiOperationDtosData
  671. data := make(map[string]interface{})
  672. data["fed"] = fed
  673. data["fdd"] = fdds
  674. data["fod"] = orders
  675. data["pd"] = pd
  676. data["pp"] = pp
  677. data["fopd"] = fopd
  678. data["trig_scen"] = trig_scen
  679. client := &http.Client{}
  680. bytesData, _ := json.Marshal(data)
  681. var req *http.Request
  682. if miConfig.MdtrtareaAdmvs == "320921" {
  683. req, _ = http.NewRequest("POST", "http://192.168.3.111:9532/"+"jsyb/3102", bytes.NewReader(bytesData))
  684. } else {
  685. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3102", bytes.NewReader(bytesData))
  686. }
  687. resp, _ := client.Do(req)
  688. defer resp.Body.Close()
  689. body, ioErr := ioutil.ReadAll(resp.Body)
  690. if ioErr != nil {
  691. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  692. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  693. return
  694. }
  695. var respJSON map[string]interface{}
  696. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  697. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  698. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  699. return
  700. }
  701. //手术操作集合
  702. //手术操作集合
  703. }
  704. func (c *HisApiController) Check() {
  705. psn_no := c.GetString("psn_no")
  706. in := c.GetString("in")
  707. mt := c.GetString("mt")
  708. baseParams := models.BaseParams{
  709. SecretKey: "MSDBYGxXm1Mtyi3PtOUB7n1ktcxwyW57",
  710. FixmedinsCode: "H15049901371",
  711. InsuplcAdmdvs: "150499",
  712. MdtrtareaAdmvs: "150499",
  713. OrgName: "赤峰费森血液透析中心",
  714. Doctor: "1111",
  715. }
  716. service.Gdyb2001(baseParams, psn_no, in, mt)
  717. }
  718. func (c *HisApiController) GetPsnNcdsInfo() {
  719. admin_user_id, _ := c.GetInt64("admin_user_id")
  720. patient_id, _ := c.GetInt64("patient_id")
  721. id, _ := c.GetInt64("id")
  722. adminUser := c.GetAdminUserInfo()
  723. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  724. //config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  725. //patient, _ := service.GetPatientByID(c.GetAdminUserInfo().CurrentOrgId, id)
  726. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  727. psn_record, _ := service.GetPsnNCDSRecordById(id)
  728. //
  729. //if psn_record.ID == 0 {
  730. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorPsnRecordNoExistWrong)
  731. // return
  732. //}
  733. var res Result5301
  734. var res10265 Result5301For10265
  735. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  736. psn_info, _ := service.GetPsnByPatientId(patient_id)
  737. var api string
  738. if miConfig.MdtrtareaAdmvs == "320921" {
  739. api = "http://192.168.3.111:9532/" + "jsyb/5301?" + "fixmedins_code=" + miConfig.Code + "&secret_key=" + miConfig.SecretKey + "&ak=" + miConfig.AccessKey + "&org_name=" + miConfig.OrgName + "&doctor=" + role.UserName +
  740. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&psn_no=" + psn_info.PsnNo + "&cainfo=" + miConfig.Cainfo
  741. } else {
  742. 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 +
  743. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&psn_no=" + psn_info.PsnNo + "&cainfo=" + miConfig.Cainfo
  744. }
  745. resp, requestErr := http.Get(api)
  746. if requestErr != nil {
  747. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  748. return
  749. }
  750. body, ioErr := ioutil.ReadAll(resp.Body)
  751. if ioErr != nil {
  752. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  753. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  754. return
  755. }
  756. var respJSON map[string]interface{}
  757. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  758. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  759. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  760. return
  761. }
  762. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  763. result, _ := json.Marshal(respJSON)
  764. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  765. utils.ErrorLog("解析失败:%v", err)
  766. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  767. return
  768. }
  769. res.ErrMsg = res10265.ErrMsg
  770. res.Output = res10265.Output
  771. res.InfRefmsgid = res10265.InfRefmsgid
  772. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  773. res.Infcode = infocode
  774. } else {
  775. result := service.Gdyb5301(psn_record.PsnNo, miConfig.OrgName, role.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey)
  776. var dat map[string]interface{}
  777. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  778. fmt.Println(dat)
  779. } else {
  780. fmt.Println(err)
  781. }
  782. userJSONBytes, _ := json.Marshal(dat)
  783. if miConfig.Code == "H15049901371" {
  784. if err := json.Unmarshal(userJSONBytes, &res10265); err != nil {
  785. utils.ErrorLog("解析失败:%v", err)
  786. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  787. return
  788. }
  789. res.InfRefmsgid = res10265.InfRefmsgid
  790. res.Output = res10265.Output
  791. res.ErrMsg = res10265.ErrMsg
  792. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  793. res.Infcode = infocode
  794. } else {
  795. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  796. utils.ErrorLog("解析失败:%v", err)
  797. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  798. return
  799. }
  800. }
  801. }
  802. if res.Infcode == 0 {
  803. c.ServeSuccessJSON(map[string]interface{}{
  804. "result": res.Output.Result,
  805. })
  806. }
  807. }
  808. func (c *HisApiController) CheckInsutype() {
  809. his_patient_id, _ := c.GetInt64("his_patient_id")
  810. admin_user_id, _ := c.GetInt64("admin_user_id")
  811. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  812. his, _ := service.GetNewHisPatientInfoFour(c.GetAdminUserInfo().CurrentOrgId, his_patient_id)
  813. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  814. result := service.Gdyb90100(his.PsnNo, miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey)
  815. var dat map[string]interface{}
  816. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  817. fmt.Println(dat)
  818. } else {
  819. fmt.Println(err)
  820. }
  821. userJSONBytes, _ := json.Marshal(dat)
  822. var res Result90100
  823. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  824. utils.ErrorLog("解析失败:%v", err)
  825. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  826. return
  827. }
  828. if res.Infcode != 0 {
  829. c.ServeSuccessJSON(map[string]interface{}{
  830. "failed_code": -10,
  831. "msg": res.ErrMsg,
  832. })
  833. return
  834. } else {
  835. fmt.Println(res)
  836. }
  837. }
  838. func (c *HisApiController) CheckCardPWD() {
  839. card_pwd := c.GetString("card_pwd")
  840. his_patient_id, _ := c.GetInt64("his_patient_id")
  841. admin_user_id, _ := c.GetInt64("admin_user_id")
  842. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  843. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  844. his, _ := service.GetNewHisPatientInfoFour(c.GetAdminUserInfo().CurrentOrgId, his_patient_id)
  845. psn, _ := service.GetPsnByPatientId(his.PatientId)
  846. bas := strings.Split(psn.CardInfo, "|")
  847. basNumber := bas[2]
  848. result := service.Gdyb90991(his.PsnNo, miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, card_pwd, basNumber)
  849. var dat map[string]interface{}
  850. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  851. fmt.Println(dat)
  852. } else {
  853. fmt.Println(err)
  854. }
  855. userJSONBytes, _ := json.Marshal(dat)
  856. var res Result90991
  857. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  858. utils.ErrorLog("解析失败:%v", err)
  859. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  860. return
  861. }
  862. if res.Infcode != 0 {
  863. c.ServeSuccessJSON(map[string]interface{}{
  864. "failed_code": -10,
  865. "msg": res.ErrMsg,
  866. })
  867. return
  868. } else {
  869. if res.Output.Result.SscnoCheckStat == "0" {
  870. var msg string
  871. switch res.Output.Result.CardStat {
  872. case "00":
  873. msg = "未激活"
  874. break
  875. case "10":
  876. msg = "激活"
  877. break
  878. case "20":
  879. msg = "窗口挂失"
  880. break
  881. case "21":
  882. msg = "电话挂失"
  883. break
  884. case "22":
  885. msg = "单位网上申报挂失"
  886. break
  887. case "23":
  888. msg = "保健办挂失"
  889. break
  890. case "24":
  891. msg = "个人网上挂失"
  892. break
  893. case "25":
  894. msg = "网上服务大厅挂失"
  895. break
  896. case "30":
  897. msg = "注销"
  898. break
  899. case "40":
  900. msg = "回收"
  901. break
  902. case "99":
  903. msg = "制卡中(无效卡)"
  904. break
  905. }
  906. c.ServeSuccessJSON(map[string]interface{}{
  907. "failed_code": -10,
  908. "msg": msg,
  909. })
  910. return
  911. } else {
  912. c.ServeSuccessJSON(map[string]interface{}{
  913. "msg": "校验成功",
  914. })
  915. return
  916. }
  917. }
  918. }
  919. func (c *HisApiController) CheckCardPWDTwo() {
  920. //card_pwd := c.GetString("card_pwd")
  921. //his_patient_id, _ := c.GetInt64("his_patient_id")
  922. admin_user_id, _ := c.GetInt64("admin_user_id")
  923. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  924. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  925. result := service.Gdyb90991("44030000000629690364", miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, "000000", "BDM421363")
  926. var dat map[string]interface{}
  927. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  928. fmt.Println(dat)
  929. } else {
  930. fmt.Println(err)
  931. }
  932. userJSONBytes, _ := json.Marshal(dat)
  933. var res Result90991
  934. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  935. utils.ErrorLog("解析失败:%v", err)
  936. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  937. return
  938. }
  939. if res.Infcode != 0 {
  940. c.ServeSuccessJSON(map[string]interface{}{
  941. "failed_code": -10,
  942. "msg": res.ErrMsg,
  943. })
  944. return
  945. } else {
  946. if res.Output.Result.SscnoCheckStat == "0" {
  947. var msg string
  948. switch res.Output.Result.CardStat {
  949. case "00":
  950. msg = "未激活"
  951. break
  952. case "10":
  953. msg = "激活"
  954. break
  955. case "20":
  956. msg = "窗口挂失"
  957. break
  958. case "21":
  959. msg = "电话挂失"
  960. break
  961. case "22":
  962. msg = "单位网上申报挂失"
  963. break
  964. case "23":
  965. msg = "保健办挂失"
  966. break
  967. case "24":
  968. msg = "个人网上挂失"
  969. break
  970. case "25":
  971. msg = "网上服务大厅挂失"
  972. break
  973. case "30":
  974. msg = "注销"
  975. break
  976. case "40":
  977. msg = "回收"
  978. break
  979. case "99":
  980. msg = "制卡中(无效卡)"
  981. break
  982. }
  983. c.ServeSuccessJSON(map[string]interface{}{
  984. "failed_code": -10,
  985. "msg": msg,
  986. })
  987. return
  988. } else {
  989. c.ServeSuccessJSON(map[string]interface{}{
  990. "msg": "校验成功",
  991. })
  992. return
  993. }
  994. }
  995. }
  996. func (c *HisApiController) ReadCard() {
  997. id_card_type, _ := c.GetInt64("id_card_type")
  998. admin_user_id, _ := c.GetInt64("admin_user_id")
  999. certificates, _ := c.GetInt64("certificates")
  1000. fmt.Println(c.GetAdminUserInfo().CurrentOrgId)
  1001. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  1002. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  1003. switch id_card_type {
  1004. case 1:
  1005. if miConfig.MdtrtareaAdmvs == "421300" {
  1006. var res ResultTwo
  1007. api := "http://192.168.124.4:9532/" + "hbyb/1101?cert_no=" + "" +
  1008. "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  1009. "&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)
  1010. resp, requestErr := http.Get(api)
  1011. if requestErr != nil {
  1012. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1013. return
  1014. }
  1015. body, ioErr := ioutil.ReadAll(resp.Body)
  1016. if ioErr != nil {
  1017. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  1018. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1019. return
  1020. }
  1021. var respJSON map[string]interface{}
  1022. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  1023. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  1024. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1025. return
  1026. }
  1027. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  1028. result, _ := json.Marshal(respJSON)
  1029. fmt.Println("log")
  1030. fmt.Println(string(result))
  1031. if err := json.Unmarshal([]byte(result), &res); err != nil {
  1032. utils.ErrorLog("解析失败:%v", err)
  1033. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1034. return
  1035. }
  1036. if res.Infcode == 0 {
  1037. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  1038. if err == gorm.ErrRecordNotFound {
  1039. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  1040. return
  1041. } else if err != nil {
  1042. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  1043. return
  1044. } else {
  1045. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  1046. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  1047. infoStr := string(Iinfos)
  1048. idetinfoStr := string(Idetinfos)
  1049. psn := &models.HisPsn{
  1050. PsnNo: res.Output.Baseinfo.PsnNo,
  1051. Age: res.Output.Baseinfo.Age,
  1052. PatientId: patient.ID,
  1053. Certno: res.Output.Baseinfo.Certno,
  1054. Brdy: res.Output.Baseinfo.Brdy,
  1055. Gend: res.Output.Baseinfo.Gend,
  1056. Naty: res.Output.Baseinfo.Naty,
  1057. PsnCertType: res.Output.Baseinfo.PsnCertType,
  1058. PsnName: res.Output.Baseinfo.PsnName,
  1059. Idetinfo: idetinfoStr,
  1060. Insuinfo: infoStr,
  1061. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  1062. }
  1063. service.CreateHisPsn(psn)
  1064. c.ServeSuccessJSON(map[string]interface{}{
  1065. "patient": patient,
  1066. "number": res.Output.Baseinfo.Certno,
  1067. })
  1068. }
  1069. } else {
  1070. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  1071. return
  1072. }
  1073. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  1074. var api string
  1075. if miConfig.MdtrtareaAdmvs == "320921" {
  1076. api = "http://192.168.3.111:9532/" + "jsyb/readcard?" + "fixmedins_code=" + miConfig.Code + "&secret_key=" + miConfig.SecretKey + "&ak=" + miConfig.AccessKey + "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName +
  1077. "&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
  1078. fmt.Println(api)
  1079. } else {
  1080. 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 +
  1081. "&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)
  1082. }
  1083. resp, requestErr := http.Get(api)
  1084. if requestErr != nil {
  1085. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1086. return
  1087. }
  1088. body, ioErr := ioutil.ReadAll(resp.Body)
  1089. if ioErr != nil {
  1090. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  1091. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1092. return
  1093. }
  1094. var respJSON map[string]interface{}
  1095. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  1096. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  1097. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1098. return
  1099. }
  1100. var status string
  1101. status = respJSON["data"].(map[string]interface{})["status"].(string)
  1102. card_type := respJSON["data"].(map[string]interface{})["type"].(string)
  1103. //console.log()
  1104. fmt.Println("type===")
  1105. fmt.Println(card_type)
  1106. var token string
  1107. var res ResultTwo //1101结果
  1108. var res10265 ResultTwo10265 //1101结果
  1109. var card_info string //卡信息
  1110. var busi_card_info string
  1111. card_info = respJSON["data"].(map[string]interface{})["card_info"].(string)
  1112. busi_card_info = respJSON["data"].(map[string]interface{})["busi_card_info"].(string)
  1113. if status == "0" { //读卡成功
  1114. if card_type == "1" {
  1115. respJSON = respJSON["data"].(map[string]interface{})["result"].(map[string]interface{})
  1116. result, _ := json.Marshal(respJSON)
  1117. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  1118. utils.ErrorLog("解析失败:%v", err)
  1119. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1120. return
  1121. }
  1122. res.ErrMsg = res10265.ErrMsg
  1123. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  1124. res.Infcode = infocode
  1125. res.Output = res10265.Output
  1126. res.InfRefmsgid = res10265.InfRefmsgid
  1127. } else {
  1128. //var card_info string //卡信息
  1129. //var busi_card_info string
  1130. token = respJSON["data"].(map[string]interface{})["token"].(string)
  1131. //busi_card_info = respJSON["data"].(map[string]interface{})["busi_card_info"].(string)
  1132. //fmt.Println(card_info)
  1133. //fmt.Println(busi_card_info)
  1134. respJSON = respJSON["data"].(map[string]interface{})["result"].(map[string]interface{})
  1135. result, _ := json.Marshal(respJSON)
  1136. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  1137. utils.ErrorLog("解析失败:%v", err)
  1138. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1139. return
  1140. }
  1141. res.ErrMsg = res10265.ErrMsg
  1142. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  1143. res.Infcode = infocode
  1144. res.Output = res10265.Output
  1145. res.InfRefmsgid = res10265.InfRefmsgid
  1146. }
  1147. if res.Infcode == 0 {
  1148. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  1149. if err == gorm.ErrRecordNotFound {
  1150. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  1151. return
  1152. } else if err != nil {
  1153. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  1154. return
  1155. } else {
  1156. if card_type == "1" {
  1157. bas := strings.Split(card_info, "|")
  1158. basNumber := bas[2]
  1159. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  1160. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  1161. infoStr := string(Iinfos)
  1162. idetinfoStr := string(Idetinfos)
  1163. psn := &models.HisPsn{
  1164. PsnNo: res.Output.Baseinfo.PsnNo,
  1165. Age: res.Output.Baseinfo.Age,
  1166. PatientId: patient.ID,
  1167. Certno: res.Output.Baseinfo.Certno,
  1168. Brdy: res.Output.Baseinfo.Brdy,
  1169. Gend: res.Output.Baseinfo.Gend,
  1170. Naty: res.Output.Baseinfo.Naty,
  1171. PsnCertType: res.Output.Baseinfo.PsnCertType,
  1172. PsnName: res.Output.Baseinfo.PsnName,
  1173. Idetinfo: idetinfoStr,
  1174. Insuinfo: infoStr,
  1175. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  1176. CardInfo: card_info,
  1177. VerifyNumber: busi_card_info,
  1178. }
  1179. service.CreateHisPsn(psn)
  1180. var rf []*ResultFive
  1181. json.Unmarshal([]byte(infoStr), &rf)
  1182. var insutypes []*ResultFive
  1183. var insutype string
  1184. var is390 int = 0
  1185. var is310 int = 0
  1186. for _, item := range rf {
  1187. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  1188. insutypes = append(insutypes, item)
  1189. }
  1190. }
  1191. if len(insutypes) == 1 {
  1192. insutype = insutypes[0].Insutype
  1193. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  1194. } else {
  1195. for _, i := range insutypes {
  1196. if i.Insutype == "390" {
  1197. is390 = 1
  1198. }
  1199. if i.Insutype == "310" {
  1200. is310 = 1
  1201. }
  1202. }
  1203. }
  1204. if is390 == 1 {
  1205. insutype = "390"
  1206. }
  1207. if is310 == 1 {
  1208. insutype = "310"
  1209. }
  1210. if len(insutypes) == 0 {
  1211. insutype = "310"
  1212. }
  1213. c.ServeSuccessJSON(map[string]interface{}{
  1214. "patient": patient,
  1215. "number": basNumber,
  1216. "insutype": insutype,
  1217. })
  1218. } else {
  1219. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  1220. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  1221. infoStr := string(Iinfos)
  1222. idetinfoStr := string(Idetinfos)
  1223. psn := &models.HisPsn{
  1224. PsnNo: res.Output.Baseinfo.PsnNo,
  1225. Age: res.Output.Baseinfo.Age,
  1226. PatientId: patient.ID,
  1227. Certno: res.Output.Baseinfo.Certno,
  1228. Brdy: res.Output.Baseinfo.Brdy,
  1229. Gend: res.Output.Baseinfo.Gend,
  1230. Naty: res.Output.Baseinfo.Naty,
  1231. PsnCertType: res.Output.Baseinfo.PsnCertType,
  1232. PsnName: res.Output.Baseinfo.PsnName,
  1233. Idetinfo: idetinfoStr,
  1234. Insuinfo: infoStr,
  1235. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  1236. CardInfo: card_info,
  1237. VerifyNumber: token,
  1238. }
  1239. service.CreateHisPsn(psn)
  1240. c.ServeSuccessJSON(map[string]interface{}{
  1241. "patient": patient,
  1242. "number": token,
  1243. })
  1244. }
  1245. }
  1246. } else {
  1247. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  1248. return
  1249. }
  1250. } else { //读卡失败
  1251. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  1252. return
  1253. }
  1254. } else if miConfig.MdtrtareaAdmvs == "350500" {
  1255. cardnum, cardCode, id_card_no, name, errmsg := c.GetFjBasBaseInfo()
  1256. fmt.Println(cardnum)
  1257. fmt.Println(cardCode)
  1258. fmt.Println(id_card_no)
  1259. fmt.Println(name)
  1260. fmt.Println(errmsg)
  1261. basStr := cardnum + "|" + cardCode + "|" + id_card_no + "|" + name
  1262. result, _ := service.FJyb1101(cardnum, miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, id_card_type, cardCode, certificates, miConfig.Url, miConfig.Code, miConfig.AppSecret, miConfig.SignKey, miConfig.EncKey)
  1263. var dat map[string]interface{}
  1264. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  1265. fmt.Println(dat)
  1266. } else {
  1267. fmt.Println(err)
  1268. }
  1269. userJSONBytes, _ := json.Marshal(dat)
  1270. var res ResultTwo
  1271. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  1272. utils.ErrorLog("解析失败:%v", err)
  1273. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1274. return
  1275. }
  1276. if res.Infcode == 0 {
  1277. patient, err := service.GetPatientByNumber(id_card_no, c.GetAdminUserInfo().CurrentOrgId)
  1278. if err == gorm.ErrRecordNotFound {
  1279. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  1280. return
  1281. } else if err != nil {
  1282. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  1283. return
  1284. } else {
  1285. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  1286. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  1287. infoStr := string(Iinfos)
  1288. idetinfoStr := string(Idetinfos)
  1289. psn := &models.HisPsn{
  1290. PsnNo: res.Output.Baseinfo.PsnNo,
  1291. Age: res.Output.Baseinfo.Age,
  1292. PatientId: patient.ID,
  1293. Certno: res.Output.Baseinfo.Certno,
  1294. Brdy: res.Output.Baseinfo.Brdy,
  1295. Gend: res.Output.Baseinfo.Gend,
  1296. Naty: res.Output.Baseinfo.Naty,
  1297. PsnCertType: res.Output.Baseinfo.PsnCertType,
  1298. PsnName: res.Output.Baseinfo.PsnName,
  1299. Idetinfo: idetinfoStr,
  1300. Insuinfo: infoStr,
  1301. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  1302. CardInfo: basStr,
  1303. VerifyNumber: "",
  1304. }
  1305. service.CreateHisPsn(psn)
  1306. c.ServeSuccessJSON(map[string]interface{}{
  1307. "patient": patient,
  1308. "number": cardnum,
  1309. })
  1310. }
  1311. } else {
  1312. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  1313. return
  1314. }
  1315. } else {
  1316. if initFlag == 0 {
  1317. c.TestGetBasBaseInit()
  1318. }
  1319. basStr := c.GetBasBaseInfo()
  1320. if len(basStr) == 0 {
  1321. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeReadCardException)
  1322. return
  1323. }
  1324. fmt.Println(basStr)
  1325. bas := strings.Split(basStr, "|")
  1326. basNumber := bas[1]
  1327. fmt.Println(basNumber)
  1328. card_sn := bas[3]
  1329. fmt.Println(card_sn)
  1330. result := service.Gdyb1101B(basNumber, miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, id_card_type, card_sn, certificates)
  1331. var dat map[string]interface{}
  1332. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  1333. fmt.Println(dat)
  1334. } else {
  1335. fmt.Println(err)
  1336. }
  1337. userJSONBytes, _ := json.Marshal(dat)
  1338. var res ResultTwo
  1339. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  1340. utils.ErrorLog("解析失败:%v", err)
  1341. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1342. return
  1343. }
  1344. if res.Infcode == 0 {
  1345. patient, err := service.GetPatientByNumber(basNumber, c.GetAdminUserInfo().CurrentOrgId)
  1346. if err == gorm.ErrRecordNotFound {
  1347. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  1348. return
  1349. } else if err != nil {
  1350. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  1351. return
  1352. } else {
  1353. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  1354. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  1355. infoStr := string(Iinfos)
  1356. idetinfoStr := string(Idetinfos)
  1357. psn := &models.HisPsn{
  1358. PsnNo: res.Output.Baseinfo.PsnNo,
  1359. Age: res.Output.Baseinfo.Age,
  1360. PatientId: patient.ID,
  1361. Certno: res.Output.Baseinfo.Certno,
  1362. Brdy: res.Output.Baseinfo.Brdy,
  1363. Gend: res.Output.Baseinfo.Gend,
  1364. Naty: res.Output.Baseinfo.Naty,
  1365. PsnCertType: res.Output.Baseinfo.PsnCertType,
  1366. PsnName: res.Output.Baseinfo.PsnName,
  1367. Idetinfo: idetinfoStr,
  1368. Insuinfo: infoStr,
  1369. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  1370. CardInfo: basStr,
  1371. VerifyNumber: "",
  1372. }
  1373. service.CreateHisPsn(psn)
  1374. c.ServeSuccessJSON(map[string]interface{}{
  1375. "patient": patient,
  1376. "number": basNumber,
  1377. })
  1378. }
  1379. } else {
  1380. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  1381. return
  1382. }
  1383. break
  1384. }
  1385. case 2:
  1386. SFZStr := c.GetSFZBaseInfo()
  1387. id_card_str := strings.Split(SFZStr, "^")
  1388. id_card_number := id_card_str[0]
  1389. card_sn := ""
  1390. result := service.Gdyb1101B(id_card_number, miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, id_card_type, card_sn, certificates)
  1391. var dat map[string]interface{}
  1392. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  1393. fmt.Println(dat)
  1394. } else {
  1395. fmt.Println(err)
  1396. }
  1397. userJSONBytes, _ := json.Marshal(dat)
  1398. var res ResultTwo
  1399. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  1400. utils.ErrorLog("解析失败:%v", err)
  1401. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1402. return
  1403. }
  1404. if res.Infcode == 0 {
  1405. patient, err := service.GetPatientByNumber(id_card_number, c.GetAdminUserInfo().CurrentOrgId)
  1406. if err == gorm.ErrRecordNotFound {
  1407. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  1408. return
  1409. } else if err != nil {
  1410. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  1411. return
  1412. } else {
  1413. c.ServeSuccessJSON(map[string]interface{}{
  1414. "patient": patient,
  1415. "number": id_card_number,
  1416. })
  1417. }
  1418. } else {
  1419. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  1420. return
  1421. }
  1422. break
  1423. case 3:
  1424. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  1425. var api string
  1426. if miConfig.MdtrtareaAdmvs == "320921" {
  1427. api = "http://192.168.3.111:9532/" + "jsyb/readcard?" + "fixmedins_code=" + miConfig.Code + "&secret_key=" + miConfig.SecretKey + "&ak=" + miConfig.AccessKey + "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName +
  1428. "&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
  1429. fmt.Println(api)
  1430. } else {
  1431. 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 +
  1432. "&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)
  1433. }
  1434. resp, requestErr := http.Get(api)
  1435. if requestErr != nil {
  1436. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1437. return
  1438. }
  1439. body, ioErr := ioutil.ReadAll(resp.Body)
  1440. if ioErr != nil {
  1441. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  1442. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1443. return
  1444. }
  1445. var respJSON map[string]interface{}
  1446. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  1447. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  1448. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1449. return
  1450. }
  1451. var status string
  1452. status = respJSON["data"].(map[string]interface{})["status"].(string)
  1453. card_type := respJSON["data"].(map[string]interface{})["type"].(string)
  1454. var token string
  1455. var res ResultTwo //1101结果
  1456. var res10265 ResultTwo10265 //1101结果
  1457. var card_info string //卡信息
  1458. var busi_card_info string
  1459. //card_info = respJSON["data"].(map[string]interface{})["card_info"].(string)
  1460. busi_card_info = respJSON["data"].(map[string]interface{})["busi_card_info"].(string)
  1461. if status == "0" { //读卡成功
  1462. if card_type == "1" {
  1463. respJSON = respJSON["data"].(map[string]interface{})["result"].(map[string]interface{})
  1464. result, _ := json.Marshal(respJSON)
  1465. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  1466. utils.ErrorLog("解析失败:%v", err)
  1467. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1468. return
  1469. }
  1470. res.ErrMsg = res10265.ErrMsg
  1471. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  1472. res.Infcode = infocode
  1473. res.Output = res10265.Output
  1474. res.InfRefmsgid = res10265.InfRefmsgid
  1475. } else {
  1476. //var card_info string //卡信息
  1477. //var busi_card_info string
  1478. token = respJSON["data"].(map[string]interface{})["token"].(string)
  1479. //busi_card_info = respJSON["data"].(map[string]interface{})["busi_card_info"].(string)
  1480. //fmt.Println(card_info)
  1481. //fmt.Println(busi_card_info)
  1482. respJSON = respJSON["data"].(map[string]interface{})["result"].(map[string]interface{})
  1483. result, _ := json.Marshal(respJSON)
  1484. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  1485. utils.ErrorLog("解析失败:%v", err)
  1486. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1487. return
  1488. }
  1489. res.ErrMsg = res10265.ErrMsg
  1490. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  1491. res.Infcode = infocode
  1492. res.Output = res10265.Output
  1493. res.InfRefmsgid = res10265.InfRefmsgid
  1494. }
  1495. if res.Infcode == 0 {
  1496. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  1497. if err == gorm.ErrRecordNotFound {
  1498. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  1499. return
  1500. } else if err != nil {
  1501. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  1502. return
  1503. } else {
  1504. if card_type == "1" {
  1505. bas := strings.Split(card_info, "|")
  1506. basNumber := bas[2]
  1507. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  1508. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  1509. infoStr := string(Iinfos)
  1510. idetinfoStr := string(Idetinfos)
  1511. psn := &models.HisPsn{
  1512. PsnNo: res.Output.Baseinfo.PsnNo,
  1513. Age: res.Output.Baseinfo.Age,
  1514. PatientId: patient.ID,
  1515. Certno: res.Output.Baseinfo.Certno,
  1516. Brdy: res.Output.Baseinfo.Brdy,
  1517. Gend: res.Output.Baseinfo.Gend,
  1518. Naty: res.Output.Baseinfo.Naty,
  1519. PsnCertType: res.Output.Baseinfo.PsnCertType,
  1520. PsnName: res.Output.Baseinfo.PsnName,
  1521. Idetinfo: idetinfoStr,
  1522. Insuinfo: infoStr,
  1523. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  1524. CardInfo: card_info,
  1525. VerifyNumber: busi_card_info,
  1526. }
  1527. service.CreateHisPsn(psn)
  1528. c.ServeSuccessJSON(map[string]interface{}{
  1529. "patient": patient,
  1530. "number": basNumber,
  1531. })
  1532. } else {
  1533. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  1534. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  1535. infoStr := string(Iinfos)
  1536. idetinfoStr := string(Idetinfos)
  1537. psn := &models.HisPsn{
  1538. PsnNo: res.Output.Baseinfo.PsnNo,
  1539. Age: res.Output.Baseinfo.Age,
  1540. PatientId: patient.ID,
  1541. Certno: res.Output.Baseinfo.Certno,
  1542. Brdy: res.Output.Baseinfo.Brdy,
  1543. Gend: res.Output.Baseinfo.Gend,
  1544. Naty: res.Output.Baseinfo.Naty,
  1545. PsnCertType: res.Output.Baseinfo.PsnCertType,
  1546. PsnName: res.Output.Baseinfo.PsnName,
  1547. Idetinfo: idetinfoStr,
  1548. Insuinfo: infoStr,
  1549. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  1550. CardInfo: card_info,
  1551. VerifyNumber: token,
  1552. }
  1553. service.CreateHisPsn(psn)
  1554. var rf []*ResultFive
  1555. json.Unmarshal([]byte(infoStr), &rf)
  1556. var insutypes []*ResultFive
  1557. var insutype string
  1558. var is390 int = 0
  1559. var is310 int = 0
  1560. for _, item := range rf {
  1561. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  1562. insutypes = append(insutypes, item)
  1563. }
  1564. }
  1565. if len(insutypes) == 1 {
  1566. insutype = insutypes[0].Insutype
  1567. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  1568. } else {
  1569. for _, i := range insutypes {
  1570. if i.Insutype == "390" {
  1571. is390 = 1
  1572. }
  1573. if i.Insutype == "310" {
  1574. is310 = 1
  1575. }
  1576. }
  1577. }
  1578. if is390 == 1 {
  1579. insutype = "390"
  1580. }
  1581. if is310 == 1 {
  1582. insutype = "310"
  1583. }
  1584. if len(insutypes) == 0 {
  1585. insutype = "310"
  1586. }
  1587. c.ServeSuccessJSON(map[string]interface{}{
  1588. "patient": patient,
  1589. "number": token,
  1590. "insutype": insutype,
  1591. })
  1592. }
  1593. }
  1594. } else {
  1595. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  1596. return
  1597. }
  1598. } else { //读卡失败
  1599. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  1600. return
  1601. }
  1602. }
  1603. break
  1604. case 4:
  1605. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  1606. var api string
  1607. if miConfig.MdtrtareaAdmvs == "320921" {
  1608. api = "http://192.168.3.111:9532/" + "jsyb/readcard?" + "fixmedins_code=" + miConfig.Code + "&secret_key=" + miConfig.SecretKey + "&ak=" + miConfig.AccessKey + "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName +
  1609. "&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
  1610. fmt.Println(api)
  1611. } else {
  1612. 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 +
  1613. "&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)
  1614. }
  1615. resp, requestErr := http.Get(api)
  1616. if requestErr != nil {
  1617. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1618. return
  1619. }
  1620. body, ioErr := ioutil.ReadAll(resp.Body)
  1621. if ioErr != nil {
  1622. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  1623. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1624. return
  1625. }
  1626. var respJSON map[string]interface{}
  1627. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  1628. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  1629. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1630. return
  1631. }
  1632. var status string
  1633. status = respJSON["data"].(map[string]interface{})["status"].(string)
  1634. //card_type := respJSON["data"].(map[string]interface{})["type"].(string)
  1635. var token string
  1636. var res ResultTwo //1101结果
  1637. var res10265 ResultTwo10265 //1101结果
  1638. if status == "0" { //读卡成功
  1639. var card_info string //卡信息
  1640. var busi_card_info string
  1641. token = respJSON["data"].(map[string]interface{})["token"].(string)
  1642. busi_card_info = respJSON["data"].(map[string]interface{})["busi_card_info"].(string)
  1643. card_info = respJSON["data"].(map[string]interface{})["card_info"].(string)
  1644. fmt.Println(card_info)
  1645. fmt.Println(busi_card_info)
  1646. respJSON = respJSON["data"].(map[string]interface{})["result"].(map[string]interface{})
  1647. result, _ := json.Marshal(respJSON)
  1648. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  1649. utils.ErrorLog("解析失败:%v", err)
  1650. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1651. return
  1652. }
  1653. res.ErrMsg = res10265.ErrMsg
  1654. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  1655. res.Infcode = infocode
  1656. res.Output = res10265.Output
  1657. res.InfRefmsgid = res10265.InfRefmsgid
  1658. if res.Infcode == 0 {
  1659. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  1660. if err == gorm.ErrRecordNotFound {
  1661. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  1662. return
  1663. } else if err != nil {
  1664. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  1665. return
  1666. } else {
  1667. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  1668. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  1669. infoStr := string(Iinfos)
  1670. idetinfoStr := string(Idetinfos)
  1671. psn := &models.HisPsn{
  1672. PsnNo: res.Output.Baseinfo.PsnNo,
  1673. Age: res.Output.Baseinfo.Age,
  1674. PatientId: patient.ID,
  1675. Certno: res.Output.Baseinfo.Certno,
  1676. Brdy: res.Output.Baseinfo.Brdy,
  1677. Gend: res.Output.Baseinfo.Gend,
  1678. Naty: res.Output.Baseinfo.Naty,
  1679. PsnCertType: res.Output.Baseinfo.PsnCertType,
  1680. PsnName: res.Output.Baseinfo.PsnName,
  1681. Idetinfo: idetinfoStr,
  1682. Insuinfo: infoStr,
  1683. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  1684. CardInfo: card_info,
  1685. VerifyNumber: token,
  1686. }
  1687. service.CreateHisPsn(psn)
  1688. c.ServeSuccessJSON(map[string]interface{}{
  1689. "patient": patient,
  1690. "number": token,
  1691. })
  1692. }
  1693. } else {
  1694. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  1695. return
  1696. }
  1697. } else { //读卡失败
  1698. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  1699. return
  1700. }
  1701. }
  1702. break
  1703. }
  1704. }
  1705. var initFlag int64 = 0
  1706. func (c *HisApiController) TestGetBasBaseInit() {
  1707. DllDef := syscall.MustLoadDLL("SSCard.dll")
  1708. Iinit := DllDef.MustFindProc("Init")
  1709. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  1710. ret, _, err := Iinit.Call(StrPtr("http://igb.hsa.gdgov.cn/gdyb_api/prd/api/card/initDll"), StrPtr(miConfig.InsuplcAdmdvs))
  1711. if ret != 0 {
  1712. fmt.Println("SSCard的报错原因:", err)
  1713. fmt.Println("SSCard的运算结果为:", ret)
  1714. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeReadCardException)
  1715. return
  1716. }
  1717. result := int(ret)
  1718. fmt.Println("SSCard的运算结果为1:", result)
  1719. initFlag = 1
  1720. return
  1721. }
  1722. func (c *HisApiController) GetSFZBaseInfo() string {
  1723. DllDef := syscall.MustLoadDLL("SSCard.dll")
  1724. readCard := DllDef.MustFindProc("ReadSFZ")
  1725. if readCard == nil {
  1726. fmt.Println("readcard is nil")
  1727. readCard = DllDef.MustFindProc("ReadSFZ")
  1728. }
  1729. str := make([]byte, 256)
  1730. str1 := make([]byte, 256)
  1731. r, _, _ := readCard.Call((uintptr)(unsafe.Pointer(&str[0])), IntPtr(1024), (uintptr)(unsafe.Pointer(&str1[0])), IntPtr(1024))
  1732. fmt.Println(r)
  1733. return string(str)
  1734. }
  1735. func (c *HisApiController) GetBasBaseInfo() string {
  1736. DllDef := syscall.MustLoadDLL("SSCard.dll")
  1737. readCard := DllDef.MustFindProc("ReadCardBas")
  1738. if readCard == nil {
  1739. fmt.Println("readcard is nil")
  1740. readCard = DllDef.MustFindProc("ReadCardBas")
  1741. }
  1742. str := make([]byte, 1024)
  1743. str1 := make([]byte, 1024)
  1744. ret2, _, _ := readCard.Call((uintptr)(unsafe.Pointer(&str[0])), uintptr(1024), (uintptr)(unsafe.Pointer(&str1[0])), uintptr(1024))
  1745. fmt.Println(string(str1))
  1746. fmt.Println(string(str))
  1747. fmt.Println(":", ConvertToString(string(str1), "gbk", "utf-8"))
  1748. fmt.Println(":", ConvertToString(string(str), "gbk", "utf-8"))
  1749. if ret2 != 0 {
  1750. return ""
  1751. }
  1752. return string(str)
  1753. }
  1754. func (c *HisApiController) GetFjBasBaseInfo() (string, string, string, string, string) {
  1755. DllDef := syscall.MustLoadDLL("chs_fjs_standard.dll")
  1756. readCard := DllDef.MustFindProc("read_cardinfo")
  1757. if readCard == nil {
  1758. fmt.Println("readcard is nil")
  1759. readCard = DllDef.MustFindProc("read_cardinfo")
  1760. }
  1761. str := make([]byte, 1024) //卡号
  1762. str1 := make([]byte, 1024) //卡识别码
  1763. str2 := make([]byte, 1024) //身份证号
  1764. str3 := make([]byte, 1024) //姓名
  1765. str4 := make([]byte, 1024) //错误信息
  1766. 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])))
  1767. fmt.Println(string(str1))
  1768. fmt.Println(string(str))
  1769. fmt.Println(string(str2))
  1770. fmt.Println(string(str3))
  1771. fmt.Println(string(str4))
  1772. fmt.Println(":", ConvertToString(string(str1), "gbk", "utf-8"))
  1773. fmt.Println(":", ConvertToString(string(str), "gbk", "utf-8"))
  1774. fmt.Println(":", ConvertToString(string(str2), "gbk", "utf-8"))
  1775. fmt.Println(":", ConvertToString(string(str3), "gbk", "utf-8"))
  1776. fmt.Println(":", ConvertToString(string(str4), "gbk", "utf-8"))
  1777. if ret2 != 0 {
  1778. return "", "", "", "", ""
  1779. }
  1780. return string(str), string(str1), string(str2), string(str3), string(str4)
  1781. }
  1782. type CustomFundPay struct {
  1783. FundPayType string `json:"fund_pay_type"`
  1784. FundPayamt float64 `json:"fund_payamt"`
  1785. }
  1786. func (c *HisApiController) GetSettleList() {
  1787. order_id, _ := c.GetInt64("order_id")
  1788. admin_user_id, _ := c.GetInt64("admin_user_id")
  1789. order, _ := service.GetHisOrderByIDTwo(order_id)
  1790. roles, _ := service.GetDoctorListTwo(c.GetAdminUserInfo().CurrentOrgId)
  1791. his, _ := service.GetHisPatientByNumber(order.MdtrtId)
  1792. admin, _ := service.GetAdminUserByUserID(roles[0].AdminUserId)
  1793. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  1794. depart, _ := service.GetDepartMentDetail(curRoles.DepartmentId)
  1795. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  1796. if order.ID == 0 {
  1797. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisOrderNoExistParamWrong)
  1798. return
  1799. }
  1800. last_order, _ := service.GetLastHisOrder(c.GetAdminUserInfo().CurrentOrgId)
  1801. max_order, _ := service.GetLastHisOrderTwo(c.GetAdminUserInfo().CurrentOrgId)
  1802. count, _ := strconv.ParseInt(max_order.FaPiaoNumber, 10, 64)
  1803. fmt.Println(count)
  1804. var zero string
  1805. number := count + 1
  1806. if number >= 1000 {
  1807. zero = "0000" + strconv.FormatInt(number, 10)
  1808. } else if number >= 10000 {
  1809. zero = "000" + strconv.FormatInt(number, 10)
  1810. } else if number >= 100000 {
  1811. zero = "00" + strconv.FormatInt(number, 10)
  1812. } else if number >= 1000000 {
  1813. zero = "0" + strconv.FormatInt(number, 10)
  1814. } else {
  1815. zero = strconv.FormatInt(number, 10)
  1816. }
  1817. fmt.Println(zero)
  1818. struct4101 := service.Struct4101{
  1819. PsnNo: order.PsnNo,
  1820. MdtrtId: order.MdtrtId,
  1821. SetlId: order.SetlId,
  1822. PsnName: order.PsnName,
  1823. Gend: order.Gend,
  1824. Brdy: his.Brdy,
  1825. Age: his.Age,
  1826. Naty: order.Naty,
  1827. PatnCertType: "01",
  1828. Certno: order.Certno,
  1829. Prfs: "90",
  1830. ConerName: roles[0].UserName,
  1831. PatnRlts: "99",
  1832. ConerAddr: miConfig.OrgName,
  1833. ConerTel: admin.Mobile,
  1834. HiType: order.Insutype,
  1835. Insuplc: miConfig.InsuplcAdmdvs,
  1836. MaindiagFlag: "1",
  1837. BillCode: last_order.FaPiaoCode,
  1838. BillNo: zero,
  1839. BizSn: order.Number,
  1840. PsnSelfPay: order.PsnPartAmt,
  1841. PsnOwnPay: order.PsnPartAmt,
  1842. AcctPay: order.AcctPay,
  1843. PsnCashpay: order.PsnCashPay,
  1844. HiPaymtd: "1",
  1845. Hsorg: miConfig.InsuplcAdmdvs,
  1846. HsorgOpter: miConfig.InsuplcAdmdvs,
  1847. MedinsFillPsn: curRoles.UserName,
  1848. MedinsFillDept: depart.Name,
  1849. IptMedType: "2",
  1850. }
  1851. struct4101.SetlBegnDate = order.SetlTime
  1852. struct4101.SetlEndDate = order.SetlTime
  1853. time_arr := strings.Split(order.SetlTime, " ")
  1854. struct4101.AdmTime = time_arr[0]
  1855. struct4101.AdmEndTime = time_arr[0]
  1856. var rf []CustomFundPay
  1857. json.Unmarshal([]byte(order.SetlDetail), &rf)
  1858. var tempFunPays []service.CustomStruct
  1859. for _, item := range rf {
  1860. var tempFunPay service.CustomStruct
  1861. tempFunPay.FundPayamt = item.FundPayamt
  1862. tempFunPay.FundPayType = item.FundPayType
  1863. tempFunPays = append(tempFunPays, tempFunPay)
  1864. }
  1865. struct4101.CustomStruct = tempFunPays
  1866. var tempDiaginfos []service.DiaginfoStructTwo
  1867. var tempOpspdiseinfo2 service.OpspdiseinfoStruct
  1868. var tempOpspdiseinfos []service.OpspdiseinfoStruct
  1869. diagnosis_ids := strings.Split(order.Diagnosis, ",")
  1870. var config []*models.HisXtDiagnoseConfig
  1871. for _, item := range diagnosis_ids {
  1872. id, _ := strconv.ParseInt(item, 10, 64)
  1873. diagnosisConfig, _ := service.FindDiagnoseById(id)
  1874. config = append(config, &diagnosisConfig)
  1875. }
  1876. for index, item := range config {
  1877. if index == 0 {
  1878. var tempDiaginfo service.DiaginfoStructTwo
  1879. tempDiaginfo.DiagCode = item.CountryCode
  1880. tempDiaginfo.DiagName = item.CountryContentName
  1881. tempDiaginfo.DiagType = "1"
  1882. tempDiaginfo.MaindiagFlag = "1"
  1883. tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  1884. } else {
  1885. var tempDiaginfo service.DiaginfoStructTwo
  1886. tempDiaginfo.DiagCode = item.CountryCode
  1887. tempDiaginfo.DiagName = item.CountryContentName
  1888. tempDiaginfo.DiagType = "2"
  1889. tempDiaginfo.MaindiagFlag = "0"
  1890. tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  1891. }
  1892. }
  1893. struct4101.Diseinfo = tempDiaginfos
  1894. sickConfigTwo, _ := service.FindSickById(his.SickType)
  1895. tempOpspdiseinfo2.DiagCode = sickConfigTwo.ContentCode
  1896. tempOpspdiseinfo2.DiagName = sickConfigTwo.CountryContentName
  1897. tempOpspdiseinfo2.OprnOprtCode = sickConfigTwo.ContentCode
  1898. tempOpspdiseinfo2.OprnOprtName = sickConfigTwo.CountryContentName
  1899. tempOpspdiseinfos = append(tempOpspdiseinfos, tempOpspdiseinfo2)
  1900. struct4101.OpspdiseinfoStruct = tempOpspdiseinfos
  1901. var iteminfo service.IteminfoStruct
  1902. var bedCostTotal float64 = 0 //床位总费
  1903. var bedCostSelfTotal float64 = 0 //床位自费
  1904. var bedCostPartSelfTotal float64 = 0 //床位部分项目自费
  1905. var operationCostTotal float64 = 0 //手术费
  1906. var operationCostSelfTotal float64 = 0 //手术费
  1907. var operationCostPartSelfTotal float64 = 0 //手术费
  1908. var otherCostTotal float64 = 0 //其他费用
  1909. var otherCostSelfTotal float64 = 0 //其他费用
  1910. var otherCostPartSelfTotal float64 = 0 //其他费用
  1911. var materialCostTotal float64 = 0 //材料费
  1912. var materialCostSelfTotal float64 = 0 //材料费
  1913. var materialCostPartSelfTotal float64 = 0 //材料费
  1914. var westernMedicineCostTotal float64 = 0 //西药费
  1915. var westernMedicineCostSelfTotal float64 = 0 //西药费
  1916. var westernMedicineCostPartSelfTotal float64 = 0 //西药费
  1917. var chineseTraditionalMedicineCostTotal float64 = 0 //中成药
  1918. var chineseTraditionalMedicineCostSelfTotal float64 = 0 //中成药
  1919. var chineseTraditionalMedicineCostPartSelfTotal float64 = 0 //中成药
  1920. var checkCostTotal float64 = 0 //检查费
  1921. var checkCostSelfTotal float64 = 0 //检查费
  1922. var checkCostPartSelfTotal float64 = 0 //检查费
  1923. var laboratoryCostTotal float64 = 0 //化验费
  1924. var laboratoryCostSelfTotal float64 = 0 //化验费
  1925. var laboratoryCostPartSelfTotal float64 = 0 //化验费
  1926. var treatCostTotal float64 = 0 //治疗费用
  1927. var treatCostSelfTotal float64 = 0 //治疗费用
  1928. var treatCostPartSelfTotal float64 = 0 //治疗费用
  1929. decimal.DivisionPrecision = 2
  1930. var bed_fulamt_ownpay_amt float64 = 0
  1931. var operation_fulamt_ownpay_amt float64 = 0
  1932. var other_fulamt_ownpay_amt float64 = 0
  1933. var westernMedicine_fulamt_ownpay_amt float64 = 0
  1934. var chineseTraditional_fulamt_ownpay_amt float64 = 0
  1935. var check_fulamt_ownpay_amt float64 = 0
  1936. var material_fulamt_ownpay_amt float64 = 0
  1937. var laboratory_fulamt_ownpay_amt float64 = 0
  1938. var treat_fulamt_ownpay_amt float64 = 0
  1939. var bed_claa_sunmfee float64 = 0
  1940. var bed_clab_amt float64 = 0
  1941. var bed_other_amt float64 = 0
  1942. var operation_claa_sunmfee float64 = 0
  1943. var operation_clab_amt float64 = 0
  1944. var operation_other_amt float64 = 0
  1945. var other_claa_sunmfee float64 = 0
  1946. var other_clab_amt float64 = 0
  1947. var other_other_amt float64 = 0
  1948. var westernMedicine_claa_sunmfee float64 = 0
  1949. var westernMedicine_clab_amt float64 = 0
  1950. var westernMedicine_other_amt float64 = 0
  1951. var chineseTraditional_claa_sunmfee float64 = 0
  1952. var chineseTraditional_clab_amt float64 = 0
  1953. var chineseTraditional_other_amt float64 = 0
  1954. var check_claa_sunmfee float64 = 0
  1955. var check_clab_amt float64 = 0
  1956. var check_other_amt float64 = 0
  1957. var material_claa_sunmfee float64 = 0
  1958. var material_clab_amt float64 = 0
  1959. var material_other_amt float64 = 0
  1960. var laboratory_claa_sunmfee float64 = 0
  1961. var laboratory_clab_amt float64 = 0
  1962. var laboratory_other_amt float64 = 0
  1963. var treat_claa_sunmfee float64 = 0
  1964. var treat_clab_amt float64 = 0
  1965. var treat_other_amt float64 = 0
  1966. for _, item := range order.HisOrderInfo {
  1967. if item.MedChrgitmType == "01" { //床位费
  1968. bedCostTotal, _ = decimal.NewFromFloat(bedCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  1969. bedCostSelfTotal, _ = decimal.NewFromFloat(bedCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  1970. bedCostPartSelfTotal, _ = decimal.NewFromFloat(bedCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  1971. bed_fulamt_ownpay_amt, _ = decimal.NewFromFloat(bed_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  1972. if item.ChrgitmLv == "1" {
  1973. bed_claa_sunmfee, _ = decimal.NewFromFloat(bed_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  1974. }
  1975. if item.ChrgitmLv == "2" {
  1976. bed_clab_amt, _ = decimal.NewFromFloat(bed_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  1977. }
  1978. if item.ChrgitmLv == "3" {
  1979. bed_other_amt, _ = decimal.NewFromFloat(bed_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  1980. }
  1981. }
  1982. if item.MedChrgitmType == "03" { //检查费
  1983. checkCostTotal, _ = decimal.NewFromFloat(checkCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  1984. checkCostSelfTotal, _ = decimal.NewFromFloat(checkCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  1985. checkCostPartSelfTotal, _ = decimal.NewFromFloat(checkCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  1986. check_fulamt_ownpay_amt, _ = decimal.NewFromFloat(check_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  1987. if item.ChrgitmLv == "1" {
  1988. check_claa_sunmfee, _ = decimal.NewFromFloat(check_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  1989. }
  1990. if item.ChrgitmLv == "2" {
  1991. check_clab_amt, _ = decimal.NewFromFloat(check_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  1992. }
  1993. if item.ChrgitmLv == "3" {
  1994. check_other_amt, _ = decimal.NewFromFloat(check_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  1995. }
  1996. }
  1997. if item.MedChrgitmType == "04" { //化验费
  1998. laboratoryCostTotal, _ = decimal.NewFromFloat(laboratoryCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  1999. laboratoryCostSelfTotal, _ = decimal.NewFromFloat(laboratoryCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2000. laboratoryCostPartSelfTotal, _ = decimal.NewFromFloat(laboratoryCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2001. laboratory_fulamt_ownpay_amt, _ = decimal.NewFromFloat(laboratory_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  2002. if item.ChrgitmLv == "1" {
  2003. laboratory_claa_sunmfee, _ = decimal.NewFromFloat(laboratory_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2004. }
  2005. if item.ChrgitmLv == "2" {
  2006. laboratory_clab_amt, _ = decimal.NewFromFloat(laboratory_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2007. }
  2008. if item.ChrgitmLv == "3" {
  2009. laboratory_other_amt, _ = decimal.NewFromFloat(laboratory_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2010. }
  2011. }
  2012. if item.MedChrgitmType == "05" { //治疗费
  2013. treatCostTotal, _ = decimal.NewFromFloat(treatCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2014. treatCostSelfTotal, _ = decimal.NewFromFloat(treatCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2015. treatCostPartSelfTotal, _ = decimal.NewFromFloat(treatCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2016. treat_fulamt_ownpay_amt, _ = decimal.NewFromFloat(treat_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  2017. if item.ChrgitmLv == "1" {
  2018. treat_claa_sunmfee, _ = decimal.NewFromFloat(treat_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2019. }
  2020. if item.ChrgitmLv == "2" {
  2021. treat_clab_amt, _ = decimal.NewFromFloat(treat_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2022. }
  2023. if item.ChrgitmLv == "3" {
  2024. treat_other_amt, _ = decimal.NewFromFloat(treat_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2025. }
  2026. }
  2027. if item.MedChrgitmType == "06" { //手术费
  2028. operationCostTotal, _ = decimal.NewFromFloat(operationCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2029. operationCostSelfTotal, _ = decimal.NewFromFloat(operationCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2030. operationCostPartSelfTotal, _ = decimal.NewFromFloat(operationCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2031. operation_fulamt_ownpay_amt, _ = decimal.NewFromFloat(operation_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  2032. if item.ChrgitmLv == "1" {
  2033. operation_claa_sunmfee, _ = decimal.NewFromFloat(operation_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2034. }
  2035. if item.ChrgitmLv == "2" {
  2036. operation_clab_amt, _ = decimal.NewFromFloat(operation_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2037. }
  2038. if item.ChrgitmLv == "3" {
  2039. operation_other_amt, _ = decimal.NewFromFloat(operation_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2040. }
  2041. }
  2042. if item.MedChrgitmType == "08" { //材料费
  2043. materialCostTotal, _ = decimal.NewFromFloat(materialCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2044. materialCostSelfTotal, _ = decimal.NewFromFloat(materialCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2045. materialCostPartSelfTotal, _ = decimal.NewFromFloat(materialCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2046. material_fulamt_ownpay_amt, _ = decimal.NewFromFloat(material_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  2047. if item.ChrgitmLv == "1" {
  2048. material_claa_sunmfee, _ = decimal.NewFromFloat(material_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2049. }
  2050. if item.ChrgitmLv == "2" {
  2051. material_clab_amt, _ = decimal.NewFromFloat(material_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2052. }
  2053. if item.ChrgitmLv == "3" {
  2054. material_other_amt, _ = decimal.NewFromFloat(material_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2055. }
  2056. }
  2057. if item.MedChrgitmType == "09" { //西药费
  2058. westernMedicineCostTotal, _ = decimal.NewFromFloat(westernMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2059. westernMedicineCostSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2060. westernMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2061. westernMedicine_fulamt_ownpay_amt, _ = decimal.NewFromFloat(westernMedicine_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  2062. if item.ChrgitmLv == "1" {
  2063. westernMedicine_claa_sunmfee, _ = decimal.NewFromFloat(westernMedicine_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2064. }
  2065. if item.ChrgitmLv == "2" {
  2066. westernMedicine_clab_amt, _ = decimal.NewFromFloat(westernMedicine_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2067. }
  2068. if item.ChrgitmLv == "3" {
  2069. westernMedicine_other_amt, _ = decimal.NewFromFloat(westernMedicine_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2070. }
  2071. }
  2072. if item.MedChrgitmType == "11" { //中成费
  2073. chineseTraditionalMedicineCostTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2074. chineseTraditionalMedicineCostSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2075. chineseTraditionalMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2076. chineseTraditional_fulamt_ownpay_amt, _ = decimal.NewFromFloat(chineseTraditional_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  2077. if item.ChrgitmLv == "1" {
  2078. chineseTraditional_claa_sunmfee, _ = decimal.NewFromFloat(chineseTraditional_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2079. }
  2080. if item.ChrgitmLv == "2" {
  2081. chineseTraditional_clab_amt, _ = decimal.NewFromFloat(chineseTraditional_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2082. }
  2083. if item.ChrgitmLv == "3" {
  2084. chineseTraditional_other_amt, _ = decimal.NewFromFloat(chineseTraditional_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2085. }
  2086. }
  2087. if item.MedChrgitmType == "14" { //其他费
  2088. otherCostTotal, _ = decimal.NewFromFloat(otherCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2089. otherCostSelfTotal, _ = decimal.NewFromFloat(otherCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2090. otherCostPartSelfTotal, _ = decimal.NewFromFloat(otherCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2091. other_fulamt_ownpay_amt, _ = decimal.NewFromFloat(other_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  2092. if item.ChrgitmLv == "1" {
  2093. other_claa_sunmfee, _ = decimal.NewFromFloat(other_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2094. }
  2095. if item.ChrgitmLv == "2" {
  2096. other_clab_amt, _ = decimal.NewFromFloat(other_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2097. }
  2098. if item.ChrgitmLv == "3" {
  2099. other_other_amt, _ = decimal.NewFromFloat(other_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2100. }
  2101. }
  2102. }
  2103. var iteminfoStructs []service.IteminfoStruct
  2104. if bedCostTotal != 0 {
  2105. iteminfo.MedChrgitm = "01"
  2106. iteminfo.FulamtOwnpayAmt = bed_fulamt_ownpay_amt
  2107. iteminfo.Amt = bedCostTotal
  2108. iteminfo.ClaaSumfee = bed_claa_sunmfee
  2109. iteminfo.ClabAmt = bed_clab_amt
  2110. iteminfo.OthAmt = bed_other_amt
  2111. iteminfoStructs = append(iteminfoStructs, iteminfo)
  2112. }
  2113. if checkCostTotal != 0 {
  2114. iteminfo.MedChrgitm = "03"
  2115. iteminfo.FulamtOwnpayAmt = check_fulamt_ownpay_amt
  2116. iteminfo.Amt = checkCostTotal
  2117. iteminfo.ClaaSumfee = check_claa_sunmfee
  2118. iteminfo.ClabAmt = check_clab_amt
  2119. iteminfo.OthAmt = check_other_amt
  2120. iteminfoStructs = append(iteminfoStructs, iteminfo)
  2121. }
  2122. if laboratoryCostTotal != 0 {
  2123. iteminfo.MedChrgitm = "04"
  2124. iteminfo.FulamtOwnpayAmt = laboratory_fulamt_ownpay_amt
  2125. iteminfo.Amt = laboratoryCostTotal
  2126. iteminfo.ClaaSumfee = laboratory_claa_sunmfee
  2127. iteminfo.ClabAmt = laboratory_clab_amt
  2128. iteminfo.OthAmt = laboratory_other_amt
  2129. iteminfoStructs = append(iteminfoStructs, iteminfo)
  2130. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  2131. }
  2132. if treatCostTotal != 0 {
  2133. iteminfo.MedChrgitm = "05"
  2134. iteminfo.FulamtOwnpayAmt = treat_fulamt_ownpay_amt
  2135. iteminfo.Amt = treatCostTotal
  2136. iteminfo.ClaaSumfee = treat_claa_sunmfee
  2137. iteminfo.ClabAmt = treat_clab_amt
  2138. iteminfo.OthAmt = treat_other_amt
  2139. iteminfoStructs = append(iteminfoStructs, iteminfo)
  2140. //(struct4101.IteminfoStruct, iteminfo)
  2141. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  2142. }
  2143. if operationCostTotal != 0 {
  2144. iteminfo.MedChrgitm = "06"
  2145. iteminfo.FulamtOwnpayAmt = bed_fulamt_ownpay_amt
  2146. iteminfo.Amt = operationCostTotal
  2147. iteminfo.ClaaSumfee = operation_claa_sunmfee
  2148. iteminfo.ClabAmt = operation_clab_amt
  2149. iteminfo.OthAmt = operation_other_amt
  2150. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  2151. iteminfoStructs = append(iteminfoStructs, iteminfo)
  2152. }
  2153. if materialCostTotal != 0 {
  2154. iteminfo.MedChrgitm = "08"
  2155. iteminfo.FulamtOwnpayAmt = material_fulamt_ownpay_amt
  2156. iteminfo.Amt = materialCostTotal
  2157. iteminfo.ClaaSumfee = material_claa_sunmfee
  2158. iteminfo.ClabAmt = material_clab_amt
  2159. iteminfo.OthAmt = material_other_amt
  2160. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  2161. iteminfoStructs = append(iteminfoStructs, iteminfo)
  2162. }
  2163. if westernMedicineCostTotal != 0 {
  2164. iteminfo.MedChrgitm = "09"
  2165. iteminfo.FulamtOwnpayAmt = westernMedicine_fulamt_ownpay_amt
  2166. iteminfo.Amt = westernMedicineCostTotal
  2167. iteminfo.ClaaSumfee = westernMedicine_claa_sunmfee
  2168. iteminfo.ClabAmt = westernMedicine_clab_amt
  2169. iteminfo.OthAmt = westernMedicine_other_amt
  2170. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  2171. iteminfoStructs = append(iteminfoStructs, iteminfo)
  2172. }
  2173. if chineseTraditionalMedicineCostTotal != 0 {
  2174. iteminfo.MedChrgitm = "11"
  2175. iteminfo.FulamtOwnpayAmt = westernMedicine_fulamt_ownpay_amt
  2176. iteminfo.Amt = westernMedicineCostTotal
  2177. iteminfo.ClaaSumfee = westernMedicine_claa_sunmfee
  2178. iteminfo.ClabAmt = westernMedicine_clab_amt
  2179. iteminfo.OthAmt = westernMedicine_other_amt
  2180. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  2181. iteminfoStructs = append(iteminfoStructs, iteminfo)
  2182. }
  2183. if otherCostTotal != 0 {
  2184. iteminfo.MedChrgitm = "14"
  2185. iteminfo.FulamtOwnpayAmt = other_fulamt_ownpay_amt
  2186. iteminfo.Amt = otherCostTotal
  2187. iteminfo.ClaaSumfee = other_claa_sunmfee
  2188. iteminfo.ClabAmt = other_clab_amt
  2189. iteminfo.OthAmt = other_other_amt
  2190. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  2191. iteminfoStructs = append(iteminfoStructs, iteminfo)
  2192. }
  2193. struct4101.IteminfoStruct = iteminfoStructs
  2194. struct4101.Ntly = "中国"
  2195. struct4101.AdmCaty = "A03.06"
  2196. var res ResultSeventeen
  2197. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  2198. var resOther ResultSeventeenOther
  2199. var pp models.PublicParams
  2200. pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  2201. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  2202. pp.FixmedinsName = miConfig.OrgName
  2203. pp.FixmedinsCode = miConfig.Code
  2204. pp.RequestUrl = miConfig.Url
  2205. pp.Cainfo = miConfig.Cainfo
  2206. pp.SecretKey = miConfig.SecretKey
  2207. pp.AccessKey = miConfig.AccessKey
  2208. pp.OpterName = curRoles.UserName
  2209. client := &http.Client{}
  2210. var req *http.Request
  2211. data := make(map[string]interface{})
  2212. data["struct4101"] = struct4101
  2213. data["pp"] = pp
  2214. bytesData, _ := json.Marshal(data)
  2215. if miConfig.MdtrtareaAdmvs == "320921" {
  2216. req, _ = http.NewRequest("POST", "http://192.168.3.111:9532/"+"jsyb/4101", bytes.NewReader(bytesData))
  2217. } else {
  2218. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/4101", bytes.NewReader(bytesData))
  2219. }
  2220. resp, _ := client.Do(req)
  2221. defer resp.Body.Close()
  2222. body, ioErr := ioutil.ReadAll(resp.Body)
  2223. if ioErr != nil {
  2224. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  2225. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2226. return
  2227. }
  2228. var respJSON map[string]interface{}
  2229. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  2230. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  2231. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2232. return
  2233. }
  2234. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  2235. userJSONBytes, _ := json.Marshal(respJSON)
  2236. fmt.Println("log")
  2237. fmt.Println(string(userJSONBytes))
  2238. if err := json.Unmarshal(userJSONBytes, &resOther); err != nil {
  2239. utils.ErrorLog("解析失败:%v", err)
  2240. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2241. return
  2242. }
  2243. res.InfRefmsgid = resOther.InfRefmsgid
  2244. res.Output = resOther.Output
  2245. res.ErrMsg = resOther.ErrMsg
  2246. infocode, _ := strconv.ParseInt(resOther.Infcode, 10, 64)
  2247. res.Infcode = infocode
  2248. } else {
  2249. result := service.Gdyb4101(struct4101, miConfig.SecretKey, miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.UserOrgId)
  2250. var dat map[string]interface{}
  2251. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  2252. fmt.Println(dat)
  2253. } else {
  2254. fmt.Println(err)
  2255. }
  2256. userJSONBytes, _ := json.Marshal(dat)
  2257. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  2258. utils.ErrorLog("解析失败:%v", err)
  2259. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2260. return
  2261. }
  2262. }
  2263. if res.Infcode != 0 {
  2264. c.ServeSuccessJSON(map[string]interface{}{
  2265. "failed_code": -10,
  2266. "msg": res.ErrMsg,
  2267. })
  2268. return
  2269. } else {
  2270. order.FaPiaoNumber = zero
  2271. order.FaPiaoCode = last_order.FaPiaoCode
  2272. service.UpdateOrder(order)
  2273. hisFundSettleListResult := &models.HisFundSettleListResult{
  2274. Number: res.Output.SetlListId,
  2275. Status: 1,
  2276. Ctime: time.Now().Unix(),
  2277. Mtime: time.Now().Unix(),
  2278. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  2279. IsUpload: 1,
  2280. OrderId: order_id,
  2281. }
  2282. service.CreateUploadRecord(hisFundSettleListResult)
  2283. c.ServeSuccessJSON(map[string]interface{}{
  2284. "msg": "上传成功",
  2285. "result": hisFundSettleListResult,
  2286. })
  2287. return
  2288. }
  2289. }
  2290. func (c *HisApiController) GetSettleListHospital() {
  2291. order_id, _ := c.GetInt64("order_id")
  2292. admin_user_id, _ := c.GetInt64("admin_user_id")
  2293. order, _ := service.GetHisOrderByIDTwo(order_id)
  2294. roles, _ := service.GetDoctorListTwo(c.GetAdminUserInfo().CurrentOrgId)
  2295. his, _ := service.GetInHospitalRecordByNumber(order.MdtrtId)
  2296. admin, _ := service.GetAdminUserByUserID(roles[0].AdminUserId)
  2297. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  2298. depart, _ := service.GetDepartMentDetail(curRoles.DepartmentId)
  2299. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  2300. if order.ID == 0 {
  2301. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisOrderNoExistParamWrong)
  2302. return
  2303. }
  2304. last_order, _ := service.GetLastHisOrder(c.GetAdminUserInfo().CurrentOrgId)
  2305. max_order, _ := service.GetLastHisOrderTwo(c.GetAdminUserInfo().CurrentOrgId)
  2306. count, _ := strconv.ParseInt(max_order.FaPiaoNumber, 10, 64)
  2307. fmt.Println(count)
  2308. var zero string
  2309. number := count + 1
  2310. if number >= 1000 {
  2311. zero = "0000" + strconv.FormatInt(number, 10)
  2312. } else if number >= 10000 {
  2313. zero = "000" + strconv.FormatInt(number, 10)
  2314. } else if number >= 100000 {
  2315. zero = "00" + strconv.FormatInt(number, 10)
  2316. } else if number >= 1000000 {
  2317. zero = "0" + strconv.FormatInt(number, 10)
  2318. } else {
  2319. zero = strconv.FormatInt(number, 10)
  2320. }
  2321. fmt.Println(zero)
  2322. struct4101 := service.Struct4101{
  2323. PsnNo: order.PsnNo,
  2324. MdtrtId: order.MdtrtId,
  2325. SetlId: order.SetlId,
  2326. PsnName: order.PsnName,
  2327. Gend: order.Gend,
  2328. Brdy: his.Brdy,
  2329. Age: int64(order.Age),
  2330. Naty: order.Naty,
  2331. PatnCertType: "01",
  2332. Certno: order.Certno,
  2333. Prfs: "90",
  2334. ConerName: roles[0].UserName,
  2335. PatnRlts: "99",
  2336. ConerAddr: miConfig.OrgName,
  2337. ConerTel: admin.Mobile,
  2338. HiType: order.Insutype,
  2339. Insuplc: miConfig.InsuplcAdmdvs,
  2340. MaindiagFlag: "1",
  2341. BillCode: last_order.FaPiaoCode,
  2342. BillNo: zero,
  2343. BizSn: order.Number,
  2344. PsnSelfPay: order.PsnPartAmt,
  2345. PsnOwnPay: order.PsnPartAmt,
  2346. AcctPay: order.AcctPay,
  2347. PsnCashpay: order.PsnCashPay,
  2348. HiPaymtd: "1",
  2349. Hsorg: miConfig.InsuplcAdmdvs,
  2350. HsorgOpter: miConfig.InsuplcAdmdvs,
  2351. MedinsFillPsn: curRoles.UserName,
  2352. MedinsFillDept: depart.Name,
  2353. IptMedType: "2",
  2354. AdmTime: his.InHosptialTime,
  2355. AdmEndTime: his.OutHosptialTime,
  2356. }
  2357. struct4101.SetlBegnDate = order.SetlTime
  2358. struct4101.SetlEndDate = order.SetlTime
  2359. var rf []CustomFundPay
  2360. json.Unmarshal([]byte(order.SetlDetail), &rf)
  2361. var tempFunPays []service.CustomStruct
  2362. for _, item := range rf {
  2363. var tempFunPay service.CustomStruct
  2364. tempFunPay.FundPayamt = item.FundPayamt
  2365. tempFunPay.FundPayType = item.FundPayType
  2366. tempFunPays = append(tempFunPays, tempFunPay)
  2367. }
  2368. struct4101.CustomStruct = tempFunPays
  2369. var tempDiaginfos []service.DiaginfoStructTwo
  2370. var tempOpspdiseinfo2 service.OpspdiseinfoStruct
  2371. var tempOpspdiseinfos []service.OpspdiseinfoStruct
  2372. diagnosis_ids := strings.Split(his.Diagnosis, ",")
  2373. var config []*models.HisXtDiagnoseConfig
  2374. for _, item := range diagnosis_ids {
  2375. id, _ := strconv.ParseInt(item, 10, 64)
  2376. diagnosisConfig, _ := service.FindDiagnoseById(id)
  2377. config = append(config, &diagnosisConfig)
  2378. }
  2379. for index, item := range config {
  2380. if index == 0 {
  2381. var tempDiaginfo service.DiaginfoStructTwo
  2382. tempDiaginfo.DiagCode = item.CountryCode
  2383. tempDiaginfo.DiagName = item.CountryContentName
  2384. tempDiaginfo.DiagType = "1"
  2385. tempDiaginfo.MaindiagFlag = "1"
  2386. tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  2387. } else {
  2388. var tempDiaginfo service.DiaginfoStructTwo
  2389. tempDiaginfo.DiagCode = item.CountryCode
  2390. tempDiaginfo.DiagName = item.CountryContentName
  2391. tempDiaginfo.DiagType = "2"
  2392. tempDiaginfo.MaindiagFlag = "0"
  2393. tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  2394. }
  2395. }
  2396. struct4101.Diseinfo = tempDiaginfos
  2397. sickConfigTwo, _ := service.FindSickById(his.SickType)
  2398. tempOpspdiseinfo2.DiagCode = sickConfigTwo.ContentCode
  2399. tempOpspdiseinfo2.DiagName = sickConfigTwo.CountryContentName
  2400. tempOpspdiseinfo2.OprnOprtCode = ""
  2401. tempOpspdiseinfo2.OprnOprtName = ""
  2402. tempOpspdiseinfos = append(tempOpspdiseinfos, tempOpspdiseinfo2)
  2403. struct4101.OpspdiseinfoStruct = tempOpspdiseinfos
  2404. var iteminfo service.IteminfoStruct
  2405. var bedCostTotal float64 = 0 //床位总费
  2406. var bedCostSelfTotal float64 = 0 //床位自费
  2407. var bedCostPartSelfTotal float64 = 0 //床位部分项目自费
  2408. var operationCostTotal float64 = 0 //手术费
  2409. var operationCostSelfTotal float64 = 0 //手术费
  2410. var operationCostPartSelfTotal float64 = 0 //手术费
  2411. var otherCostTotal float64 = 0 //其他费用
  2412. var otherCostSelfTotal float64 = 0 //其他费用
  2413. var otherCostPartSelfTotal float64 = 0 //其他费用
  2414. var materialCostTotal float64 = 0 //材料费
  2415. var materialCostSelfTotal float64 = 0 //材料费
  2416. var materialCostPartSelfTotal float64 = 0 //材料费
  2417. var westernMedicineCostTotal float64 = 0 //西药费
  2418. var westernMedicineCostSelfTotal float64 = 0 //西药费
  2419. var westernMedicineCostPartSelfTotal float64 = 0 //西药费
  2420. var chineseTraditionalMedicineCostTotal float64 = 0 //中成药
  2421. var chineseTraditionalMedicineCostSelfTotal float64 = 0 //中成药
  2422. var chineseTraditionalMedicineCostPartSelfTotal float64 = 0 //中成药
  2423. var checkCostTotal float64 = 0 //检查费
  2424. var checkCostSelfTotal float64 = 0 //检查费
  2425. var checkCostPartSelfTotal float64 = 0 //检查费
  2426. var laboratoryCostTotal float64 = 0 //化验费
  2427. var laboratoryCostSelfTotal float64 = 0 //化验费
  2428. var laboratoryCostPartSelfTotal float64 = 0 //化验费
  2429. var treatCostTotal float64 = 0 //治疗费用
  2430. var treatCostSelfTotal float64 = 0 //治疗费用
  2431. var treatCostPartSelfTotal float64 = 0 //治疗费用
  2432. decimal.DivisionPrecision = 2
  2433. var bed_fulamt_ownpay_amt float64 = 0
  2434. var operation_fulamt_ownpay_amt float64 = 0
  2435. var other_fulamt_ownpay_amt float64 = 0
  2436. var westernMedicine_fulamt_ownpay_amt float64 = 0
  2437. var chineseTraditional_fulamt_ownpay_amt float64 = 0
  2438. var check_fulamt_ownpay_amt float64 = 0
  2439. var material_fulamt_ownpay_amt float64 = 0
  2440. var laboratory_fulamt_ownpay_amt float64 = 0
  2441. var treat_fulamt_ownpay_amt float64 = 0
  2442. var bed_claa_sunmfee float64 = 0
  2443. var bed_clab_amt float64 = 0
  2444. var bed_other_amt float64 = 0
  2445. var operation_claa_sunmfee float64 = 0
  2446. var operation_clab_amt float64 = 0
  2447. var operation_other_amt float64 = 0
  2448. var other_claa_sunmfee float64 = 0
  2449. var other_clab_amt float64 = 0
  2450. var other_other_amt float64 = 0
  2451. var westernMedicine_claa_sunmfee float64 = 0
  2452. var westernMedicine_clab_amt float64 = 0
  2453. var westernMedicine_other_amt float64 = 0
  2454. var chineseTraditional_claa_sunmfee float64 = 0
  2455. var chineseTraditional_clab_amt float64 = 0
  2456. var chineseTraditional_other_amt float64 = 0
  2457. var check_claa_sunmfee float64 = 0
  2458. var check_clab_amt float64 = 0
  2459. var check_other_amt float64 = 0
  2460. var material_claa_sunmfee float64 = 0
  2461. var material_clab_amt float64 = 0
  2462. var material_other_amt float64 = 0
  2463. var laboratory_claa_sunmfee float64 = 0
  2464. var laboratory_clab_amt float64 = 0
  2465. var laboratory_other_amt float64 = 0
  2466. var treat_claa_sunmfee float64 = 0
  2467. var treat_clab_amt float64 = 0
  2468. var treat_other_amt float64 = 0
  2469. for _, item := range order.HisOrderInfo {
  2470. if item.MedChrgitmType == "01" { //床位费
  2471. bedCostTotal, _ = decimal.NewFromFloat(bedCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2472. bedCostSelfTotal, _ = decimal.NewFromFloat(bedCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2473. bedCostPartSelfTotal, _ = decimal.NewFromFloat(bedCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2474. bed_fulamt_ownpay_amt, _ = decimal.NewFromFloat(bed_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  2475. if item.ChrgitmLv == "1" {
  2476. bed_claa_sunmfee, _ = decimal.NewFromFloat(bed_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2477. }
  2478. if item.ChrgitmLv == "2" {
  2479. bed_clab_amt, _ = decimal.NewFromFloat(bed_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2480. }
  2481. if item.ChrgitmLv == "3" {
  2482. bed_other_amt, _ = decimal.NewFromFloat(bed_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2483. }
  2484. }
  2485. if item.MedChrgitmType == "03" { //检查费
  2486. checkCostTotal, _ = decimal.NewFromFloat(checkCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2487. checkCostSelfTotal, _ = decimal.NewFromFloat(checkCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2488. checkCostPartSelfTotal, _ = decimal.NewFromFloat(checkCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2489. check_fulamt_ownpay_amt, _ = decimal.NewFromFloat(check_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  2490. if item.ChrgitmLv == "1" {
  2491. check_claa_sunmfee, _ = decimal.NewFromFloat(check_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2492. }
  2493. if item.ChrgitmLv == "2" {
  2494. check_clab_amt, _ = decimal.NewFromFloat(check_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2495. }
  2496. if item.ChrgitmLv == "3" {
  2497. check_other_amt, _ = decimal.NewFromFloat(check_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2498. }
  2499. }
  2500. if item.MedChrgitmType == "04" { //化验费
  2501. laboratoryCostTotal, _ = decimal.NewFromFloat(laboratoryCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2502. laboratoryCostSelfTotal, _ = decimal.NewFromFloat(laboratoryCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2503. laboratoryCostPartSelfTotal, _ = decimal.NewFromFloat(laboratoryCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2504. laboratory_fulamt_ownpay_amt, _ = decimal.NewFromFloat(laboratory_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  2505. if item.ChrgitmLv == "1" {
  2506. laboratory_claa_sunmfee, _ = decimal.NewFromFloat(laboratory_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2507. }
  2508. if item.ChrgitmLv == "2" {
  2509. laboratory_clab_amt, _ = decimal.NewFromFloat(laboratory_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2510. }
  2511. if item.ChrgitmLv == "3" {
  2512. laboratory_other_amt, _ = decimal.NewFromFloat(laboratory_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2513. }
  2514. }
  2515. if item.MedChrgitmType == "05" { //治疗费
  2516. treatCostTotal, _ = decimal.NewFromFloat(treatCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2517. treatCostSelfTotal, _ = decimal.NewFromFloat(treatCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2518. treatCostPartSelfTotal, _ = decimal.NewFromFloat(treatCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2519. treat_fulamt_ownpay_amt, _ = decimal.NewFromFloat(treat_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  2520. if item.ChrgitmLv == "1" {
  2521. treat_claa_sunmfee, _ = decimal.NewFromFloat(treat_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2522. }
  2523. if item.ChrgitmLv == "2" {
  2524. treat_clab_amt, _ = decimal.NewFromFloat(treat_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2525. }
  2526. if item.ChrgitmLv == "3" {
  2527. treat_other_amt, _ = decimal.NewFromFloat(treat_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2528. }
  2529. }
  2530. if item.MedChrgitmType == "06" { //手术费
  2531. operationCostTotal, _ = decimal.NewFromFloat(operationCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2532. operationCostSelfTotal, _ = decimal.NewFromFloat(operationCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2533. operationCostPartSelfTotal, _ = decimal.NewFromFloat(operationCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2534. operation_fulamt_ownpay_amt, _ = decimal.NewFromFloat(operation_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  2535. if item.ChrgitmLv == "1" {
  2536. operation_claa_sunmfee, _ = decimal.NewFromFloat(operation_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2537. }
  2538. if item.ChrgitmLv == "2" {
  2539. operation_clab_amt, _ = decimal.NewFromFloat(operation_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2540. }
  2541. if item.ChrgitmLv == "3" {
  2542. operation_other_amt, _ = decimal.NewFromFloat(operation_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2543. }
  2544. }
  2545. if item.MedChrgitmType == "08" { //材料费
  2546. materialCostTotal, _ = decimal.NewFromFloat(materialCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2547. materialCostSelfTotal, _ = decimal.NewFromFloat(materialCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2548. materialCostPartSelfTotal, _ = decimal.NewFromFloat(materialCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2549. material_fulamt_ownpay_amt, _ = decimal.NewFromFloat(material_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  2550. if item.ChrgitmLv == "1" {
  2551. material_claa_sunmfee, _ = decimal.NewFromFloat(material_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2552. }
  2553. if item.ChrgitmLv == "2" {
  2554. material_clab_amt, _ = decimal.NewFromFloat(material_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2555. }
  2556. if item.ChrgitmLv == "3" {
  2557. material_other_amt, _ = decimal.NewFromFloat(material_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2558. }
  2559. }
  2560. if item.MedChrgitmType == "09" { //西药费
  2561. westernMedicineCostTotal, _ = decimal.NewFromFloat(westernMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2562. westernMedicineCostSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2563. westernMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2564. westernMedicine_fulamt_ownpay_amt, _ = decimal.NewFromFloat(westernMedicine_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  2565. if item.ChrgitmLv == "1" {
  2566. westernMedicine_claa_sunmfee, _ = decimal.NewFromFloat(westernMedicine_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2567. }
  2568. if item.ChrgitmLv == "2" {
  2569. westernMedicine_clab_amt, _ = decimal.NewFromFloat(westernMedicine_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2570. }
  2571. if item.ChrgitmLv == "3" {
  2572. westernMedicine_other_amt, _ = decimal.NewFromFloat(westernMedicine_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2573. }
  2574. }
  2575. if item.MedChrgitmType == "11" { //中成费
  2576. chineseTraditionalMedicineCostTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2577. chineseTraditionalMedicineCostSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2578. chineseTraditionalMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2579. chineseTraditional_fulamt_ownpay_amt, _ = decimal.NewFromFloat(chineseTraditional_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  2580. if item.ChrgitmLv == "1" {
  2581. chineseTraditional_claa_sunmfee, _ = decimal.NewFromFloat(chineseTraditional_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2582. }
  2583. if item.ChrgitmLv == "2" {
  2584. chineseTraditional_clab_amt, _ = decimal.NewFromFloat(chineseTraditional_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2585. }
  2586. if item.ChrgitmLv == "3" {
  2587. chineseTraditional_other_amt, _ = decimal.NewFromFloat(chineseTraditional_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2588. }
  2589. }
  2590. if item.MedChrgitmType == "14" { //其他费
  2591. otherCostTotal, _ = decimal.NewFromFloat(otherCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2592. otherCostSelfTotal, _ = decimal.NewFromFloat(otherCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2593. otherCostPartSelfTotal, _ = decimal.NewFromFloat(otherCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2594. other_fulamt_ownpay_amt, _ = decimal.NewFromFloat(other_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  2595. if item.ChrgitmLv == "1" {
  2596. other_claa_sunmfee, _ = decimal.NewFromFloat(other_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2597. }
  2598. if item.ChrgitmLv == "2" {
  2599. other_clab_amt, _ = decimal.NewFromFloat(other_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2600. }
  2601. if item.ChrgitmLv == "3" {
  2602. other_other_amt, _ = decimal.NewFromFloat(other_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2603. }
  2604. }
  2605. }
  2606. var iteminfoStructs []service.IteminfoStruct
  2607. if bedCostTotal != 0 {
  2608. iteminfo.MedChrgitm = "01"
  2609. iteminfo.FulamtOwnpayAmt = bed_fulamt_ownpay_amt
  2610. iteminfo.Amt = bedCostTotal
  2611. iteminfo.ClaaSumfee = bed_claa_sunmfee
  2612. iteminfo.ClabAmt = bed_clab_amt
  2613. iteminfo.OthAmt = bed_other_amt
  2614. iteminfoStructs = append(iteminfoStructs, iteminfo)
  2615. }
  2616. if checkCostTotal != 0 {
  2617. iteminfo.MedChrgitm = "03"
  2618. iteminfo.FulamtOwnpayAmt = check_fulamt_ownpay_amt
  2619. iteminfo.Amt = checkCostTotal
  2620. iteminfo.ClaaSumfee = check_claa_sunmfee
  2621. iteminfo.ClabAmt = check_clab_amt
  2622. iteminfo.OthAmt = check_other_amt
  2623. iteminfoStructs = append(iteminfoStructs, iteminfo)
  2624. }
  2625. if laboratoryCostTotal != 0 {
  2626. iteminfo.MedChrgitm = "04"
  2627. iteminfo.FulamtOwnpayAmt = laboratory_fulamt_ownpay_amt
  2628. iteminfo.Amt = laboratoryCostTotal
  2629. iteminfo.ClaaSumfee = laboratory_claa_sunmfee
  2630. iteminfo.ClabAmt = laboratory_clab_amt
  2631. iteminfo.OthAmt = laboratory_other_amt
  2632. iteminfoStructs = append(iteminfoStructs, iteminfo)
  2633. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  2634. }
  2635. if treatCostTotal != 0 {
  2636. iteminfo.MedChrgitm = "05"
  2637. iteminfo.FulamtOwnpayAmt = treat_fulamt_ownpay_amt
  2638. iteminfo.Amt = treatCostTotal
  2639. iteminfo.ClaaSumfee = treat_claa_sunmfee
  2640. iteminfo.ClabAmt = treat_clab_amt
  2641. iteminfo.OthAmt = treat_other_amt
  2642. iteminfoStructs = append(iteminfoStructs, iteminfo)
  2643. //(struct4101.IteminfoStruct, iteminfo)
  2644. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  2645. }
  2646. if operationCostTotal != 0 {
  2647. iteminfo.MedChrgitm = "06"
  2648. iteminfo.FulamtOwnpayAmt = bed_fulamt_ownpay_amt
  2649. iteminfo.Amt = operationCostTotal
  2650. iteminfo.ClaaSumfee = operation_claa_sunmfee
  2651. iteminfo.ClabAmt = operation_clab_amt
  2652. iteminfo.OthAmt = operation_other_amt
  2653. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  2654. iteminfoStructs = append(iteminfoStructs, iteminfo)
  2655. }
  2656. if materialCostTotal != 0 {
  2657. iteminfo.MedChrgitm = "08"
  2658. iteminfo.FulamtOwnpayAmt = material_fulamt_ownpay_amt
  2659. iteminfo.Amt = materialCostTotal
  2660. iteminfo.ClaaSumfee = material_claa_sunmfee
  2661. iteminfo.ClabAmt = material_clab_amt
  2662. iteminfo.OthAmt = material_other_amt
  2663. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  2664. iteminfoStructs = append(iteminfoStructs, iteminfo)
  2665. }
  2666. if westernMedicineCostTotal != 0 {
  2667. iteminfo.MedChrgitm = "09"
  2668. iteminfo.FulamtOwnpayAmt = westernMedicine_fulamt_ownpay_amt
  2669. iteminfo.Amt = westernMedicineCostTotal
  2670. iteminfo.ClaaSumfee = westernMedicine_claa_sunmfee
  2671. iteminfo.ClabAmt = westernMedicine_clab_amt
  2672. iteminfo.OthAmt = westernMedicine_other_amt
  2673. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  2674. iteminfoStructs = append(iteminfoStructs, iteminfo)
  2675. }
  2676. if chineseTraditionalMedicineCostTotal != 0 {
  2677. iteminfo.MedChrgitm = "11"
  2678. iteminfo.FulamtOwnpayAmt = westernMedicine_fulamt_ownpay_amt
  2679. iteminfo.Amt = westernMedicineCostTotal
  2680. iteminfo.ClaaSumfee = westernMedicine_claa_sunmfee
  2681. iteminfo.ClabAmt = westernMedicine_clab_amt
  2682. iteminfo.OthAmt = westernMedicine_other_amt
  2683. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  2684. iteminfoStructs = append(iteminfoStructs, iteminfo)
  2685. }
  2686. if otherCostTotal != 0 {
  2687. iteminfo.MedChrgitm = "14"
  2688. iteminfo.FulamtOwnpayAmt = other_fulamt_ownpay_amt
  2689. iteminfo.Amt = otherCostTotal
  2690. iteminfo.ClaaSumfee = other_claa_sunmfee
  2691. iteminfo.ClabAmt = other_clab_amt
  2692. iteminfo.OthAmt = other_other_amt
  2693. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  2694. iteminfoStructs = append(iteminfoStructs, iteminfo)
  2695. }
  2696. struct4101.IteminfoStruct = iteminfoStructs
  2697. struct4101.Ntly = "中国"
  2698. struct4101.AdmCaty = "A03.06"
  2699. result := service.Gdyb4101(struct4101, miConfig.SecretKey, miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.UserOrgId)
  2700. fmt.Println(result)
  2701. var dat map[string]interface{}
  2702. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  2703. fmt.Println(dat)
  2704. } else {
  2705. fmt.Println(err)
  2706. }
  2707. userJSONBytes, _ := json.Marshal(dat)
  2708. var res ResultSeventeen
  2709. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  2710. utils.ErrorLog("解析失败:%v", err)
  2711. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2712. return
  2713. }
  2714. if res.Infcode != 0 {
  2715. c.ServeSuccessJSON(map[string]interface{}{
  2716. "failed_code": -10,
  2717. "msg": res.ErrMsg,
  2718. })
  2719. return
  2720. } else {
  2721. order.FaPiaoNumber = zero
  2722. order.FaPiaoCode = last_order.FaPiaoCode
  2723. service.UpdateOrder(order)
  2724. hisFundSettleListResult := &models.HisFundSettleListResult{
  2725. Number: res.Output.SetlListId,
  2726. Status: 1,
  2727. Ctime: time.Now().Unix(),
  2728. Mtime: time.Now().Unix(),
  2729. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  2730. IsUpload: 1,
  2731. OrderId: order_id,
  2732. }
  2733. service.CreateUploadRecord(hisFundSettleListResult)
  2734. c.ServeSuccessJSON(map[string]interface{}{
  2735. "msg": "上传成功",
  2736. "result": hisFundSettleListResult,
  2737. })
  2738. return
  2739. }
  2740. }
  2741. func (c *HisApiController) GetBatchSettleList() {
  2742. orders, _ := service.GetAllHisOrder(10106)
  2743. for _, item := range orders {
  2744. order_id := item.ID
  2745. order, _ := service.GetHisOrderByIDTwo(order_id)
  2746. roles, _ := service.GetDoctorListTwo(c.GetAdminUserInfo().CurrentOrgId)
  2747. his, _ := service.GetHisPatientByNumber(order.MdtrtId)
  2748. admin, _ := service.GetAdminUserByUserID(roles[0].AdminUserId)
  2749. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, 2495)
  2750. depart, _ := service.GetDepartMentDetail(curRoles.DepartmentId)
  2751. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  2752. if order.ID == 0 {
  2753. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisOrderNoExistParamWrong)
  2754. return
  2755. }
  2756. if his.BalanceAccountsType == 2 {
  2757. continue
  2758. }
  2759. struct4101 := service.Struct4101{
  2760. PsnNo: order.PsnNo,
  2761. MdtrtId: order.MdtrtId,
  2762. SetlId: order.SetlId,
  2763. PsnName: order.PsnName,
  2764. Gend: order.Gend,
  2765. Brdy: his.Brdy,
  2766. Age: his.Age,
  2767. Naty: order.Naty,
  2768. PatnCertType: "01",
  2769. Certno: order.Certno,
  2770. Prfs: "90",
  2771. ConerName: roles[0].UserName,
  2772. PatnRlts: "99",
  2773. ConerAddr: miConfig.OrgName,
  2774. ConerTel: admin.Mobile,
  2775. HiType: order.Insutype,
  2776. Insuplc: his.InsuplcAdmdvs,
  2777. MaindiagFlag: "1",
  2778. BillCode: order.FaPiaoCode,
  2779. BillNo: order.FaPiaoNumber,
  2780. BizSn: order.Number,
  2781. PsnSelfPay: order.PsnPartAmt,
  2782. PsnOwnPay: order.PsnPartAmt,
  2783. AcctPay: order.AcctPay,
  2784. PsnCashpay: order.PsnCashPay,
  2785. HiPaymtd: "1",
  2786. Hsorg: his.InsuplcAdmdvs,
  2787. HsorgOpter: his.InsuplcAdmdvs,
  2788. MedinsFillPsn: curRoles.UserName,
  2789. MedinsFillDept: depart.Name,
  2790. IptMedType: "2",
  2791. }
  2792. struct4101.SetlBegnDate = order.SetlTime
  2793. struct4101.SetlEndDate = order.SetlTime
  2794. //if order.SettleType == 1 {
  2795. // t := time.Unix(int64(order.SettleAccountsDate), 0)
  2796. // dateStr := t.Format("2006-01-02")
  2797. // struct4101.SetlBegnDate = dateStr
  2798. // struct4101.SetlEndDate = dateStr
  2799. //} else {
  2800. // t := time.Unix(int64(order.SettleStartTime), 0)
  2801. // t2 := time.Unix(int64(order.SettleEndTime), 0)
  2802. // dateStartStr := t.Format("2006-01-02")
  2803. // dateEndStr := t2.Format("2006-01-02")
  2804. // struct4101.SetlBegnDate = dateStartStr
  2805. // struct4101.SetlEndDate = dateEndStr
  2806. //}
  2807. var rf []CustomFundPay
  2808. json.Unmarshal([]byte(order.SetlDetail), &rf)
  2809. var tempFunPays []service.CustomStruct
  2810. var tempFunPay610100 service.CustomStruct
  2811. for _, item := range rf {
  2812. if item.FundPayType == "610100" {
  2813. tempFunPay610100.FundPayamt, _ = decimal.NewFromFloat(tempFunPay610100.FundPayamt).Add(decimal.NewFromFloat(item.FundPayamt)).Float64()
  2814. tempFunPay610100.FundPayType = item.FundPayType
  2815. } else {
  2816. var tempFunPay service.CustomStruct
  2817. tempFunPay.FundPayamt = item.FundPayamt
  2818. tempFunPay.FundPayType = item.FundPayType
  2819. tempFunPays = append(tempFunPays, tempFunPay)
  2820. }
  2821. }
  2822. tempFunPays = append(tempFunPays, tempFunPay610100)
  2823. struct4101.CustomStruct = tempFunPays
  2824. var tempDiaginfos []service.DiaginfoStructTwo
  2825. var tempOpspdiseinfo2 service.OpspdiseinfoStruct
  2826. var tempOpspdiseinfos []service.OpspdiseinfoStruct
  2827. diagnosis_ids := strings.Split(his.Diagnosis, ",")
  2828. var config []*models.HisXtDiagnoseConfig
  2829. for _, item := range diagnosis_ids {
  2830. id, _ := strconv.ParseInt(item, 10, 64)
  2831. diagnosisConfig, _ := service.FindDiagnoseById(id)
  2832. config = append(config, &diagnosisConfig)
  2833. }
  2834. for index, item := range config {
  2835. if index == 0 {
  2836. var tempDiaginfo service.DiaginfoStructTwo
  2837. tempDiaginfo.DiagCode = item.CountryCode
  2838. tempDiaginfo.DiagName = item.CountryContentName
  2839. tempDiaginfo.DiagType = "1"
  2840. tempDiaginfo.MaindiagFlag = "1"
  2841. tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  2842. } else {
  2843. var tempDiaginfo service.DiaginfoStructTwo
  2844. tempDiaginfo.DiagCode = item.CountryCode
  2845. tempDiaginfo.DiagName = item.CountryContentName
  2846. tempDiaginfo.DiagType = "2"
  2847. tempDiaginfo.MaindiagFlag = "0"
  2848. tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  2849. }
  2850. }
  2851. struct4101.Diseinfo = tempDiaginfos
  2852. sickConfigTwo, _ := service.FindSickById(his.SickType)
  2853. tempOpspdiseinfo2.DiagCode = sickConfigTwo.ContentCode
  2854. tempOpspdiseinfo2.DiagName = sickConfigTwo.CountryContentName
  2855. tempOpspdiseinfo2.OprnOprtCode = ""
  2856. tempOpspdiseinfo2.OprnOprtName = ""
  2857. tempOpspdiseinfos = append(tempOpspdiseinfos, tempOpspdiseinfo2)
  2858. struct4101.OpspdiseinfoStruct = tempOpspdiseinfos
  2859. var iteminfo service.IteminfoStruct
  2860. var bedCostTotal float64 = 0 //床位总费
  2861. var bedCostSelfTotal float64 = 0 //床位自费
  2862. var bedCostPartSelfTotal float64 = 0 //床位部分项目自费
  2863. var examineCostTotal float64 = 0 //诊查总费
  2864. var examineCostSelfTotal float64 = 0 //诊查自费
  2865. var examineCostPartSelfTotal float64 = 0 //诊查部分项目自费
  2866. var nursingCostTotal float64 = 0 //护理总费
  2867. var nursingCostSelfTotal float64 = 0 //护理自费
  2868. var nursingCostPartSelfTotal float64 = 0 //护理部分项目自费
  2869. var chineseMedicineCostTotal float64 = 0 //中成药
  2870. var chineseMedicineCostSelfTotal float64 = 0 //中成药
  2871. var chineseMedicineCostPartSelfTotal float64 = 0 //中成药
  2872. var commonlyTreatmentCostTotal float64 = 0 //一般诊疗费
  2873. var commonlyTreatmentCostSelfTotal float64 = 0 //一般诊疗费
  2874. var commonlyTreatmentCostPartSelfTotal float64 = 0 //一般诊疗费
  2875. var registerCostTotal float64 = 0 //一般诊疗费
  2876. var registerCostSelfTotal float64 = 0 //一般诊疗费
  2877. var registerPartSelfTotal float64 = 0 //一般诊疗费
  2878. var operationCostTotal float64 = 0 //手术费
  2879. var operationCostSelfTotal float64 = 0 //手术费
  2880. var operationCostPartSelfTotal float64 = 0 //手术费
  2881. var otherCostTotal float64 = 0 //其他费用
  2882. var otherCostSelfTotal float64 = 0 //其他费用
  2883. var otherCostPartSelfTotal float64 = 0 //其他费用
  2884. var materialCostTotal float64 = 0 //材料费
  2885. var materialCostSelfTotal float64 = 0 //材料费
  2886. var materialCostPartSelfTotal float64 = 0 //材料费
  2887. var westernMedicineCostTotal float64 = 0 //西药费
  2888. var westernMedicineCostSelfTotal float64 = 0 //西药费
  2889. var westernMedicineCostPartSelfTotal float64 = 0 //西药费
  2890. var chineseTraditionalMedicineCostTotal float64 = 0 //中成药
  2891. var chineseTraditionalMedicineCostSelfTotal float64 = 0 //中成药
  2892. var chineseTraditionalMedicineCostPartSelfTotal float64 = 0 //中成药
  2893. var checkCostTotal float64 = 0 //检查费
  2894. var checkCostSelfTotal float64 = 0 //检查费
  2895. var checkCostPartSelfTotal float64 = 0 //检查费
  2896. var laboratoryCostTotal float64 = 0 //化验费
  2897. var laboratoryCostSelfTotal float64 = 0 //化验费
  2898. var laboratoryCostPartSelfTotal float64 = 0 //化验费
  2899. var treatCostTotal float64 = 0 //治疗费用
  2900. var treatCostSelfTotal float64 = 0 //治疗费用
  2901. var treatCostPartSelfTotal float64 = 0 //治疗费用
  2902. decimal.DivisionPrecision = 2
  2903. var bed_fulamt_ownpay_amt float64 = 0
  2904. var examine_fulamt_ownpay_amt float64 = 0
  2905. var nursing_fulamt_ownpay_amt float64 = 0
  2906. var chinese_medicine_fulamt_ownpay_amt float64 = 0
  2907. var commonly_treatment_fulamt_ownpay_amt float64 = 0
  2908. var register_fulamt_ownpay_amt float64 = 0
  2909. var operation_fulamt_ownpay_amt float64 = 0
  2910. var other_fulamt_ownpay_amt float64 = 0
  2911. var westernMedicine_fulamt_ownpay_amt float64 = 0
  2912. var chineseTraditional_fulamt_ownpay_amt float64 = 0
  2913. var check_fulamt_ownpay_amt float64 = 0
  2914. var material_fulamt_ownpay_amt float64 = 0
  2915. var laboratory_fulamt_ownpay_amt float64 = 0
  2916. var treat_fulamt_ownpay_amt float64 = 0
  2917. var bed_claa_sunmfee float64 = 0
  2918. var bed_clab_amt float64 = 0
  2919. var bed_other_amt float64 = 0
  2920. var examine_claa_sunmfee float64 = 0
  2921. var examine_clab_amt float64 = 0
  2922. var examine_other_amt float64 = 0
  2923. var nursing_claa_sunmfee float64 = 0
  2924. var nursing_clab_amt float64 = 0
  2925. var nursing_other_amt float64 = 0
  2926. var chinese_medicine_claa_sunmfee float64 = 0
  2927. var chinese_medicine_clab_amt float64 = 0
  2928. var chinese_medicine_other_amt float64 = 0
  2929. var commonly_treatment_claa_sunmfee float64 = 0
  2930. var commonly_treatment_clab_amt float64 = 0
  2931. var commonly_treatment_other_amt float64 = 0
  2932. var operation_claa_sunmfee float64 = 0
  2933. var operation_clab_amt float64 = 0
  2934. var operation_other_amt float64 = 0
  2935. var other_claa_sunmfee float64 = 0
  2936. var other_clab_amt float64 = 0
  2937. var other_other_amt float64 = 0
  2938. var westernMedicine_claa_sunmfee float64 = 0
  2939. var westernMedicine_clab_amt float64 = 0
  2940. var westernMedicine_other_amt float64 = 0
  2941. var chineseTraditional_claa_sunmfee float64 = 0
  2942. var chineseTraditional_clab_amt float64 = 0
  2943. var chineseTraditional_other_amt float64 = 0
  2944. var check_claa_sunmfee float64 = 0
  2945. var check_clab_amt float64 = 0
  2946. var check_other_amt float64 = 0
  2947. var material_claa_sunmfee float64 = 0
  2948. var material_clab_amt float64 = 0
  2949. var material_other_amt float64 = 0
  2950. var laboratory_claa_sunmfee float64 = 0
  2951. var laboratory_clab_amt float64 = 0
  2952. var laboratory_other_amt float64 = 0
  2953. var treat_claa_sunmfee float64 = 0
  2954. var treat_clab_amt float64 = 0
  2955. var treat_other_amt float64 = 0
  2956. var register_claa_sunmfee float64 = 0
  2957. var register_clab_amt float64 = 0
  2958. var register_other_amt float64 = 0
  2959. for _, item := range order.HisOrderInfo {
  2960. if item.MedChrgitmType == "01" { //床位费
  2961. bedCostTotal, _ = decimal.NewFromFloat(bedCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2962. bedCostSelfTotal, _ = decimal.NewFromFloat(bedCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2963. bedCostPartSelfTotal, _ = decimal.NewFromFloat(bedCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2964. bed_fulamt_ownpay_amt, _ = decimal.NewFromFloat(bed_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  2965. if item.ChrgitmLv == "1" {
  2966. bed_claa_sunmfee, _ = decimal.NewFromFloat(bed_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2967. }
  2968. if item.ChrgitmLv == "2" {
  2969. bed_clab_amt, _ = decimal.NewFromFloat(bed_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2970. }
  2971. if item.ChrgitmLv == "3" {
  2972. bed_other_amt, _ = decimal.NewFromFloat(bed_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2973. }
  2974. }
  2975. if item.MedChrgitmType == "02" { //诊查
  2976. examineCostTotal, _ = decimal.NewFromFloat(examineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2977. examineCostSelfTotal, _ = decimal.NewFromFloat(examineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2978. examineCostPartSelfTotal, _ = decimal.NewFromFloat(examineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2979. examine_fulamt_ownpay_amt, _ = decimal.NewFromFloat(examine_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  2980. if item.ChrgitmLv == "1" {
  2981. examine_claa_sunmfee, _ = decimal.NewFromFloat(examine_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2982. }
  2983. if item.ChrgitmLv == "2" {
  2984. examine_clab_amt, _ = decimal.NewFromFloat(examine_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2985. }
  2986. if item.ChrgitmLv == "3" {
  2987. examine_other_amt, _ = decimal.NewFromFloat(examine_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2988. }
  2989. }
  2990. if item.MedChrgitmType == "03" { //检查费
  2991. checkCostTotal, _ = decimal.NewFromFloat(checkCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2992. checkCostSelfTotal, _ = decimal.NewFromFloat(checkCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2993. checkCostPartSelfTotal, _ = decimal.NewFromFloat(checkCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2994. check_fulamt_ownpay_amt, _ = decimal.NewFromFloat(check_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  2995. if item.ChrgitmLv == "1" {
  2996. check_claa_sunmfee, _ = decimal.NewFromFloat(check_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2997. }
  2998. if item.ChrgitmLv == "2" {
  2999. check_clab_amt, _ = decimal.NewFromFloat(check_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  3000. }
  3001. if item.ChrgitmLv == "3" {
  3002. check_other_amt, _ = decimal.NewFromFloat(check_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  3003. }
  3004. }
  3005. if item.MedChrgitmType == "04" { //化验费
  3006. laboratoryCostTotal, _ = decimal.NewFromFloat(laboratoryCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  3007. laboratoryCostSelfTotal, _ = decimal.NewFromFloat(laboratoryCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  3008. laboratoryCostPartSelfTotal, _ = decimal.NewFromFloat(laboratoryCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  3009. laboratory_fulamt_ownpay_amt, _ = decimal.NewFromFloat(laboratory_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  3010. if item.ChrgitmLv == "1" {
  3011. laboratory_claa_sunmfee, _ = decimal.NewFromFloat(laboratory_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  3012. }
  3013. if item.ChrgitmLv == "2" {
  3014. laboratory_clab_amt, _ = decimal.NewFromFloat(laboratory_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  3015. }
  3016. if item.ChrgitmLv == "3" {
  3017. laboratory_other_amt, _ = decimal.NewFromFloat(laboratory_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  3018. }
  3019. }
  3020. if item.MedChrgitmType == "05" { //治疗费
  3021. treatCostTotal, _ = decimal.NewFromFloat(treatCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  3022. treatCostSelfTotal, _ = decimal.NewFromFloat(treatCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  3023. treatCostPartSelfTotal, _ = decimal.NewFromFloat(treatCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  3024. treat_fulamt_ownpay_amt, _ = decimal.NewFromFloat(treat_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  3025. if item.ChrgitmLv == "1" {
  3026. treat_claa_sunmfee, _ = decimal.NewFromFloat(treat_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  3027. }
  3028. if item.ChrgitmLv == "2" {
  3029. treat_clab_amt, _ = decimal.NewFromFloat(treat_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  3030. }
  3031. if item.ChrgitmLv == "3" {
  3032. treat_other_amt, _ = decimal.NewFromFloat(treat_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  3033. }
  3034. }
  3035. if item.MedChrgitmType == "06" { //手术费
  3036. operationCostTotal, _ = decimal.NewFromFloat(operationCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  3037. operationCostSelfTotal, _ = decimal.NewFromFloat(operationCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  3038. operationCostPartSelfTotal, _ = decimal.NewFromFloat(operationCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  3039. operation_fulamt_ownpay_amt, _ = decimal.NewFromFloat(operation_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  3040. if item.ChrgitmLv == "1" {
  3041. operation_claa_sunmfee, _ = decimal.NewFromFloat(operation_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  3042. }
  3043. if item.ChrgitmLv == "2" {
  3044. operation_clab_amt, _ = decimal.NewFromFloat(operation_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  3045. }
  3046. if item.ChrgitmLv == "3" {
  3047. operation_other_amt, _ = decimal.NewFromFloat(operation_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  3048. }
  3049. }
  3050. if item.MedChrgitmType == "07" { //手术费
  3051. nursingCostTotal, _ = decimal.NewFromFloat(nursingCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  3052. nursingCostSelfTotal, _ = decimal.NewFromFloat(nursingCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  3053. nursingCostPartSelfTotal, _ = decimal.NewFromFloat(nursingCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  3054. nursing_fulamt_ownpay_amt, _ = decimal.NewFromFloat(nursing_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  3055. if item.ChrgitmLv == "1" {
  3056. nursing_claa_sunmfee, _ = decimal.NewFromFloat(nursing_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  3057. }
  3058. if item.ChrgitmLv == "2" {
  3059. nursing_clab_amt, _ = decimal.NewFromFloat(nursing_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  3060. }
  3061. if item.ChrgitmLv == "3" {
  3062. nursing_other_amt, _ = decimal.NewFromFloat(nursing_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  3063. }
  3064. }
  3065. if item.MedChrgitmType == "08" { //材料费
  3066. materialCostTotal, _ = decimal.NewFromFloat(materialCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  3067. materialCostSelfTotal, _ = decimal.NewFromFloat(materialCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  3068. materialCostPartSelfTotal, _ = decimal.NewFromFloat(materialCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  3069. material_fulamt_ownpay_amt, _ = decimal.NewFromFloat(material_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  3070. if item.ChrgitmLv == "1" {
  3071. material_claa_sunmfee, _ = decimal.NewFromFloat(material_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  3072. }
  3073. if item.ChrgitmLv == "2" {
  3074. material_clab_amt, _ = decimal.NewFromFloat(material_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  3075. }
  3076. if item.ChrgitmLv == "3" {
  3077. material_other_amt, _ = decimal.NewFromFloat(material_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  3078. }
  3079. }
  3080. if item.MedChrgitmType == "09" { //西药费
  3081. westernMedicineCostTotal, _ = decimal.NewFromFloat(westernMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  3082. westernMedicineCostSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  3083. westernMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  3084. westernMedicine_fulamt_ownpay_amt, _ = decimal.NewFromFloat(westernMedicine_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  3085. if item.ChrgitmLv == "1" {
  3086. westernMedicine_claa_sunmfee, _ = decimal.NewFromFloat(westernMedicine_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  3087. }
  3088. if item.ChrgitmLv == "2" {
  3089. westernMedicine_clab_amt, _ = decimal.NewFromFloat(westernMedicine_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  3090. }
  3091. if item.ChrgitmLv == "3" {
  3092. westernMedicine_other_amt, _ = decimal.NewFromFloat(westernMedicine_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  3093. }
  3094. }
  3095. if item.MedChrgitmType == "10" { //中药饮片
  3096. chineseMedicineCostTotal, _ = decimal.NewFromFloat(chineseMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  3097. chineseMedicineCostSelfTotal, _ = decimal.NewFromFloat(chineseMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  3098. chineseMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(chineseMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  3099. chinese_medicine_fulamt_ownpay_amt, _ = decimal.NewFromFloat(chinese_medicine_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  3100. if item.ChrgitmLv == "1" {
  3101. chinese_medicine_claa_sunmfee, _ = decimal.NewFromFloat(chinese_medicine_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  3102. }
  3103. if item.ChrgitmLv == "2" {
  3104. chinese_medicine_clab_amt, _ = decimal.NewFromFloat(chinese_medicine_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  3105. }
  3106. if item.ChrgitmLv == "3" {
  3107. chinese_medicine_other_amt, _ = decimal.NewFromFloat(chinese_medicine_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  3108. }
  3109. }
  3110. if item.MedChrgitmType == "11" { //中成费
  3111. chineseTraditionalMedicineCostTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  3112. chineseTraditionalMedicineCostSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  3113. chineseTraditionalMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  3114. chineseTraditional_fulamt_ownpay_amt, _ = decimal.NewFromFloat(chineseTraditional_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  3115. if item.ChrgitmLv == "1" {
  3116. chineseTraditional_claa_sunmfee, _ = decimal.NewFromFloat(chineseTraditional_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  3117. }
  3118. if item.ChrgitmLv == "2" {
  3119. chineseTraditional_clab_amt, _ = decimal.NewFromFloat(chineseTraditional_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  3120. }
  3121. if item.ChrgitmLv == "3" {
  3122. chineseTraditional_other_amt, _ = decimal.NewFromFloat(chineseTraditional_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  3123. }
  3124. }
  3125. if item.MedChrgitmType == "12" { //中成费
  3126. commonlyTreatmentCostTotal, _ = decimal.NewFromFloat(commonlyTreatmentCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  3127. commonlyTreatmentCostSelfTotal, _ = decimal.NewFromFloat(commonlyTreatmentCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  3128. commonlyTreatmentCostPartSelfTotal, _ = decimal.NewFromFloat(commonlyTreatmentCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  3129. commonly_treatment_fulamt_ownpay_amt, _ = decimal.NewFromFloat(commonly_treatment_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  3130. if item.ChrgitmLv == "1" {
  3131. commonly_treatment_claa_sunmfee, _ = decimal.NewFromFloat(commonly_treatment_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  3132. }
  3133. if item.ChrgitmLv == "2" {
  3134. commonly_treatment_clab_amt, _ = decimal.NewFromFloat(commonly_treatment_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  3135. }
  3136. if item.ChrgitmLv == "3" {
  3137. commonly_treatment_other_amt, _ = decimal.NewFromFloat(commonly_treatment_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  3138. }
  3139. }
  3140. if item.MedChrgitmType == "13" { //中成费
  3141. registerCostTotal, _ = decimal.NewFromFloat(registerCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  3142. registerCostSelfTotal, _ = decimal.NewFromFloat(registerCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  3143. registerPartSelfTotal, _ = decimal.NewFromFloat(registerPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  3144. register_fulamt_ownpay_amt, _ = decimal.NewFromFloat(register_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  3145. if item.ChrgitmLv == "1" {
  3146. register_claa_sunmfee, _ = decimal.NewFromFloat(register_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  3147. }
  3148. if item.ChrgitmLv == "2" {
  3149. register_clab_amt, _ = decimal.NewFromFloat(register_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  3150. }
  3151. if item.ChrgitmLv == "3" {
  3152. register_other_amt, _ = decimal.NewFromFloat(register_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  3153. }
  3154. }
  3155. if item.MedChrgitmType == "14" { //其他费
  3156. otherCostTotal, _ = decimal.NewFromFloat(otherCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  3157. otherCostSelfTotal, _ = decimal.NewFromFloat(otherCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  3158. otherCostPartSelfTotal, _ = decimal.NewFromFloat(otherCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  3159. other_fulamt_ownpay_amt, _ = decimal.NewFromFloat(other_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  3160. if item.ChrgitmLv == "1" {
  3161. other_claa_sunmfee, _ = decimal.NewFromFloat(other_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  3162. }
  3163. if item.ChrgitmLv == "2" {
  3164. other_clab_amt, _ = decimal.NewFromFloat(other_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  3165. }
  3166. if item.ChrgitmLv == "3" {
  3167. other_other_amt, _ = decimal.NewFromFloat(other_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  3168. }
  3169. }
  3170. }
  3171. var iteminfoStructs []service.IteminfoStruct
  3172. if bedCostTotal != 0 {
  3173. iteminfo.MedChrgitm = "01"
  3174. iteminfo.FulamtOwnpayAmt = bed_fulamt_ownpay_amt
  3175. iteminfo.Amt = bedCostTotal
  3176. iteminfo.ClaaSumfee = bed_claa_sunmfee
  3177. iteminfo.ClabAmt = bed_clab_amt
  3178. iteminfo.OthAmt = bed_other_amt
  3179. iteminfoStructs = append(iteminfoStructs, iteminfo)
  3180. }
  3181. if examineCostTotal != 0 {
  3182. iteminfo.MedChrgitm = "02"
  3183. iteminfo.FulamtOwnpayAmt = examine_fulamt_ownpay_amt
  3184. iteminfo.Amt = examineCostTotal
  3185. iteminfo.ClaaSumfee = examine_claa_sunmfee
  3186. iteminfo.ClabAmt = examine_clab_amt
  3187. iteminfo.OthAmt = examine_other_amt
  3188. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  3189. iteminfoStructs = append(iteminfoStructs, iteminfo)
  3190. }
  3191. if checkCostTotal != 0 {
  3192. iteminfo.MedChrgitm = "03"
  3193. iteminfo.FulamtOwnpayAmt = check_fulamt_ownpay_amt
  3194. iteminfo.Amt = checkCostTotal
  3195. iteminfo.ClaaSumfee = check_claa_sunmfee
  3196. iteminfo.ClabAmt = check_clab_amt
  3197. iteminfo.OthAmt = check_other_amt
  3198. iteminfoStructs = append(iteminfoStructs, iteminfo)
  3199. }
  3200. if laboratoryCostTotal != 0 {
  3201. iteminfo.MedChrgitm = "04"
  3202. iteminfo.FulamtOwnpayAmt = laboratory_fulamt_ownpay_amt
  3203. iteminfo.Amt = laboratoryCostTotal
  3204. iteminfo.ClaaSumfee = laboratory_claa_sunmfee
  3205. iteminfo.ClabAmt = laboratory_clab_amt
  3206. iteminfo.OthAmt = laboratory_other_amt
  3207. iteminfoStructs = append(iteminfoStructs, iteminfo)
  3208. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  3209. }
  3210. if treatCostTotal != 0 {
  3211. iteminfo.MedChrgitm = "05"
  3212. iteminfo.FulamtOwnpayAmt = treat_fulamt_ownpay_amt
  3213. iteminfo.Amt = treatCostTotal
  3214. iteminfo.ClaaSumfee = treat_claa_sunmfee
  3215. iteminfo.ClabAmt = treat_clab_amt
  3216. iteminfo.OthAmt = treat_other_amt
  3217. iteminfoStructs = append(iteminfoStructs, iteminfo)
  3218. //(struct4101.IteminfoStruct, iteminfo)
  3219. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  3220. }
  3221. if operationCostTotal != 0 {
  3222. iteminfo.MedChrgitm = "06"
  3223. iteminfo.FulamtOwnpayAmt = bed_fulamt_ownpay_amt
  3224. iteminfo.Amt = operationCostTotal
  3225. iteminfo.ClaaSumfee = operation_claa_sunmfee
  3226. iteminfo.ClabAmt = operation_clab_amt
  3227. iteminfo.OthAmt = operation_other_amt
  3228. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  3229. iteminfoStructs = append(iteminfoStructs, iteminfo)
  3230. }
  3231. if nursingCostTotal != 0 {
  3232. iteminfo.MedChrgitm = "07"
  3233. iteminfo.FulamtOwnpayAmt = nursing_fulamt_ownpay_amt
  3234. iteminfo.Amt = nursingCostTotal
  3235. iteminfo.ClaaSumfee = nursing_claa_sunmfee
  3236. iteminfo.ClabAmt = nursing_clab_amt
  3237. iteminfo.OthAmt = nursing_other_amt
  3238. iteminfoStructs = append(iteminfoStructs, iteminfo)
  3239. }
  3240. if materialCostTotal != 0 {
  3241. iteminfo.MedChrgitm = "08"
  3242. iteminfo.FulamtOwnpayAmt = material_fulamt_ownpay_amt
  3243. iteminfo.Amt = materialCostTotal
  3244. iteminfo.ClaaSumfee = material_claa_sunmfee
  3245. iteminfo.ClabAmt = material_clab_amt
  3246. iteminfo.OthAmt = material_other_amt
  3247. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  3248. iteminfoStructs = append(iteminfoStructs, iteminfo)
  3249. }
  3250. if westernMedicineCostTotal != 0 {
  3251. iteminfo.MedChrgitm = "09"
  3252. iteminfo.FulamtOwnpayAmt = westernMedicine_fulamt_ownpay_amt
  3253. iteminfo.Amt = westernMedicineCostTotal
  3254. iteminfo.ClaaSumfee = westernMedicine_claa_sunmfee
  3255. iteminfo.ClabAmt = westernMedicine_clab_amt
  3256. iteminfo.OthAmt = westernMedicine_other_amt
  3257. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  3258. iteminfoStructs = append(iteminfoStructs, iteminfo)
  3259. }
  3260. if chineseMedicineCostTotal != 0 {
  3261. iteminfo.MedChrgitm = "10"
  3262. iteminfo.FulamtOwnpayAmt = chinese_medicine_fulamt_ownpay_amt
  3263. iteminfo.Amt = chineseMedicineCostTotal
  3264. iteminfo.ClaaSumfee = chinese_medicine_claa_sunmfee
  3265. iteminfo.ClabAmt = chinese_medicine_clab_amt
  3266. iteminfo.OthAmt = chinese_medicine_other_amt
  3267. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  3268. iteminfoStructs = append(iteminfoStructs, iteminfo)
  3269. }
  3270. if chineseTraditionalMedicineCostTotal != 0 {
  3271. iteminfo.MedChrgitm = "11"
  3272. iteminfo.FulamtOwnpayAmt = westernMedicine_fulamt_ownpay_amt
  3273. iteminfo.Amt = westernMedicineCostTotal
  3274. iteminfo.ClaaSumfee = westernMedicine_claa_sunmfee
  3275. iteminfo.ClabAmt = westernMedicine_clab_amt
  3276. iteminfo.OthAmt = westernMedicine_other_amt
  3277. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  3278. iteminfoStructs = append(iteminfoStructs, iteminfo)
  3279. }
  3280. if commonlyTreatmentCostTotal != 0 {
  3281. iteminfo.MedChrgitm = "12"
  3282. iteminfo.FulamtOwnpayAmt = commonly_treatment_fulamt_ownpay_amt
  3283. iteminfo.Amt = commonlyTreatmentCostTotal
  3284. iteminfo.ClaaSumfee = commonly_treatment_claa_sunmfee
  3285. iteminfo.ClabAmt = commonly_treatment_clab_amt
  3286. iteminfo.OthAmt = commonly_treatment_other_amt
  3287. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  3288. iteminfoStructs = append(iteminfoStructs, iteminfo)
  3289. }
  3290. if registerCostTotal != 0 {
  3291. iteminfo.MedChrgitm = "13"
  3292. iteminfo.FulamtOwnpayAmt = register_fulamt_ownpay_amt
  3293. iteminfo.Amt = registerCostTotal
  3294. iteminfo.ClaaSumfee = register_claa_sunmfee
  3295. iteminfo.ClabAmt = register_clab_amt
  3296. iteminfo.OthAmt = register_other_amt
  3297. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  3298. iteminfoStructs = append(iteminfoStructs, iteminfo)
  3299. }
  3300. if otherCostTotal != 0 {
  3301. iteminfo.MedChrgitm = "14"
  3302. iteminfo.FulamtOwnpayAmt = other_fulamt_ownpay_amt
  3303. iteminfo.Amt = otherCostTotal
  3304. iteminfo.ClaaSumfee = other_claa_sunmfee
  3305. iteminfo.ClabAmt = other_clab_amt
  3306. iteminfo.OthAmt = other_other_amt
  3307. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  3308. iteminfoStructs = append(iteminfoStructs, iteminfo)
  3309. }
  3310. struct4101.IteminfoStruct = iteminfoStructs
  3311. struct4101.Ntly = "中国"
  3312. struct4101.AdmCaty = "A03.06"
  3313. result := service.Gdyb4101(struct4101, miConfig.SecretKey, miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, c.GetAdminUserInfo().CurrentOrgId)
  3314. fmt.Println(result)
  3315. var dat map[string]interface{}
  3316. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  3317. fmt.Println(dat)
  3318. } else {
  3319. fmt.Println(err)
  3320. }
  3321. userJSONBytes, _ := json.Marshal(dat)
  3322. var res ResultSeventeen
  3323. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  3324. utils.ErrorLog("解析失败:%v", err)
  3325. //c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3326. adminUser := c.GetAdminUserInfo()
  3327. errlog := &models.HisOrderError{
  3328. UserOrgId: adminUser.CurrentOrgId,
  3329. Ctime: time.Now().Unix(),
  3330. Mtime: time.Now().Unix(),
  3331. ErrMsg: res.ErrMsg + "解析失败",
  3332. Status: 1,
  3333. PatientId: order_id,
  3334. Stage: 10106,
  3335. }
  3336. service.CreateErrMsgLog(errlog)
  3337. continue
  3338. }
  3339. if res.Infcode != 0 {
  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. } else {
  3353. hisFundSettleListResult := &models.HisFundSettleListResult{
  3354. Number: res.Output.SetlListId,
  3355. Status: 1,
  3356. Ctime: time.Now().Unix(),
  3357. Mtime: time.Now().Unix(),
  3358. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  3359. IsUpload: 1,
  3360. OrderId: order_id,
  3361. }
  3362. service.CreateUploadRecord(hisFundSettleListResult)
  3363. continue
  3364. }
  3365. }
  3366. }
  3367. func (c *HisApiController) GetOrgInfo() {
  3368. miConfig, _ := service.FindMedicalInsuranceInfo(4)
  3369. service.Gdyb1201("", miConfig.OrgName, "1122", miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, 1, "")
  3370. }
  3371. func (c *HisApiController) GetHisPatientInfo() {
  3372. medical_insurance_card := c.GetString("medical_insurance_card")
  3373. id_card_type, _ := c.GetInt64("id_card_type")
  3374. id_card := c.GetString("id_card")
  3375. adminInfo := c.GetAdminUserInfo()
  3376. config, _ := service.GetMedicalInsuranceConfig(adminInfo.CurrentOrgId)
  3377. miConfig, _ := service.FindMedicalInsuranceInfo(adminInfo.CurrentOrgId)
  3378. appRole, _ := service.GetAppRole(adminInfo.CurrentOrgId)
  3379. IdCardNo := ""
  3380. if id_card_type == 1 {
  3381. IdCardNo = medical_insurance_card
  3382. } else if id_card_type == 2 {
  3383. IdCardNo = id_card
  3384. }
  3385. if config.IsOpen == 1 {
  3386. 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
  3387. resp, requestErr := http.Get(api)
  3388. if requestErr != nil {
  3389. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3390. return
  3391. }
  3392. defer resp.Body.Close()
  3393. body, ioErr := ioutil.ReadAll(resp.Body)
  3394. if ioErr != nil {
  3395. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  3396. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3397. return
  3398. }
  3399. var respJSON map[string]interface{}
  3400. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  3401. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  3402. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3403. return
  3404. }
  3405. userJSON := respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  3406. userJSONBytes, _ := json.Marshal(userJSON)
  3407. var res ResultTwo
  3408. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  3409. utils.ErrorLog("解析失败:%v", err)
  3410. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3411. return
  3412. }
  3413. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  3414. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  3415. infoStr := string(Iinfos)
  3416. idetinfoStr := string(Idetinfos)
  3417. if res.Infcode == 0 {
  3418. his := models.VMHisPatient{
  3419. Status: 1,
  3420. Ctime: time.Now().Unix(),
  3421. Mtime: time.Now().Unix(),
  3422. PsnNo: res.Output.Baseinfo.PsnNo,
  3423. PsnCertType: res.Output.Baseinfo.PsnCertType,
  3424. Certno: res.Output.Baseinfo.Certno,
  3425. PsnName: res.Output.Baseinfo.PsnName,
  3426. Gend: res.Output.Baseinfo.Gend,
  3427. Naty: res.Output.Baseinfo.Naty,
  3428. Brdy: res.Output.Baseinfo.Brdy,
  3429. Age: res.Output.Baseinfo.Age,
  3430. Iinfo: infoStr,
  3431. Idetinfo: idetinfoStr,
  3432. UserOrgId: adminInfo.CurrentOrgId,
  3433. IsReturn: 1,
  3434. IdCardType: id_card_type,
  3435. }
  3436. c.ServeSuccessJSON(map[string]interface{}{
  3437. "info": his,
  3438. })
  3439. } else {
  3440. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  3441. return
  3442. }
  3443. }
  3444. }
  3445. //func GetBasBaseInfo() (jsonStr string, err error) {
  3446. //
  3447. // handle := syscall.NewLazyDLL("SSCard.dll")
  3448. // add := handle.NewProc("ReadCardBas")
  3449. // str := make([]byte, 1024)
  3450. // str1 := make([]byte, 1024)
  3451. // ret, _, _ := add.Call((uintptr)(unsafe.Pointer(&str[0])), IntPtr(1024), (uintptr)(unsafe.Pointer(&str1[0])), IntPtr(1024))
  3452. // fmt.Println(ConvertToString(string(str), "gbk", "utf-8"))
  3453. //
  3454. // fmt.Println(ConvertToString(string(str1), "gbk", "utf-8"))
  3455. //
  3456. // fmt.Println("> Add(4,5)的结果为:", ret)
  3457. // handle.Release()
  3458. //
  3459. // return "", nil
  3460. //
  3461. //}
  3462. //func GetQRBaseInfo() (jsonStr string, err error) {
  3463. // handle := syscall.LoadDLL("SSCard.dll")
  3464. // ReadCardBas := handle.FindProc("GetQRBase")
  3465. //
  3466. // str := make([]byte, 256)
  3467. // str1 := make([]byte, 256)
  3468. // r, _, _ := ReadCardBas.Call((uintptr)(unsafe.Pointer(&str[0])), IntPtr(1024), (uintptr)(unsafe.Pointer(&str1[0])), IntPtr(1024))
  3469. //
  3470. // fmt.Println(string(str))
  3471. // fmt.Println(r)
  3472. // return string(str), nil
  3473. //}
  3474. //func CardInit() int {
  3475. // DllTestDef := syscall.MustLoadDLL("SSCard.dll")
  3476. // add := DllTestDef.MustFindProc("Init")
  3477. // ret, _, err := add.Call(StrPtr("http://igb.hsa.gdgov.cn/gdyb_inf/poc/api/card/initDll"), StrPtr("440200"))
  3478. // if err != nil {
  3479. // fmt.Println("SSCard的运算结果为:", ret)
  3480. // }
  3481. // result := int(ret)
  3482. // return result
  3483. //}
  3484. //func CardInit() int {
  3485. // ret, _, err := add.Call(StrPtr("http://igb.hsa.gdgov.cn/gdyb_inf/poc/api/card/initDll"), StrPtr("440200"))
  3486. // if err != nil {
  3487. // fmt.Println("SSCard的运算结果为:", ret)
  3488. // }
  3489. // fmt.Println(err)
  3490. // result := int(ret)
  3491. // return result
  3492. //}
  3493. func IntPtr(n int) uintptr {
  3494. return uintptr(n)
  3495. }
  3496. func StrPtr(s string) uintptr {
  3497. return uintptr(unsafe.Pointer(syscall.StringBytePtr(s)))
  3498. }
  3499. type Result2001 struct {
  3500. Cainfo interface{} `json:"cainfo"`
  3501. ErrMsg string `json:"err_msg"`
  3502. InfRefmsgid string `json:"inf_refmsgid"`
  3503. Infcode int64 `json:"infcode"`
  3504. Output struct {
  3505. Trtinfo struct {
  3506. PsnNo string `json:"psn_no"`
  3507. TrtChkType string `json:"trt_chk_type"`
  3508. FundPayType string `json:"fund_pay_type"`
  3509. TrtEnjymntFlag string `json:"trt_enjymnt_flag"`
  3510. Begndate string `json:"begndate"`
  3511. Enddate string `json:"enddate"`
  3512. TrtChkRslt string `json:"trt_chk_rslt"`
  3513. } `json:"trtinfo"`
  3514. } `json:"output"`
  3515. RefmsgTime string `json:"refmsg_time"`
  3516. RespondTime string `json:"respond_time"`
  3517. Signtype interface{} `json:"signtype"`
  3518. WarnMsg interface{} `json:"warn_msg"`
  3519. }
  3520. type Result2001Org10265 struct {
  3521. Cainfo interface{} `json:"cainfo"`
  3522. ErrMsg string `json:"err_msg"`
  3523. InfRefmsgid string `json:"inf_refmsgid"`
  3524. Infcode string `json:"infcode"`
  3525. Output struct {
  3526. Trtinfo struct {
  3527. PsnNo string `json:"psn_no"`
  3528. TrtChkType string `json:"trt_chk_type"`
  3529. FundPayType string `json:"fund_pay_type"`
  3530. TrtEnjymntFlag string `json:"trt_enjymnt_flag"`
  3531. Begndate string `json:"begndate"`
  3532. Enddate string `json:"enddate"`
  3533. TrtChkRslt string `json:"trt_chk_rslt"`
  3534. } `json:"trtinfo"`
  3535. } `json:"output"`
  3536. RefmsgTime string `json:"refmsg_time"`
  3537. RespondTime string `json:"respond_time"`
  3538. Signtype interface{} `json:"signtype"`
  3539. WarnMsg interface{} `json:"warn_msg"`
  3540. }
  3541. type ResultTwo struct {
  3542. ErrMsg string `json:"err_msg"`
  3543. InfRefmsgid string `json:"inf_refmsgid"`
  3544. Infcode int64 `json:"infcode"`
  3545. Output struct {
  3546. Baseinfo struct {
  3547. Age float64 `json:"age"`
  3548. Brdy string `json:"brdy"`
  3549. Certno string `json:"certno"`
  3550. Gend string `json:"gend"`
  3551. Naty string `json:"naty"`
  3552. PsnCertType string `json:"psn_cert_type"`
  3553. PsnName string `json:"psn_name"`
  3554. PsnNo string `json:"psn_no"`
  3555. } `json:"baseinfo"`
  3556. Idetinfo []interface{} `json:"idetinfo"`
  3557. Iinfo []struct {
  3558. Balc float64 `json:"balc"`
  3559. CvlservFlag string `json:"cvlserv_flag"`
  3560. EmpName string `json:"emp_name"`
  3561. InsuplcAdmdvs string `json:"insuplc_admdvs"`
  3562. Insutype string `json:"insutype"`
  3563. PausInsuDansuplcAdmdvs string `json:"paus_insu_dansuplc_admdvs"`
  3564. PausInsuDate string `json:"paus_insu_date"`
  3565. PsnInsuDate string `json:"psn_insu_date"`
  3566. PsnInsuStas string `json:"psn_insu_stas"`
  3567. PsnType string `json:"psn_type"`
  3568. } `json:"insuinfo"`
  3569. } `json:"output"`
  3570. RefmsgTime string `json:"refmsg_time"`
  3571. RespondTime string `json:"respond_time"`
  3572. Signtype interface{} `json:"signtype"`
  3573. WarnInfo interface{} `json:"warn_info"`
  3574. }
  3575. type ResultTwo10265 struct {
  3576. ErrMsg string `json:"err_msg"`
  3577. InfRefmsgid string `json:"inf_refmsgid"`
  3578. Infcode string `json:"infcode"`
  3579. Output struct {
  3580. Baseinfo struct {
  3581. Age float64 `json:"age"`
  3582. Brdy string `json:"brdy"`
  3583. Certno string `json:"certno"`
  3584. Gend string `json:"gend"`
  3585. Naty string `json:"naty"`
  3586. PsnCertType string `json:"psn_cert_type"`
  3587. PsnName string `json:"psn_name"`
  3588. PsnNo string `json:"psn_no"`
  3589. } `json:"baseinfo"`
  3590. Idetinfo []interface{} `json:"idetinfo"`
  3591. Iinfo []struct {
  3592. Balc float64 `json:"balc"`
  3593. CvlservFlag string `json:"cvlserv_flag"`
  3594. EmpName string `json:"emp_name"`
  3595. InsuplcAdmdvs string `json:"insuplc_admdvs"`
  3596. Insutype string `json:"insutype"`
  3597. PausInsuDansuplcAdmdvs string `json:"paus_insu_dansuplc_admdvs"`
  3598. PausInsuDate string `json:"paus_insu_date"`
  3599. PsnInsuDate string `json:"psn_insu_date"`
  3600. PsnInsuStas string `json:"psn_insu_stas"`
  3601. PsnType string `json:"psn_type"`
  3602. } `json:"insuinfo"`
  3603. } `json:"output"`
  3604. RefmsgTime string `json:"refmsg_time"`
  3605. RespondTime string `json:"respond_time"`
  3606. Signtype interface{} `json:"signtype"`
  3607. WarnInfo interface{} `json:"warn_info"`
  3608. }
  3609. type ResultThree struct {
  3610. Cainfo interface{} `json:"cainfo"`
  3611. ErrMsg string `json:"err_msg"`
  3612. InfRefmsgid string `json:"inf_refmsgid"`
  3613. Infcode int64 `json:"infcode"`
  3614. Output struct {
  3615. Data struct {
  3616. IptOtpNo string `json:"ipt_otp_no"`
  3617. MdtrtID string `json:"mdtrt_id"`
  3618. PsnNo string `json:"psn_no"`
  3619. } `json:"data"`
  3620. } `json:"output"`
  3621. RefmsgTime string `json:"refmsg_time"`
  3622. RespondTime string `json:"respond_time"`
  3623. Signtype interface{} `json:"signtype"`
  3624. WarnMsg interface{} `json:"warn_msg"`
  3625. }
  3626. type ResultThree10265 struct {
  3627. Cainfo interface{} `json:"cainfo"`
  3628. ErrMsg string `json:"err_msg"`
  3629. InfRefmsgid string `json:"inf_refmsgid"`
  3630. Infcode string `json:"infcode"`
  3631. Output struct {
  3632. Data struct {
  3633. IptOtpNo string `json:"ipt_otp_no"`
  3634. MdtrtID string `json:"mdtrt_id"`
  3635. PsnNo string `json:"psn_no"`
  3636. } `json:"data"`
  3637. } `json:"output"`
  3638. RefmsgTime string `json:"refmsg_time"`
  3639. RespondTime string `json:"respond_time"`
  3640. Signtype interface{} `json:"signtype"`
  3641. WarnMsg interface{} `json:"warn_msg"`
  3642. }
  3643. type ResultFour struct {
  3644. Cainfo string `json:"cainfo"`
  3645. ErrMsg string `json:"err_msg"`
  3646. InfRefmsgid string `json:"inf_refmsgid"`
  3647. Infcode int64 `json:"infcode"`
  3648. Output struct {
  3649. Result []struct {
  3650. BasMednFlag string `json:"bas_medn_flag"`
  3651. ChldMedcFlag string `json:"chld_medc_flag"`
  3652. ChrgitmLv string `json:"chrgitm_lv"`
  3653. Cnt float64 `json:"cnt"`
  3654. DetItemFeeSumamt float64 `json:"det_item_fee_sumamt"`
  3655. DrtReimFlag string `json:"drt_reim_flag"`
  3656. FeedetlSn string `json:"feedetl_sn"`
  3657. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  3658. HiNegoDrugFlag string `json:"hi_nego_drug_flag"`
  3659. InscpScpAmt float64 `json:"inscp_scp_amt"`
  3660. ListSpItemFlag string `json:"list_sp_item_flag"`
  3661. LmtUsedFlag string `json:"lmt_used_flag"`
  3662. MedChrgitmType string `json:"med_chrgitm_type"`
  3663. Memo string `json:"memo"`
  3664. OverlmtAmt float64 `json:"overlmt_amt"`
  3665. PreselfpayAmt float64 `json:"preselfpay_amt"`
  3666. Pric float64 `json:"pric"`
  3667. PricUplmtAmt float64 `json:"pric_uplmt_amt"`
  3668. SelfpayProp float64 `json:"selfpay_prop"`
  3669. } `json:"result"`
  3670. } `json:"output"`
  3671. RefmsgTime string `json:"refmsg_time"`
  3672. RespondTime string `json:"respond_time"`
  3673. Signtype string `json:"signtype"`
  3674. WarnMsg string `json:"warn_msg"`
  3675. }
  3676. type ResultFour10265 struct {
  3677. Cainfo string `json:"cainfo"`
  3678. ErrMsg string `json:"err_msg"`
  3679. InfRefmsgid string `json:"inf_refmsgid"`
  3680. Infcode string `json:"infcode"`
  3681. Output struct {
  3682. Result []struct {
  3683. BasMednFlag string `json:"bas_medn_flag"`
  3684. ChldMedcFlag string `json:"chld_medc_flag"`
  3685. ChrgitmLv string `json:"chrgitm_lv"`
  3686. Cnt float64 `json:"cnt"`
  3687. DetItemFeeSumamt float64 `json:"det_item_fee_sumamt"`
  3688. DrtReimFlag string `json:"drt_reim_flag"`
  3689. FeedetlSn string `json:"feedetl_sn"`
  3690. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  3691. HiNegoDrugFlag string `json:"hi_nego_drug_flag"`
  3692. InscpScpAmt float64 `json:"inscp_scp_amt"`
  3693. ListSpItemFlag string `json:"list_sp_item_flag"`
  3694. LmtUsedFlag string `json:"lmt_used_flag"`
  3695. MedChrgitmType string `json:"med_chrgitm_type"`
  3696. Memo string `json:"memo"`
  3697. OverlmtAmt float64 `json:"overlmt_amt"`
  3698. PreselfpayAmt float64 `json:"preselfpay_amt"`
  3699. Pric float64 `json:"pric"`
  3700. PricUplmtAmt float64 `json:"pric_uplmt_amt"`
  3701. SelfpayProp float64 `json:"selfpay_prop"`
  3702. } `json:"result"`
  3703. } `json:"output"`
  3704. RefmsgTime string `json:"refmsg_time"`
  3705. RespondTime string `json:"respond_time"`
  3706. Signtype string `json:"signtype"`
  3707. WarnMsg string `json:"warn_msg"`
  3708. }
  3709. type ResultFive struct {
  3710. Balc float64 `json:"balc"`
  3711. CvlservFlag string `json:"cvlserv_flag"`
  3712. EmpName string `json:"emp_name"`
  3713. InsuplcAdmdvs string `json:"insuplc_admdvs"`
  3714. Insutype string `json:"insutype"`
  3715. PausInsuDansuplcAdmdvs string `json:"paus_insu_dansuplc_admdvs"`
  3716. PausInsuDate string `json:"paus_insu_date"`
  3717. PsnInsuDate string `json:"psn_insu_date"`
  3718. PsnInsuStas string `json:"psn_insu_stas"`
  3719. PsnType string `json:"psn_type"`
  3720. }
  3721. type ResultSix struct {
  3722. Cainfo interface{} `json:"cainfo"`
  3723. ErrMsg string `json:"err_msg"`
  3724. InfRefmsgid string `json:"inf_refmsgid"`
  3725. Infcode int64 `json:"infcode"`
  3726. Output struct {
  3727. } `json:"output"`
  3728. RefmsgTime string `json:"refmsg_time"`
  3729. RespondTime string `json:"respond_time"`
  3730. Signtype interface{} `json:"signtype"`
  3731. WarnMsg interface{} `json:"warn_msg"`
  3732. }
  3733. type ResultSix10265 struct {
  3734. Cainfo interface{} `json:"cainfo"`
  3735. ErrMsg string `json:"err_msg"`
  3736. InfRefmsgid string `json:"inf_refmsgid"`
  3737. Infcode string `json:"infcode"`
  3738. Output struct {
  3739. } `json:"output"`
  3740. RefmsgTime string `json:"refmsg_time"`
  3741. RespondTime string `json:"respond_time"`
  3742. Signtype interface{} `json:"signtype"`
  3743. WarnMsg interface{} `json:"warn_msg"`
  3744. }
  3745. type ResultSeven struct {
  3746. Cainfo string `json:"cainfo"`
  3747. ErrMsg string `json:"err_msg"`
  3748. InfRefmsgid string `json:"inf_refmsgid"`
  3749. Infcode int64 `json:"infcode"`
  3750. Output struct {
  3751. Setldetail []interface{} `json:"setldetail"`
  3752. Setlinfo struct {
  3753. AcctMulaidPay float64 `json:"acct_mulaid_pay"`
  3754. AcctPay float64 `json:"acct_pay"`
  3755. ActPayDedc float64 `json:"act_pay_dedc"`
  3756. Age float64 `json:"age"`
  3757. Balc float64 `json:"balc"`
  3758. Brdy string `json:"brdy"`
  3759. Certno string `json:"certno"`
  3760. ClrOptins string `json:"clr_optins"`
  3761. ClrType string `json:"clr_type"`
  3762. ClrWay string `json:"clr_way"`
  3763. CvlservFlag string `json:"cvlserv_flag"`
  3764. CvlservPay float64 `json:"cvlserv_pay"`
  3765. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  3766. FundPaySumamt float64 `json:"fund_pay_sumamt"`
  3767. Gend string `json:"gend"`
  3768. HifesPay float64 `json:"hifes_pay"`
  3769. HifmiPay float64 `json:"hifmi_pay"`
  3770. HifpPay float64 `json:"hifp_pay"`
  3771. HospPartAmt float64 `json:"hosp_part_amt"`
  3772. InscpScpAmt float64 `json:"inscp_scp_amt"`
  3773. Insutype string `json:"insutype"`
  3774. MafPay float64 `json:"maf_pay"`
  3775. MdtrtCertType string `json:"mdtrt_cert_type"`
  3776. HifobPay float64 `json:"hifob_pay"`
  3777. MdtrtID string `json:"mdtrt_id"`
  3778. MedType string `json:"med_type"`
  3779. MedfeeSumamt float64 `json:"medfee_sumamt"`
  3780. MedinsSetlID string `json:"medins_setl_id"`
  3781. Naty string `json:"naty"`
  3782. OthPay float64 `json:"oth_pay"`
  3783. OverlmtSelfpay float64 `json:"overlmt_selfpay"`
  3784. PoolPropSelfpay float64 `json:"pool_prop_selfpay"`
  3785. PreselfpayAmt float64 `json:"preselfpay_amt"`
  3786. PsnCashPay float64 `json:"psn_cash_pay"`
  3787. PsnCertType string `json:"psn_cert_type"`
  3788. PsnName string `json:"psn_name"`
  3789. PsnNo string `json:"psn_no"`
  3790. PsnPartAmt float64 `json:"psn_part_amt"`
  3791. PsnType string `json:"psn_type"`
  3792. SetlID string `json:"setl_id"`
  3793. SetlTime string `json:"setl_time"`
  3794. } `json:"setlinfo"`
  3795. } `json:"output"`
  3796. RefmsgTime string `json:"refmsg_time"`
  3797. RespondTime string `json:"respond_time"`
  3798. Signtype interface{} `json:"signtype"`
  3799. WarnMsg interface{} `json:"warn_msg"`
  3800. }
  3801. type ResultSeven10265 struct {
  3802. Cainfo string `json:"cainfo"`
  3803. ErrMsg string `json:"err_msg"`
  3804. InfRefmsgid string `json:"inf_refmsgid"`
  3805. Infcode string `json:"infcode"`
  3806. Output struct {
  3807. Setldetail []interface{} `json:"setldetail"`
  3808. Setlinfo struct {
  3809. AcctMulaidPay float64 `json:"acct_mulaid_pay"`
  3810. AcctPay float64 `json:"acct_pay"`
  3811. ActPayDedc float64 `json:"act_pay_dedc"`
  3812. Age float64 `json:"age"`
  3813. Balc float64 `json:"balc"`
  3814. Brdy string `json:"brdy"`
  3815. Certno string `json:"certno"`
  3816. ClrOptins string `json:"clr_optins"`
  3817. ClrType string `json:"clr_type"`
  3818. ClrWay string `json:"clr_way"`
  3819. CvlservFlag string `json:"cvlserv_flag"`
  3820. CvlservPay float64 `json:"cvlserv_pay"`
  3821. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  3822. FundPaySumamt float64 `json:"fund_pay_sumamt"`
  3823. Gend string `json:"gend"`
  3824. HifesPay float64 `json:"hifes_pay"`
  3825. HifmiPay float64 `json:"hifmi_pay"`
  3826. HifpPay float64 `json:"hifp_pay"`
  3827. HospPartAmt float64 `json:"hosp_part_amt"`
  3828. InscpScpAmt float64 `json:"inscp_scp_amt"`
  3829. Insutype string `json:"insutype"`
  3830. MafPay float64 `json:"maf_pay"`
  3831. MdtrtCertType string `json:"mdtrt_cert_type"`
  3832. HifobPay float64 `json:"hifob_pay"`
  3833. MdtrtID string `json:"mdtrt_id"`
  3834. MedType string `json:"med_type"`
  3835. MedfeeSumamt float64 `json:"medfee_sumamt"`
  3836. MedinsSetlID string `json:"medins_setl_id"`
  3837. Naty string `json:"naty"`
  3838. OthPay float64 `json:"oth_pay"`
  3839. OverlmtSelfpay float64 `json:"overlmt_selfpay"`
  3840. PoolPropSelfpay float64 `json:"pool_prop_selfpay"`
  3841. PreselfpayAmt float64 `json:"preselfpay_amt"`
  3842. PsnCashPay float64 `json:"psn_cash_pay"`
  3843. PsnCertType string `json:"psn_cert_type"`
  3844. PsnName string `json:"psn_name"`
  3845. PsnNo string `json:"psn_no"`
  3846. PsnPartAmt float64 `json:"psn_part_amt"`
  3847. PsnType string `json:"psn_type"`
  3848. SetlID string `json:"setl_id"`
  3849. SetlTime string `json:"setl_time"`
  3850. } `json:"setlinfo"`
  3851. } `json:"output"`
  3852. RefmsgTime string `json:"refmsg_time"`
  3853. RespondTime string `json:"respond_time"`
  3854. Signtype interface{} `json:"signtype"`
  3855. WarnMsg interface{} `json:"warn_msg"`
  3856. }
  3857. type ResultEight struct {
  3858. Cainfo string `json:"cainfo"`
  3859. ErrMsg string `json:"err_msg"`
  3860. InfRefmsgid string `json:"inf_refmsgid"`
  3861. Infcode int64 `json:"infcode"`
  3862. Output struct {
  3863. Stmtinfo struct {
  3864. SetlOptins string `json:"setl_optins"`
  3865. StmtRslt string `json:"stmt_rslt"`
  3866. StmtRsltDscr string `json:"stmt_rslt_dscr"`
  3867. } `json:"stmtinfo"`
  3868. } `json:"output"`
  3869. RefmsgTime string `json:"refmsg_time"`
  3870. RespondTime string `json:"respond_time"`
  3871. Signtype interface{} `json:"signtype"`
  3872. WarnMsg interface{} `json:"warn_msg"`
  3873. }
  3874. type ResultEightFor10188 struct {
  3875. Cainfo string `json:"cainfo"`
  3876. ErrMsg string `json:"err_msg"`
  3877. InfRefmsgid string `json:"inf_refmsgid"`
  3878. Infcode string `json:"infcode"`
  3879. Output struct {
  3880. Stmtinfo struct {
  3881. SetlOptins string `json:"setl_optins"`
  3882. StmtRslt string `json:"stmt_rslt"`
  3883. StmtRsltDscr string `json:"stmt_rslt_dscr"`
  3884. } `json:"stmtinfo"`
  3885. } `json:"output"`
  3886. RefmsgTime string `json:"refmsg_time"`
  3887. RespondTime string `json:"respond_time"`
  3888. Signtype interface{} `json:"signtype"`
  3889. WarnMsg interface{} `json:"warn_msg"`
  3890. }
  3891. type ResultNine struct {
  3892. Cainfo string `json:"cainfo"`
  3893. ErrMsg string `json:"err_msg"`
  3894. InfRefmsgid string `json:"inf_refmsgid"`
  3895. Infcode int64 `json:"infcode"`
  3896. Output struct {
  3897. FileQuryNo string `json:"file_qury_no"`
  3898. } `json:"output"`
  3899. RefmsgTime string `json:"refmsg_time"`
  3900. RespondTime string `json:"respond_time"`
  3901. Signtype interface{} `json:"signtype"`
  3902. WarnMsg interface{} `json:"warn_msg"`
  3903. }
  3904. type ResultTen struct {
  3905. Cainfo string `json:"cainfo"`
  3906. ErrMsg string `json:"err_msg"`
  3907. InfRefmsgid string `json:"inf_refmsgid"`
  3908. Infcode int64 `json:"infcode"`
  3909. Output struct {
  3910. DldEndtime string `json:"dld_endtime"`
  3911. FileQuryNo string `json:"file_qury_no"`
  3912. Filename string `json:"filename"`
  3913. } `json:"output"`
  3914. RefmsgTime string `json:"refmsg_time"`
  3915. RespondTime string `json:"respond_time"`
  3916. Signtype interface{} `json:"signtype"`
  3917. WarnMsg interface{} `json:"warn_msg"`
  3918. }
  3919. //type Autogenerated struct {
  3920. // Output struct {
  3921. // Setlinfo struct {
  3922. // SetlTime string `json:"setl_time"`
  3923. // CvlservPay float64 `json:"cvlserv_pay"`
  3924. // Year string `json:"year"`
  3925. // MedType string `json:"med_type"`
  3926. // PsnPay float64 `json:"psn_pay"`
  3927. // OpterID string `json:"opter_id"`
  3928. // Begndate string `json:"begndate"`
  3929. // FlxempeFlag string `json:"flxempe_flag"`
  3930. // HifmiPay float64 `json:"hifmi_pay"`
  3931. // PsnNo string `json:"psn_no"`
  3932. // ActPayDedc float64 `json:"act_pay_dedc"`
  3933. // MedinsSetlID interface{} `json:"medins_setl_id"`
  3934. // AcctMulaidPay interface{} `json:"acct_mulaid_pay"`
  3935. // ClrWay string `json:"clr_way"`
  3936. // OthPay float64 `json:"oth_pay"`
  3937. // Gend string `json:"gend"`
  3938. // MdtrtID string `json:"mdtrt_id"`
  3939. // AcctPay float64 `json:"acct_pay"`
  3940. // InscpScpAmt float64 `json:"inscp_scp_amt"`
  3941. // Insutype string `json:"insutype"`
  3942. // Invono interface{} `json:"invono"`
  3943. // Enddate string `json:"enddate"`
  3944. // CashPayamt float64 `json:"cash_payamt"`
  3945. // PsnType string `json:"psn_type"`
  3946. // FixmedinsName string `json:"fixmedins_name"`
  3947. // HifpPay float64 `json:"hifp_pay"`
  3948. // NewFlag interface{} `json:"new_flag"`
  3949. // OverlmtSelfpay float64 `json:"overlmt_selfpay"`
  3950. // PreselfpayAmt float64 `json:"preselfpay_amt"`
  3951. // PayLoc string `json:"pay_loc"`
  3952. // ClrType string `json:"clr_type"`
  3953. // RefdSetlFlag string `json:"refd_setl_flag"`
  3954. // CvlservFlag string `json:"cvlserv_flag"`
  3955. // EmpName string `json:"emp_name"`
  3956. // Brdy string `json:"brdy"`
  3957. // Naty string `json:"naty"`
  3958. // Certno string `json:"certno"`
  3959. // DiseCode string `json:"dise_code"`
  3960. // FixmedinsCode string `json:"fixmedins_code"`
  3961. // DedcHospLv string `json:"dedc_hosp_lv"`
  3962. // OpterName string `json:"opter_name"`
  3963. // Balc float64 `json:"balc"`
  3964. // FixmedinsPoolarea string `json:"fixmedins_poolarea"`
  3965. // PsnCertType string `json:"psn_cert_type"`
  3966. // HifobPay float64 `json:"hifob_pay"`
  3967. // MedfeeSumamt float64 `json:"medfee_sumamt"`
  3968. // HifesPay float64 `json:"hifes_pay"`
  3969. // FundPaySumamt float64 `json:"fund_pay_sumamt"`
  3970. // OptTime string `json:"opt_time"`
  3971. // FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  3972. // SetlID string `json:"setl_id"`
  3973. // MafPay float64 `json:"maf_pay"`
  3974. // PsnName string `json:"psn_name"`
  3975. // InsuOptins interface{} `json:"insu_optins"`
  3976. // PrefFundPay interface{} `json:"pref_fund_pay"`
  3977. // ClrOptins string `json:"clr_optins"`
  3978. // PoolPropSelfpay float64 `json:"pool_prop_selfpay"`
  3979. // DiseName string `json:"dise_name"`
  3980. // LmtpricHospLv string `json:"lmtpric_hosp_lv"`
  3981. // Age float64 `json:"age"`
  3982. // DtrtCertType string `json:"dtrt_cert_type"`
  3983. // HospLv string `json:"hosp_lv"`
  3984. // } `json:"setlinfo"`
  3985. // Setldetail []struct {
  3986. // FundPayType string `json:"fund_pay_type"`
  3987. // FundPayamt float64 `json:"fund_payamt"`
  3988. // SetlProcInfo interface{} `json:"setl_proc_info"`
  3989. // CrtPaybLmtAmt interface{} `json:"crt_payb_lmt_amt"`
  3990. // InscpScpAmt interface{} `json:"inscp_scp_amt"`
  3991. // FundPayTypeName interface{} `json:"fund_pay_type_name"`
  3992. // PrefFundPay interface{} `json:"pref_fund_pay"`
  3993. // } `json:"setldetail"`
  3994. // } `json:"output"`
  3995. // Infcode int `json:"infcode"`
  3996. // WarnMsg interface{} `json:"warn_msg"`
  3997. // Cainfo interface{} `json:"cainfo"`
  3998. // ErrMsg interface{} `json:"err_msg"`
  3999. // RefmsgTime string `json:"refmsg_time"`
  4000. // Signtype interface{} `json:"signtype"`
  4001. // RespondTime string `json:"respond_time"`
  4002. // InfRefmsgid string `json:"inf_refmsgid"`
  4003. //}
  4004. type ResultEleven struct {
  4005. Cainfo string `json:"cainfo"`
  4006. ErrMsg string `json:"err_msg"`
  4007. InfRefmsgid string `json:"inf_refmsgid"`
  4008. Infcode int64 `json:"infcode"`
  4009. Output struct {
  4010. Setlinfo struct {
  4011. SetlTime string `json:"setl_time"`
  4012. CvlservPay float64 `json:"cvlserv_pay"`
  4013. Year string `json:"year"`
  4014. MedType string `json:"med_type"`
  4015. PsnPay float64 `json:"psn_pay"`
  4016. OpterID string `json:"opter_id"`
  4017. Begndate string `json:"begndate"`
  4018. FlxempeFlag string `json:"flxempe_flag"`
  4019. HifmiPay float64 `json:"hifmi_pay"`
  4020. PsnNo string `json:"psn_no"`
  4021. ActPayDedc float64 `json:"act_pay_dedc"`
  4022. MedinsSetlID interface{} `json:"medins_setl_id"`
  4023. AcctMulaidPay interface{} `json:"acct_mulaid_pay"`
  4024. ClrWay string `json:"clr_way"`
  4025. OthPay float64 `json:"oth_pay"`
  4026. Gend string `json:"gend"`
  4027. MdtrtID string `json:"mdtrt_id"`
  4028. AcctPay float64 `json:"acct_pay"`
  4029. InscpScpAmt float64 `json:"inscp_scp_amt"`
  4030. Insutype string `json:"insutype"`
  4031. Invono interface{} `json:"invono"`
  4032. Enddate string `json:"enddate"`
  4033. CashPayamt float64 `json:"cash_payamt"`
  4034. PsnType string `json:"psn_type"`
  4035. FixmedinsName string `json:"fixmedins_name"`
  4036. HifpPay float64 `json:"hifp_pay"`
  4037. NewFlag interface{} `json:"new_flag"`
  4038. OverlmtSelfpay float64 `json:"overlmt_selfpay"`
  4039. PreselfpayAmt float64 `json:"preselfpay_amt"`
  4040. PayLoc string `json:"pay_loc"`
  4041. ClrType string `json:"clr_type"`
  4042. RefdSetlFlag string `json:"refd_setl_flag"`
  4043. CvlservFlag string `json:"cvlserv_flag"`
  4044. EmpName string `json:"emp_name"`
  4045. Brdy string `json:"brdy"`
  4046. Naty string `json:"naty"`
  4047. Certno string `json:"certno"`
  4048. DiseCode string `json:"dise_code"`
  4049. FixmedinsCode string `json:"fixmedins_code"`
  4050. DedcHospLv string `json:"dedc_hosp_lv"`
  4051. OpterName string `json:"opter_name"`
  4052. Balc float64 `json:"balc"`
  4053. FixmedinsPoolarea string `json:"fixmedins_poolarea"`
  4054. PsnCertType string `json:"psn_cert_type"`
  4055. HifobPay float64 `json:"hifob_pay"`
  4056. MedfeeSumamt float64 `json:"medfee_sumamt"`
  4057. HifesPay float64 `json:"hifes_pay"`
  4058. FundPaySumamt float64 `json:"fund_pay_sumamt"`
  4059. OptTime string `json:"opt_time"`
  4060. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  4061. SetlID string `json:"setl_id"`
  4062. MafPay float64 `json:"maf_pay"`
  4063. PsnName string `json:"psn_name"`
  4064. InsuOptins interface{} `json:"insu_optins"`
  4065. PrefFundPay interface{} `json:"pref_fund_pay"`
  4066. ClrOptins string `json:"clr_optins"`
  4067. PoolPropSelfpay float64 `json:"pool_prop_selfpay"`
  4068. DiseName string `json:"dise_name"`
  4069. LmtpricHospLv string `json:"lmtpric_hosp_lv"`
  4070. Age float64 `json:"age"`
  4071. DtrtCertType string `json:"dtrt_cert_type"`
  4072. HospLv string `json:"hosp_lv"`
  4073. } `json:"setlinfo"`
  4074. } `json:"output"`
  4075. RefmsgTime string `json:"refmsg_time"`
  4076. RespondTime string `json:"respond_time"`
  4077. Signtype interface{} `json:"signtype"`
  4078. WarnMsg interface{} `json:"warn_msg"`
  4079. }
  4080. type ResultEleven10265 struct {
  4081. Cainfo string `json:"cainfo"`
  4082. ErrMsg string `json:"err_msg"`
  4083. InfRefmsgid string `json:"inf_refmsgid"`
  4084. Infcode string `json:"infcode"`
  4085. Output struct {
  4086. Setlinfo struct {
  4087. SetlTime string `json:"setl_time"`
  4088. CvlservPay float64 `json:"cvlserv_pay"`
  4089. Year string `json:"year"`
  4090. MedType string `json:"med_type"`
  4091. PsnPay float64 `json:"psn_pay"`
  4092. OpterID string `json:"opter_id"`
  4093. Begndate string `json:"begndate"`
  4094. FlxempeFlag string `json:"flxempe_flag"`
  4095. HifmiPay float64 `json:"hifmi_pay"`
  4096. PsnNo string `json:"psn_no"`
  4097. ActPayDedc float64 `json:"act_pay_dedc"`
  4098. MedinsSetlID interface{} `json:"medins_setl_id"`
  4099. AcctMulaidPay interface{} `json:"acct_mulaid_pay"`
  4100. ClrWay string `json:"clr_way"`
  4101. OthPay float64 `json:"oth_pay"`
  4102. Gend string `json:"gend"`
  4103. MdtrtID string `json:"mdtrt_id"`
  4104. AcctPay float64 `json:"acct_pay"`
  4105. InscpScpAmt float64 `json:"inscp_scp_amt"`
  4106. Insutype string `json:"insutype"`
  4107. Invono interface{} `json:"invono"`
  4108. Enddate string `json:"enddate"`
  4109. CashPayamt float64 `json:"cash_payamt"`
  4110. PsnType string `json:"psn_type"`
  4111. FixmedinsName string `json:"fixmedins_name"`
  4112. HifpPay float64 `json:"hifp_pay"`
  4113. NewFlag interface{} `json:"new_flag"`
  4114. OverlmtSelfpay float64 `json:"overlmt_selfpay"`
  4115. PreselfpayAmt float64 `json:"preselfpay_amt"`
  4116. PayLoc string `json:"pay_loc"`
  4117. ClrType string `json:"clr_type"`
  4118. RefdSetlFlag string `json:"refd_setl_flag"`
  4119. CvlservFlag string `json:"cvlserv_flag"`
  4120. EmpName string `json:"emp_name"`
  4121. Brdy string `json:"brdy"`
  4122. Naty string `json:"naty"`
  4123. Certno string `json:"certno"`
  4124. DiseCode string `json:"dise_code"`
  4125. FixmedinsCode string `json:"fixmedins_code"`
  4126. DedcHospLv string `json:"dedc_hosp_lv"`
  4127. OpterName string `json:"opter_name"`
  4128. Balc float64 `json:"balc"`
  4129. FixmedinsPoolarea string `json:"fixmedins_poolarea"`
  4130. PsnCertType string `json:"psn_cert_type"`
  4131. HifobPay float64 `json:"hifob_pay"`
  4132. MedfeeSumamt float64 `json:"medfee_sumamt"`
  4133. HifesPay float64 `json:"hifes_pay"`
  4134. FundPaySumamt float64 `json:"fund_pay_sumamt"`
  4135. OptTime string `json:"opt_time"`
  4136. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  4137. SetlID string `json:"setl_id"`
  4138. MafPay float64 `json:"maf_pay"`
  4139. PsnName string `json:"psn_name"`
  4140. InsuOptins interface{} `json:"insu_optins"`
  4141. PrefFundPay interface{} `json:"pref_fund_pay"`
  4142. ClrOptins string `json:"clr_optins"`
  4143. PoolPropSelfpay float64 `json:"pool_prop_selfpay"`
  4144. DiseName string `json:"dise_name"`
  4145. LmtpricHospLv string `json:"lmtpric_hosp_lv"`
  4146. Age float64 `json:"age"`
  4147. DtrtCertType string `json:"dtrt_cert_type"`
  4148. HospLv string `json:"hosp_lv"`
  4149. } `json:"setlinfo"`
  4150. } `json:"output"`
  4151. RefmsgTime string `json:"refmsg_time"`
  4152. RespondTime string `json:"respond_time"`
  4153. Signtype interface{} `json:"signtype"`
  4154. WarnMsg interface{} `json:"warn_msg"`
  4155. }
  4156. type ResultTwelve struct {
  4157. Cainfo string `json:"cainfo"`
  4158. ErrMsg string `json:"err_msg"`
  4159. InfRefmsgid string `json:"inf_refmsgid"`
  4160. Infcode int64 `json:"infcode"`
  4161. Output struct {
  4162. MdtrtId string `json:"mdtrt_id"`
  4163. ChrgBchno string `json:"chrg_bchno"`
  4164. PsnNo string `json:"psn_no"`
  4165. } `json:"output"`
  4166. RefmsgTime string `json:"refmsg_time"`
  4167. RespondTime string `json:"respond_time"`
  4168. Signtype interface{} `json:"signtype"`
  4169. WarnMsg interface{} `json:"warn_msg"`
  4170. }
  4171. type ResultThirteen struct {
  4172. ErrMsg string `json:"err_msg"`
  4173. InfRefmsgid string `json:"inf_refmsgid"`
  4174. Infcode int64 `json:"infcode"`
  4175. Output struct {
  4176. Result struct {
  4177. TrtDclaDetlSn string `json:"trt_dcla_detl_sn"`
  4178. } `json:"result"`
  4179. } `json:"output"`
  4180. RefmsgTime string `json:"refmsg_time"`
  4181. RespondTime string `json:"respond_time"`
  4182. Signtype interface{} `json:"signtype"`
  4183. WarnInfo interface{} `json:"warn_info"`
  4184. }
  4185. type ResultThirteen10265 struct {
  4186. ErrMsg string `json:"err_msg"`
  4187. InfRefmsgid string `json:"inf_refmsgid"`
  4188. Infcode string `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 ResultFourteen struct {
  4200. ErrMsg string `json:"err_msg"`
  4201. InfRefmsgid string `json:"inf_refmsgid"`
  4202. Infcode int64 `json:"infcode"`
  4203. Output struct {
  4204. } `json:"output"`
  4205. RefmsgTime string `json:"refmsg_time"`
  4206. RespondTime string `json:"respond_time"`
  4207. Signtype interface{} `json:"signtype"`
  4208. WarnInfo interface{} `json:"warn_info"`
  4209. }
  4210. type ResultFourteen10265 struct {
  4211. ErrMsg string `json:"err_msg"`
  4212. InfRefmsgid string `json:"inf_refmsgid"`
  4213. Infcode string `json:"infcode"`
  4214. Output struct {
  4215. } `json:"output"`
  4216. RefmsgTime string `json:"refmsg_time"`
  4217. RespondTime string `json:"respond_time"`
  4218. Signtype interface{} `json:"signtype"`
  4219. WarnInfo interface{} `json:"warn_info"`
  4220. }
  4221. type ResultSixteen struct {
  4222. Cainfo string `json:"cainfo"`
  4223. ErrMsg string `json:"err_msg"`
  4224. InfRefmsgid string `json:"inf_refmsgid"`
  4225. Infcode int64 `json:"infcode"`
  4226. Output struct {
  4227. Setldetail []interface{} `json:"setldetail"`
  4228. Setlinfo struct {
  4229. MdtrtID string `json:"mdtrt_id"`
  4230. SetlID string `json:"setl_id"`
  4231. ClrOptins string `json:"clr_optins"`
  4232. SetlTime string `json:"setl_time"`
  4233. MedfeeSumamt float64 `json:"medfee_sumamt"`
  4234. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  4235. OverlmtSelfpay float64 `json:"overlmt_selfpay"`
  4236. PreselfpayAmt float64 `json:"preselfpay_amt"`
  4237. InscpScpAmt float64 `json:"inscp_scp_amt"`
  4238. ActPayDedc float64 `json:"act_pay_dedc"`
  4239. HifpPay float64 `json:"hifp_pay"`
  4240. PoolPropSe float64 `json:"pool_prop_selfpay"`
  4241. Lfpay float64 `json:"selfpay"`
  4242. CvlservPay float64 `json:"cvlserv_pay"`
  4243. HifesPay float64 `json:"hifes_pay"`
  4244. HifmiPay float64 `json:"hifmi_pay"`
  4245. HifobPay float64 `json:"hifob_pay"`
  4246. MafPay float64 `json:"maf_pay"`
  4247. OthPay float64 `json:"oth_pay"`
  4248. FundPaySumamt float64 `json:"fund_pay_sumamt"`
  4249. PsnPartAmt float64 `json:"psn_part_amt"`
  4250. AcctPay float64 `json:"acct_pay"`
  4251. Balc float64 `json:"balc"`
  4252. AcctMulaidPay float64 `json:"acct_mulaid_pay"`
  4253. HospPartAmt float64 `json:"hosp_part_amt"`
  4254. MedinsSetlID string `json:"medins_setl_id"`
  4255. PdnCashPay string `json:"pdn_cash_pay"`
  4256. } `json:"setlinfo"`
  4257. } `json:"output"`
  4258. RefmsgTime string `json:"refmsg_time"`
  4259. RespondTime string `json:"respond_time"`
  4260. Signtype interface{} `json:"signtype"`
  4261. WarnMsg interface{} `json:"warn_msg"`
  4262. }
  4263. type ResultSixteen10265 struct {
  4264. Cainfo string `json:"cainfo"`
  4265. ErrMsg string `json:"err_msg"`
  4266. InfRefmsgid string `json:"inf_refmsgid"`
  4267. Infcode string `json:"infcode"`
  4268. Output struct {
  4269. Setldetail []interface{} `json:"setldetail"`
  4270. Setlinfo struct {
  4271. MdtrtID string `json:"mdtrt_id"`
  4272. SetlID string `json:"setl_id"`
  4273. ClrOptins string `json:"clr_optins"`
  4274. SetlTime string `json:"setl_time"`
  4275. MedfeeSumamt float64 `json:"medfee_sumamt"`
  4276. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  4277. OverlmtSelfpay float64 `json:"overlmt_selfpay"`
  4278. PreselfpayAmt float64 `json:"preselfpay_amt"`
  4279. InscpScpAmt float64 `json:"inscp_scp_amt"`
  4280. ActPayDedc float64 `json:"act_pay_dedc"`
  4281. HifpPay float64 `json:"hifp_pay"`
  4282. PoolPropSe float64 `json:"pool_prop_selfpay"`
  4283. Lfpay float64 `json:"selfpay"`
  4284. CvlservPay float64 `json:"cvlserv_pay"`
  4285. HifesPay float64 `json:"hifes_pay"`
  4286. HifmiPay float64 `json:"hifmi_pay"`
  4287. HifobPay float64 `json:"hifob_pay"`
  4288. MafPay float64 `json:"maf_pay"`
  4289. OthPay float64 `json:"oth_pay"`
  4290. FundPaySumamt float64 `json:"fund_pay_sumamt"`
  4291. PsnPartAmt float64 `json:"psn_part_amt"`
  4292. AcctPay float64 `json:"acct_pay"`
  4293. Balc float64 `json:"balc"`
  4294. AcctMulaidPay float64 `json:"acct_mulaid_pay"`
  4295. HospPartAmt float64 `json:"hosp_part_amt"`
  4296. MedinsSetlID string `json:"medins_setl_id"`
  4297. PdnCashPay string `json:"pdn_cash_pay"`
  4298. } `json:"setlinfo"`
  4299. } `json:"output"`
  4300. RefmsgTime string `json:"refmsg_time"`
  4301. RespondTime string `json:"respond_time"`
  4302. Signtype interface{} `json:"signtype"`
  4303. WarnMsg interface{} `json:"warn_msg"`
  4304. }
  4305. type ResultSeventeen struct {
  4306. ErrMsg string `json:"err_msg"`
  4307. InfRefmsgid string `json:"inf_refmsgid"`
  4308. Infcode int64 `json:"infcode"`
  4309. Output struct {
  4310. SetlListId string `json:"setl_list_id"`
  4311. } `json:"output"`
  4312. RefmsgTime string `json:"refmsg_time"`
  4313. RespondTime string `json:"respond_time"`
  4314. Signtype string `json:"signtype"`
  4315. WarnInfo string `json:"warn_info"`
  4316. }
  4317. type ResultSeventeenOther struct {
  4318. ErrMsg string `json:"err_msg"`
  4319. InfRefmsgid string `json:"inf_refmsgid"`
  4320. Infcode string `json:"infcode"`
  4321. Output struct {
  4322. SetlListId string `json:"setl_list_id"`
  4323. } `json:"output"`
  4324. RefmsgTime string `json:"refmsg_time"`
  4325. RespondTime string `json:"respond_time"`
  4326. Signtype string `json:"signtype"`
  4327. WarnInfo string `json:"warn_info"`
  4328. }
  4329. type Result90991 struct {
  4330. ErrMsg string `json:"err_msg"`
  4331. InfRefmsgid string `json:"inf_refmsgid"`
  4332. Infcode int64 `json:"infcode"`
  4333. Output struct {
  4334. Result struct {
  4335. PsnNo string `json:"psn_no"`
  4336. CardStat string `json:"card_stat"`
  4337. Certno string `json:"certno"`
  4338. PsnName string `json:"psn_name"`
  4339. CheckStat string `json:"check_stat"`
  4340. SscnoCheckStat string `json:"sscno_check_stat"`
  4341. } `json:"result"`
  4342. } `json:"output"`
  4343. RefmsgTime string `json:"refmsg_time"`
  4344. RespondTime string `json:"respond_time"`
  4345. Signtype interface{} `json:"signtype"`
  4346. WarnInfo interface{} `json:"warn_info"`
  4347. }
  4348. type Result90100 struct {
  4349. ErrMsg string `json:"err_msg"`
  4350. InfRefmsgid string `json:"inf_refmsgid"`
  4351. Infcode int64 `json:"infcode"`
  4352. Output struct {
  4353. PoolareaNo string `json:"poolarea_no"`
  4354. PoolareaNoName string `json:"poolarea_no_name"`
  4355. Insutype string `json:"insutype"`
  4356. InsutypeName string `json:"insutype_name"`
  4357. ClctType string `json:"clct_type"`
  4358. ClctTypeName string `json:"clct_type_name"`
  4359. ClctFlag string `json:"clct_flag"`
  4360. ClctFlagName string `json:"clct_flag_name"`
  4361. AccrymBegn string `json:"accrym_begn"`
  4362. AccrymEnd string `json:"accrym_end"`
  4363. ClctTime string `json:"clct_time"`
  4364. ClctstdCrtfRuleCodg string `json:"clctstd_crtf_rule_codg"`
  4365. } `json:"output"`
  4366. RefmsgTime string `json:"refmsg_time"`
  4367. RespondTime string `json:"respond_time"`
  4368. Signtype interface{} `json:"signtype"`
  4369. WarnInfo interface{} `json:"warn_info"`
  4370. }
  4371. type Custom struct {
  4372. DetItemFeeSumamt string
  4373. Cut string
  4374. FeedetlSn string
  4375. Price string
  4376. MedListCodg string
  4377. Type int64
  4378. AdviceId int64
  4379. ProjectId int64
  4380. ItemId int64
  4381. }
  4382. type Result5301 struct {
  4383. ErrMsg string `json:"err_msg"`
  4384. InfRefmsgid string `json:"inf_refmsgid"`
  4385. Infcode int64 `json:"infcode"`
  4386. Output struct {
  4387. Result []struct {
  4388. OpspDiseCode string `json:"opsp_dise_code"`
  4389. OpspDiseName string `json:"opsp_dise_name"`
  4390. Begndate string `json:"begndate"`
  4391. Enddate string `json:"enddate"`
  4392. } `json:"feedetail"`
  4393. } `json:"output"`
  4394. RefmsgTime string `json:"refmsg_time"`
  4395. RespondTime string `json:"respond_time"`
  4396. Signtype interface{} `json:"signtype"`
  4397. WarnInfo interface{} `json:"warn_info"`
  4398. }
  4399. type Result5301For10265 struct {
  4400. ErrMsg string `json:"err_msg"`
  4401. InfRefmsgid string `json:"inf_refmsgid"`
  4402. Infcode string `json:"infcode"`
  4403. Output struct {
  4404. Result []struct {
  4405. OpspDiseCode string `json:"opsp_dise_code"`
  4406. OpspDiseName string `json:"opsp_dise_name"`
  4407. Begndate string `json:"begndate"`
  4408. Enddate string `json:"enddate"`
  4409. } `json:"feedetail"`
  4410. } `json:"output"`
  4411. RefmsgTime string `json:"refmsg_time"`
  4412. RespondTime string `json:"respond_time"`
  4413. Signtype interface{} `json:"signtype"`
  4414. WarnInfo interface{} `json:"warn_info"`
  4415. }
  4416. //获取个人信息----挂号-----上传就诊信息
  4417. func (c *HisApiController) GetRegisterInfo() {
  4418. id, _ := c.GetInt64("id")
  4419. record_time := c.GetString("record_time")
  4420. settlementValue, _ := c.GetInt64("settlement_value")
  4421. medical_insurance_card := c.GetString("medical_insurance_card")
  4422. name := c.GetString("name")
  4423. id_card_type, _ := c.GetInt64("id_card_type")
  4424. certificates, _ := c.GetInt64("certificates")
  4425. medical_care, _ := c.GetInt64("medical_care")
  4426. birthday := c.GetString("birthday")
  4427. id_card := c.GetString("id_card")
  4428. register_type, _ := c.GetInt64("register")
  4429. doctor, _ := c.GetInt64("doctor")
  4430. department, _ := c.GetInt64("department")
  4431. gender, _ := c.GetInt64("sex")
  4432. registration_fee, _ := c.GetFloat("registration_fee")
  4433. medical_expenses, _ := c.GetFloat("medical_expenses")
  4434. social_type, _ := c.GetInt64("social_type")
  4435. med_type := c.GetString("social_type")
  4436. admin_user_id, _ := c.GetInt64("admin_user_id")
  4437. insuplc_admdvs := c.GetString("insuplc_admdvs")
  4438. timeLayout := "2006-01-02"
  4439. loc, _ := time.LoadLocation("Local")
  4440. birthdays, _ := time.ParseInLocation(timeLayout+" 15:04:05", birthday+" 00:00:00", loc)
  4441. birthUnix := birthdays.Unix()
  4442. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  4443. if err != nil {
  4444. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  4445. return
  4446. }
  4447. recordDateTime := theTime.Unix()
  4448. adminInfo := c.GetAdminUserInfo()
  4449. var patient service.Patients
  4450. if id == 0 {
  4451. patient, _ = service.GetPatientByIDCard(id_card, adminInfo.CurrentOrgId)
  4452. } else {
  4453. patient, _ = service.GetPatientByIDTwo(adminInfo.CurrentOrgId, id)
  4454. }
  4455. patientPrescription, _ := service.FindPatientPrescriptionInfo(adminInfo.CurrentOrgId, id, recordDateTime)
  4456. if patientPrescription.ID == 0 {
  4457. patientPrescription, _ = service.FindLastPatientPrescriptionInfo(adminInfo.CurrentOrgId, id, recordDateTime)
  4458. }
  4459. miConfig, _ := service.FindMedicalInsuranceInfo(adminInfo.CurrentOrgId)
  4460. if patient.ID == 0 {
  4461. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodePatientNoExist)
  4462. return
  4463. }
  4464. if len(patient.IdCardNo) == 0 {
  4465. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeIDCartNo)
  4466. return
  4467. }
  4468. config, _ := service.GetMedicalInsuranceConfig(adminInfo.CurrentOrgId)
  4469. roles, _ := service.GetAdminUserInfoByID(adminInfo.CurrentOrgId, admin_user_id)
  4470. doctor_info, _ := service.GetAdminUserInfoByID(adminInfo.CurrentOrgId, doctor)
  4471. //就诊结算未完成,不能进行二次挂号
  4472. his, _ := service.GetHisPatientInfoTwo(adminInfo.CurrentOrgId, patient.ID, recordDateTime)
  4473. if len(his) >= 1 {
  4474. order, _ := service.GetNewHisOrderTwo(adminInfo.CurrentOrgId, his[len(his)-1].Number, his[len(his)-1].PatientId, recordDateTime)
  4475. if len(his) >= 1 && order.ID == 0 {
  4476. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisPatientParamWrong)
  4477. return
  4478. }
  4479. }
  4480. //var register_log string
  4481. if config.IsOpen == 1 {
  4482. var res ResultTwo
  4483. var res10265 ResultTwo10265
  4484. var PsnNo string
  4485. var PsnCertType string
  4486. var Certno string
  4487. var PsnName string
  4488. var Gend string
  4489. var Naty string
  4490. var Brdy string
  4491. var Age float64
  4492. var infoStr string
  4493. var idetinfoStr string
  4494. var infocode int64
  4495. var verify_number string
  4496. fmt.Println(verify_number)
  4497. if miConfig.MdtrtareaAdmvs == "421300" {
  4498. psn_info, _ := service.GetPsnByPatientId(id)
  4499. PsnNo = psn_info.PsnNo
  4500. PsnCertType = psn_info.PsnCertType
  4501. Certno = psn_info.Certno
  4502. PsnName = psn_info.PsnName
  4503. Gend = psn_info.Gend
  4504. Naty = psn_info.Naty
  4505. Brdy = psn_info.Brdy
  4506. Age = psn_info.Age
  4507. infoStr = psn_info.Insuinfo
  4508. idetinfoStr = psn_info.Idetinfo
  4509. infocode = 0
  4510. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  4511. psn_info, _ := service.GetPsnByPatientId(id)
  4512. PsnNo = psn_info.PsnNo
  4513. PsnCertType = psn_info.PsnCertType
  4514. Certno = psn_info.Certno
  4515. PsnName = psn_info.PsnName
  4516. Gend = psn_info.Gend
  4517. Naty = psn_info.Naty
  4518. Brdy = psn_info.Brdy
  4519. Age = psn_info.Age
  4520. infoStr = psn_info.Insuinfo
  4521. idetinfoStr = psn_info.Idetinfo
  4522. infocode = 0
  4523. verify_number = psn_info.VerifyNumber
  4524. } else if miConfig.MdtrtareaAdmvs == "350500" {
  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 {
  4539. var result string
  4540. var requestLog string
  4541. if miConfig.UserOrgId == 10138 {
  4542. 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)
  4543. } else {
  4544. 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)
  4545. }
  4546. saveLog(result, requestLog, "1101", "人员基本信息获取")
  4547. if miConfig.Code == "H15049901371" {
  4548. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  4549. utils.ErrorLog("解析失败:%v", err)
  4550. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4551. return
  4552. }
  4553. res.ErrMsg = res10265.ErrMsg
  4554. res.Output = res10265.Output
  4555. res.InfRefmsgid = res10265.InfRefmsgid
  4556. } else {
  4557. if err := json.Unmarshal([]byte(result), &res); err != nil {
  4558. utils.ErrorLog("解析失败:%v", err)
  4559. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4560. return
  4561. }
  4562. }
  4563. PsnNo = res.Output.Baseinfo.PsnNo
  4564. PsnCertType = res.Output.Baseinfo.PsnCertType
  4565. Certno = res.Output.Baseinfo.Certno
  4566. PsnName = res.Output.Baseinfo.PsnName
  4567. Gend = res.Output.Baseinfo.Gend
  4568. Naty = res.Output.Baseinfo.Naty
  4569. Brdy = res.Output.Baseinfo.Brdy
  4570. Age = res.Output.Baseinfo.Age
  4571. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  4572. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  4573. infoStr = string(Iinfos)
  4574. idetinfoStr = string(Idetinfos)
  4575. if miConfig.Code == "H15049901371" {
  4576. infocode, _ = strconv.ParseInt(res10265.Infcode, 10, 64)
  4577. } else {
  4578. infocode = res.Infcode
  4579. }
  4580. }
  4581. if infocode == 0 {
  4582. his := models.VMHisPatient{
  4583. Name: name,
  4584. Gender: gender,
  4585. Birthday: birthUnix,
  4586. MedicalTreatmentType: medical_care,
  4587. IdType: certificates,
  4588. IdCardNo: id_card,
  4589. BalanceAccountsType: settlementValue,
  4590. SocialType: social_type,
  4591. MedicalInsuranceNumber: medical_insurance_card,
  4592. RegisterType: register_type,
  4593. RegisterCost: registration_fee,
  4594. TreatmentCost: medical_expenses,
  4595. Status: 1,
  4596. Ctime: time.Now().Unix(),
  4597. Mtime: time.Now().Unix(),
  4598. PsnNo: PsnNo,
  4599. PsnCertType: PsnCertType,
  4600. Certno: Certno,
  4601. PsnName: PsnName,
  4602. Gend: Gend,
  4603. Naty: Naty,
  4604. Brdy: Brdy,
  4605. Age: Age,
  4606. Iinfo: infoStr,
  4607. Idetinfo: idetinfoStr,
  4608. PatientId: patient.ID,
  4609. RecordDate: theTime.Unix(),
  4610. UserOrgId: adminInfo.CurrentOrgId,
  4611. AdminUserId: admin_user_id,
  4612. IsReturn: 1,
  4613. IdCardType: id_card_type,
  4614. Doctor: doctor,
  4615. Departments: department,
  4616. }
  4617. timestamp := time.Now().Unix()
  4618. tempTime := time.Unix(timestamp, 0)
  4619. timeFormat := tempTime.Format("20060102150405")
  4620. chrgBchno := rand.Intn(100000) + 10000
  4621. ipt_otp_no := timeFormat + strconv.FormatInt(int64(chrgBchno), 10) + strconv.FormatInt(his.PatientId, 10)
  4622. //count, _ := service.FindHisRegisterRecord(theTime.Unix(), patient.ID, adminInfo.CurrentOrgId)
  4623. department, _ := service.GetDepartMentDetail(department)
  4624. doctor_id := strconv.FormatInt(patientPrescription.DoctorId, 10)
  4625. IdCardNo := ""
  4626. if id_card_type == 1 {
  4627. // IdCardNo = medical_insurance_card
  4628. IdCardNo = patient.IdCardNo
  4629. } else {
  4630. IdCardNo = patient.IdCardNo
  4631. }
  4632. var rf []*ResultFive
  4633. json.Unmarshal([]byte(his.Iinfo), &rf)
  4634. var insutypes []*ResultFive
  4635. var insutype string
  4636. var insuplc_admdvs_temp string
  4637. var is390 int = 0
  4638. var is310 int = 0
  4639. for _, item := range rf {
  4640. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  4641. insutypes = append(insutypes, item)
  4642. }
  4643. }
  4644. if len(insutypes) == 1 {
  4645. insutype = insutypes[0].Insutype
  4646. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  4647. } else {
  4648. for _, i := range insutypes {
  4649. if i.Insutype == "390" {
  4650. is390 = 1
  4651. }
  4652. if i.Insutype == "310" {
  4653. is310 = 1
  4654. }
  4655. }
  4656. }
  4657. if is390 == 1 {
  4658. insutype = "390"
  4659. }
  4660. if is310 == 1 {
  4661. insutype = "310"
  4662. }
  4663. if len(insutypes) == 0 {
  4664. insutype = "310"
  4665. }
  4666. if len(insutypes) == 2 {
  4667. insutype = med_type
  4668. }
  4669. if len(med_type) > 0 {
  4670. insutype = med_type
  4671. }
  4672. //for _, item := range rf {
  4673. // if item.Insutype == insutype {
  4674. // insuplc_admdvs = item.InsuplcAdmdvs
  4675. // }
  4676. //}
  4677. var infocode int64
  4678. var resThree ResultThree
  4679. var resThree10265 ResultThree10265
  4680. if len(insuplc_admdvs) == 0 {
  4681. insuplc_admdvs_temp = miConfig.InsuplcAdmdvs
  4682. } else {
  4683. insuplc_admdvs_temp = insuplc_admdvs
  4684. }
  4685. if miConfig.MdtrtareaAdmvs == "421300" {
  4686. hb_doctor_info, _ := service.GetAdminUserInfoByID(adminInfo.CurrentOrgId, patientPrescription.DoctorId)
  4687. api := "http://192.168.124.4:9532/" + "hbyb/2201?psn_no=" + PsnNo + "&insutype=" + insutype + "&cert_no=" + Certno + "&ipt_otp_no=" + ipt_otp_no +
  4688. "&org_name=" + miConfig.OrgName + "&doctor=" + hb_doctor_info.UserName + "&fixmedins_code=" + miConfig.Code +
  4689. "&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
  4690. resp, requestErr := http.Get(api)
  4691. if requestErr != nil {
  4692. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4693. return
  4694. }
  4695. body, ioErr := ioutil.ReadAll(resp.Body)
  4696. if ioErr != nil {
  4697. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  4698. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4699. return
  4700. }
  4701. var respJSON map[string]interface{}
  4702. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  4703. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  4704. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4705. return
  4706. }
  4707. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  4708. result, _ := json.Marshal(respJSON)
  4709. if err := json.Unmarshal([]byte(result), &resThree); err != nil {
  4710. utils.ErrorLog("解析失败:%v", err)
  4711. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4712. return
  4713. }
  4714. infocode = resThree.Infcode
  4715. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  4716. psn_info, _ := service.GetPsnByPatientId(id)
  4717. psn_info.VerifyNumber = strings.Replace(psn_info.VerifyNumber, "+", "%2B", -1)
  4718. var cert_no string
  4719. if id_card_type == 3 {
  4720. psn_info.VerifyNumber = IdCardNo + "|" + psn_info.VerifyNumber
  4721. cert_no = IdCardNo
  4722. } else if id_card_type == 4 {
  4723. cert_no = IdCardNo
  4724. psn_info.VerifyNumber = psn_info.VerifyNumber
  4725. } else {
  4726. bas := strings.Split(psn_info.CardInfo, "|")
  4727. cert_no = bas[2]
  4728. }
  4729. var api string
  4730. if miConfig.MdtrtareaAdmvs == "320921" {
  4731. api = "http://192.168.3.111:9532/" + "jsyb/2201?psn_no=" + PsnNo + "&insutype=" + insutype + "&cert_no=" + cert_no + "&ipt_otp_no=" + ipt_otp_no +
  4732. "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&doctor_name=" + doctor_info.UserName + "&fixmedins_code=" + miConfig.Code +
  4733. "&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
  4734. } else {
  4735. api = "http://192.168.5.251:9532/" + "jsyb/2201?psn_no=" + PsnNo + "&insutype=" + insutype + "&cert_no=" + cert_no + "&ipt_otp_no=" + ipt_otp_no +
  4736. "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&doctor_name=" + doctor_info.UserName + "&fixmedins_code=" + miConfig.Code +
  4737. "&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
  4738. }
  4739. resp, requestErr := http.Get(api)
  4740. if requestErr != nil {
  4741. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4742. return
  4743. }
  4744. body, ioErr := ioutil.ReadAll(resp.Body)
  4745. if ioErr != nil {
  4746. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  4747. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4748. return
  4749. }
  4750. var respJSON map[string]interface{}
  4751. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  4752. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  4753. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4754. return
  4755. }
  4756. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  4757. result, _ := json.Marshal(respJSON)
  4758. if err := json.Unmarshal([]byte(result), &resThree10265); err != nil {
  4759. utils.ErrorLog("解析失败:%v", err)
  4760. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4761. return
  4762. }
  4763. resThree.ErrMsg = resThree10265.ErrMsg
  4764. resThree.Output = resThree10265.Output
  4765. resThree.InfRefmsgid = resThree10265.InfRefmsgid
  4766. infocode, _ = strconv.ParseInt(resThree10265.Infcode, 10, 64)
  4767. } else if miConfig.MdtrtareaAdmvs == "350500" {
  4768. result, requestLog := service.FJyb2201(res.Output.Baseinfo.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)
  4769. saveLog(result, requestLog, "2201", "挂号")
  4770. if miConfig.Code == "H15049901371" {
  4771. if err := json.Unmarshal([]byte(result), &resThree10265); err != nil {
  4772. utils.ErrorLog("解析失败:%v", err)
  4773. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4774. return
  4775. }
  4776. resThree.ErrMsg = resThree10265.ErrMsg
  4777. resThree.Output = resThree10265.Output
  4778. resThree.InfRefmsgid = resThree10265.InfRefmsgid
  4779. } else {
  4780. if err := json.Unmarshal([]byte(result), &resThree); err != nil {
  4781. utils.ErrorLog("解析失败:%v", err)
  4782. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4783. return
  4784. }
  4785. }
  4786. infocode, _ = strconv.ParseInt(resThree10265.Infcode, 10, 64)
  4787. } else {
  4788. 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)
  4789. saveLog(result, requestLog, "2201A", "挂号")
  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. if miConfig.Code == "H15049901371" {
  4807. infocode, _ = strconv.ParseInt(resThree10265.Infcode, 10, 64)
  4808. } else {
  4809. infocode = resThree.Infcode
  4810. }
  4811. }
  4812. if infocode != 0 {
  4813. adminUser := c.GetAdminUserInfo()
  4814. errlog := &models.HisOrderError{
  4815. UserOrgId: adminUser.CurrentOrgId,
  4816. Ctime: time.Now().Unix(),
  4817. Mtime: time.Now().Unix(),
  4818. ErrMsg: resThree.ErrMsg,
  4819. Status: 1,
  4820. PatientId: id,
  4821. RecordTime: recordDateTime,
  4822. Stage: 2,
  4823. }
  4824. service.CreateErrMsgLog(errlog)
  4825. c.ServeSuccessJSON(map[string]interface{}{
  4826. "failed_code": -10,
  4827. "msg": resThree.ErrMsg,
  4828. })
  4829. return
  4830. }
  4831. his.Number = resThree.Output.Data.MdtrtID
  4832. his.PsnNo = resThree.Output.Data.PsnNo
  4833. his.IptOtpNo = resThree.Output.Data.IptOtpNo
  4834. his.IdCardNo = patient.IdCardNo
  4835. his.PhoneNumber = patient.Phone
  4836. his.UserOrgId = adminInfo.CurrentOrgId
  4837. his.Insutype = insutype
  4838. his.Ctime = time.Now().Unix()
  4839. his.Mtime = time.Now().Unix()
  4840. his.InsuplcAdmdvs = insuplc_admdvs_temp
  4841. his.Status = 1
  4842. service.UpdateHisPatientStatus(&his)
  4843. service.UpdateHisPrescriptionHisID(his.ID, patient.ID, recordDateTime, adminInfo.CurrentOrgId)
  4844. c.ServeSuccessJSON(map[string]interface{}{
  4845. "his_info": his,
  4846. })
  4847. } else {
  4848. adminUser := c.GetAdminUserInfo()
  4849. errlog := &models.HisOrderError{
  4850. UserOrgId: adminUser.CurrentOrgId,
  4851. Ctime: time.Now().Unix(),
  4852. Mtime: time.Now().Unix(),
  4853. ErrMsg: res.ErrMsg,
  4854. Status: 1,
  4855. PatientId: id,
  4856. RecordTime: recordDateTime,
  4857. Stage: 1,
  4858. }
  4859. service.CreateErrMsgLog(errlog)
  4860. c.ServeSuccessJSON(map[string]interface{}{
  4861. "failed_code": -10,
  4862. "msg": res.ErrMsg,
  4863. })
  4864. return
  4865. //c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeGdybOneException)
  4866. }
  4867. }
  4868. }
  4869. //上传明细----预结算----确认订单
  4870. func (c *HisApiController) GetUploadInfo() {
  4871. id, _ := c.GetInt64("id")
  4872. record_time := c.GetString("record_time")
  4873. his_patient_id, _ := c.GetInt64("his_patient_id")
  4874. order_id, _ := c.GetInt64("order_id")
  4875. pay_way, _ := c.GetInt64("pay_way")
  4876. pay_price, _ := c.GetFloat("pay_price")
  4877. pay_card_no := c.GetString("pay_card_no")
  4878. token := c.GetString("token")
  4879. discount_price, _ := c.GetFloat("discount_price")
  4880. preferential_price, _ := c.GetFloat("preferential_price")
  4881. reality_price, _ := c.GetFloat("reality_price")
  4882. found_price, _ := c.GetFloat("found_price")
  4883. medical_insurance_price, _ := c.GetFloat("medical_insurance_price")
  4884. private_price, _ := c.GetFloat("private_price")
  4885. settle_accounts_type, _ := c.GetInt64("settle_accounts_type")
  4886. admin_user_id, _ := c.GetInt64("admin_user_id")
  4887. fapiao_code := c.GetString("fapiao_code")
  4888. fapiao_number := c.GetString("fapiao_number")
  4889. diagnosis_id := c.GetString("diagnosis")
  4890. sick_type, _ := c.GetInt64("sick_type")
  4891. reg_type, _ := c.GetInt64("p_type")
  4892. begin_time := c.GetString("begin_time")
  4893. id_str := c.GetString("ids")
  4894. ids_arr := strings.Split(id_str, ",")
  4895. timeLayout := "2006-01-02"
  4896. loc, _ := time.LoadLocation("Local")
  4897. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  4898. if err != nil {
  4899. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  4900. return
  4901. }
  4902. recordDateTime := theTime.Unix()
  4903. adminUser := c.GetAdminUserInfo()
  4904. var tempOrder models.HisOrder
  4905. tempOrder, _ = service.GetHisOrderByID(order_id)
  4906. var prescriptions []*models.HisPrescription
  4907. var start_time int64
  4908. var end_time int64
  4909. //押金模块
  4910. dec_way := c.GetString("dec_way") //是否使用押金支付bool类型
  4911. tmp_decimal := c.GetString("tmp_decimal")
  4912. var decimal float64 //本次使用的押金
  4913. var errmsg error
  4914. if dec_way == "true" && tmp_decimal == "0" || dec_way == "true" && tmp_decimal == "" {
  4915. c.ServeFailJsonSend(enums.ErrorCodeParamWrong, "押金不能为0")
  4916. return
  4917. }
  4918. if len(tmp_decimal) > 0 {
  4919. if tmp_decimal[0] == 45 {
  4920. c.ServeFailJsonSend(enums.ErrorCodeParamWrong, "押金不能为负数")
  4921. return
  4922. }
  4923. }
  4924. tt, errs := strconv.ParseFloat(tmp_decimal, 64)
  4925. fmt.Println(errs)
  4926. decimal = tt
  4927. //if adminUser.CurrentOrgId == 10106{
  4928. // if len(fapiao_code) == 0{
  4929. // fapiao_code = "144072080589"
  4930. // }
  4931. // if len(fapiao_number) == 0{
  4932. // order, _ := service.GetLastHisOrder(adminUser.CurrentOrgId)
  4933. // if order.ID == 0{
  4934. // fapiao_number = "00001520"
  4935. // }else{
  4936. // //fapiao_code = "00001520"
  4937. // fpNumber, _ := strconv.Atoi(order.FaPiaoNumber)
  4938. // var zero string
  4939. // if fpNumber >= 1000{
  4940. // zero = "0000" + strconv.Itoa(fpNumber)
  4941. // }else if fpNumber >= 10000{
  4942. // zero = "000" + strconv.Itoa(fpNumber)
  4943. // } else if fpNumber >= 100000{
  4944. // zero = "00" + strconv.Itoa(fpNumber)
  4945. // } else if fpNumber >= 1000000{
  4946. // zero = "0" + strconv.Itoa(fpNumber)
  4947. // }else {
  4948. // zero = strconv.Itoa(fpNumber)
  4949. // }
  4950. // fapiao_number = zero
  4951. // }
  4952. // }
  4953. //}
  4954. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  4955. his, _ := service.GetNewHisPatientInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  4956. var patientPrescription models.HisPrescriptionInfo
  4957. patientPrescription, _ = service.FindHisPatientPrescriptionInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  4958. if patientPrescription.ID == 0 {
  4959. patientPrescription, _ = service.FindLastPatientPrescriptionInfo(adminUser.CurrentOrgId, id, recordDateTime)
  4960. }
  4961. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  4962. department, _ := service.GetDepartMentDetail(patientPrescription.Departments)
  4963. doctor_info, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, patientPrescription.DoctorId)
  4964. diagnosis_ids := strings.Split(diagnosis_id, ",")
  4965. var config []*models.HisXtDiagnoseConfig
  4966. for _, item := range diagnosis_ids {
  4967. id, _ := strconv.ParseInt(item, 10, 64)
  4968. diagnosisConfig, _ := service.FindDiagnoseById(id)
  4969. config = append(config, &diagnosisConfig)
  4970. }
  4971. sickConfig, _ := service.FindSickById(sick_type)
  4972. //if tempOrder.ID == 0 {
  4973. // tempOrder, _ = service.GetTodayHisOrder(adminUser.CurrentOrgId, id, recordDateTime, his.Number)
  4974. //}
  4975. if tempOrder.ID == 0 {
  4976. var result string
  4977. var requestLog string
  4978. var res2 ResultSix
  4979. var ressix10265 ResultSix10265
  4980. if miConfig.MdtrtareaAdmvs == "421300" {
  4981. data := make(map[string]interface{})
  4982. client := &http.Client{}
  4983. data["psn_no"] = his.PsnNo
  4984. data["mdtrt_id"] = his.Number
  4985. data["opter"] = roles.UserName
  4986. data["org_name"] = miConfig.OrgName
  4987. data["med_type"] = strconv.FormatInt(reg_type, 10)
  4988. data["doctor_id"] = doctor_info.DoctorNumber
  4989. data["doctor_name"] = doctor_info.UserName
  4990. data["department"] = department.Name
  4991. data["fixmedins_code"] = miConfig.Code
  4992. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  4993. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  4994. data["secret_key"] = miConfig.SecretKey
  4995. data["sick_code"] = sickConfig.CountryCode
  4996. data["sick_name"] = sickConfig.ClassName
  4997. data["dept"] = strconv.FormatInt(department.ID, 10)
  4998. data["config"] = config
  4999. data["begin_time"] = begin_time
  5000. bytesData, _ := json.Marshal(data)
  5001. req, _ := http.NewRequest("POST", "http://192.168.124.4:9532/"+"hbyb/2203", bytes.NewReader(bytesData))
  5002. resp, _ := client.Do(req)
  5003. defer resp.Body.Close()
  5004. body, ioErr := ioutil.ReadAll(resp.Body)
  5005. if ioErr != nil {
  5006. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  5007. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5008. return
  5009. }
  5010. var respJSON map[string]interface{}
  5011. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  5012. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  5013. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5014. return
  5015. }
  5016. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  5017. userJSONBytes, _ := json.Marshal(respJSON)
  5018. fmt.Println("log")
  5019. fmt.Println(string(userJSONBytes))
  5020. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  5021. utils.ErrorLog("解析失败:%v", err)
  5022. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5023. return
  5024. }
  5025. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  5026. //江苏地区国家医保医疗类别
  5027. //职工透析:医疗类别选特殊情况门诊9933
  5028. //居民血透门慢: 医疗类别选门诊慢病1402
  5029. //var med_type string
  5030. //if his.Insutype == "310" {
  5031. // if reg_type == 14 {
  5032. // med_type = "9933"
  5033. // } else if reg_type == 11 {
  5034. // med_type = "11"
  5035. //
  5036. // }
  5037. //} else if his.Insutype == "390" {
  5038. // if reg_type == 14 {
  5039. // med_type = "1402"
  5040. // } else if reg_type == 11 {
  5041. // med_type = "11"
  5042. // }
  5043. //}
  5044. data := make(map[string]interface{})
  5045. client := &http.Client{}
  5046. data["psn_no"] = his.PsnNo
  5047. data["mdtrt_id"] = his.Number
  5048. data["doctor"] = roles.UserName
  5049. data["department"] = department.Name
  5050. data["org_name"] = miConfig.OrgName
  5051. data["med_type"] = strconv.FormatInt(reg_type, 10)
  5052. data["doctor_id"] = strconv.FormatInt(doctor_info.AdminUserId, 10)
  5053. data["fixmedins_code"] = miConfig.Code
  5054. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  5055. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  5056. data["secret_key"] = miConfig.SecretKey
  5057. data["sick_code"] = sickConfig.CountryCode
  5058. data["sick_name"] = sickConfig.ClassName
  5059. data["url"] = miConfig.Url
  5060. data["ak"] = miConfig.AccessKey
  5061. data["begin_time"] = begin_time
  5062. data["cainfo"] = miConfig.Cainfo
  5063. data["dept"] = strconv.FormatInt(department.ID, 10)
  5064. data["config"] = config
  5065. bytesData, _ := json.Marshal(data)
  5066. var req *http.Request
  5067. if miConfig.MdtrtareaAdmvs == "320921" {
  5068. req, _ = http.NewRequest("POST", "http://192.168.3.111:9532/"+"jsyb/2203", bytes.NewReader(bytesData))
  5069. //api = "http://192.168.3.111:9532/" + "jsyb/readcard?" + "fixmedins_code=" + miConfig.Code + "&secret_key=" + miConfig.SecretKey + "&ak=" + miConfig.AccessKey + "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName +
  5070. // "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&cainfo=" + miConfig.Cainfo
  5071. } else {
  5072. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2203", bytes.NewReader(bytesData))
  5073. }
  5074. resp, _ := client.Do(req)
  5075. defer resp.Body.Close()
  5076. body, ioErr := ioutil.ReadAll(resp.Body)
  5077. if ioErr != nil {
  5078. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  5079. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5080. return
  5081. }
  5082. var respJSON map[string]interface{}
  5083. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  5084. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  5085. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5086. return
  5087. }
  5088. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  5089. userJSONBytes, _ := json.Marshal(respJSON)
  5090. fmt.Println("log")
  5091. fmt.Println(string(userJSONBytes))
  5092. if err := json.Unmarshal(userJSONBytes, &ressix10265); err != nil {
  5093. utils.ErrorLog("解析失败:%v", err)
  5094. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5095. return
  5096. }
  5097. res2.InfRefmsgid = ressix10265.InfRefmsgid
  5098. res2.Output = ressix10265.Output
  5099. res2.ErrMsg = ressix10265.ErrMsg
  5100. res2.Cainfo = ressix10265.Cainfo
  5101. res2.WarnMsg = ressix10265.WarnMsg
  5102. infocode, _ := strconv.ParseInt(ressix10265.Infcode, 10, 64)
  5103. res2.Infcode = infocode
  5104. } else {
  5105. if miConfig.MdtrtareaAdmvs == "440781" { //
  5106. 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)
  5107. } else {
  5108. if miConfig.Code == "H15049901371" {
  5109. //赤峰地区国家医保医疗类别
  5110. //职工透析:医疗类别选特殊情况门诊990502
  5111. //居民定额血透门慢: 医疗类别选门诊慢病140104
  5112. var med_type string
  5113. if his.Insutype == "390" {
  5114. if reg_type == 14 {
  5115. med_type = "9933"
  5116. } else if reg_type == 11 {
  5117. med_type = "11"
  5118. }
  5119. } else if his.Insutype == "310" {
  5120. if reg_type == 14 {
  5121. med_type = "990502"
  5122. } else if reg_type == 11 {
  5123. med_type = "11"
  5124. }
  5125. }
  5126. 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)
  5127. } else {
  5128. 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)
  5129. }
  5130. }
  5131. saveLog(result, requestLog, "2203", "上传就诊信息")
  5132. var respJSON2 map[string]interface{}
  5133. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  5134. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  5135. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5136. return
  5137. }
  5138. userJSONBytes2, _ := json.Marshal(respJSON2)
  5139. if miConfig.Code == "H15049901371" {
  5140. if err := json.Unmarshal(userJSONBytes2, &ressix10265); err != nil {
  5141. utils.ErrorLog("解析失败:%v", err)
  5142. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5143. return
  5144. }
  5145. res2.InfRefmsgid = ressix10265.InfRefmsgid
  5146. res2.Output = ressix10265.Output
  5147. res2.ErrMsg = ressix10265.ErrMsg
  5148. res2.Cainfo = ressix10265.Cainfo
  5149. res2.WarnMsg = ressix10265.WarnMsg
  5150. infocode, _ := strconv.ParseInt(ressix10265.Infcode, 10, 64)
  5151. res2.Infcode = infocode
  5152. } else {
  5153. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  5154. utils.ErrorLog("解析失败:%v", err)
  5155. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5156. return
  5157. }
  5158. }
  5159. }
  5160. if res2.Infcode != 0 {
  5161. adminUser := c.GetAdminUserInfo()
  5162. errlog := &models.HisOrderError{
  5163. UserOrgId: adminUser.CurrentOrgId,
  5164. Ctime: time.Now().Unix(),
  5165. Mtime: time.Now().Unix(),
  5166. ErrMsg: res2.ErrMsg,
  5167. Status: 1,
  5168. PatientId: id,
  5169. RecordTime: recordDateTime,
  5170. Stage: 3,
  5171. }
  5172. service.CreateErrMsgLog(errlog)
  5173. c.ServeSuccessJSON(map[string]interface{}{
  5174. "failed_code": -10,
  5175. "msg": res2.ErrMsg,
  5176. })
  5177. return
  5178. } else {
  5179. his.Diagnosis = diagnosis_id
  5180. his.SickType = sickConfig.ID
  5181. //var p_type int64
  5182. //if reg_type == 1111 || reg_type == 1112 {
  5183. // p_type = 11
  5184. //
  5185. //}
  5186. his.PType = fmt.Sprintf("%d", reg_type)
  5187. service.UpdateHisPatientThree(&his)
  5188. data := make(map[string]interface{})
  5189. if settle_accounts_type == 1 { //日结
  5190. if reg_type == 11 || reg_type == 1111 || reg_type == 1112 {
  5191. prescriptions, _ = service.GetPrescriptionByIds(ids_arr, adminUser.CurrentOrgId)
  5192. } else {
  5193. prescriptions, _ = service.GetNewHisPrescription(adminUser.CurrentOrgId, his_patient_id, recordDateTime, strconv.Itoa(int(reg_type)))
  5194. }
  5195. //prescriptions, _ = service.GetNewHisPrescriptionTwo(adminUser.CurrentOrgId, his_patient_id, recordDateTime, reg_type)
  5196. data["pre"] = prescriptions
  5197. } else { //月结
  5198. start_time_str := c.GetString("start_time")
  5199. end_time_str := c.GetString("end_time")
  5200. timeLayout := "2006-01-02"
  5201. loc, _ := time.LoadLocation("Local")
  5202. theStartTime, err := time.ParseInLocation(timeLayout+" 15:04:05", start_time_str+" 00:00:00", loc)
  5203. if err != nil {
  5204. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  5205. return
  5206. }
  5207. recordStartTime := theStartTime.Unix()
  5208. start_time = recordStartTime
  5209. theEndTime, err := time.ParseInLocation(timeLayout+" 15:04:05", end_time_str+" 00:00:00", loc)
  5210. if err != nil {
  5211. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  5212. return
  5213. }
  5214. recordEndTime := theEndTime.Unix()
  5215. end_time = recordEndTime
  5216. prescriptions, _ = service.GetMonthHisPrescriptionTwo(adminUser.CurrentOrgId, id, recordStartTime, recordEndTime, reg_type)
  5217. data["pre"] = prescriptions
  5218. }
  5219. timestamp := time.Now().Unix()
  5220. tempTime := time.Unix(timestamp, 0)
  5221. timeFormat := tempTime.Format("20060102150405")
  5222. chrgBchno := rand.Intn(100000) + 10000
  5223. chrg_bchno := timeFormat + strconv.FormatInt(int64(chrgBchno), 10) + strconv.FormatInt(his.PatientId, 10)
  5224. strconv.FormatInt(his.PatientId, 10)
  5225. client := &http.Client{}
  5226. data["psn_no"] = his.PsnNo
  5227. data["mdtrt_id"] = his.Number
  5228. data["chrg_bchno"] = chrg_bchno
  5229. data["org_name"] = miConfig.OrgName
  5230. data["doctor"] = doctor_info.UserName
  5231. data["doctor_id"] = doctor_info.DoctorNumber
  5232. data["dept"] = strconv.FormatInt(patientPrescription.Departments, 10)
  5233. data["fixmedins_code"] = miConfig.Code
  5234. data["opter"] = roles.UserName
  5235. data["dept_code"] = department.Number
  5236. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  5237. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  5238. data["secret_key"] = miConfig.SecretKey
  5239. data["balance_accounts_type"] = strconv.FormatInt(his.BalanceAccountsType, 10)
  5240. data["url"] = miConfig.Url
  5241. data["ak"] = miConfig.AccessKey
  5242. data["new_doctor_name"] = patientPrescription.Doctor
  5243. data["diag_code"] = sickConfig.CountryCode
  5244. data["cainfo"] = miConfig.Cainfo
  5245. var ids []int64
  5246. for _, item := range prescriptions {
  5247. ids = append(ids, item.ID)
  5248. }
  5249. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  5250. if config.IsOpen == 1 { //对接了医保,走医保流程
  5251. var res ResultFour
  5252. var resFour10265 ResultFour10265
  5253. if miConfig.MdtrtareaAdmvs == "421300" {
  5254. bytesData, _ := json.Marshal(data)
  5255. req, _ := http.NewRequest("POST", "http://192.168.124.4:9532/"+"hbyb/2204", bytes.NewReader(bytesData))
  5256. resp, _ := client.Do(req)
  5257. defer resp.Body.Close()
  5258. body, ioErr := ioutil.ReadAll(resp.Body)
  5259. if ioErr != nil {
  5260. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  5261. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5262. return
  5263. }
  5264. var respJSON map[string]interface{}
  5265. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  5266. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  5267. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5268. return
  5269. }
  5270. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  5271. userJSONBytes, _ := json.Marshal(respJSON)
  5272. fmt.Println("log")
  5273. fmt.Println(string(userJSONBytes))
  5274. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  5275. utils.ErrorLog("解析失败:%v", err)
  5276. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5277. return
  5278. }
  5279. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  5280. bytesData, _ := json.Marshal(data)
  5281. var req *http.Request
  5282. if miConfig.MdtrtareaAdmvs == "320921" {
  5283. req, _ = http.NewRequest("POST", "http://192.168.3.111:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  5284. } else {
  5285. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  5286. }
  5287. resp, _ := client.Do(req)
  5288. defer resp.Body.Close()
  5289. body, ioErr := ioutil.ReadAll(resp.Body)
  5290. if ioErr != nil {
  5291. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  5292. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5293. return
  5294. }
  5295. var respJSON map[string]interface{}
  5296. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  5297. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  5298. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5299. return
  5300. }
  5301. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  5302. userJSONBytes, _ := json.Marshal(respJSON)
  5303. fmt.Println("log")
  5304. fmt.Println(string(userJSONBytes))
  5305. if err := json.Unmarshal(userJSONBytes, &resFour10265); err != nil {
  5306. utils.ErrorLog("解析失败:%v", err)
  5307. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5308. return
  5309. }
  5310. res.InfRefmsgid = resFour10265.InfRefmsgid
  5311. res.Output = resFour10265.Output
  5312. res.ErrMsg = resFour10265.ErrMsg
  5313. res.Cainfo = resFour10265.Cainfo
  5314. res.WarnMsg = resFour10265.WarnMsg
  5315. infocode, _ := strconv.ParseInt(resFour10265.Infcode, 10, 64)
  5316. res.Infcode = infocode
  5317. } else {
  5318. if miConfig.Code == "H15049901371" {
  5319. 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)
  5320. var dat map[string]interface{}
  5321. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  5322. fmt.Println(dat)
  5323. } else {
  5324. fmt.Println(err)
  5325. }
  5326. saveLog(result, request_log, "2204", "上传费用明细")
  5327. userJSONBytes, _ := json.Marshal(dat)
  5328. if err := json.Unmarshal(userJSONBytes, &resFour10265); err != nil {
  5329. utils.ErrorLog("解析失败:%v", err)
  5330. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5331. return
  5332. }
  5333. res.InfRefmsgid = resFour10265.InfRefmsgid
  5334. res.Output = resFour10265.Output
  5335. res.ErrMsg = resFour10265.ErrMsg
  5336. res.Cainfo = resFour10265.Cainfo
  5337. res.WarnMsg = resFour10265.WarnMsg
  5338. infocode, _ := strconv.ParseInt(resFour10265.Infcode, 10, 64)
  5339. res.Infcode = infocode
  5340. } else {
  5341. 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)
  5342. var dat map[string]interface{}
  5343. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  5344. fmt.Println(dat)
  5345. } else {
  5346. fmt.Println(err)
  5347. }
  5348. saveLog(result, request_log, "2204", "上传费用明细")
  5349. userJSONBytes, _ := json.Marshal(dat)
  5350. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  5351. utils.ErrorLog("解析失败:%v", err)
  5352. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5353. return
  5354. }
  5355. }
  5356. }
  5357. if res.Infcode == 0 {
  5358. order := &models.HisOrder{
  5359. UserOrgId: adminUser.CurrentOrgId,
  5360. HisPatientId: his.ID,
  5361. PatientId: his.PatientId,
  5362. SettleAccountsDate: recordDateTime,
  5363. MdtrtId: his.Number,
  5364. PsnNo: his.PsnNo,
  5365. MedType: strconv.FormatInt(reg_type, 10),
  5366. Ctime: time.Now().Unix(),
  5367. Mtime: time.Now().Unix(),
  5368. Status: 1,
  5369. Number: chrg_bchno,
  5370. Infcode: res.Infcode,
  5371. WarnMsg: res.WarnMsg,
  5372. Cainfo: res.Cainfo,
  5373. ErrMsg: res.ErrMsg,
  5374. RespondTime: res.RefmsgTime,
  5375. InfRefmsgid: res.InfRefmsgid,
  5376. OrderStatus: 1,
  5377. PayWay: pay_way,
  5378. PayPrice: pay_price,
  5379. PayCardNo: pay_card_no,
  5380. DiscountPrice: discount_price,
  5381. PreferentialPrice: preferential_price,
  5382. RealityPrice: reality_price,
  5383. FoundPrice: found_price,
  5384. MedicalInsurancePrice: medical_insurance_price,
  5385. PrivatePrice: private_price,
  5386. IsMedicineInsurance: 1,
  5387. SettleType: settle_accounts_type,
  5388. SettleStartTime: start_time,
  5389. SettleEndTime: end_time,
  5390. Creator: roles.AdminUserId,
  5391. Modify: roles.AdminUserId,
  5392. FaPiaoNumber: fapiao_number,
  5393. FaPiaoCode: fapiao_code,
  5394. PType: 2,
  5395. Diagnosis: diagnosis_id,
  5396. }
  5397. err = service.CreateOrder(order)
  5398. if err != nil {
  5399. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCreatePreOrderException)
  5400. return
  5401. }
  5402. for _, item := range res.Output.Result {
  5403. temp := strings.Split(item.FeedetlSn, "-")
  5404. var advice_id int64 = 0
  5405. var project_id int64 = 0
  5406. var types int64 = 0
  5407. id, _ := strconv.ParseInt(temp[2], 10, 64)
  5408. types, _ = strconv.ParseInt(temp[1], 10, 64)
  5409. if temp[1] == "1" {
  5410. advice_id = id
  5411. project_id = 0
  5412. } else if temp[1] == "2" {
  5413. advice_id = 0
  5414. project_id = id
  5415. }
  5416. info := &models.HisOrderInfo{
  5417. OrderNumber: order.Number,
  5418. FeedetlSn: item.FeedetlSn,
  5419. UploadDate: time.Now().Unix(),
  5420. AdviceId: advice_id,
  5421. DetItemFeeSumamt: item.DetItemFeeSumamt,
  5422. Cnt: item.Cnt,
  5423. Pric: float64(item.Pric),
  5424. PatientId: his.PatientId,
  5425. PricUplmtAmt: item.PricUplmtAmt,
  5426. SelfpayProp: item.SelfpayProp,
  5427. FulamtOwnpayAmt: item.FulamtOwnpayAmt,
  5428. OverlmtAmt: item.OverlmtAmt,
  5429. PreselfpayAmt: item.PreselfpayAmt,
  5430. BasMednFlag: item.BasMednFlag,
  5431. MedChrgitmType: item.MedChrgitmType,
  5432. HiNegoDrugFlag: item.HiNegoDrugFlag,
  5433. Status: 1,
  5434. Memo: item.Memo,
  5435. Mtime: time.Now().Unix(),
  5436. InscpScpAmt: item.InscpScpAmt,
  5437. DrtReimFlag: item.DrtReimFlag,
  5438. Ctime: time.Now().Unix(),
  5439. ListSpItemFlag: item.ListSpItemFlag,
  5440. ChldMedcFlag: item.ChldMedcFlag,
  5441. LmtUsedFlag: item.LmtUsedFlag,
  5442. ChrgitmLv: item.ChrgitmLv,
  5443. UserOrgId: adminUser.CurrentOrgId,
  5444. HisPatientId: his.ID,
  5445. OrderId: order.ID,
  5446. ProjectId: project_id,
  5447. Type: types,
  5448. }
  5449. service.CreateOrderInfo(info)
  5450. }
  5451. service.UpDatePrescriptionNumber(adminUser.CurrentOrgId, ids, chrg_bchno)
  5452. service.UpDateHisPrescriptionInfoNumber(adminUser.CurrentOrgId, his_patient_id, chrg_bchno, recordDateTime)
  5453. var total float64
  5454. for _, item := range prescriptions {
  5455. if item.Type == 1 { //药品
  5456. for _, subItem := range item.HisDoctorAdviceInfo {
  5457. total = total + (subItem.Price * subItem.PrescribingNumber)
  5458. }
  5459. }
  5460. if item.Type == 2 { //项目
  5461. for _, subItem := range item.HisPrescriptionProject {
  5462. cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  5463. total = total + (subItem.Price * cnt)
  5464. }
  5465. }
  5466. }
  5467. for _, item := range prescriptions {
  5468. for _, subItem := range item.HisAdditionalCharge {
  5469. total = total + (subItem.Price * float64(subItem.Count))
  5470. }
  5471. }
  5472. var allTotal string
  5473. if adminUser.CurrentOrgId == 9919 {
  5474. allTotal = fmt.Sprintf("%.4f", total)
  5475. } else {
  5476. allTotal = fmt.Sprintf("%.4f", total)
  5477. }
  5478. if res.Infcode == 0 {
  5479. var rf []*ResultFive
  5480. json.Unmarshal([]byte(his.Iinfo), &rf)
  5481. chrg_bchno := chrg_bchno
  5482. cert_no := his.Certno
  5483. var insutypes []string
  5484. var insutype string
  5485. var is390 int = 0
  5486. var is310 int = 0
  5487. for _, item := range rf {
  5488. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  5489. insutypes = append(insutypes, item.Insutype)
  5490. }
  5491. }
  5492. if len(insutypes) == 1 {
  5493. insutype = insutypes[0]
  5494. } else {
  5495. for _, i := range insutypes {
  5496. if i == "390" {
  5497. is390 = 1
  5498. }
  5499. if i == "310" {
  5500. is310 = 1
  5501. }
  5502. }
  5503. }
  5504. if is390 == 1 {
  5505. insutype = "390"
  5506. }
  5507. if is310 == 1 {
  5508. insutype = "310"
  5509. }
  5510. if len(insutypes) == 0 {
  5511. insutype = "310"
  5512. }
  5513. if len(insutypes) == 2 {
  5514. insutype = strconv.FormatInt(his.SocialType, 10)
  5515. }
  5516. insutype = strconv.FormatInt(his.SocialType, 10)
  5517. //insutype = "390"
  5518. if his.IdCardType == 1 {
  5519. // cert_no = his.MedicalInsuranceNumber
  5520. cert_no = his.Certno
  5521. } else {
  5522. cert_no = his.Certno
  5523. }
  5524. var res ResultSeven
  5525. var resSeven10265 ResultSeven10265
  5526. var src_resquest string
  5527. var result2 string
  5528. var acct_used_flag string
  5529. fmt.Println("pay_way")
  5530. fmt.Println(pay_way)
  5531. fmt.Println("pay_way")
  5532. if pay_way == 4 {
  5533. acct_used_flag = "1"
  5534. } else {
  5535. acct_used_flag = "0"
  5536. }
  5537. if miConfig.MdtrtareaAdmvs == "421300" {
  5538. api := "http://192.168.124.4:9532/" + "hbyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  5539. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  5540. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  5541. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  5542. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  5543. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  5544. "&insutype=" + insutype + "&total=" + allTotal + "&med_type=" + strconv.FormatInt(reg_type, 10) + "&acct_used_flag=" + acct_used_flag
  5545. resp, requestErr := http.Get(api)
  5546. if requestErr != nil {
  5547. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5548. return
  5549. }
  5550. body, ioErr := ioutil.ReadAll(resp.Body)
  5551. if ioErr != nil {
  5552. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  5553. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5554. return
  5555. }
  5556. var respJSON map[string]interface{}
  5557. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  5558. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  5559. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5560. return
  5561. }
  5562. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  5563. result, _ := json.Marshal(respJSON)
  5564. if miConfig.Code == "H15049901371" {
  5565. if err := json.Unmarshal([]byte(result), &resSeven10265); err != nil {
  5566. utils.ErrorLog("解析失败:%v", err)
  5567. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5568. return
  5569. }
  5570. res.InfRefmsgid = resSeven10265.InfRefmsgid
  5571. res.Output = resSeven10265.Output
  5572. res.ErrMsg = resSeven10265.ErrMsg
  5573. res.Cainfo = resSeven10265.Cainfo
  5574. res.WarnMsg = resSeven10265.WarnMsg
  5575. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  5576. res.Infcode = infocode
  5577. } else {
  5578. if err := json.Unmarshal([]byte(result), &res); err != nil {
  5579. utils.ErrorLog("解析失败:%v", err)
  5580. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5581. return
  5582. }
  5583. }
  5584. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  5585. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  5586. psn_info.VerifyNumber = strings.Replace(psn_info.VerifyNumber, "+", "%2B", -1)
  5587. bas := strings.Split(psn_info.CardInfo, "|")
  5588. if his.IdCardType == 1 {
  5589. cert_no = bas[2]
  5590. } else if his.IdCardType == 3 {
  5591. cert_no = his.Certno
  5592. psn_info.VerifyNumber = his.Certno + "|" + psn_info.VerifyNumber
  5593. } else if his.IdCardType == 4 {
  5594. cert_no = his.Certno
  5595. psn_info.VerifyNumber = token
  5596. }
  5597. var api string
  5598. if miConfig.MdtrtareaAdmvs == "320921" {
  5599. api = "http://192.168.3.111:9532/" + "jsyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  5600. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  5601. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  5602. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  5603. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  5604. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  5605. "&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
  5606. } else {
  5607. api = "http://192.168.5.251:9532/" + "jsyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  5608. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  5609. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  5610. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  5611. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  5612. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  5613. "&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
  5614. }
  5615. resp, requestErr := http.Get(api)
  5616. if requestErr != nil {
  5617. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5618. return
  5619. }
  5620. body, ioErr := ioutil.ReadAll(resp.Body)
  5621. if ioErr != nil {
  5622. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  5623. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5624. return
  5625. }
  5626. var respJSON map[string]interface{}
  5627. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  5628. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  5629. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5630. return
  5631. }
  5632. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  5633. result, _ := json.Marshal(respJSON)
  5634. if err := json.Unmarshal([]byte(result), &resSeven10265); err != nil {
  5635. utils.ErrorLog("解析失败:%v", err)
  5636. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5637. return
  5638. }
  5639. res.InfRefmsgid = resSeven10265.InfRefmsgid
  5640. res.Output = resSeven10265.Output
  5641. res.ErrMsg = resSeven10265.ErrMsg
  5642. res.Cainfo = resSeven10265.Cainfo
  5643. res.WarnMsg = resSeven10265.WarnMsg
  5644. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  5645. res.Infcode = infocode
  5646. } else {
  5647. if miConfig.Code == "H15049901371" {
  5648. //赤峰地区国家医保医疗类别
  5649. //职工透析:医疗类别选特殊情况门诊990502
  5650. //居民定额血透门慢: 医疗类别选门诊慢病140104
  5651. var med_type string
  5652. if his.Insutype == "390" {
  5653. if reg_type == 14 {
  5654. med_type = "9933"
  5655. } else if reg_type == 11 {
  5656. med_type = "11"
  5657. }
  5658. } else if his.Insutype == "310" {
  5659. if reg_type == 14 {
  5660. med_type = "990502"
  5661. } else if reg_type == 11 {
  5662. med_type = "11"
  5663. }
  5664. }
  5665. 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)
  5666. } else {
  5667. 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)
  5668. }
  5669. //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)
  5670. var dat map[string]interface{}
  5671. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  5672. fmt.Println(dat)
  5673. } else {
  5674. fmt.Println(err)
  5675. }
  5676. saveLog(result2, src_resquest, "2207", "结算")
  5677. userJSONBytes, _ := json.Marshal(dat)
  5678. if miConfig.Code == "H15049901371" {
  5679. if err := json.Unmarshal(userJSONBytes, &resSeven10265); err != nil {
  5680. utils.ErrorLog("解析失败:%v", err)
  5681. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5682. return
  5683. }
  5684. res.InfRefmsgid = resSeven10265.InfRefmsgid
  5685. res.Output = resSeven10265.Output
  5686. res.ErrMsg = resSeven10265.ErrMsg
  5687. res.Cainfo = resSeven10265.Cainfo
  5688. res.WarnMsg = resSeven10265.WarnMsg
  5689. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  5690. res.Infcode = infocode
  5691. } else {
  5692. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  5693. utils.ErrorLog("解析失败:%v", err)
  5694. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5695. return
  5696. }
  5697. }
  5698. }
  5699. if res.Infcode != 0 {
  5700. errlog := &models.HisOrderError{
  5701. UserOrgId: adminUser.CurrentOrgId,
  5702. Ctime: time.Now().Unix(),
  5703. Mtime: time.Now().Unix(),
  5704. Number: chrg_bchno,
  5705. ErrMsg: res.ErrMsg,
  5706. Status: 1,
  5707. PatientId: id,
  5708. RecordTime: recordDateTime,
  5709. Stage: 6,
  5710. }
  5711. service.CreateErrMsgLog(errlog)
  5712. c.ServeSuccessJSON(map[string]interface{}{
  5713. "failed_code": -10,
  5714. "msg": res.ErrMsg,
  5715. })
  5716. return
  5717. } else {
  5718. order, _ := service.GetHisOrderTwo(adminUser.CurrentOrgId, chrg_bchno, id)
  5719. order.OrderStatus = 2
  5720. order.Status = 1
  5721. order.MdtrtId = res.Output.Setlinfo.MdtrtID
  5722. order.SetlId = res.Output.Setlinfo.SetlID
  5723. order.PsnNo = res.Output.Setlinfo.PsnNo
  5724. order.PsnName = res.Output.Setlinfo.PsnName
  5725. order.PsnCertType = res.Output.Setlinfo.PsnCertType
  5726. order.Certno = res.Output.Setlinfo.Certno
  5727. order.Gend = res.Output.Setlinfo.Gend
  5728. order.Naty = res.Output.Setlinfo.Naty
  5729. order.Age = res.Output.Setlinfo.Age
  5730. order.Insutype = res.Output.Setlinfo.Insutype
  5731. order.PsnType = res.Output.Setlinfo.PsnType
  5732. order.CvlservFlag = res.Output.Setlinfo.CvlservFlag
  5733. order.SetlTime = res.Output.Setlinfo.SetlTime
  5734. order.MdtrtCertType = res.Output.Setlinfo.MdtrtCertType
  5735. if res.Output.Setlinfo.MedType == "140101" {
  5736. order.MedType = "14"
  5737. } else {
  5738. order.MedType = res.Output.Setlinfo.MedType
  5739. }
  5740. if reg_type == 1112 {
  5741. order.MedType = "1112"
  5742. }
  5743. if reg_type == 1111 {
  5744. order.MedType = "1111"
  5745. }
  5746. order.MedfeeSumamt = res.Output.Setlinfo.MedfeeSumamt
  5747. order.FulamtOwnpayAmt = res.Output.Setlinfo.FulamtOwnpayAmt
  5748. order.OverlmtSelfPay = res.Output.Setlinfo.OverlmtSelfpay
  5749. order.PreselfpayAmt = res.Output.Setlinfo.PreselfpayAmt
  5750. order.InscpScpAmt = res.Output.Setlinfo.InscpScpAmt
  5751. order.ActPayDedc = res.Output.Setlinfo.ActPayDedc
  5752. order.HifpPay = res.Output.Setlinfo.HifpPay
  5753. order.CvlservPay = res.Output.Setlinfo.CvlservPay
  5754. order.PoolPropSelfpay = res.Output.Setlinfo.PoolPropSelfpay
  5755. order.HifesPay = res.Output.Setlinfo.HifesPay
  5756. order.HifobPay = res.Output.Setlinfo.HifobPay
  5757. order.MafPay = res.Output.Setlinfo.MafPay
  5758. order.HifmiPay = res.Output.Setlinfo.HifmiPay
  5759. order.OthPay = res.Output.Setlinfo.OthPay
  5760. order.FundPaySumamt = res.Output.Setlinfo.FundPaySumamt
  5761. order.PsnPartAmt = res.Output.Setlinfo.PsnPartAmt
  5762. order.AcctPay = res.Output.Setlinfo.AcctPay
  5763. order.PsnCashPay = res.Output.Setlinfo.PsnCashPay
  5764. order.HospPartAmt = res.Output.Setlinfo.HospPartAmt
  5765. order.Balc = res.Output.Setlinfo.Balc
  5766. order.AcctMulaidPay = res.Output.Setlinfo.AcctMulaidPay
  5767. order.MedinsSetlId = res.Output.Setlinfo.MedinsSetlID
  5768. order.ClrOptins = res.Output.Setlinfo.ClrOptins
  5769. order.ClrType = res.Output.Setlinfo.ClrType
  5770. order.ClrWay = res.Output.Setlinfo.ClrWay
  5771. order.Creator = order.Creator
  5772. order.Modify = roles.AdminUserId
  5773. order.RequestLog = src_resquest
  5774. setlDetail, _ := json.Marshal(res.Output.Setldetail)
  5775. detailStr := string(setlDetail)
  5776. order.SetlDetail = detailStr
  5777. err := service.UpdataOrderStatusTwo(chrg_bchno, adminUser.CurrentOrgId)
  5778. err = service.UpDateOrder(order)
  5779. if err == nil {
  5780. //判断是否使用了押金
  5781. if dec_way == "true" {
  5782. tmpstring := strconv.FormatInt(order.ID, 10)
  5783. order.Decimal = decimal
  5784. service.UpDateOrder(order)
  5785. //扣押金
  5786. errmsg = service.SpendDeposit(c.GetAdminUserInfo().CurrentOrgId, id, c.GetAdminUserInfo().AdminUser.Id, tmpstring, decimal)
  5787. if errmsg != nil {
  5788. c.ServeFailJsonSend(enums.ErrorCodeParamWrong, errmsg.Error())
  5789. return
  5790. }
  5791. }
  5792. c.ServeSuccessJSON(map[string]interface{}{
  5793. "msg": "结算成功",
  5794. })
  5795. } else {
  5796. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeAmountAccountException)
  5797. return
  5798. }
  5799. }
  5800. } else {
  5801. adminUser := c.GetAdminUserInfo()
  5802. errlog := &models.HisOrderError{
  5803. UserOrgId: adminUser.CurrentOrgId,
  5804. Ctime: time.Now().Unix(),
  5805. Mtime: time.Now().Unix(),
  5806. ErrMsg: res.ErrMsg,
  5807. Status: 1,
  5808. PatientId: id,
  5809. RecordTime: recordDateTime,
  5810. Stage: 4,
  5811. }
  5812. service.CreateErrMsgLog(errlog)
  5813. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeRegisterRepeatException)
  5814. return
  5815. }
  5816. } else {
  5817. adminUser := c.GetAdminUserInfo()
  5818. errlog := &models.HisOrderError{
  5819. UserOrgId: adminUser.CurrentOrgId,
  5820. Ctime: time.Now().Unix(),
  5821. Mtime: time.Now().Unix(),
  5822. ErrMsg: res.ErrMsg,
  5823. Status: 1,
  5824. PatientId: id,
  5825. RecordTime: recordDateTime,
  5826. Stage: 4,
  5827. }
  5828. service.CreateErrMsgLog(errlog)
  5829. c.ServeSuccessJSON(map[string]interface{}{
  5830. "failed_code": -10,
  5831. "msg": res.ErrMsg,
  5832. })
  5833. return
  5834. //c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCalOrderException)
  5835. //return
  5836. }
  5837. }
  5838. }
  5839. } else if tempOrder.ID > 0 {
  5840. if tempOrder.IsPre == 1 {
  5841. allTotal := fmt.Sprintf("%.4f", tempOrder.MedfeeSumamt)
  5842. var rf []*ResultFive
  5843. json.Unmarshal([]byte(his.Iinfo), &rf)
  5844. chrg_bchno := tempOrder.Number
  5845. cert_no := his.Certno
  5846. var insutypes []string
  5847. var insutype string
  5848. var is390 int = 0
  5849. var is310 int = 0
  5850. for _, item := range rf {
  5851. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  5852. insutypes = append(insutypes, item.Insutype)
  5853. }
  5854. }
  5855. if len(insutypes) == 1 {
  5856. insutype = insutypes[0]
  5857. } else {
  5858. for _, i := range insutypes {
  5859. if i == "390" {
  5860. is390 = 1
  5861. }
  5862. if i == "310" {
  5863. is310 = 1
  5864. }
  5865. }
  5866. }
  5867. if is390 == 1 {
  5868. insutype = "390"
  5869. }
  5870. if is310 == 1 {
  5871. insutype = "310"
  5872. }
  5873. if len(insutypes) == 0 {
  5874. insutype = "310"
  5875. }
  5876. if len(insutypes) == 2 {
  5877. insutype = strconv.FormatInt(his.SocialType, 64)
  5878. }
  5879. //insutype = "390"
  5880. if his.IdCardType == 1 {
  5881. // cert_no = his.MedicalInsuranceNumber
  5882. cert_no = his.Certno
  5883. } else {
  5884. cert_no = his.Certno
  5885. }
  5886. var res ResultSeven
  5887. var resSeven10265 ResultSeven10265
  5888. var src_resquest string
  5889. var result2 string
  5890. var acct_used_flag string
  5891. fmt.Println("pay_way")
  5892. fmt.Println(pay_way)
  5893. fmt.Println("pay_way")
  5894. if pay_way == 4 {
  5895. acct_used_flag = "1"
  5896. } else {
  5897. acct_used_flag = "0"
  5898. }
  5899. if miConfig.MdtrtareaAdmvs == "421300" {
  5900. api := "http://192.168.124.4:9532/" + "hbyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  5901. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  5902. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  5903. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  5904. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  5905. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  5906. "&insutype=" + insutype + "&total=" + allTotal + "&med_type=" + strconv.FormatInt(reg_type, 10) + "&acct_used_flag=" + acct_used_flag
  5907. resp, requestErr := http.Get(api)
  5908. if requestErr != nil {
  5909. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5910. return
  5911. }
  5912. body, ioErr := ioutil.ReadAll(resp.Body)
  5913. if ioErr != nil {
  5914. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  5915. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5916. return
  5917. }
  5918. var respJSON map[string]interface{}
  5919. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  5920. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  5921. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5922. return
  5923. }
  5924. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  5925. result, _ := json.Marshal(respJSON)
  5926. fmt.Println("log")
  5927. fmt.Println(string(result))
  5928. if err := json.Unmarshal([]byte(result), &res); err != nil {
  5929. utils.ErrorLog("解析失败:%v", err)
  5930. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5931. return
  5932. }
  5933. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  5934. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  5935. psn_info.VerifyNumber = strings.Replace(psn_info.VerifyNumber, "+", "%2B", -1)
  5936. //psn_info, _ := service.GetPsnByPatientId(id)
  5937. bas := strings.Split(psn_info.CardInfo, "|")
  5938. if his.IdCardType == 1 {
  5939. cert_no = bas[2]
  5940. } else {
  5941. cert_no = bas[1]
  5942. }
  5943. //江苏地区国家医保医疗类别
  5944. //职工透析:医疗类别选特殊情况门诊9933
  5945. //居民血透门慢: 医疗类别选门诊慢病1402
  5946. //var med_type string
  5947. //if his.Insutype == "310" {
  5948. // if reg_type == 14 {
  5949. // med_type = "9933"
  5950. // } else if reg_type == 11 {
  5951. // med_type = "11"
  5952. //
  5953. // }
  5954. //} else if his.Insutype == "390" {
  5955. // if reg_type == 14 {
  5956. // med_type = "1402"
  5957. // } else if reg_type == 11 {
  5958. // med_type = "11"
  5959. // }
  5960. //}
  5961. var api string
  5962. if miConfig.MdtrtareaAdmvs == "320921" {
  5963. api = "http://192.168.3.111:9532/" + "jsyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  5964. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  5965. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  5966. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  5967. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  5968. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  5969. "&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
  5970. //req, _ = http.NewRequest("POST", "http://192.168.3.111:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  5971. } else {
  5972. //req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  5973. api = "http://192.168.5.251:9532/" + "jsyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  5974. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  5975. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  5976. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  5977. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  5978. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  5979. "&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
  5980. }
  5981. resp, requestErr := http.Get(api)
  5982. if requestErr != nil {
  5983. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5984. return
  5985. }
  5986. body, ioErr := ioutil.ReadAll(resp.Body)
  5987. if ioErr != nil {
  5988. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  5989. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5990. return
  5991. }
  5992. var respJSON map[string]interface{}
  5993. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  5994. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  5995. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5996. return
  5997. }
  5998. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  5999. result, _ := json.Marshal(respJSON)
  6000. fmt.Println("log")
  6001. fmt.Println(string(result))
  6002. if err := json.Unmarshal([]byte(result), &resSeven10265); err != nil {
  6003. utils.ErrorLog("解析失败:%v", err)
  6004. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6005. return
  6006. }
  6007. res.InfRefmsgid = resSeven10265.InfRefmsgid
  6008. res.Output = resSeven10265.Output
  6009. res.ErrMsg = resSeven10265.ErrMsg
  6010. res.Cainfo = resSeven10265.Cainfo
  6011. res.WarnMsg = resSeven10265.WarnMsg
  6012. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  6013. res.Infcode = infocode
  6014. } else {
  6015. var src_resquest string
  6016. if miConfig.Code == "H15049901371" {
  6017. //赤峰地区国家医保医疗类别
  6018. //职工透析:医疗类别选特殊情况门诊990502
  6019. //居民定额血透门慢: 医疗类别选门诊慢病140104
  6020. var med_type string
  6021. if his.Insutype == "390" {
  6022. if reg_type == 14 {
  6023. med_type = "9933"
  6024. } else if reg_type == 11 {
  6025. med_type = "11"
  6026. }
  6027. } else if his.Insutype == "310" {
  6028. if reg_type == 14 {
  6029. med_type = "990502"
  6030. } else if reg_type == 11 {
  6031. med_type = "11"
  6032. }
  6033. }
  6034. 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)
  6035. } else {
  6036. 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)
  6037. }
  6038. var dat map[string]interface{}
  6039. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  6040. fmt.Println(dat)
  6041. } else {
  6042. fmt.Println(err)
  6043. }
  6044. saveLog(result2, src_resquest, "2207", "结算")
  6045. userJSONBytes, _ := json.Marshal(dat)
  6046. if miConfig.Code == "H15049901371" {
  6047. if err := json.Unmarshal(userJSONBytes, &resSeven10265); err != nil {
  6048. utils.ErrorLog("解析失败:%v", err)
  6049. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6050. return
  6051. }
  6052. res.InfRefmsgid = resSeven10265.InfRefmsgid
  6053. res.Output = resSeven10265.Output
  6054. res.ErrMsg = resSeven10265.ErrMsg
  6055. res.Cainfo = resSeven10265.Cainfo
  6056. res.WarnMsg = resSeven10265.WarnMsg
  6057. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  6058. res.Infcode = infocode
  6059. } else {
  6060. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  6061. utils.ErrorLog("解析失败:%v", err)
  6062. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6063. return
  6064. }
  6065. }
  6066. }
  6067. if res.Infcode != 0 {
  6068. errlog := &models.HisOrderError{
  6069. UserOrgId: adminUser.CurrentOrgId,
  6070. Ctime: time.Now().Unix(),
  6071. Mtime: time.Now().Unix(),
  6072. Number: chrg_bchno,
  6073. ErrMsg: res.ErrMsg,
  6074. Status: 1,
  6075. PatientId: id,
  6076. RecordTime: recordDateTime,
  6077. Stage: 6,
  6078. }
  6079. service.CreateErrMsgLog(errlog)
  6080. c.ServeSuccessJSON(map[string]interface{}{
  6081. "failed_code": -10,
  6082. "msg": res.ErrMsg,
  6083. })
  6084. return
  6085. } else {
  6086. order, _ := service.GetHisOrderTwo(adminUser.CurrentOrgId, chrg_bchno, id)
  6087. order.OrderStatus = 2
  6088. order.MdtrtId = res.Output.Setlinfo.MdtrtID
  6089. order.SetlId = res.Output.Setlinfo.SetlID
  6090. order.PsnNo = res.Output.Setlinfo.PsnNo
  6091. order.PsnName = res.Output.Setlinfo.PsnName
  6092. order.PsnCertType = res.Output.Setlinfo.PsnCertType
  6093. order.Certno = res.Output.Setlinfo.Certno
  6094. order.Gend = res.Output.Setlinfo.Gend
  6095. order.Naty = res.Output.Setlinfo.Naty
  6096. order.Age = res.Output.Setlinfo.Age
  6097. order.Insutype = res.Output.Setlinfo.Insutype
  6098. order.PsnType = res.Output.Setlinfo.PsnType
  6099. order.CvlservFlag = res.Output.Setlinfo.CvlservFlag
  6100. order.SetlTime = res.Output.Setlinfo.SetlTime
  6101. order.MdtrtCertType = res.Output.Setlinfo.MdtrtCertType
  6102. //order.MedType = res.Output.Setlinfo.MedType
  6103. if reg_type == 1112 {
  6104. order.MedType = "1112"
  6105. }
  6106. if reg_type == 1111 {
  6107. order.MedType = "1111"
  6108. }
  6109. order.MedfeeSumamt = res.Output.Setlinfo.MedfeeSumamt
  6110. order.FulamtOwnpayAmt = res.Output.Setlinfo.FulamtOwnpayAmt
  6111. order.OverlmtSelfPay = res.Output.Setlinfo.OverlmtSelfpay
  6112. order.PreselfpayAmt = res.Output.Setlinfo.PreselfpayAmt
  6113. order.InscpScpAmt = res.Output.Setlinfo.InscpScpAmt
  6114. order.ActPayDedc = res.Output.Setlinfo.ActPayDedc
  6115. order.HifpPay = res.Output.Setlinfo.HifpPay
  6116. order.CvlservPay = res.Output.Setlinfo.CvlservPay
  6117. order.PoolPropSelfpay = res.Output.Setlinfo.PoolPropSelfpay
  6118. order.HifesPay = res.Output.Setlinfo.HifesPay
  6119. order.HifobPay = res.Output.Setlinfo.HifobPay
  6120. order.MafPay = res.Output.Setlinfo.MafPay
  6121. order.HifmiPay = res.Output.Setlinfo.HifmiPay
  6122. order.OthPay = res.Output.Setlinfo.OthPay
  6123. order.FundPaySumamt = res.Output.Setlinfo.FundPaySumamt
  6124. order.PsnPartAmt = res.Output.Setlinfo.PsnPartAmt
  6125. order.AcctPay = res.Output.Setlinfo.AcctPay
  6126. order.PsnCashPay = res.Output.Setlinfo.PsnCashPay
  6127. order.HospPartAmt = res.Output.Setlinfo.HospPartAmt
  6128. order.Balc = res.Output.Setlinfo.Balc
  6129. order.AcctMulaidPay = res.Output.Setlinfo.AcctMulaidPay
  6130. order.MedinsSetlId = res.Output.Setlinfo.MedinsSetlID
  6131. order.ClrOptins = res.Output.Setlinfo.ClrOptins
  6132. order.ClrWay = res.Output.Setlinfo.ClrWay
  6133. order.Creator = order.Creator
  6134. order.Modify = roles.AdminUserId
  6135. order.RequestLog = src_resquest
  6136. order.Diagnosis = diagnosis_id
  6137. setlDetail, _ := json.Marshal(res.Output.Setldetail)
  6138. detailStr := string(setlDetail)
  6139. order.SetlDetail = detailStr
  6140. err := service.UpdataOrderStatusTwo(chrg_bchno, adminUser.CurrentOrgId)
  6141. err = service.UpDateOrder(order)
  6142. if err == nil {
  6143. //判断是否使用了押金
  6144. if dec_way == "true" {
  6145. tmpstring := strconv.FormatInt(order.ID, 10)
  6146. //扣押金
  6147. order.Decimal = decimal
  6148. service.UpDateOrder(order)
  6149. errmsg = service.SpendDeposit(c.GetAdminUserInfo().CurrentOrgId, id, c.GetAdminUserInfo().AdminUser.Id, tmpstring, decimal)
  6150. if errmsg != nil {
  6151. c.ServeFailJsonSend(enums.ErrorCodeParamWrong, errmsg.Error())
  6152. return
  6153. }
  6154. }
  6155. c.ServeSuccessJSON(map[string]interface{}{
  6156. "msg": "结算成功",
  6157. })
  6158. } else {
  6159. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeAmountAccountException)
  6160. return
  6161. }
  6162. }
  6163. }
  6164. }
  6165. }
  6166. //func (c *HisApiController) GetPreUploadInfo() {
  6167. // id, _ := c.GetInt64("id")
  6168. // record_time := c.GetString("record_time")
  6169. // settle_accounts_type, _ := c.GetInt64("settle_accounts_type")
  6170. // admin_user_id, _ := c.GetInt64("admin_user_id")
  6171. //
  6172. // timeLayout := "2006-01-02"
  6173. // loc, _ := time.LoadLocation("Local")
  6174. // theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  6175. // if err != nil {
  6176. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  6177. // return
  6178. // }
  6179. // recordDateTime := theTime.Unix()
  6180. // adminUser := c.GetAdminUserInfo()
  6181. //
  6182. // var prescriptions []*models.HisPrescription
  6183. //
  6184. // var start_time int64
  6185. // var end_time int64
  6186. //
  6187. // data := make(map[string]interface{})
  6188. // if settle_accounts_type == 1 { //日结
  6189. // prescriptions, _ = service.GetHisPrescription(adminUser.CurrentOrgId, id, recordDateTime)
  6190. // data["pre"] = prescriptions
  6191. //
  6192. // } else { //月结
  6193. // start_time_str := c.GetString("start_time")
  6194. // end_time_str := c.GetString("end_time")
  6195. // timeLayout := "2006-01-02"
  6196. // loc, _ := time.LoadLocation("Local")
  6197. // theStartTime, err := time.ParseInLocation(timeLayout+" 15:04:05", start_time_str+" 00:00:00", loc)
  6198. // if err != nil {
  6199. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  6200. // return
  6201. // }
  6202. // recordStartTime := theStartTime.Unix()
  6203. // start_time = recordStartTime
  6204. // theEndTime, err := time.ParseInLocation(timeLayout+" 15:04:05", end_time_str+" 00:00:00", loc)
  6205. // if err != nil {
  6206. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  6207. // return
  6208. // }
  6209. // recordEndTime := theEndTime.Unix()
  6210. // end_time = recordEndTime
  6211. // prescriptions, _ = service.GetMonthHisPrescription(adminUser.CurrentOrgId, id, recordStartTime, recordEndTime)
  6212. // data["pre"] = prescriptions
  6213. //
  6214. // }
  6215. //
  6216. // roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  6217. //
  6218. // his, _ := service.GetVMHisPatientInfo(adminUser.CurrentOrgId, id, recordDateTime)
  6219. // timestamp := time.Now().Unix()
  6220. // tempTime := time.Unix(timestamp, 0)
  6221. // timeFormat := tempTime.Format("20060102150405")
  6222. // chrgBchno := rand.Intn(100000) + 10000
  6223. // chrg_bchno := timeFormat + strconv.FormatInt(int64(chrgBchno), 10) + strconv.FormatInt(his.PatientId, 10)
  6224. // miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  6225. // patientPrescription, _ := service.FindPatientPrescriptionInfo(adminUser.CurrentOrgId, id, recordDateTime)
  6226. // department, _ := service.GetDepartMentDetail(patientPrescription.Departments)
  6227. // strconv.FormatInt(his.PatientId, 10)
  6228. // client := &http.Client{}
  6229. // data["psn_no"] = his.PsnNo
  6230. // data["mdtrt_id"] = his.Number
  6231. // data["chrg_bchno"] = chrg_bchno
  6232. // data["org_name"] = miConfig.OrgName
  6233. // data["doctor"] = roles.UserName
  6234. // data["doctor_id"] = strconv.FormatInt(roles.AdminUserId, 10)
  6235. // data["dept"] = strconv.FormatInt(patientPrescription.Departments, 10)
  6236. // data["fixmedins_code"] = miConfig.Code
  6237. // data["dept_code"] = department.Number
  6238. // data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  6239. // data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  6240. // data["secret_key"] = miConfig.SecretKey
  6241. // var ids []int64
  6242. //
  6243. // for _, item := range prescriptions {
  6244. // ids = append(ids, item.ID)
  6245. // }
  6246. // config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  6247. // if config.IsOpen == 1 { //对接了医保,走医保流程
  6248. // bytesData, _ := json.Marshal(data)
  6249. // req, _ := http.NewRequest("POST", "http://127.0.0.1:9532/"+"gdyb/five", bytes.NewReader(bytesData))
  6250. // resp, _ := client.Do(req)
  6251. // defer resp.Body.Close()
  6252. // body, ioErr := ioutil.ReadAll(resp.Body)
  6253. // if ioErr != nil {
  6254. // utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  6255. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6256. // return
  6257. // }
  6258. // var respJSON map[string]interface{}
  6259. // if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  6260. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  6261. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6262. // return
  6263. // }
  6264. //
  6265. // respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  6266. // userJSONBytes, _ := json.Marshal(respJSON)
  6267. // var res ResultFour
  6268. // if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  6269. // utils.ErrorLog("解析失败:%v", err)
  6270. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6271. // return
  6272. // }
  6273. //
  6274. // if res.Infcode == 0 {
  6275. // order := &models.HisOrder{
  6276. // UserOrgId: adminUser.CurrentOrgId,
  6277. // HisPatientId: his.ID,
  6278. // PatientId: his.PatientId,
  6279. // SettleAccountsDate: recordDateTime,
  6280. // Ctime: time.Now().Unix(),
  6281. // Mtime: time.Now().Unix(),
  6282. // Status: 1,
  6283. // Number: chrg_bchno,
  6284. // Infcode: res.Infcode,
  6285. // WarnMsg: res.WarnMsg,
  6286. // Cainfo: res.Cainfo,
  6287. // ErrMsg: res.ErrMsg,
  6288. // RespondTime: res.RefmsgTime,
  6289. // InfRefmsgid: res.InfRefmsgid,
  6290. // OrderStatus: 1,
  6291. // IsMedicineInsurance: 1,
  6292. // SettleType: settle_accounts_type,
  6293. // SettleStartTime: start_time,
  6294. // SettleEndTime: end_time,
  6295. // Creator: roles.ID,
  6296. // Modify: roles.ID,
  6297. // PType: 2,
  6298. // }
  6299. // err = service.CreateOrder(order)
  6300. // if err != nil {
  6301. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCreatePreOrderException)
  6302. // return
  6303. // }
  6304. //
  6305. // for _, item := range res.Output.Result {
  6306. // temp := strings.Split(item.FeedetlSn, "-")
  6307. // var advice_id int64 = 0
  6308. // var project_id int64 = 0
  6309. // var types int64 = 0
  6310. //
  6311. // id, _ := strconv.ParseInt(temp[2], 10, 64)
  6312. // types, _ = strconv.ParseInt(temp[1], 10, 64)
  6313. //
  6314. // if temp[1] == "1" {
  6315. // advice_id = id
  6316. // project_id = 0
  6317. // } else if temp[1] == "2" {
  6318. // advice_id = 0
  6319. // project_id = id
  6320. // }
  6321. //
  6322. // info := &models.HisOrderInfo{
  6323. // OrderNumber: order.Number,
  6324. // FeedetlSn: item.FeedetlSn,
  6325. // UploadDate: time.Now().Unix(),
  6326. // AdviceId: advice_id,
  6327. // DetItemFeeSumamt: item.DetItemFeeSumamt,
  6328. // Cnt: item.Cnt,
  6329. // Pric: float64(item.Pric),
  6330. // PatientId: his.PatientId,
  6331. // PricUplmtAmt: item.PricUplmtAmt,
  6332. // SelfpayProp: item.SelfpayProp,
  6333. // FulamtOwnpayAmt: item.FulamtOwnpayAmt,
  6334. // OverlmtAmt: item.OverlmtAmt,
  6335. // PreselfpayAmt: item.PreselfpayAmt,
  6336. // BasMednFlag: item.BasMednFlag,
  6337. // MedChrgitmType: item.MedChrgitmType,
  6338. // HiNegoDrugFlag: item.HiNegoDrugFlag,
  6339. // Status: 1,
  6340. // Memo: item.Memo,
  6341. // Mtime: time.Now().Unix(),
  6342. // InscpScpAmt: item.InscpScpAmt,
  6343. // DrtReimFlag: item.DrtReimFlag,
  6344. // Ctime: time.Now().Unix(),
  6345. // ListSpItemFlag: item.ListSpItemFlag,
  6346. // ChldMedcFlag: item.ChldMedcFlag,
  6347. // LmtUsedFlag: item.LmtUsedFlag,
  6348. // ChrgitmLv: item.ChrgitmLv,
  6349. // UserOrgId: adminUser.CurrentOrgId,
  6350. // HisPatientId: his.ID,
  6351. // OrderId: order.ID,
  6352. // ProjectId: project_id,
  6353. // Type: types,
  6354. // }
  6355. // service.CreateOrderInfo(info)
  6356. //
  6357. // }
  6358. // service.UpDatePrescriptionNumber(adminUser.CurrentOrgId, ids, chrg_bchno)
  6359. // service.UpDatePrescriptionInfoNumber(adminUser.CurrentOrgId, patientPrescription.PatientId, chrg_bchno, recordDateTime)
  6360. //
  6361. // var total float64
  6362. // for _, item := range prescriptions {
  6363. // if item.Type == 1 { //药品
  6364. // for _, subItem := range item.HisDoctorAdviceInfo {
  6365. // total = total + (subItem.Price * subItem.PrescribingNumber)
  6366. // }
  6367. // }
  6368. // if item.Type == 2 { //项目
  6369. // for _, subItem := range item.HisPrescriptionProject {
  6370. // total = total + (subItem.Price * float64(subItem.Count))
  6371. // }
  6372. // }
  6373. // }
  6374. //
  6375. // for _, item := range prescriptions {
  6376. // for _, subItem := range item.HisAdditionalCharge {
  6377. // total = total + (subItem.Price * float64(subItem.Count))
  6378. // }
  6379. // }
  6380. //
  6381. // allTotal := fmt.Sprintf("%.2f", total)
  6382. // if res.Infcode == 0 {
  6383. // var rf []*ResultFive
  6384. // json.Unmarshal([]byte(his.Iinfo), &rf)
  6385. // psn_no := his.PsnNo
  6386. // mdtrt_id := his.Number
  6387. // chrg_bchno := chrg_bchno
  6388. // cert_no := his.Certno
  6389. // insutype := rf[0].Insutype
  6390. //
  6391. // if his.IdCardType == 1 {
  6392. // cert_no = his.MedicalInsuranceNumber
  6393. //
  6394. // } else {
  6395. //
  6396. // cert_no = his.Certno
  6397. //
  6398. // }
  6399. //
  6400. // api := "http://127.0.0.1:9532/" + "gdyb/seven?cert_no=" + cert_no + "&insutype=" +
  6401. // insutype + "&psn_no=" + psn_no + "&chrg_bchno=" + chrg_bchno + "&mdtrt_id=" + mdtrt_id +
  6402. // "&total=" + allTotal + "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code + "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" +
  6403. // miConfig.SecretKey + "&med_type=" + strconv.FormatInt(patientPrescription.RegisterType, 10) + "&id_card_type=" + strconv.FormatInt(int64(his.IdCardType), 10)
  6404. // resp, requestErr := http.Get(api)
  6405. // if requestErr != nil {
  6406. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6407. // return
  6408. // }
  6409. // defer resp.Body.Close()
  6410. // body, ioErr := ioutil.ReadAll(resp.Body)
  6411. // if ioErr != nil {
  6412. // utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  6413. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6414. // return
  6415. // }
  6416. // var respJSON map[string]interface{}
  6417. // if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  6418. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  6419. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6420. // return
  6421. // }
  6422. // fmt.Println(respJSON)
  6423. // respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  6424. // userJSONBytes, _ := json.Marshal(respJSON)
  6425. // var res ResultSeven
  6426. // if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  6427. // utils.ErrorLog("解析失败:%v", err)
  6428. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6429. // return
  6430. // }
  6431. // if res.Infcode != 0 {
  6432. // errlog := &models.HisOrderError{
  6433. // UserOrgId: adminUser.CurrentOrgId,
  6434. // Ctime: time.Now().Unix(),
  6435. // Mtime: time.Now().Unix(),
  6436. // Number: chrg_bchno,
  6437. // ErrMsg: res.ErrMsg,
  6438. // Status: 1,
  6439. // PatientId: id,
  6440. // RecordTime: recordDateTime,
  6441. // Stage: 7,
  6442. // }
  6443. // service.CreateErrMsgLog(errlog)
  6444. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeRegisterRepeatException)
  6445. // return
  6446. // } else {
  6447. // order, _ := service.GetHisOrderTwo(adminUser.CurrentOrgId, chrg_bchno, id)
  6448. // order.OrderStatus = 1
  6449. // order.MdtrtId = res.Output.Setlinfo.MdtrtID
  6450. // order.SetlId = res.Output.Setlinfo.SetlID
  6451. // order.PsnNo = res.Output.Setlinfo.PsnNo
  6452. // order.PsnName = res.Output.Setlinfo.PsnName
  6453. // order.PsnCertType = res.Output.Setlinfo.PsnCertType
  6454. // order.Certno = res.Output.Setlinfo.Certno
  6455. // order.Gend = res.Output.Setlinfo.Gend
  6456. // order.Naty = res.Output.Setlinfo.Naty
  6457. // order.Age = res.Output.Setlinfo.Age
  6458. // order.Insutype = res.Output.Setlinfo.Insutype
  6459. // order.PsnType = res.Output.Setlinfo.PsnType
  6460. // order.CvlservFlag = res.Output.Setlinfo.CvlservFlag
  6461. // order.SetlTime = res.Output.Setlinfo.SetlTime
  6462. // order.MdtrtCertType = res.Output.Setlinfo.MdtrtCertType
  6463. // order.MedType = res.Output.Setlinfo.MedType
  6464. // order.MedfeeSumamt = res.Output.Setlinfo.MedfeeSumamt
  6465. // order.FulamtOwnpayAmt = res.Output.Setlinfo.FulamtOwnpayAmt
  6466. // order.OverlmtSelfPay = res.Output.Setlinfo.OverlmtSelfpay
  6467. // order.PreselfpayAmt = res.Output.Setlinfo.PreselfpayAmt
  6468. // order.InscpScpAmt = res.Output.Setlinfo.InscpScpAmt
  6469. // order.ActPayDedc = res.Output.Setlinfo.ActPayDedc
  6470. // order.HifpPay = res.Output.Setlinfo.HifpPay
  6471. // order.CvlservPay = res.Output.Setlinfo.CvlservPay
  6472. // order.PoolPropSelfpay = res.Output.Setlinfo.PoolPropSelfpay
  6473. // order.HifesPay = res.Output.Setlinfo.HifesPay
  6474. // order.HifobPay = res.Output.Setlinfo.HifobPay
  6475. // order.MafPay = res.Output.Setlinfo.MafPay
  6476. // order.OthPay = res.Output.Setlinfo.OthPay
  6477. // order.FundPaySumamt = res.Output.Setlinfo.FundPaySumamt
  6478. // order.PsnPartAmt = res.Output.Setlinfo.PsnPartAmt
  6479. // order.AcctPay = res.Output.Setlinfo.AcctPay
  6480. // order.PsnCashPay = res.Output.Setlinfo.PsnCashPay
  6481. // order.HospPartAmt = res.Output.Setlinfo.HospPartAmt
  6482. // order.Balc = res.Output.Setlinfo.Balc
  6483. // order.AcctMulaidPay = res.Output.Setlinfo.AcctMulaidPay
  6484. // order.MedinsSetlId = res.Output.Setlinfo.MedinsSetlID
  6485. // order.ClrOptins = res.Output.Setlinfo.ClrOptins
  6486. // order.ClrWay = res.Output.Setlinfo.ClrWay
  6487. // order.Creator = order.Creator
  6488. // order.Modify = roles.ID
  6489. // setlDetail, _ := json.Marshal(res.Output.Setldetail)
  6490. // detailStr := string(setlDetail)
  6491. // order.SetlDetail = detailStr
  6492. // //err := service.UpdataOrderStatusTwo(chrg_bchno, adminUser.CurrentOrgId)
  6493. // err = service.UpDateOrder(order)
  6494. // if err == nil {
  6495. // c.ServeSuccessJSON(map[string]interface{}{
  6496. // "msg": "预结算成功",
  6497. // })
  6498. // } else {
  6499. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeAmountAccountException)
  6500. // return
  6501. // }
  6502. // }
  6503. // } else {
  6504. // adminUser := c.GetAdminUserInfo()
  6505. // errlog := &models.HisOrderError{
  6506. // UserOrgId: adminUser.CurrentOrgId,
  6507. // Ctime: time.Now().Unix(),
  6508. // Mtime: time.Now().Unix(),
  6509. // ErrMsg: res.ErrMsg,
  6510. // Status: 1,
  6511. // PatientId: id,
  6512. // RecordTime: recordDateTime,
  6513. // Stage: 4,
  6514. // }
  6515. // service.CreateErrMsgLog(errlog)
  6516. //
  6517. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeRegisterRepeatException)
  6518. // return
  6519. // }
  6520. // } else {
  6521. // adminUser := c.GetAdminUserInfo()
  6522. // errlog := &models.HisOrderError{
  6523. // UserOrgId: adminUser.CurrentOrgId,
  6524. // Ctime: time.Now().Unix(),
  6525. // Mtime: time.Now().Unix(),
  6526. // ErrMsg: res.ErrMsg,
  6527. // Status: 1,
  6528. // PatientId: id,
  6529. // RecordTime: recordDateTime,
  6530. // Stage: 4,
  6531. // }
  6532. // service.CreateErrMsgLog(errlog)
  6533. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCalOrderException)
  6534. // return
  6535. // }
  6536. //
  6537. // } else {
  6538. // var total float64
  6539. // for _, item := range prescriptions {
  6540. // if item.Type == 1 { //药品
  6541. // for _, subItem := range item.HisDoctorAdviceInfo {
  6542. // total = total + (subItem.Price * subItem.PrescribingNumber)
  6543. // }
  6544. // }
  6545. // if item.Type == 2 { //项目
  6546. // for _, subItem := range item.HisPrescriptionProject {
  6547. // total = total + (subItem.Price * float64(subItem.Count))
  6548. // }
  6549. // }
  6550. //
  6551. // for _, subItem := range item.HisAdditionalCharge {
  6552. // total = total + (subItem.Price * float64(subItem.Count))
  6553. // }
  6554. // }
  6555. //
  6556. // allTotal := fmt.Sprintf("%.2f", total)
  6557. // totals, _ := strconv.ParseFloat(allTotal, 64)
  6558. // order := &models.HisOrder{
  6559. // UserOrgId: adminUser.CurrentOrgId,
  6560. // HisPatientId: his.ID,
  6561. // PatientId: id,
  6562. // SettleAccountsDate: recordDateTime,
  6563. // Ctime: time.Now().Unix(),
  6564. // Mtime: time.Now().Unix(),
  6565. // Status: 1,
  6566. // OrderStatus: 2,
  6567. // Number: chrg_bchno,
  6568. // MedfeeSumamt: totals,
  6569. // }
  6570. // err = service.CreateOrder(order)
  6571. // if err != nil {
  6572. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCreatePreOrderException)
  6573. // return
  6574. // }
  6575. //
  6576. // var customs []*Custom
  6577. // for _, item := range prescriptions {
  6578. //
  6579. // if item.Type == 1 { //药品
  6580. // for _, subItem := range item.HisDoctorAdviceInfo {
  6581. // cus := &Custom{
  6582. // AdviceId: subItem.ID,
  6583. // ProjectId: 0,
  6584. // DetItemFeeSumamt: fmt.Sprintf("%.2f", subItem.Price*subItem.PrescribingNumber),
  6585. // Cut: fmt.Sprintf("%.2f", subItem.PrescribingNumber),
  6586. // FeedetlSn: subItem.FeedetlSn,
  6587. // Price: fmt.Sprintf("%.2f", subItem.Price),
  6588. // MedListCodg: subItem.MedListCodg,
  6589. // Type: 1,
  6590. // }
  6591. // customs = append(customs, cus)
  6592. // }
  6593. // }
  6594. //
  6595. // if item.Type == 2 { //项目
  6596. // for _, subItem := range item.HisPrescriptionProject {
  6597. //
  6598. // cus := &Custom{
  6599. // AdviceId: 0,
  6600. // ProjectId: subItem.ID,
  6601. // DetItemFeeSumamt: fmt.Sprintf("%.2f", subItem.Price*float64(subItem.Count)),
  6602. // Cut: fmt.Sprintf("%.2f", float64(subItem.Count)),
  6603. // FeedetlSn: subItem.FeedetlSn,
  6604. // Price: fmt.Sprintf("%.2f", float64(subItem.Price)),
  6605. // MedListCodg: subItem.MedListCodg,
  6606. // Type: 2,
  6607. // }
  6608. //
  6609. // customs = append(customs, cus)
  6610. // }
  6611. // }
  6612. //
  6613. // for _, item := range item.HisAdditionalCharge {
  6614. // cus := &Custom{
  6615. // ItemId: item.ID,
  6616. // AdviceId: 0,
  6617. // ProjectId: 0,
  6618. // DetItemFeeSumamt: fmt.Sprintf("%.2f", item.Price),
  6619. // Cut: fmt.Sprintf("%.2f", float64(item.Count)),
  6620. // FeedetlSn: item.FeedetlSn,
  6621. // Price: fmt.Sprintf("%.2f", float64(item.Price)),
  6622. // MedListCodg: item.XtHisAddtionConfig.Code,
  6623. // Type: 3,
  6624. // }
  6625. //
  6626. // customs = append(customs, cus)
  6627. // }
  6628. //
  6629. // }
  6630. //
  6631. // for _, item := range customs {
  6632. // var advice_id int64 = 0
  6633. // var project_id int64 = 0
  6634. // var item_id int64 = 0
  6635. //
  6636. // var types int64 = 0
  6637. //
  6638. // if item.Type == 1 {
  6639. // advice_id = item.AdviceId
  6640. // project_id = 0
  6641. // item_id = 0
  6642. // } else if item.Type == 2 {
  6643. // advice_id = 0
  6644. // item_id = 0
  6645. //
  6646. // project_id = item.ProjectId
  6647. // } else if item.Type == 3 {
  6648. // advice_id = 0
  6649. // item_id = item.ItemId
  6650. // project_id = 0
  6651. // }
  6652. //
  6653. // detItemFeeSumamt, _ := strconv.ParseFloat(item.DetItemFeeSumamt, 32)
  6654. // cut, _ := strconv.ParseFloat(item.Cut, 32)
  6655. // pric, _ := strconv.ParseFloat(item.Price, 32)
  6656. //
  6657. // info := &models.HisOrderInfo{
  6658. // OrderNumber: order.Number,
  6659. // UploadDate: time.Now().Unix(),
  6660. // AdviceId: advice_id,
  6661. // DetItemFeeSumamt: detItemFeeSumamt,
  6662. // Cnt: cut,
  6663. // Pric: pric,
  6664. // PatientId: id,
  6665. // Status: 1,
  6666. // Mtime: time.Now().Unix(),
  6667. // Ctime: time.Now().Unix(),
  6668. // UserOrgId: adminUser.CurrentOrgId,
  6669. // HisPatientId: his.ID,
  6670. // OrderId: order.ID,
  6671. // ProjectId: project_id,
  6672. // Type: types,
  6673. // ItemId: item_id,
  6674. // }
  6675. // service.CreateOrderInfo(info)
  6676. // }
  6677. // //err := service.UpDateAddtionNumber(adminUser.CurrentOrgId, ids, chrg_bchno)
  6678. // err = service.UpDatePrescriptionNumber(adminUser.CurrentOrgId, ids, chrg_bchno)
  6679. // err = service.UpDatePrescriptionInfoNumber(adminUser.CurrentOrgId, id, chrg_bchno, recordDateTime)
  6680. // err = service.UpdataOrderStatusTwo(chrg_bchno, adminUser.CurrentOrgId)
  6681. // if err == nil {
  6682. // c.ServeSuccessJSON(map[string]interface{}{
  6683. // "msg": "结算成功",
  6684. // })
  6685. // } else {
  6686. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeAmountAccountException)
  6687. // return
  6688. // }
  6689. // }
  6690. //}
  6691. //上传明细-预结算-
  6692. func (c *HisApiController) GetPreUploadInfo() {
  6693. id, _ := c.GetInt64("id")
  6694. record_time := c.GetString("record_time")
  6695. his_patient_id, _ := c.GetInt64("his_patient_id")
  6696. settle_accounts_type, _ := c.GetInt64("settle_accounts_type")
  6697. admin_user_id, _ := c.GetInt64("admin_user_id")
  6698. diagnosis_id := c.GetString("diagnosis")
  6699. sick_type, _ := c.GetInt64("sick_type")
  6700. reg_type, _ := c.GetInt64("p_type")
  6701. begin_time := c.GetString("begin_time")
  6702. id_str := c.GetString("ids")
  6703. ids_arr := strings.Split(id_str, ",")
  6704. timeLayout := "2006-01-02"
  6705. loc, _ := time.LoadLocation("Local")
  6706. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  6707. if err != nil {
  6708. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  6709. return
  6710. }
  6711. recordDateTime := theTime.Unix()
  6712. adminUser := c.GetAdminUserInfo()
  6713. diagnosis_ids := strings.Split(diagnosis_id, ",")
  6714. var config []*models.HisXtDiagnoseConfig
  6715. for _, item := range diagnosis_ids {
  6716. id, _ := strconv.ParseInt(item, 10, 64)
  6717. diagnosisConfig, _ := service.FindDiagnoseById(id)
  6718. config = append(config, &diagnosisConfig)
  6719. }
  6720. //diagnosisConfig, _ := service.FindDiagnoseById(diagnosis_id)
  6721. sickConfig, _ := service.FindSickById(sick_type)
  6722. var prescriptions []*models.HisPrescription
  6723. var start_time int64
  6724. var end_time int64
  6725. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  6726. fmt.Println(his_patient_id)
  6727. his, _ := service.GetNewHisPatientInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  6728. timestamp := time.Now().Unix()
  6729. tempTime := time.Unix(timestamp, 0)
  6730. timeFormat := tempTime.Format("20060102150405")
  6731. chrgBchno := rand.Intn(100000) + 10000
  6732. chrg_bchno := timeFormat + strconv.FormatInt(int64(chrgBchno), 10) + strconv.FormatInt(his.PatientId, 10)
  6733. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  6734. var patientPrescription models.HisPrescriptionInfo
  6735. patientPrescription, _ = service.FindHisPatientPrescriptionInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  6736. if patientPrescription.ID == 0 {
  6737. patientPrescription, _ = service.FindLastPatientPrescriptionInfo(adminUser.CurrentOrgId, id, recordDateTime)
  6738. }
  6739. //miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  6740. department, _ := service.GetDepartMentDetail(patientPrescription.Departments)
  6741. doctor_info, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, patientPrescription.DoctorId)
  6742. strconv.FormatInt(his.PatientId, 10)
  6743. var res2 ResultSix
  6744. var resSix10265 ResultSix10265
  6745. var time_stamp string
  6746. if miConfig.MdtrtareaAdmvs == "421300" {
  6747. data := make(map[string]interface{})
  6748. client := &http.Client{}
  6749. data["psn_no"] = his.PsnNo
  6750. data["mdtrt_id"] = his.Number
  6751. data["department"] = department.Name
  6752. data["org_name"] = miConfig.OrgName
  6753. data["med_type"] = strconv.FormatInt(reg_type, 10)
  6754. data["doctor_id"] = doctor_info.DoctorNumber
  6755. data["doctor_name"] = roles.UserName
  6756. data["fixmedins_code"] = miConfig.Code
  6757. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  6758. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  6759. data["secret_key"] = miConfig.SecretKey
  6760. data["sick_code"] = sickConfig.CountryCode
  6761. data["sick_name"] = sickConfig.ClassName
  6762. data["begin_time"] = begin_time
  6763. data["dept"] = strconv.FormatInt(department.ID, 10)
  6764. data["config"] = config
  6765. data["opter"] = roles.UserName
  6766. fmt.Println(data)
  6767. bytesData, _ := json.Marshal(data)
  6768. req, _ := http.NewRequest("POST", "http://192.168.124.4:9532/"+"hbyb/2203", bytes.NewReader(bytesData))
  6769. resp, _ := client.Do(req)
  6770. defer resp.Body.Close()
  6771. body, ioErr := ioutil.ReadAll(resp.Body)
  6772. if ioErr != nil {
  6773. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  6774. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6775. return
  6776. }
  6777. var respJSON map[string]interface{}
  6778. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  6779. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  6780. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6781. return
  6782. }
  6783. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  6784. userJSONBytes, _ := json.Marshal(respJSON)
  6785. fmt.Println("log")
  6786. fmt.Println(string(userJSONBytes))
  6787. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  6788. utils.ErrorLog("解析失败:%v", err)
  6789. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6790. return
  6791. }
  6792. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  6793. //江苏地区国家医保医疗类别
  6794. //职工透析:医疗类别选特殊情况门诊9933
  6795. //居民血透门慢: 医疗类别选门诊慢病1402
  6796. //var med_type string
  6797. //if his.Insutype == "310" {
  6798. // if reg_type == 14 {
  6799. // med_type = "9933"
  6800. // } else if reg_type == 11 {
  6801. // med_type = "11"
  6802. //
  6803. // }
  6804. //} else if his.Insutype == "390" {
  6805. // if reg_type == 14 {
  6806. // med_type = "1402"
  6807. // } else if reg_type == 11 {
  6808. // med_type = "11"
  6809. // }
  6810. //}
  6811. data := make(map[string]interface{})
  6812. client := &http.Client{}
  6813. data["psn_no"] = his.PsnNo
  6814. data["mdtrt_id"] = his.Number
  6815. data["doctor"] = roles.UserName
  6816. data["department"] = department.Name
  6817. data["org_name"] = miConfig.OrgName
  6818. data["med_type"] = strconv.FormatInt(reg_type, 10)
  6819. data["doctor_id"] = strconv.FormatInt(doctor_info.AdminUserId, 10)
  6820. data["fixmedins_code"] = miConfig.Code
  6821. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  6822. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  6823. data["secret_key"] = miConfig.SecretKey
  6824. data["sick_code"] = sickConfig.CountryCode
  6825. data["sick_name"] = sickConfig.ClassName
  6826. data["begin_time"] = begin_time
  6827. data["dept"] = strconv.FormatInt(department.ID, 10)
  6828. data["config"] = config
  6829. data["url"] = miConfig.Url
  6830. data["ak"] = miConfig.AccessKey
  6831. data["cainfo"] = miConfig.Cainfo
  6832. bytesData, _ := json.Marshal(data)
  6833. var req *http.Request
  6834. if miConfig.MdtrtareaAdmvs == "320921" {
  6835. req, _ = http.NewRequest("POST", "http://192.168.3.111:9532/"+"jsyb/2203", bytes.NewReader(bytesData))
  6836. //api = "http://192.168.3.111:9532/" + "jsyb/readcard?" + "fixmedins_code=" + miConfig.Code + "&secret_key=" + miConfig.SecretKey + "&ak=" + miConfig.AccessKey + "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName +
  6837. // "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&cainfo=" + miConfig.Cainfo
  6838. } else {
  6839. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2203", bytes.NewReader(bytesData))
  6840. }
  6841. resp, _ := client.Do(req)
  6842. defer resp.Body.Close()
  6843. body, ioErr := ioutil.ReadAll(resp.Body)
  6844. if ioErr != nil {
  6845. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  6846. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6847. return
  6848. }
  6849. var respJSON map[string]interface{}
  6850. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  6851. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  6852. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6853. return
  6854. }
  6855. time_stamp = strconv.FormatInt(int64(respJSON["data"].(map[string]interface{})["time_stamp"].(float64)), 10)
  6856. //fmt.Println(respJSON["data"].(map[string]interface{})["time_stamp"].(string))
  6857. //time_stamp = respJSON["data"].(map[string]interface{})["time_stamp"].(string)
  6858. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  6859. userJSONBytes, _ := json.Marshal(respJSON)
  6860. fmt.Println("log")
  6861. fmt.Println(string(userJSONBytes))
  6862. if err := json.Unmarshal(userJSONBytes, &resSix10265); err != nil {
  6863. utils.ErrorLog("解析失败:%v", err)
  6864. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6865. return
  6866. }
  6867. res2.InfRefmsgid = resSix10265.InfRefmsgid
  6868. res2.Output = resSix10265.Output
  6869. res2.ErrMsg = resSix10265.ErrMsg
  6870. res2.Cainfo = resSix10265.Cainfo
  6871. res2.WarnMsg = resSix10265.WarnMsg
  6872. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  6873. res2.Infcode = infocode
  6874. } else {
  6875. var result string
  6876. var requestLog string
  6877. if miConfig.MdtrtareaAdmvs == "440781" { //
  6878. 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)
  6879. } else {
  6880. if miConfig.Code == "H15049901371" {
  6881. //赤峰地区国家医保医疗类别
  6882. //职工透析:医疗类别选特殊情况门诊990502
  6883. //居民定额血透门慢: 医疗类别选门诊慢病140104
  6884. var med_type string
  6885. if his.Insutype == "390" {
  6886. if reg_type == 14 {
  6887. med_type = "9933"
  6888. } else if reg_type == 11 {
  6889. med_type = "11"
  6890. }
  6891. } else if his.Insutype == "310" {
  6892. if reg_type == 14 {
  6893. med_type = "990502"
  6894. } else if reg_type == 11 {
  6895. med_type = "11"
  6896. }
  6897. }
  6898. 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)
  6899. } else {
  6900. 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)
  6901. }
  6902. saveLog(result, requestLog, "2203", "上传就诊信息")
  6903. var respJSON2 map[string]interface{}
  6904. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  6905. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  6906. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6907. return
  6908. }
  6909. userJSONBytes2, _ := json.Marshal(respJSON2)
  6910. if miConfig.Code == "H15049901371" {
  6911. if err := json.Unmarshal(userJSONBytes2, &resSix10265); err != nil {
  6912. utils.ErrorLog("解析失败:%v", err)
  6913. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6914. return
  6915. }
  6916. res2.InfRefmsgid = resSix10265.InfRefmsgid
  6917. res2.Output = resSix10265.Output
  6918. res2.ErrMsg = resSix10265.ErrMsg
  6919. res2.Cainfo = resSix10265.Cainfo
  6920. res2.WarnMsg = resSix10265.WarnMsg
  6921. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  6922. res2.Infcode = infocode
  6923. } else {
  6924. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  6925. utils.ErrorLog("解析失败:%v", err)
  6926. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6927. return
  6928. }
  6929. }
  6930. }
  6931. }
  6932. if res2.Infcode != 0 {
  6933. adminUser := c.GetAdminUserInfo()
  6934. errlog := &models.HisOrderError{
  6935. UserOrgId: adminUser.CurrentOrgId,
  6936. Ctime: time.Now().Unix(),
  6937. Mtime: time.Now().Unix(),
  6938. ErrMsg: res2.ErrMsg,
  6939. Status: 1,
  6940. PatientId: id,
  6941. RecordTime: recordDateTime,
  6942. Stage: 3,
  6943. }
  6944. service.CreateErrMsgLog(errlog)
  6945. c.ServeSuccessJSON(map[string]interface{}{
  6946. "failed_code": -10,
  6947. "msg": res2.ErrMsg,
  6948. })
  6949. return
  6950. } else {
  6951. his.Diagnosis = diagnosis_id
  6952. his.SickType = sickConfig.ID
  6953. his.PType = fmt.Sprintf("%d", reg_type)
  6954. service.UpdateHisPatientThree(&his)
  6955. data := make(map[string]interface{})
  6956. if settle_accounts_type == 1 { //日结
  6957. if reg_type == 11 || reg_type == 1111 || reg_type == 1112 {
  6958. prescriptions, _ = service.GetPrescriptionByIds(ids_arr, adminUser.CurrentOrgId)
  6959. } else {
  6960. prescriptions, _ = service.GetNewHisPrescription(adminUser.CurrentOrgId, his_patient_id, recordDateTime, strconv.Itoa(int(reg_type)))
  6961. }
  6962. data["pre"] = prescriptions
  6963. } else { //月结
  6964. start_time_str := c.GetString("start_time")
  6965. end_time_str := c.GetString("end_time")
  6966. timeLayout := "2006-01-02"
  6967. loc, _ := time.LoadLocation("Local")
  6968. theStartTime, err := time.ParseInLocation(timeLayout+" 15:04:05", start_time_str+" 00:00:00", loc)
  6969. if err != nil {
  6970. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  6971. return
  6972. }
  6973. recordStartTime := theStartTime.Unix()
  6974. start_time = recordStartTime
  6975. theEndTime, err := time.ParseInLocation(timeLayout+" 15:04:05", end_time_str+" 00:00:00", loc)
  6976. if err != nil {
  6977. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  6978. return
  6979. }
  6980. recordEndTime := theEndTime.Unix()
  6981. end_time = recordEndTime
  6982. prescriptions, _ = service.GetMonthHisPrescriptionTwo(adminUser.CurrentOrgId, id, recordStartTime, recordEndTime, reg_type)
  6983. data["pre"] = prescriptions
  6984. }
  6985. client := &http.Client{}
  6986. data["psn_no"] = his.PsnNo
  6987. data["mdtrt_id"] = his.Number
  6988. data["chrg_bchno"] = chrg_bchno
  6989. data["org_name"] = miConfig.OrgName
  6990. data["doctor"] = roles.UserName
  6991. data["doctor_id"] = strconv.FormatInt(roles.AdminUserId, 10)
  6992. data["dept"] = strconv.FormatInt(patientPrescription.Departments, 10)
  6993. data["fixmedins_code"] = miConfig.Code
  6994. data["balance_accounts_type"] = strconv.FormatInt(his.BalanceAccountsType, 10)
  6995. if (department.ID == 0 && adminUser.CurrentOrgId == 9919) || (department.ID == 0 && adminUser.CurrentOrgId == 10106) {
  6996. data["dept_code"] = "15"
  6997. } else {
  6998. data["dept_code"] = department.Number
  6999. }
  7000. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  7001. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  7002. data["secret_key"] = miConfig.SecretKey
  7003. data["url"] = miConfig.Url
  7004. data["ak"] = miConfig.AccessKey
  7005. data["new_doctor_name"] = patientPrescription.Doctor
  7006. data["diag_code"] = sickConfig.CountryCode
  7007. data["time_stamp"] = time_stamp
  7008. data["cainfo"] = miConfig.Cainfo
  7009. var ids []int64
  7010. for _, item := range prescriptions {
  7011. ids = append(ids, item.ID)
  7012. }
  7013. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  7014. if config.IsOpen == 1 { //对接了医保,走医保流程
  7015. var res ResultFour
  7016. var resFour10265 ResultFour10265
  7017. if miConfig.MdtrtareaAdmvs == "421300" {
  7018. bytesData, _ := json.Marshal(data)
  7019. req, _ := http.NewRequest("POST", "http://192.168.124.4:9532/"+"hbyb/2204", bytes.NewReader(bytesData))
  7020. resp, _ := client.Do(req)
  7021. defer resp.Body.Close()
  7022. body, ioErr := ioutil.ReadAll(resp.Body)
  7023. if ioErr != nil {
  7024. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  7025. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7026. return
  7027. }
  7028. var respJSON map[string]interface{}
  7029. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  7030. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  7031. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7032. return
  7033. }
  7034. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  7035. userJSONBytes, _ := json.Marshal(respJSON)
  7036. fmt.Println("log")
  7037. fmt.Println(string(userJSONBytes))
  7038. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  7039. utils.ErrorLog("解析失败:%v", err)
  7040. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7041. return
  7042. }
  7043. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  7044. bytesData, _ := json.Marshal(data)
  7045. var req *http.Request
  7046. if miConfig.MdtrtareaAdmvs == "320921" {
  7047. req, _ = http.NewRequest("POST", "http://192.168.3.111:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  7048. } else {
  7049. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  7050. }
  7051. resp, _ := client.Do(req)
  7052. defer resp.Body.Close()
  7053. body, ioErr := ioutil.ReadAll(resp.Body)
  7054. if ioErr != nil {
  7055. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  7056. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7057. return
  7058. }
  7059. var respJSON map[string]interface{}
  7060. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  7061. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  7062. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7063. return
  7064. }
  7065. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  7066. userJSONBytes, _ := json.Marshal(respJSON)
  7067. fmt.Println("log")
  7068. fmt.Println(string(userJSONBytes))
  7069. if err := json.Unmarshal(userJSONBytes, &resFour10265); err != nil {
  7070. utils.ErrorLog("解析失败:%v", err)
  7071. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7072. return
  7073. }
  7074. res.InfRefmsgid = resFour10265.InfRefmsgid
  7075. res.Output = resFour10265.Output
  7076. res.ErrMsg = resFour10265.ErrMsg
  7077. res.Cainfo = resFour10265.Cainfo
  7078. res.WarnMsg = resFour10265.WarnMsg
  7079. infocode, _ := strconv.ParseInt(resFour10265.Infcode, 10, 64)
  7080. res.Infcode = infocode
  7081. } else {
  7082. if miConfig.Code == "H15049901371" {
  7083. 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)
  7084. var dat map[string]interface{}
  7085. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  7086. fmt.Println(dat)
  7087. } else {
  7088. fmt.Println(err)
  7089. }
  7090. saveLog(result, request_log, "2204", "上传费用明细")
  7091. userJSONBytes, _ := json.Marshal(dat)
  7092. if err := json.Unmarshal(userJSONBytes, &resFour10265); err != nil {
  7093. utils.ErrorLog("解析失败:%v", err)
  7094. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7095. return
  7096. }
  7097. res.InfRefmsgid = resFour10265.InfRefmsgid
  7098. res.Output = resFour10265.Output
  7099. res.ErrMsg = resFour10265.ErrMsg
  7100. res.Cainfo = resFour10265.Cainfo
  7101. res.WarnMsg = resFour10265.WarnMsg
  7102. infocode, _ := strconv.ParseInt(resFour10265.Infcode, 10, 64)
  7103. res.Infcode = infocode
  7104. } else {
  7105. 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)
  7106. var dat map[string]interface{}
  7107. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  7108. fmt.Println(dat)
  7109. } else {
  7110. fmt.Println(err)
  7111. }
  7112. saveLog(result, request_log, "2204", "上传费用明细")
  7113. userJSONBytes, _ := json.Marshal(dat)
  7114. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  7115. utils.ErrorLog("解析失败:%v", err)
  7116. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7117. return
  7118. }
  7119. }
  7120. }
  7121. if res.Infcode == 0 {
  7122. order := &models.HisOrder{
  7123. UserOrgId: adminUser.CurrentOrgId,
  7124. HisPatientId: his.ID,
  7125. PatientId: his.PatientId,
  7126. SettleAccountsDate: recordDateTime,
  7127. Ctime: time.Now().Unix(),
  7128. Mtime: time.Now().Unix(),
  7129. MdtrtId: his.Number,
  7130. PsnNo: his.PsnNo,
  7131. MedType: strconv.FormatInt(reg_type, 10),
  7132. Status: 1,
  7133. Number: chrg_bchno,
  7134. Infcode: res.Infcode,
  7135. WarnMsg: res.WarnMsg,
  7136. Cainfo: res.Cainfo,
  7137. ErrMsg: res.ErrMsg,
  7138. RespondTime: res.RefmsgTime,
  7139. InfRefmsgid: res.InfRefmsgid,
  7140. OrderStatus: 1,
  7141. IsMedicineInsurance: 1,
  7142. SettleType: settle_accounts_type,
  7143. SettleStartTime: start_time,
  7144. SettleEndTime: end_time,
  7145. Creator: roles.AdminUserId,
  7146. Modify: roles.AdminUserId,
  7147. PType: 2,
  7148. Diagnosis: diagnosis_id,
  7149. }
  7150. err = service.CreateOrder(order)
  7151. if err != nil {
  7152. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCreatePreOrderException)
  7153. return
  7154. }
  7155. for _, item := range res.Output.Result {
  7156. temp := strings.Split(item.FeedetlSn, "-")
  7157. var advice_id int64 = 0
  7158. var project_id int64 = 0
  7159. var types int64 = 0
  7160. id, _ := strconv.ParseInt(temp[2], 10, 64)
  7161. types, _ = strconv.ParseInt(temp[1], 10, 64)
  7162. if temp[1] == "1" {
  7163. advice_id = id
  7164. project_id = 0
  7165. } else if temp[1] == "2" {
  7166. advice_id = 0
  7167. project_id = id
  7168. }
  7169. info := &models.HisOrderInfo{
  7170. OrderNumber: order.Number,
  7171. FeedetlSn: item.FeedetlSn,
  7172. UploadDate: time.Now().Unix(),
  7173. AdviceId: advice_id,
  7174. DetItemFeeSumamt: item.DetItemFeeSumamt,
  7175. Cnt: item.Cnt,
  7176. Pric: float64(item.Pric),
  7177. PatientId: his.PatientId,
  7178. PricUplmtAmt: item.PricUplmtAmt,
  7179. SelfpayProp: item.SelfpayProp,
  7180. FulamtOwnpayAmt: item.FulamtOwnpayAmt,
  7181. OverlmtAmt: item.OverlmtAmt,
  7182. PreselfpayAmt: item.PreselfpayAmt,
  7183. BasMednFlag: item.BasMednFlag,
  7184. MedChrgitmType: item.MedChrgitmType,
  7185. HiNegoDrugFlag: item.HiNegoDrugFlag,
  7186. Status: 1,
  7187. Memo: item.Memo,
  7188. Mtime: time.Now().Unix(),
  7189. InscpScpAmt: item.InscpScpAmt,
  7190. DrtReimFlag: item.DrtReimFlag,
  7191. Ctime: time.Now().Unix(),
  7192. ListSpItemFlag: item.ListSpItemFlag,
  7193. ChldMedcFlag: item.ChldMedcFlag,
  7194. LmtUsedFlag: item.LmtUsedFlag,
  7195. ChrgitmLv: item.ChrgitmLv,
  7196. UserOrgId: adminUser.CurrentOrgId,
  7197. HisPatientId: his.ID,
  7198. OrderId: order.ID,
  7199. ProjectId: project_id,
  7200. Type: types,
  7201. }
  7202. service.CreateOrderInfo(info)
  7203. }
  7204. service.UpDatePrescriptionNumber(adminUser.CurrentOrgId, ids, chrg_bchno)
  7205. service.UpDateHisPrescriptionInfoNumber(adminUser.CurrentOrgId, his_patient_id, chrg_bchno, recordDateTime)
  7206. var total float64
  7207. for _, item := range prescriptions {
  7208. if item.Type == 1 { //药品
  7209. for _, subItem := range item.HisDoctorAdviceInfo {
  7210. total = total + (subItem.Price * subItem.PrescribingNumber)
  7211. }
  7212. }
  7213. if item.Type == 2 { //项目
  7214. for _, subItem := range item.HisPrescriptionProject {
  7215. cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  7216. total = total + (subItem.Price * cnt)
  7217. }
  7218. }
  7219. }
  7220. for _, item := range prescriptions {
  7221. for _, subItem := range item.HisAdditionalCharge {
  7222. total = total + (subItem.Price * float64(subItem.Count))
  7223. }
  7224. }
  7225. allTotal := fmt.Sprintf("%.4f", total)
  7226. if res.Infcode == 0 {
  7227. var rf []*ResultFive
  7228. json.Unmarshal([]byte(his.Iinfo), &rf)
  7229. chrg_bchno := chrg_bchno
  7230. cert_no := his.Certno
  7231. var insutypes []string
  7232. var insutype string
  7233. var is390 int = 0
  7234. var is310 int = 0
  7235. for _, item := range rf {
  7236. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  7237. insutypes = append(insutypes, item.Insutype)
  7238. }
  7239. }
  7240. if len(insutypes) == 1 {
  7241. insutype = insutypes[0]
  7242. } else {
  7243. for _, i := range insutypes {
  7244. if i == "390" {
  7245. is390 = 1
  7246. }
  7247. if i == "310" {
  7248. is310 = 1
  7249. }
  7250. }
  7251. }
  7252. if is390 == 1 {
  7253. insutype = "390"
  7254. }
  7255. if is310 == 1 {
  7256. insutype = "310"
  7257. }
  7258. if len(insutypes) == 0 {
  7259. insutype = "310"
  7260. }
  7261. if len(insutypes) == 2 {
  7262. insutype = strconv.FormatInt(his.SocialType, 64)
  7263. }
  7264. //insutype = "390"
  7265. if his.IdCardType == 1 {
  7266. cert_no = his.MedicalInsuranceNumber
  7267. } else {
  7268. cert_no = his.Certno
  7269. }
  7270. var res ResultSeven
  7271. var resSeven10265 ResultSeven10265
  7272. if miConfig.MdtrtareaAdmvs == "421300" {
  7273. api := "http://192.168.124.4:9532/" + "hbyb/2206?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  7274. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  7275. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  7276. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  7277. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  7278. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  7279. "&insutype=" + insutype + "&total=" + allTotal + "&med_type=" + strconv.FormatInt(reg_type, 10)
  7280. resp, requestErr := http.Get(api)
  7281. if requestErr != nil {
  7282. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7283. return
  7284. }
  7285. body, ioErr := ioutil.ReadAll(resp.Body)
  7286. if ioErr != nil {
  7287. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  7288. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7289. return
  7290. }
  7291. var respJSON map[string]interface{}
  7292. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  7293. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  7294. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7295. return
  7296. }
  7297. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  7298. result, _ := json.Marshal(respJSON)
  7299. fmt.Println("log")
  7300. fmt.Println(string(result))
  7301. if err := json.Unmarshal([]byte(result), &res); err != nil {
  7302. utils.ErrorLog("解析失败:%v", err)
  7303. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7304. return
  7305. }
  7306. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  7307. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  7308. psn_info.VerifyNumber = strings.Replace(psn_info.VerifyNumber, "+", "%2B", -1)
  7309. bas := strings.Split(psn_info.CardInfo, "|")
  7310. if his.IdCardType == 1 {
  7311. cert_no = bas[2]
  7312. } else {
  7313. cert_no = bas[1]
  7314. }
  7315. //江苏地区国家医保医疗类别
  7316. //职工透析:医疗类别选特殊情况门诊9933
  7317. //居民血透门慢: 医疗类别选门诊慢病1402
  7318. //var med_type string
  7319. //if his.Insutype == "310" {
  7320. // if reg_type == 14 {
  7321. // med_type = "9933"
  7322. // } else if reg_type == 11 {
  7323. // med_type = "11"
  7324. //
  7325. // }
  7326. //} else if his.Insutype == "390" {
  7327. // if reg_type == 14 {
  7328. // med_type = "1402"
  7329. // } else if reg_type == 11 {
  7330. // med_type = "11"
  7331. // }
  7332. //}
  7333. var api string
  7334. if miConfig.MdtrtareaAdmvs == "320921" {
  7335. api = "http://192.168.3.111:9532/" + "jsyb/2206?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  7336. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  7337. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  7338. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  7339. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  7340. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  7341. "&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
  7342. //req, _ = http.NewRequest("POST", "http://192.168.3.111:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  7343. } else {
  7344. //req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  7345. api = "http://192.168.5.251:9532/" + "jsyb/2206?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  7346. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  7347. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  7348. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  7349. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  7350. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  7351. "&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
  7352. }
  7353. resp, requestErr := http.Get(api)
  7354. if requestErr != nil {
  7355. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7356. return
  7357. }
  7358. body, ioErr := ioutil.ReadAll(resp.Body)
  7359. if ioErr != nil {
  7360. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  7361. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7362. return
  7363. }
  7364. var respJSON map[string]interface{}
  7365. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  7366. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  7367. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7368. return
  7369. }
  7370. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  7371. result, _ := json.Marshal(respJSON)
  7372. fmt.Println("log")
  7373. fmt.Println(string(result))
  7374. if err := json.Unmarshal([]byte(result), &resSeven10265); err != nil {
  7375. utils.ErrorLog("解析失败:%v", err)
  7376. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7377. return
  7378. }
  7379. res.InfRefmsgid = resSeven10265.InfRefmsgid
  7380. res.Output = resSeven10265.Output
  7381. res.ErrMsg = resSeven10265.ErrMsg
  7382. res.Cainfo = resSeven10265.Cainfo
  7383. res.WarnMsg = resSeven10265.WarnMsg
  7384. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  7385. res.Infcode = infocode
  7386. } else {
  7387. var result string
  7388. var request_log string
  7389. if miConfig.Code == "H15049901371" {
  7390. //赤峰地区国家医保医疗类别
  7391. //职工透析:医疗类别选特殊情况门诊990502
  7392. //居民定额血透门慢: 医疗类别选门诊慢病140104
  7393. var med_type string
  7394. if his.Insutype == "390" {
  7395. if reg_type == 14 {
  7396. med_type = "9933"
  7397. } else if reg_type == 11 {
  7398. med_type = "11"
  7399. }
  7400. } else if his.Insutype == "310" {
  7401. if reg_type == 14 {
  7402. med_type = "990502"
  7403. } else if reg_type == 11 {
  7404. med_type = "11"
  7405. }
  7406. }
  7407. 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)
  7408. } else {
  7409. 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)
  7410. }
  7411. var dat map[string]interface{}
  7412. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  7413. fmt.Println(dat)
  7414. } else {
  7415. fmt.Println(err)
  7416. }
  7417. saveLog(result, request_log, "2206", "预结算")
  7418. //userJSONBytes, _ := json.Marshal(dat)
  7419. //
  7420. //if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  7421. // utils.ErrorLog("解析失败:%v", err)
  7422. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7423. // return
  7424. //}
  7425. userJSONBytes, _ := json.Marshal(dat)
  7426. if miConfig.Code == "H15049901371" {
  7427. if err := json.Unmarshal(userJSONBytes, &resSeven10265); err != nil {
  7428. utils.ErrorLog("解析失败:%v", err)
  7429. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7430. return
  7431. }
  7432. res.InfRefmsgid = resSeven10265.InfRefmsgid
  7433. res.Output = resSeven10265.Output
  7434. res.ErrMsg = resSeven10265.ErrMsg
  7435. res.Cainfo = resSeven10265.Cainfo
  7436. res.WarnMsg = resSeven10265.WarnMsg
  7437. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  7438. res.Infcode = infocode
  7439. } else {
  7440. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  7441. utils.ErrorLog("解析失败:%v", err)
  7442. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7443. return
  7444. }
  7445. }
  7446. }
  7447. if res.Infcode != 0 {
  7448. errlog := &models.HisOrderError{
  7449. UserOrgId: adminUser.CurrentOrgId,
  7450. Ctime: time.Now().Unix(),
  7451. Mtime: time.Now().Unix(),
  7452. Number: chrg_bchno,
  7453. ErrMsg: res.ErrMsg,
  7454. Status: 1,
  7455. PatientId: id,
  7456. RecordTime: recordDateTime,
  7457. Stage: 20,
  7458. }
  7459. service.CreateErrMsgLog(errlog)
  7460. c.ServeSuccessJSON(map[string]interface{}{
  7461. "failed_code": -10,
  7462. "msg": res.ErrMsg,
  7463. })
  7464. return
  7465. } else {
  7466. order, _ := service.GetHisOrderTwo(adminUser.CurrentOrgId, chrg_bchno, id)
  7467. order.OrderStatus = 1
  7468. order.IsPre = 1
  7469. order.Status = 1
  7470. order.MdtrtId = res.Output.Setlinfo.MdtrtID
  7471. order.SetlId = res.Output.Setlinfo.SetlID
  7472. order.PsnNo = res.Output.Setlinfo.PsnNo
  7473. order.PsnName = res.Output.Setlinfo.PsnName
  7474. order.PsnCertType = res.Output.Setlinfo.PsnCertType
  7475. order.Certno = res.Output.Setlinfo.Certno
  7476. order.Gend = res.Output.Setlinfo.Gend
  7477. order.Naty = res.Output.Setlinfo.Naty
  7478. order.Age = res.Output.Setlinfo.Age
  7479. order.Insutype = res.Output.Setlinfo.Insutype
  7480. order.PsnType = res.Output.Setlinfo.PsnType
  7481. order.CvlservFlag = res.Output.Setlinfo.CvlservFlag
  7482. order.SetlTime = res.Output.Setlinfo.SetlTime
  7483. order.MdtrtCertType = res.Output.Setlinfo.MdtrtCertType
  7484. if res.Output.Setlinfo.MedType == "140101" {
  7485. order.MedType = "14"
  7486. } else {
  7487. order.MedType = res.Output.Setlinfo.MedType
  7488. }
  7489. if reg_type == 1112 {
  7490. order.MedType = "1112"
  7491. }
  7492. if reg_type == 1111 {
  7493. order.MedType = "1111"
  7494. }
  7495. order.MedfeeSumamt = res.Output.Setlinfo.MedfeeSumamt
  7496. order.FulamtOwnpayAmt = res.Output.Setlinfo.FulamtOwnpayAmt
  7497. order.OverlmtSelfPay = res.Output.Setlinfo.OverlmtSelfpay
  7498. order.PreselfpayAmt = res.Output.Setlinfo.PreselfpayAmt
  7499. order.InscpScpAmt = res.Output.Setlinfo.InscpScpAmt
  7500. order.ActPayDedc = res.Output.Setlinfo.ActPayDedc
  7501. order.HifpPay = res.Output.Setlinfo.HifpPay
  7502. order.CvlservPay = res.Output.Setlinfo.CvlservPay
  7503. order.PoolPropSelfpay = res.Output.Setlinfo.PoolPropSelfpay
  7504. order.HifesPay = res.Output.Setlinfo.HifesPay
  7505. order.HifobPay = res.Output.Setlinfo.HifobPay
  7506. order.MafPay = res.Output.Setlinfo.MafPay
  7507. order.HifmiPay = res.Output.Setlinfo.HifmiPay
  7508. order.OthPay = res.Output.Setlinfo.OthPay
  7509. order.FundPaySumamt = res.Output.Setlinfo.FundPaySumamt
  7510. order.PsnPartAmt = res.Output.Setlinfo.PsnPartAmt
  7511. order.AcctPay = res.Output.Setlinfo.AcctPay
  7512. order.PsnCashPay = res.Output.Setlinfo.PsnCashPay
  7513. order.HospPartAmt = res.Output.Setlinfo.HospPartAmt
  7514. order.Balc = res.Output.Setlinfo.Balc
  7515. order.AcctMulaidPay = res.Output.Setlinfo.AcctMulaidPay
  7516. order.MedinsSetlId = res.Output.Setlinfo.MedinsSetlID
  7517. order.ClrOptins = res.Output.Setlinfo.ClrOptins
  7518. order.ClrWay = res.Output.Setlinfo.ClrWay
  7519. order.Creator = order.Creator
  7520. order.Modify = roles.AdminUserId
  7521. setlDetail, _ := json.Marshal(res.Output.Setldetail)
  7522. detailStr := string(setlDetail)
  7523. order.SetlDetail = detailStr
  7524. //err := service.UpdataOrderStatusTwo(chrg_bchno, adminUser.CurrentOrgId)
  7525. err = service.UpDateOrder(order)
  7526. if err == nil {
  7527. c.ServeSuccessJSON(map[string]interface{}{
  7528. "msg": "预结算成功",
  7529. })
  7530. } else {
  7531. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeAmountAccountException)
  7532. return
  7533. }
  7534. }
  7535. } else {
  7536. adminUser := c.GetAdminUserInfo()
  7537. errlog := &models.HisOrderError{
  7538. UserOrgId: adminUser.CurrentOrgId,
  7539. Ctime: time.Now().Unix(),
  7540. Mtime: time.Now().Unix(),
  7541. ErrMsg: res.ErrMsg,
  7542. Status: 1,
  7543. PatientId: id,
  7544. RecordTime: recordDateTime,
  7545. Stage: 4,
  7546. }
  7547. service.CreateErrMsgLog(errlog)
  7548. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeRegisterRepeatException)
  7549. return
  7550. }
  7551. } else {
  7552. adminUser := c.GetAdminUserInfo()
  7553. errlog := &models.HisOrderError{
  7554. UserOrgId: adminUser.CurrentOrgId,
  7555. Ctime: time.Now().Unix(),
  7556. Mtime: time.Now().Unix(),
  7557. ErrMsg: res.ErrMsg,
  7558. Status: 1,
  7559. PatientId: id,
  7560. RecordTime: recordDateTime,
  7561. Stage: 4,
  7562. }
  7563. service.CreateErrMsgLog(errlog)
  7564. c.ServeSuccessJSON(map[string]interface{}{
  7565. "failed_code": -10,
  7566. "msg": res.ErrMsg,
  7567. })
  7568. return
  7569. }
  7570. }
  7571. }
  7572. }
  7573. //func (c *HisApiController) GetSettleInfo() {
  7574. // id, _ := c.GetInt64("id")
  7575. // order_id, _ := c.GetInt64("order_id")
  7576. //
  7577. // record_time := c.GetString("record_time")
  7578. // pay_way, _ := c.GetInt64("pay_way")
  7579. // pay_price, _ := c.GetFloat("pay_price")
  7580. // pay_card_no := c.GetString("pay_card_no")
  7581. // discount_price, _ := c.GetFloat("discount_price")
  7582. // preferential_price, _ := c.GetFloat("preferential_price")
  7583. // reality_price, _ := c.GetFloat("reality_price")
  7584. // found_price, _ := c.GetFloat("found_price")
  7585. // medical_insurance_price, _ := c.GetFloat("medical_insurance_price")
  7586. // private_price, _ := c.GetFloat("private_price")
  7587. // settle_accounts_type, _ := c.GetInt64("settle_accounts_type")
  7588. // admin_user_id, _ := c.GetInt64("admin_user_id")
  7589. //
  7590. // timeLayout := "2006-01-02"
  7591. // loc, _ := time.LoadLocation("Local")
  7592. // theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  7593. // if err != nil {
  7594. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  7595. // return
  7596. // }
  7597. // recordDateTime := theTime.Unix()
  7598. // adminUser := c.GetAdminUserInfo()
  7599. //
  7600. // var prescriptions []*models.HisPrescription
  7601. //
  7602. // data := make(map[string]interface{})
  7603. // if settle_accounts_type == 1 { //日结
  7604. // prescriptions, _ = service.GetHisPrescription(adminUser.CurrentOrgId, id, recordDateTime)
  7605. // data["pre"] = prescriptions
  7606. //
  7607. // } else { //月结
  7608. // start_time_str := c.GetString("start_time")
  7609. // end_time_str := c.GetString("end_time")
  7610. // timeLayout := "2006-01-02"
  7611. // loc, _ := time.LoadLocation("Local")
  7612. // theStartTime, err := time.ParseInLocation(timeLayout+" 15:04:05", start_time_str+" 00:00:00", loc)
  7613. // if err != nil {
  7614. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  7615. // return
  7616. // }
  7617. // recordStartTime := theStartTime.Unix()
  7618. // theEndTime, err := time.ParseInLocation(timeLayout+" 15:04:05", end_time_str+" 00:00:00", loc)
  7619. // if err != nil {
  7620. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  7621. // return
  7622. // }
  7623. // recordEndTime := theEndTime.Unix()
  7624. // prescriptions, _ = service.GetMonthHisPrescription(adminUser.CurrentOrgId, id, recordStartTime, recordEndTime)
  7625. // data["pre"] = prescriptions
  7626. //
  7627. // }
  7628. //
  7629. // roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  7630. //
  7631. // his, _ := service.GetVMHisPatientInfo(adminUser.CurrentOrgId, id, recordDateTime)
  7632. // miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  7633. // patientPrescription, _ := service.FindPatientPrescriptionInfo(adminUser.CurrentOrgId, id, recordDateTime)
  7634. // strconv.FormatInt(his.PatientId, 10)
  7635. //
  7636. // order_src, _ := service.GetHisOrderByID(order_id)
  7637. //
  7638. // config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  7639. // if config.IsOpen == 1 { //对接了医保,走医保流程
  7640. //
  7641. // var total float64
  7642. // for _, item := range prescriptions {
  7643. // if item.Type == 1 { //药品
  7644. // for _, subItem := range item.HisDoctorAdviceInfo {
  7645. // total = total + (subItem.Price * subItem.PrescribingNumber)
  7646. // }
  7647. // }
  7648. // if item.Type == 2 { //项目
  7649. // for _, subItem := range item.HisPrescriptionProject {
  7650. // total = total + (subItem.Price * float64(subItem.Count))
  7651. // }
  7652. // }
  7653. // }
  7654. //
  7655. // for _, item := range prescriptions {
  7656. // for _, subItem := range item.HisAdditionalCharge {
  7657. // total = total + (subItem.Price * float64(subItem.Count))
  7658. // }
  7659. // }
  7660. //
  7661. // allTotal := fmt.Sprintf("%.2f", total)
  7662. // var rf []*ResultFive
  7663. // json.Unmarshal([]byte(his.Iinfo), &rf)
  7664. // psn_no := order_src.PsnNo
  7665. // mdtrt_id := order_src.MdtrtId
  7666. // chrg_bchno := order_src.Number
  7667. // cert_no := order_src.Certno
  7668. // insutype := rf[0].Insutype
  7669. //
  7670. // if his.IdCardType == 1 {
  7671. // cert_no = his.MedicalInsuranceNumber
  7672. // } else {
  7673. // cert_no = his.Certno
  7674. // }
  7675. //
  7676. // result, src_resquest := service.Gdyb2207(his.PsnNo, his.Number, chrg_bchno, cert_no, insutype, strconv.FormatFloat(total, 'E', -1, 64) ,miConfig.OrgName,roles.UserName,miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, strconv.FormatInt(patientPrescription.RegisterType, 10),his.IdCardType, order_src.FulamtOwnpayAmt,order_src.OverlmtSelfPay,order_src.PreselfpayAmt,order_src.InscpScpAmt)
  7677. // var dat map[string]interface{}
  7678. // if err := json.Unmarshal([]byte(result), &dat); err == nil {
  7679. // fmt.Println(dat)
  7680. // } else {
  7681. // fmt.Println(err)
  7682. // }
  7683. //
  7684. // userJSONBytes, _ := json.Marshal(dat)
  7685. //
  7686. //
  7687. //
  7688. // var res ResultSeven
  7689. // if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  7690. // utils.ErrorLog("解析失败:%v", err)
  7691. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7692. // return
  7693. // }
  7694. // if res.Infcode == -1 {
  7695. // errlog := &models.HisOrderError{
  7696. // UserOrgId: adminUser.CurrentOrgId,
  7697. // Ctime: time.Now().Unix(),
  7698. // Mtime: time.Now().Unix(),
  7699. // Number: chrg_bchno,
  7700. // ErrMsg: res.ErrMsg,
  7701. // Status: 1,
  7702. // PatientId: id,
  7703. // RecordTime: recordDateTime,
  7704. // Stage: 6,
  7705. // }
  7706. // service.CreateErrMsgLog(errlog)
  7707. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeRegisterRepeatException)
  7708. // return
  7709. // } else {
  7710. // order_src.OrderStatus = 2
  7711. // order_src.PayWay = pay_way
  7712. // order_src.PayPrice = pay_price
  7713. // order_src.PayCardNo = pay_card_no
  7714. // order_src.DiscountPrice = discount_price
  7715. // order_src.PreferentialPrice = preferential_price
  7716. // order_src.RealityPrice = reality_price
  7717. // order_src.FoundPrice = found_price
  7718. // order_src.MedicalInsurancePrice = medical_insurance_price
  7719. // order_src.PrivatePrice = private_price
  7720. // order_src.MdtrtId = res.Output.Setlinfo.MdtrtID
  7721. // order_src.SetlId = res.Output.Setlinfo.SetlID
  7722. // order_src.PsnNo = res.Output.Setlinfo.PsnNo
  7723. // order_src.PsnName = res.Output.Setlinfo.PsnName
  7724. // order_src.PsnCertType = res.Output.Setlinfo.PsnCertType
  7725. // order_src.Certno = res.Output.Setlinfo.Certno
  7726. // order_src.Gend = res.Output.Setlinfo.Gend
  7727. // order_src.Naty = res.Output.Setlinfo.Naty
  7728. // order_src.Age = res.Output.Setlinfo.Age
  7729. // order_src.Insutype = res.Output.Setlinfo.Insutype
  7730. // order_src.PsnType = res.Output.Setlinfo.PsnType
  7731. // order_src.CvlservFlag = res.Output.Setlinfo.CvlservFlag
  7732. // order_src.SetlTime = res.Output.Setlinfo.SetlTime
  7733. // order_src.MdtrtCertType = res.Output.Setlinfo.MdtrtCertType
  7734. // order_src.MedType = res.Output.Setlinfo.MedType
  7735. // order_src.MedfeeSumamt = res.Output.Setlinfo.MedfeeSumamt
  7736. // order_src.FulamtOwnpayAmt = res.Output.Setlinfo.FulamtOwnpayAmt
  7737. // order_src.OverlmtSelfPay = res.Output.Setlinfo.OverlmtSelfpay
  7738. // order_src.PreselfpayAmt = res.Output.Setlinfo.PreselfpayAmt
  7739. // order_src.InscpScpAmt = res.Output.Setlinfo.InscpScpAmt
  7740. // order_src.ActPayDedc = res.Output.Setlinfo.ActPayDedc
  7741. // order_src.HifpPay = res.Output.Setlinfo.HifpPay
  7742. // order_src.CvlservPay = res.Output.Setlinfo.CvlservPay
  7743. // order_src.PoolPropSelfpay = res.Output.Setlinfo.PoolPropSelfpay
  7744. // order_src.HifesPay = res.Output.Setlinfo.HifesPay
  7745. // order_src.HifobPay = res.Output.Setlinfo.HifobPay
  7746. // order_src.MafPay = res.Output.Setlinfo.MafPay
  7747. // order_src.OthPay = res.Output.Setlinfo.OthPay
  7748. // order_src.FundPaySumamt = res.Output.Setlinfo.FundPaySumamt
  7749. // order_src.PsnPartAmt = res.Output.Setlinfo.PsnPartAmt
  7750. // order_src.AcctPay = res.Output.Setlinfo.AcctPay
  7751. // order_src.PsnCashPay = res.Output.Setlinfo.PsnCashPay
  7752. // order_src.HospPartAmt = res.Output.Setlinfo.HospPartAmt
  7753. // order_src.Balc = res.Output.Setlinfo.Balc
  7754. // order_src.AcctMulaidPay = res.Output.Setlinfo.AcctMulaidPay
  7755. // order_src.MedinsSetlId = res.Output.Setlinfo.MedinsSetlID
  7756. // order_src.ClrOptins = res.Output.Setlinfo.ClrOptins
  7757. // order_src.ClrWay = res.Output.Setlinfo.ClrWay
  7758. // order_src.Creator = order_src.Creator
  7759. // order_src.Modify = roles.ID
  7760. // order_src.RequestLog = src_resquest
  7761. // setlDetail, _ := json.Marshal(res.Output.Setldetail)
  7762. // detailStr := string(setlDetail)
  7763. // order_src.SetlDetail = detailStr
  7764. // err = service.UpdataOrderStatusTwo(chrg_bchno, adminUser.CurrentOrgId)
  7765. // err = service.UpDateOrder(order_src)
  7766. //
  7767. // if err == nil {
  7768. // c.ServeSuccessJSON(map[string]interface{}{
  7769. // "msg": "结算成功",
  7770. // })
  7771. // } else {
  7772. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeAmountAccountException)
  7773. // return
  7774. // }
  7775. // }
  7776. // }
  7777. //}
  7778. //退款
  7779. func (c *HisApiController) Refund() {
  7780. order_id, _ := c.GetInt64("order_id")
  7781. admin_user_id, _ := c.GetInt64("admin_user_id")
  7782. adminUser := c.GetAdminUserInfo()
  7783. var order models.HisOrder
  7784. order, _ = service.GetHisOrderByID(order_id)
  7785. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  7786. if order.ID == 0 {
  7787. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  7788. return
  7789. }
  7790. his, _ := service.GetHisPatientByNumber(order.MdtrtId)
  7791. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  7792. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  7793. if config.IsOpen == 1 { //对接了医保,走医保流程
  7794. var res ResultSixteen
  7795. var resSixteen10265 ResultSixteen10265
  7796. var src_resquest string
  7797. var result string
  7798. if miConfig.MdtrtareaAdmvs == "421300" {
  7799. api3 := "http://192.168.124.4:9532/" + "hbyb/2208?psn_no=" + order.PsnNo +
  7800. "&mdtrt_id=" + order.MdtrtId + "&setl_id=" + order.SetlId + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  7801. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  7802. resp3, requestErr3 := http.Get(api3)
  7803. if requestErr3 != nil {
  7804. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7805. return
  7806. }
  7807. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  7808. if ioErr3 != nil {
  7809. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  7810. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7811. return
  7812. }
  7813. var respJSON3 map[string]interface{}
  7814. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  7815. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  7816. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7817. return
  7818. }
  7819. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  7820. userJSONBytes3, _ := json.Marshal(respJSON3)
  7821. fmt.Println("log")
  7822. fmt.Println(string(userJSONBytes3))
  7823. if err := json.Unmarshal(userJSONBytes3, &res); err != nil {
  7824. utils.ErrorLog("解析失败:%v", err)
  7825. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7826. return
  7827. }
  7828. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  7829. var api3 string
  7830. if miConfig.MdtrtareaAdmvs == "320921" {
  7831. api3 = "http://192.168.3.111:9532/" + "jsyb/2208?psn_no=" + order.PsnNo +
  7832. "&mdtrt_id=" + order.MdtrtId + "&setl_id=" + order.SetlId + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  7833. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  7834. //req, _ = http.NewRequest("POST", "http://192.168.3.111:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  7835. } else {
  7836. //req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  7837. api3 = "http://192.168.5.251:9532/" + "jsyb/2208?psn_no=" + order.PsnNo +
  7838. "&mdtrt_id=" + order.MdtrtId + "&setl_id=" + order.SetlId + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  7839. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  7840. }
  7841. resp3, requestErr3 := http.Get(api3)
  7842. if requestErr3 != nil {
  7843. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7844. return
  7845. }
  7846. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  7847. if ioErr3 != nil {
  7848. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  7849. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7850. return
  7851. }
  7852. var respJSON3 map[string]interface{}
  7853. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  7854. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  7855. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7856. return
  7857. }
  7858. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  7859. userJSONBytes3, _ := json.Marshal(respJSON3)
  7860. if err := json.Unmarshal(userJSONBytes3, &resSixteen10265); err != nil {
  7861. utils.ErrorLog("解析失败:%v", err)
  7862. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7863. return
  7864. }
  7865. res.InfRefmsgid = resSixteen10265.InfRefmsgid
  7866. res.Output = resSixteen10265.Output
  7867. res.ErrMsg = resSixteen10265.ErrMsg
  7868. res.Cainfo = resSixteen10265.Cainfo
  7869. res.WarnMsg = resSixteen10265.WarnMsg
  7870. infocode, _ := strconv.ParseInt(resSixteen10265.Infcode, 10, 64)
  7871. res.Infcode = infocode
  7872. } else {
  7873. if miConfig.Code == "H15049901371" {
  7874. result, src_resquest = service.Gdyb2208(order.PsnNo, order.MdtrtId, order.SetlId, miConfig.OrgName, roles.UserName, miConfig.SecretKey, miConfig.Code, his.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs)
  7875. var dat map[string]interface{}
  7876. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  7877. fmt.Println(dat)
  7878. } else {
  7879. fmt.Println(err)
  7880. }
  7881. saveLog(result, src_resquest, "2208", "退费")
  7882. userJSONBytes, _ := json.Marshal(dat)
  7883. if err := json.Unmarshal(userJSONBytes, &resSixteen10265); err != nil {
  7884. utils.ErrorLog("解析失败:%v", err)
  7885. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7886. return
  7887. }
  7888. res.InfRefmsgid = resSixteen10265.InfRefmsgid
  7889. res.Output = resSixteen10265.Output
  7890. res.ErrMsg = resSixteen10265.ErrMsg
  7891. res.Cainfo = resSixteen10265.Cainfo
  7892. res.WarnMsg = resSixteen10265.WarnMsg
  7893. infocode, _ := strconv.ParseInt(resSixteen10265.Infcode, 10, 64)
  7894. res.Infcode = infocode
  7895. } else {
  7896. result, src_resquest = service.Gdyb2208(order.PsnNo, order.MdtrtId, order.SetlId, miConfig.OrgName, roles.UserName, miConfig.SecretKey, miConfig.Code, his.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs)
  7897. var dat map[string]interface{}
  7898. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  7899. fmt.Println(dat)
  7900. } else {
  7901. fmt.Println(err)
  7902. }
  7903. saveLog(result, src_resquest, "2208", "退费")
  7904. userJSONBytes, _ := json.Marshal(dat)
  7905. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  7906. utils.ErrorLog("解析失败:%v", err)
  7907. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7908. return
  7909. }
  7910. }
  7911. }
  7912. if res.Infcode == 0 {
  7913. var res2 ResultSix
  7914. var resSix10265 ResultSix10265
  7915. if miConfig.MdtrtareaAdmvs == "421300" {
  7916. api3 := "http://192.168.124.4:9532/" + "hbyb/2205?psn_no=" + order.PsnNo +
  7917. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  7918. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  7919. resp3, requestErr3 := http.Get(api3)
  7920. if requestErr3 != nil {
  7921. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7922. return
  7923. }
  7924. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  7925. if ioErr3 != nil {
  7926. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  7927. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7928. return
  7929. }
  7930. var respJSON3 map[string]interface{}
  7931. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  7932. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  7933. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7934. return
  7935. }
  7936. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  7937. userJSONBytes3, _ := json.Marshal(respJSON3)
  7938. fmt.Println("log")
  7939. fmt.Println(string(userJSONBytes3))
  7940. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  7941. utils.ErrorLog("解析失败:%v", err)
  7942. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7943. return
  7944. }
  7945. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  7946. var api3 string
  7947. if miConfig.MdtrtareaAdmvs == "320921" {
  7948. api3 = "http://192.168.3.111:9532/" + "jsyb/2205?psn_no=" + order.PsnNo +
  7949. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  7950. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  7951. //req, _ = http.NewRequest("POST", "http://192.168.3.111:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  7952. } else {
  7953. //req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  7954. api3 = "http://192.168.5.251:9532/" + "jsyb/2205?psn_no=" + order.PsnNo +
  7955. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  7956. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  7957. }
  7958. resp3, requestErr3 := http.Get(api3)
  7959. if requestErr3 != nil {
  7960. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7961. return
  7962. }
  7963. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  7964. if ioErr3 != nil {
  7965. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  7966. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7967. return
  7968. }
  7969. var respJSON3 map[string]interface{}
  7970. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  7971. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  7972. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7973. return
  7974. }
  7975. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  7976. userJSONBytes3, _ := json.Marshal(respJSON3)
  7977. fmt.Println("log")
  7978. fmt.Println(string(userJSONBytes3))
  7979. if err := json.Unmarshal(userJSONBytes3, &resSix10265); err != nil {
  7980. utils.ErrorLog("解析失败:%v", err)
  7981. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7982. return
  7983. }
  7984. res2.InfRefmsgid = resSix10265.InfRefmsgid
  7985. res2.Output = resSix10265.Output
  7986. res2.ErrMsg = resSix10265.ErrMsg
  7987. res2.Cainfo = resSix10265.Cainfo
  7988. res2.WarnMsg = resSix10265.WarnMsg
  7989. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  7990. res2.Infcode = infocode
  7991. } else {
  7992. if miConfig.Code == "H15049901371" {
  7993. result2, src_request := service.Gdyb2205(order.PsnNo, order.MdtrtId, order.Number, miConfig.OrgName, roles.UserName, his.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, miConfig.Code)
  7994. var dat map[string]interface{}
  7995. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  7996. fmt.Println(dat)
  7997. } else {
  7998. fmt.Println(err)
  7999. }
  8000. saveLog(result2, src_request, "2205", "撤销明细")
  8001. userJSONBytes, _ := json.Marshal(dat)
  8002. if err := json.Unmarshal(userJSONBytes, &resSix10265); err != nil {
  8003. utils.ErrorLog("解析失败:%v", err)
  8004. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8005. return
  8006. }
  8007. res2.InfRefmsgid = resSix10265.InfRefmsgid
  8008. res2.Output = resSix10265.Output
  8009. res2.ErrMsg = resSix10265.ErrMsg
  8010. res2.Cainfo = resSix10265.Cainfo
  8011. res2.WarnMsg = resSix10265.WarnMsg
  8012. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  8013. res2.Infcode = infocode
  8014. } else {
  8015. result2, src_request := service.Gdyb2205(order.PsnNo, order.MdtrtId, order.Number, miConfig.OrgName, roles.UserName, his.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, miConfig.Code)
  8016. var dat map[string]interface{}
  8017. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  8018. fmt.Println(dat)
  8019. } else {
  8020. fmt.Println(err)
  8021. }
  8022. saveLog(result2, src_request, "2205", "撤销明细")
  8023. userJSONBytes, _ := json.Marshal(dat)
  8024. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  8025. utils.ErrorLog("解析失败:%v", err)
  8026. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8027. return
  8028. }
  8029. }
  8030. }
  8031. if res2.Infcode == 0 {
  8032. err := service.UpdataOrderStatus(order_id, order.Number, adminUser.CurrentOrgId, src_resquest, result)
  8033. if err == nil {
  8034. //当押金不为零时产生退费记录
  8035. if order.Decimal != 0 {
  8036. tmp := strconv.FormatInt(order.ID, 10)
  8037. err = service.MoneyIncrease(adminUser.CurrentOrgId, order.PatientId, tmp, order.Decimal)
  8038. if err != nil {
  8039. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8040. return
  8041. }
  8042. }
  8043. c.ServeSuccessJSON(map[string]interface{}{
  8044. "msg": "退费成功",
  8045. })
  8046. } else {
  8047. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8048. return
  8049. }
  8050. } else {
  8051. c.ServeSuccessJSON(map[string]interface{}{
  8052. "code": -10,
  8053. "msg": res2.ErrMsg,
  8054. })
  8055. }
  8056. } else {
  8057. c.ServeSuccessJSON(map[string]interface{}{
  8058. "code": -10,
  8059. "msg": res.ErrMsg,
  8060. })
  8061. }
  8062. }
  8063. }
  8064. func (c *HisApiController) RefundNumber() {
  8065. record_time := c.GetString("record_time")
  8066. //patient_id, _ := c.GetInt64("patient_id")
  8067. admin_user_id, _ := c.GetInt64("admin_user_id")
  8068. his_patient_id, _ := c.GetInt64("id")
  8069. timeLayout := "2006-01-02"
  8070. loc, _ := time.LoadLocation("Local")
  8071. adminUser := c.GetAdminUserInfo()
  8072. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  8073. fmt.Println(err)
  8074. if err != nil {
  8075. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  8076. return
  8077. }
  8078. recordDateTime := theTime.Unix()
  8079. //his, _ := service.GetVMHisPatientInfo(adminUser.CurrentOrgId, patient_id, recordDateTime)
  8080. his, _ := service.GetHisPatientRecord(adminUser.CurrentOrgId, his_patient_id)
  8081. //patientPrescription, _ := service.FindPatientPrescriptionInfo(adminUser.CurrentOrgId, patient_id, recordDateTime)
  8082. //order, _ := service.GetHisOrderByID(order_id)
  8083. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  8084. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  8085. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  8086. count, _ := service.GetOrderCountByNumber(adminUser.CurrentOrgId, his.PatientId, recordDateTime, his.Number)
  8087. if count > 0 {
  8088. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeOrderParamWrong)
  8089. return
  8090. }
  8091. if config.IsOpen == 1 { //对接了医保,走医保流程
  8092. var res2 ResultSix
  8093. var resSix10265 ResultSix10265
  8094. if miConfig.MdtrtareaAdmvs == "421300" {
  8095. api3 := "http://192.168.124.4:9532/" + "hbyb/2202?psn_no=" + his.PsnNo +
  8096. "&mdtrt_id=" + his.Number + "&ipt_otp_no=" + his.IptOtpNo + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  8097. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  8098. resp3, requestErr3 := http.Get(api3)
  8099. if requestErr3 != nil {
  8100. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8101. return
  8102. }
  8103. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  8104. if ioErr3 != nil {
  8105. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  8106. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8107. return
  8108. }
  8109. var respJSON3 map[string]interface{}
  8110. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  8111. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  8112. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8113. return
  8114. }
  8115. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  8116. userJSONBytes3, _ := json.Marshal(respJSON3)
  8117. fmt.Println("log")
  8118. fmt.Println(string(userJSONBytes3))
  8119. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  8120. utils.ErrorLog("解析失败:%v", err)
  8121. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8122. return
  8123. }
  8124. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  8125. var api3 string
  8126. if miConfig.MdtrtareaAdmvs == "320921" {
  8127. api3 = "http://192.168.3.111:9532/" + "jsyb/2202?psn_no=" + his.PsnNo +
  8128. "&mdtrt_id=" + his.Number + "&ipt_otp_no=" + his.IptOtpNo + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  8129. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  8130. //req, _ = http.NewRequest("POST", "http://192.168.3.111:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  8131. } else {
  8132. //req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  8133. api3 = "http://192.168.5.251:9532/" + "jsyb/2202?psn_no=" + his.PsnNo +
  8134. "&mdtrt_id=" + his.Number + "&ipt_otp_no=" + his.IptOtpNo + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  8135. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  8136. }
  8137. resp3, requestErr3 := http.Get(api3)
  8138. if requestErr3 != nil {
  8139. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8140. return
  8141. }
  8142. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  8143. if ioErr3 != nil {
  8144. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  8145. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8146. return
  8147. }
  8148. var respJSON3 map[string]interface{}
  8149. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  8150. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  8151. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8152. return
  8153. }
  8154. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  8155. userJSONBytes3, _ := json.Marshal(respJSON3)
  8156. if err := json.Unmarshal(userJSONBytes3, &resSix10265); err != nil {
  8157. utils.ErrorLog("解析失败:%v", err)
  8158. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8159. return
  8160. }
  8161. res2.InfRefmsgid = resSix10265.InfRefmsgid
  8162. res2.Output = resSix10265.Output
  8163. res2.ErrMsg = resSix10265.ErrMsg
  8164. res2.Cainfo = resSix10265.Cainfo
  8165. res2.WarnMsg = resSix10265.WarnMsg
  8166. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  8167. res2.Infcode = infocode
  8168. } else {
  8169. var api3 string
  8170. if miConfig.Code == "H15049901371" {
  8171. api3 = "http://127.0.0.1:9532/" + "gdyb/three?psn_no=" + his.PsnNo +
  8172. "&mdtrt_id=" + his.Number + "&ipt_otp_no=" + his.IptOtpNo + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  8173. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  8174. } else {
  8175. api3 = "http://127.0.0.1:9532/" + "gdyb/three?psn_no=" + his.PsnNo +
  8176. "&mdtrt_id=" + his.Number + "&ipt_otp_no=" + his.IptOtpNo + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  8177. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  8178. }
  8179. resp3, requestErr3 := http.Get(api3)
  8180. if requestErr3 != nil {
  8181. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8182. return
  8183. }
  8184. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  8185. if ioErr3 != nil {
  8186. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  8187. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8188. return
  8189. }
  8190. var respJSON3 map[string]interface{}
  8191. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  8192. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  8193. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8194. return
  8195. }
  8196. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  8197. userJSONBytes3, _ := json.Marshal(respJSON3)
  8198. if miConfig.Code == "H15049901371" {
  8199. if err := json.Unmarshal(userJSONBytes3, &resSix10265); err != nil {
  8200. utils.ErrorLog("解析失败:%v", err)
  8201. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8202. return
  8203. }
  8204. res2.InfRefmsgid = resSix10265.InfRefmsgid
  8205. res2.Output = resSix10265.Output
  8206. res2.ErrMsg = resSix10265.ErrMsg
  8207. res2.Cainfo = resSix10265.Cainfo
  8208. res2.WarnMsg = resSix10265.WarnMsg
  8209. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  8210. res2.Infcode = infocode
  8211. } else {
  8212. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  8213. utils.ErrorLog("解析失败:%v", err)
  8214. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8215. return
  8216. }
  8217. }
  8218. }
  8219. if res2.Infcode == 0 {
  8220. if err == nil {
  8221. c.ServeSuccessJSON(map[string]interface{}{
  8222. "msg": "退号成功",
  8223. })
  8224. service.UpdataRegStatusTwo(his_patient_id, recordDateTime, adminUser.CurrentOrgId)
  8225. } else {
  8226. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8227. return
  8228. }
  8229. } else {
  8230. c.ServeSuccessJSON(map[string]interface{}{
  8231. "code": -10,
  8232. "msg": res2.ErrMsg,
  8233. })
  8234. }
  8235. } else {
  8236. //err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId)
  8237. //if err == nil {
  8238. // c.ServeSuccessJSON(map[string]interface{}{
  8239. // "msg": "退费成功",
  8240. // })
  8241. //} else {
  8242. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8243. // return
  8244. //}
  8245. }
  8246. }
  8247. func (c *HisApiController) RefundDetail() {
  8248. order_id, _ := c.GetInt64("order_id")
  8249. //admin_user_id, _ := c.GetInt64("admin_user_id")
  8250. //his_patient_id, _ := c.GetInt64("his_patient_id")
  8251. number := c.GetString("number")
  8252. record_time := c.GetString("record_time")
  8253. patient_id, _ := c.GetInt64("patient_id")
  8254. //med_type, _ := c.GetInt64("med_type")
  8255. timeLayout := "2006-01-02"
  8256. loc, _ := time.LoadLocation("Local")
  8257. adminUser := c.GetAdminUserInfo()
  8258. //roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  8259. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  8260. fmt.Println(err)
  8261. if err != nil {
  8262. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  8263. return
  8264. }
  8265. recordDateTime := theTime.Unix()
  8266. //his, _ := service.GetNewVMHisPatientInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  8267. patientPrescription, _ := service.FindPatientPrescriptionInfo(adminUser.CurrentOrgId, patient_id, recordDateTime)
  8268. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  8269. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  8270. var order models.HisOrder
  8271. order, _ = service.GetHisOrderByID(order_id)
  8272. his, _ := service.GetHisPatientByNumber(order.MdtrtId)
  8273. if config.IsOpen == 1 { //对接了医保,走医保流程
  8274. var res2 ResultSix
  8275. if miConfig.MdtrtareaAdmvs == "421300" {
  8276. api3 := "http://192.168.124.4:9532/" + "hbyb/2205?psn_no=" + order.PsnNo +
  8277. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + patientPrescription.Doctor + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  8278. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  8279. resp3, requestErr3 := http.Get(api3)
  8280. if requestErr3 != nil {
  8281. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8282. return
  8283. }
  8284. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  8285. if ioErr3 != nil {
  8286. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  8287. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8288. return
  8289. }
  8290. var respJSON3 map[string]interface{}
  8291. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  8292. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  8293. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8294. return
  8295. }
  8296. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  8297. userJSONBytes3, _ := json.Marshal(respJSON3)
  8298. fmt.Println("log")
  8299. fmt.Println(string(userJSONBytes3))
  8300. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  8301. utils.ErrorLog("解析失败:%v", err)
  8302. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8303. return
  8304. }
  8305. err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId, "", "")
  8306. if err == nil {
  8307. c.ServeSuccessJSON(map[string]interface{}{
  8308. "msg": "撤销明细成功",
  8309. })
  8310. return
  8311. } else {
  8312. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8313. return
  8314. }
  8315. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  8316. var resSix10265 ResultSix10265
  8317. var api3 string
  8318. if miConfig.MdtrtareaAdmvs == "320921" {
  8319. api3 = "http://192.168.3.111:9532/" + "jsyb/2205?psn_no=" + order.PsnNo +
  8320. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + patientPrescription.Doctor + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  8321. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  8322. //req, _ = http.NewRequest("POST", "http://192.168.3.111:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  8323. } else {
  8324. //req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  8325. api3 = "http://192.168.5.251:9532/" + "jsyb/2205?psn_no=" + order.PsnNo +
  8326. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + patientPrescription.Doctor + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  8327. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  8328. }
  8329. resp3, requestErr3 := http.Get(api3)
  8330. if requestErr3 != nil {
  8331. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8332. return
  8333. }
  8334. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  8335. if ioErr3 != nil {
  8336. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  8337. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8338. return
  8339. }
  8340. var respJSON3 map[string]interface{}
  8341. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  8342. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  8343. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8344. return
  8345. }
  8346. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  8347. userJSONBytes3, _ := json.Marshal(respJSON3)
  8348. fmt.Println("log")
  8349. fmt.Println(string(userJSONBytes3))
  8350. if err := json.Unmarshal(userJSONBytes3, &resSix10265); err != nil {
  8351. utils.ErrorLog("解析失败:%v", err)
  8352. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8353. return
  8354. }
  8355. res2.InfRefmsgid = resSix10265.InfRefmsgid
  8356. res2.Output = resSix10265.Output
  8357. res2.ErrMsg = resSix10265.ErrMsg
  8358. res2.Cainfo = resSix10265.Cainfo
  8359. res2.WarnMsg = resSix10265.WarnMsg
  8360. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  8361. res2.Infcode = infocode
  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. api2 := "http://127.0.0.1:9532/" + "gdyb/six?psn_no=" + his.PsnNo +
  8374. "&mdtrt_id=" + his.Number + "&chrg_bchno=" + order.Number + "&doctor=" + patientPrescription.Doctor + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  8375. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  8376. resp2, requestErr2 := http.Get(api2)
  8377. if requestErr2 != nil {
  8378. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8379. return
  8380. }
  8381. body2, ioErr2 := ioutil.ReadAll(resp2.Body)
  8382. if ioErr2 != nil {
  8383. utils.ErrorLog("接口返回数据读取失败: %v", ioErr2)
  8384. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8385. return
  8386. }
  8387. var respJSON2 map[string]interface{}
  8388. if err := json.Unmarshal([]byte(string(body2)), &respJSON2); err != nil {
  8389. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  8390. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8391. return
  8392. }
  8393. err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId, "", "")
  8394. if err == nil {
  8395. c.ServeSuccessJSON(map[string]interface{}{
  8396. "msg": "撤销明细成功",
  8397. })
  8398. return
  8399. } else {
  8400. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8401. return
  8402. }
  8403. }
  8404. } else {
  8405. err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId, "", "")
  8406. if err == nil {
  8407. c.ServeSuccessJSON(map[string]interface{}{
  8408. "msg": "退费成功",
  8409. })
  8410. } else {
  8411. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8412. return
  8413. }
  8414. }
  8415. }
  8416. //对账
  8417. func (c *HisApiController) GetCheckAccount() {
  8418. start_time := c.GetString("start_time")
  8419. end_time := c.GetString("end_time")
  8420. insutype := c.GetString("insutype")
  8421. clr_type := c.GetString("clr_type")
  8422. clr_org := c.GetString("clr_optins")
  8423. admin_user_id, _ := c.GetInt64("admin_user_id")
  8424. adminUser := c.GetAdminUserInfo()
  8425. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  8426. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  8427. if len(clr_org) == 0 {
  8428. clr_org = miConfig.MdtrtareaAdmvs
  8429. }
  8430. timeLayout := "2006-01-02"
  8431. loc, _ := time.LoadLocation("Local")
  8432. startime, _ := time.ParseInLocation(timeLayout+" 15:04:05", start_time+" 00:00:00", loc)
  8433. endtime, _ := time.ParseInLocation(timeLayout+" 15:04:05", end_time+" 23:59:59", loc)
  8434. orders, _ := service.GetOrderByTime(startime.Unix(), endtime.Unix(), adminUser.CurrentOrgId, insutype, "", clr_type)
  8435. fixmedins_setl_cnt := int64(len(orders))
  8436. var medfee_sumamt float64
  8437. var acct_pay float64
  8438. var fund_pay_sumamt float64
  8439. for _, item := range orders {
  8440. medfee_sumamt = medfee_sumamt + item.MedfeeSumamt
  8441. acct_pay = acct_pay + item.AcctPay
  8442. fund_pay_sumamt = fund_pay_sumamt + item.FundPaySumamt
  8443. }
  8444. var user_name string
  8445. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  8446. if role.ID == 0 {
  8447. user_name = "xxx"
  8448. } else {
  8449. user_name = role.UserName
  8450. }
  8451. var res ResultEight
  8452. var res10188 ResultEightFor10188
  8453. if config.IsOpen == 1 {
  8454. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  8455. api := "http://192.168.3.111:9532/" + "jsyb/3201?" +
  8456. "insutype=" + insutype +
  8457. "&clr_type=" + clr_type +
  8458. "&setl_optins=" + clr_org +
  8459. "&stmt_begndate=" + start_time +
  8460. "&stm_enddate=" + end_time +
  8461. "&medfee_sumamt=" + fmt.Sprintf("%.4f", medfee_sumamt) +
  8462. "&fund_pay_sumamt=" + fmt.Sprintf("%.4f", fund_pay_sumamt) +
  8463. "&acct_pay=" + fmt.Sprintf("%.4f", acct_pay) +
  8464. "&fixmedins_setl_cnt=" + strconv.FormatInt(fixmedins_setl_cnt, 10) +
  8465. "&fixmedins_code=" + miConfig.Code +
  8466. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs +
  8467. "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  8468. "&secret_key=" + miConfig.SecretKey +
  8469. "&org_name=" + miConfig.OrgName +
  8470. "&doctor=" + user_name +
  8471. "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  8472. fmt.Println(api)
  8473. resp, requestErr := http.Get(api)
  8474. if requestErr != nil {
  8475. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8476. return
  8477. }
  8478. body, ioErr := ioutil.ReadAll(resp.Body)
  8479. fmt.Println(body)
  8480. if ioErr != nil {
  8481. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  8482. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8483. return
  8484. }
  8485. var respJSON map[string]interface{}
  8486. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  8487. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  8488. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8489. return
  8490. }
  8491. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  8492. userJSONBytes, _ := json.Marshal(respJSON)
  8493. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  8494. utils.ErrorLog("解析失败:%v", err)
  8495. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8496. return
  8497. }
  8498. res.InfRefmsgid = res10188.InfRefmsgid
  8499. res.Output = res10188.Output
  8500. res.ErrMsg = res10188.ErrMsg
  8501. res.Cainfo = res10188.Cainfo
  8502. res.WarnMsg = res10188.WarnMsg
  8503. infocode, _ := strconv.ParseInt(res10188.Infcode, 10, 64)
  8504. res.Infcode = infocode
  8505. } else if miConfig.MdtrtareaAdmvs == "150499" {
  8506. api := "http://172.16.13.254:9532/" + "nmyb/3201?" +
  8507. "insutype=" + insutype +
  8508. "&clr_type=" + clr_type +
  8509. "&setl_optins=" + clr_org +
  8510. "&stmt_begndate=" + start_time +
  8511. "&stm_enddate=" + end_time +
  8512. "&medfee_sumamt=" + fmt.Sprintf("%.4f", medfee_sumamt) +
  8513. "&fund_pay_sumamt=" + fmt.Sprintf("%.4f", fund_pay_sumamt) +
  8514. "&acct_pay=" + fmt.Sprintf("%.4f", acct_pay) +
  8515. "&fixmedins_setl_cnt=" + strconv.FormatInt(fixmedins_setl_cnt, 10) +
  8516. "&fixmedins_code=" + miConfig.Code +
  8517. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs +
  8518. "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  8519. "&secret_key=" + miConfig.SecretKey +
  8520. "&org_name=" + miConfig.OrgName +
  8521. "&doctor=" + user_name
  8522. resp, requestErr := http.Get(api)
  8523. if requestErr != nil {
  8524. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8525. return
  8526. }
  8527. body, ioErr := ioutil.ReadAll(resp.Body)
  8528. if ioErr != nil {
  8529. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  8530. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8531. return
  8532. }
  8533. var respJSON map[string]interface{}
  8534. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  8535. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  8536. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8537. return
  8538. }
  8539. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  8540. result, _ := json.Marshal(respJSON)
  8541. fmt.Println("log")
  8542. fmt.Println(string(result))
  8543. if err := json.Unmarshal([]byte(result), &res10188); err != nil {
  8544. utils.ErrorLog("解析失败:%v", err)
  8545. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8546. return
  8547. }
  8548. res.InfRefmsgid = res10188.InfRefmsgid
  8549. res.Output = res10188.Output
  8550. res.ErrMsg = res10188.ErrMsg
  8551. res.Cainfo = res10188.Cainfo
  8552. res.WarnMsg = res10188.WarnMsg
  8553. infocode, _ := strconv.ParseInt(res10188.Infcode, 10, 64)
  8554. res.Infcode = infocode
  8555. } else {
  8556. api := "http://127.0.0.1:9532/" + "gdyb/ten?" +
  8557. "insutype=" + insutype +
  8558. "&clr_type=" + clr_type +
  8559. "&setl_optins=" + clr_org +
  8560. "&stmt_begndate=" + start_time +
  8561. "&stm_enddate=" + end_time +
  8562. "&medfee_sumamt=" + fmt.Sprintf("%.4f", medfee_sumamt) +
  8563. "&fund_pay_sumamt=" + fmt.Sprintf("%.4f", fund_pay_sumamt) +
  8564. "&acct_pay=" + fmt.Sprintf("%.4f", acct_pay) +
  8565. "&fixmedins_setl_cnt=" + strconv.FormatInt(fixmedins_setl_cnt, 10) +
  8566. "&fixmedins_code=" + miConfig.Code +
  8567. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs +
  8568. "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  8569. "&secret_key=" + miConfig.SecretKey +
  8570. "&org_name=" + miConfig.OrgName +
  8571. "&doctor=" + user_name
  8572. fmt.Println(api)
  8573. resp, requestErr := http.Get(api)
  8574. if requestErr != nil {
  8575. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8576. return
  8577. }
  8578. body, ioErr := ioutil.ReadAll(resp.Body)
  8579. fmt.Println(body)
  8580. if ioErr != nil {
  8581. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  8582. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8583. return
  8584. }
  8585. var respJSON map[string]interface{}
  8586. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  8587. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  8588. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8589. return
  8590. }
  8591. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  8592. userJSONBytes, _ := json.Marshal(respJSON)
  8593. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  8594. utils.ErrorLog("解析失败:%v", err)
  8595. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8596. return
  8597. }
  8598. }
  8599. if res.Infcode == 0 {
  8600. if res.Output.Stmtinfo.StmtRslt == "0" {
  8601. micc := &models.MedicalInsuranceCostCompare{
  8602. StartTime: startime.Unix(),
  8603. EndTime: endtime.Unix(),
  8604. Insutype: insutype,
  8605. CheckType: 1,
  8606. Num: fixmedins_setl_cnt,
  8607. Mtime: time.Now().Unix(),
  8608. Status: 1,
  8609. UserOrgId: adminUser.CurrentOrgId,
  8610. CostTotal: medfee_sumamt,
  8611. FuncTotal: fund_pay_sumamt,
  8612. PsnPay: acct_pay,
  8613. Creator: admin_user_id,
  8614. Ctime: time.Now().Unix(),
  8615. ClrType: clr_type,
  8616. }
  8617. err := service.CreateMedicalInsuranceCostCompareRecord(micc)
  8618. if err == nil {
  8619. c.ServeSuccessJSON(map[string]interface{}{
  8620. "stmt_rslt": res.Output.Stmtinfo.StmtRslt,
  8621. "stmt_rslt_dscr": res.Output.Stmtinfo.StmtRsltDscr,
  8622. })
  8623. } else {
  8624. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8625. }
  8626. } else {
  8627. c.ServeSuccessJSON(map[string]interface{}{
  8628. "stmt_rslt": res.Output.Stmtinfo.StmtRslt,
  8629. "stmt_rslt_dscr": res.Output.Stmtinfo.StmtRsltDscr,
  8630. })
  8631. }
  8632. } else {
  8633. c.ServeSuccessJSON(map[string]interface{}{
  8634. "code": -10,
  8635. "msg": res.ErrMsg,
  8636. })
  8637. }
  8638. }
  8639. }
  8640. func (c *HisApiController) Check310() {
  8641. adminUser := c.GetAdminUserInfo()
  8642. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  8643. var user_name string
  8644. user_name = "高慧裕"
  8645. api := "http://127.0.0.1:9532/" + "gdyb/ten?" +
  8646. "insutype=" + "310" +
  8647. "&clr_type=" + "" +
  8648. "&setl_optins=" + "441202" +
  8649. "&stmt_begndate=" + "2022-03-01" +
  8650. "&stm_enddate=" + "2022-03-31" +
  8651. "&medfee_sumamt=" + "194930.12" +
  8652. "&fund_pay_sumamt=" + "188741.46" +
  8653. "&acct_pay=" + "0" +
  8654. "&fixmedins_setl_cnt=" + "452" +
  8655. "&fixmedins_code=" + miConfig.Code +
  8656. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs +
  8657. "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  8658. "&secret_key=" + miConfig.SecretKey +
  8659. "&org_name=" + miConfig.OrgName +
  8660. "&doctor=" + user_name
  8661. fmt.Println(api)
  8662. resp, requestErr := http.Get(api)
  8663. if requestErr != nil {
  8664. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8665. return
  8666. }
  8667. body, ioErr := ioutil.ReadAll(resp.Body)
  8668. fmt.Println(body)
  8669. if ioErr != nil {
  8670. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  8671. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8672. return
  8673. }
  8674. var respJSON map[string]interface{}
  8675. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  8676. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  8677. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8678. return
  8679. }
  8680. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  8681. userJSONBytes, _ := json.Marshal(respJSON)
  8682. var res ResultEight
  8683. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  8684. utils.ErrorLog("解析失败:%v", err)
  8685. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8686. return
  8687. }
  8688. }
  8689. func (c *HisApiController) Check390() {
  8690. adminUser := c.GetAdminUserInfo()
  8691. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  8692. var user_name string
  8693. user_name = "高慧裕"
  8694. api := "http://127.0.0.1:9532/" + "gdyb/ten?" +
  8695. "insutype=" + "390" +
  8696. "&clr_type=" + "" +
  8697. "&setl_optins=" + "441202" +
  8698. "&stmt_begndate=" + "2022-03-01" +
  8699. "&stm_enddate=" + "2022-03-31" +
  8700. "&medfee_sumamt=" + "1068448.89" +
  8701. "&fund_pay_sumamt=" + "1014677.62" +
  8702. "&acct_pay=" + "0" +
  8703. "&fixmedins_setl_cnt=" + "1950" +
  8704. "&fixmedins_code=" + miConfig.Code +
  8705. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs +
  8706. "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  8707. "&secret_key=" + miConfig.SecretKey +
  8708. "&org_name=" + miConfig.OrgName +
  8709. "&doctor=" + user_name
  8710. fmt.Println(api)
  8711. resp, requestErr := http.Get(api)
  8712. if requestErr != nil {
  8713. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8714. return
  8715. }
  8716. body, ioErr := ioutil.ReadAll(resp.Body)
  8717. fmt.Println(body)
  8718. if ioErr != nil {
  8719. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  8720. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8721. return
  8722. }
  8723. var respJSON map[string]interface{}
  8724. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  8725. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  8726. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8727. return
  8728. }
  8729. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  8730. userJSONBytes, _ := json.Marshal(respJSON)
  8731. var res ResultEight
  8732. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  8733. utils.ErrorLog("解析失败:%v", err)
  8734. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8735. return
  8736. }
  8737. }
  8738. //对账明细
  8739. func (c *HisApiController) GetCheckDetailAccount() {
  8740. start_time := c.GetString("start_time")
  8741. end_time := c.GetString("end_time")
  8742. admin_user_id, _ := c.GetInt64("admin_user_id")
  8743. adminUser := c.GetAdminUserInfo()
  8744. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  8745. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  8746. timeLayout := "2006-01-02"
  8747. loc, _ := time.LoadLocation("Local")
  8748. startime, _ := time.ParseInLocation(timeLayout+" 15:04:05", start_time+" 00:00:00", loc)
  8749. endtime, _ := time.ParseInLocation(timeLayout+" 15:04:05", end_time+" 23:59:59", loc)
  8750. orders, _ := service.GetOrderByTimeTwo(startime.Unix(), endtime.Unix(), adminUser.CurrentOrgId)
  8751. rand.Seed(time.Now().UnixNano())
  8752. num := rand.Intn(30000)
  8753. Mkdir(miConfig.OrgName)
  8754. file := strconv.FormatInt(int64(num), 10)
  8755. file_name := file + ".txt"
  8756. zip_name := file + ".zip"
  8757. zip_path := miConfig.OrgName + "/" + zip_name
  8758. file_path := miConfig.OrgName + "/" + file_name
  8759. decimal.DivisionPrecision = 2
  8760. var medfee_sumamt float64
  8761. var psn_cash_pay float64
  8762. var fund_pay_sumamt float64
  8763. fixmedins_setl_cnt := int64(len(orders))
  8764. for _, item := range orders {
  8765. medfee_sumamt = medfee_sumamt + item.MedfeeSumamt
  8766. psn_cash_pay = psn_cash_pay + item.PsnCashPay
  8767. fund_pay_sumamt = fund_pay_sumamt + item.FundPaySumamt
  8768. }
  8769. f, err := os.Create(miConfig.OrgName + "/" + file_name)
  8770. defer f.Close()
  8771. if err != nil {
  8772. fmt.Println(err.Error())
  8773. } else {
  8774. for _, item := range orders {
  8775. var refd_setl_flag string
  8776. if item.OrderStatus == 2 {
  8777. refd_setl_flag = "0"
  8778. var str string
  8779. str = item.SetlId + " " +
  8780. item.MdtrtId + " " +
  8781. item.PsnNo + " " +
  8782. fmt.Sprintf("%.4f", item.MedfeeSumamt) + " " +
  8783. fmt.Sprintf("%.4f", item.FundPaySumamt) + " " +
  8784. fmt.Sprintf("%.4f", item.AcctPay) + " " + refd_setl_flag + "\r\n"
  8785. _, err = f.Write([]byte(str))
  8786. }
  8787. if item.OrderStatus == 3 {
  8788. var str string
  8789. str = item.SetlId + " " +
  8790. item.MdtrtId + " " +
  8791. item.PsnNo + " " +
  8792. fmt.Sprintf("%.4f", item.MedfeeSumamt) + " " +
  8793. fmt.Sprintf("%.4f", item.FundPaySumamt) + " " +
  8794. fmt.Sprintf("%.4f", item.AcctPay) + " " + "1" + "\r\n"
  8795. _, err = f.Write([]byte(str))
  8796. var str2 string
  8797. str2 = item.SetlId + " " +
  8798. item.MdtrtId + " " +
  8799. item.PsnNo + " " +
  8800. fmt.Sprintf("%.4f", 0-item.MedfeeSumamt) + " " +
  8801. fmt.Sprintf("%.4f", 0-item.FundPaySumamt) + " " +
  8802. fmt.Sprintf("%.4f", 0-item.AcctPay) + " " + "1" + "\r\n"
  8803. _, err = f.Write([]byte(str2))
  8804. }
  8805. }
  8806. }
  8807. Zip(file_path, zip_path)
  8808. fmt.Println(ReadFile(zip_path))
  8809. fmt.Println(string(ReadFile(zip_path)))
  8810. if config.IsOpen == 1 {
  8811. var user_name string
  8812. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  8813. if role.ID == 0 {
  8814. user_name = "管理员"
  8815. } else {
  8816. user_name = role.UserName
  8817. }
  8818. baseParams := models.BaseParams{
  8819. SecretKey: miConfig.SecretKey,
  8820. FixmedinsCode: miConfig.Code,
  8821. InsuplcAdmdvs: miConfig.InsuplcAdmdvs,
  8822. MdtrtareaAdmvs: miConfig.MdtrtareaAdmvs,
  8823. OrgName: miConfig.OrgName,
  8824. Doctor: user_name,
  8825. }
  8826. result := service.Gdyb9101(baseParams, file_name, ReadFile(file_path))
  8827. var dat map[string]interface{}
  8828. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  8829. fmt.Println(dat)
  8830. } else {
  8831. fmt.Println(err)
  8832. }
  8833. userJSONBytes, _ := json.Marshal(dat)
  8834. var res ResultNine
  8835. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  8836. utils.ErrorLog("解析失败:%v", err)
  8837. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8838. return
  8839. }
  8840. if res.Infcode == 0 {
  8841. fileNo := res.Output.FileQuryNo
  8842. api := "http://127.0.0.1:9532/" + "gdyb/twelve?" +
  8843. "file_qury_no=" + fileNo +
  8844. "&setl_optins=" + "定点医保中心" +
  8845. "&stmt_begndate=" + start_time +
  8846. "&stm_enddate=" + end_time +
  8847. "&medfee_sumamt=" + fmt.Sprintf("%.4f", medfee_sumamt) +
  8848. "&fund_pay_sumamt=" + fmt.Sprintf("%.4f", fund_pay_sumamt) +
  8849. "&cash_payamt=" + fmt.Sprintf("%.4f", psn_cash_pay) +
  8850. "&fixmedins_setl_cnt=" + strconv.FormatInt(fixmedins_setl_cnt, 10) +
  8851. "&fixmedins_code=" + miConfig.Code +
  8852. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs +
  8853. "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  8854. "&secret_key=" + miConfig.SecretKey +
  8855. "&org_name=" + miConfig.OrgName +
  8856. "&doctor=" + user_name
  8857. resp, requestErr := http.Get(api)
  8858. if requestErr != nil {
  8859. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8860. return
  8861. }
  8862. body, ioErr := ioutil.ReadAll(resp.Body)
  8863. if ioErr != nil {
  8864. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  8865. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8866. return
  8867. }
  8868. var respJSON map[string]interface{}
  8869. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  8870. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  8871. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8872. return
  8873. }
  8874. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  8875. userJSONBytes, _ := json.Marshal(respJSON)
  8876. var res ResultTen
  8877. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  8878. utils.ErrorLog("解析失败:%v", err)
  8879. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8880. return
  8881. }
  8882. if res.Infcode == 0 {
  8883. service.Gdyb9102(baseParams, zip_name, fileNo)
  8884. micc := &models.MedicalInsuranceCostCompare{
  8885. StartTime: startime.Unix(),
  8886. EndTime: endtime.Unix(),
  8887. Insutype: "0",
  8888. CheckType: 2,
  8889. Num: fixmedins_setl_cnt,
  8890. Mtime: time.Now().Unix(),
  8891. Status: 1,
  8892. UserOrgId: adminUser.CurrentOrgId,
  8893. CostTotal: medfee_sumamt,
  8894. FuncTotal: fund_pay_sumamt,
  8895. PsnPay: psn_cash_pay,
  8896. Creator: admin_user_id,
  8897. Ctime: time.Now().Unix(),
  8898. }
  8899. service.CreateMedicalInsuranceCostCompareRecord(micc)
  8900. c.ServeSuccessJSON(map[string]interface{}{
  8901. "msg": "明细对账成功",
  8902. })
  8903. }
  8904. } else {
  8905. }
  8906. }
  8907. }
  8908. type CustomOrderInfo struct {
  8909. Name string
  8910. Spec string
  8911. Unit string
  8912. Count float64
  8913. Price float64
  8914. Total float64
  8915. }
  8916. func (c *HisApiController) GetSettleAccounts() {
  8917. //id, _ := c.GetInt64("id")
  8918. //record_time := c.GetString("record_time")
  8919. order_id, _ := c.GetInt64("order_id")
  8920. admin_user_id, _ := c.GetInt64("admin_user_id")
  8921. //timeLayout := "2006-01-02"
  8922. //loc, _ := time.LoadLocation("Local")
  8923. //
  8924. //theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  8925. //if err != nil {
  8926. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  8927. // return
  8928. //}
  8929. //recordDateTime := theTime.Unix()
  8930. adminUser := c.GetAdminUserInfo()
  8931. order, _ := service.GetHisOrderByID(order_id)
  8932. his, _ := service.GetHisPatientByNumber(order.MdtrtId)
  8933. orderInfos, _ := service.GetHisOrderInfoByNumber(order.Number)
  8934. orderInfos_two, _ := service.GetHisOrderInfoByNumberTwo(order.Number)
  8935. orderInfos = append(orderInfos, orderInfos_two...)
  8936. his_hospital, _ := service.GetInHospitalRecordByNumber(order.MdtrtId)
  8937. //diagnosisConfig, _ := service.FindDiagnoseById(his.Diagnosis)
  8938. var diagnosis_ids []string
  8939. if his.ID > 0 {
  8940. diagnosis_ids = strings.Split(his.Diagnosis, ",")
  8941. } else {
  8942. diagnosis_ids = strings.Split(his_hospital.Diagnosis, ",")
  8943. }
  8944. patient, _ := service.GetPatientByIDTwo(adminUser.CurrentOrgId, order.PatientId)
  8945. var dia_config []*models.HisXtDiagnoseConfig
  8946. var name string
  8947. for _, item := range diagnosis_ids {
  8948. id, _ := strconv.ParseInt(item, 10, 64)
  8949. diagnosisConfig, _ := service.FindDiagnoseById(id)
  8950. dia_config = append(dia_config, &diagnosisConfig)
  8951. if len(name) == 0 {
  8952. name = diagnosisConfig.ClassName
  8953. } else {
  8954. name = name + "," + diagnosisConfig.ClassName
  8955. }
  8956. }
  8957. var bedCostTotal float64 = 0 //床位总费
  8958. var bedCostSelfTotal float64 = 0 //床位自费
  8959. var bedCostPartSelfTotal float64 = 0 //床位部分项目自费
  8960. var operationCostTotal float64 = 0 //手术费
  8961. var operationCostSelfTotal float64 = 0 //手术费
  8962. var operationCostPartSelfTotal float64 = 0 //手术费
  8963. var otherCostTotal float64 = 0 //其他费用
  8964. var otherCostSelfTotal float64 = 0 //其他费用
  8965. var otherCostPartSelfTotal float64 = 0 //其他费用
  8966. var materialCostTotal float64 = 0 //材料费
  8967. var materialCostSelfTotal float64 = 0 //材料费
  8968. var materialCostPartSelfTotal float64 = 0 //材料费
  8969. var westernMedicineCostTotal float64 = 0 //西药费
  8970. var westernMedicineCostSelfTotal float64 = 0 //西药费
  8971. var westernMedicineCostPartSelfTotal float64 = 0 //西药费
  8972. var chineseTraditionalMedicineCostTotal float64 = 0 //中成药
  8973. var chineseTraditionalMedicineCostSelfTotal float64 = 0 //中成药
  8974. var chineseTraditionalMedicineCostPartSelfTotal float64 = 0 //中成药
  8975. var checkCostTotal float64 = 0 //检查费
  8976. var checkCostSelfTotal float64 = 0 //检查费
  8977. var checkCostPartSelfTotal float64 = 0 //检查费
  8978. var laboratoryCostTotal float64 = 0 //化验费
  8979. var laboratoryCostSelfTotal float64 = 0 //化验费
  8980. var laboratoryCostPartSelfTotal float64 = 0 //化验费
  8981. var treatCostTotal float64 = 0 //治疗费用
  8982. var treatCostSelfTotal float64 = 0 //治疗费用
  8983. var treatCostPartSelfTotal float64 = 0 //治疗费用
  8984. decimal.DivisionPrecision = 2
  8985. for _, item := range orderInfos {
  8986. if item.MedChrgitmType == "01" { //床位费
  8987. bedCostTotal, _ = decimal.NewFromFloat(bedCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  8988. bedCostSelfTotal, _ = decimal.NewFromFloat(bedCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  8989. bedCostPartSelfTotal, _ = decimal.NewFromFloat(bedCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  8990. }
  8991. if c.GetAdminUserInfo().CurrentOrgId == 10188 || c.GetAdminUserInfo().CurrentOrgId == 10217 {
  8992. if item.MedChrgitmType == "03" { //检查费
  8993. laboratoryCostTotal, _ = decimal.NewFromFloat(laboratoryCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  8994. laboratoryCostSelfTotal, _ = decimal.NewFromFloat(laboratoryCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  8995. laboratoryCostPartSelfTotal, _ = decimal.NewFromFloat(laboratoryCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  8996. }
  8997. } else {
  8998. if item.MedChrgitmType == "03" { //检查费
  8999. checkCostTotal, _ = decimal.NewFromFloat(checkCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  9000. checkCostSelfTotal, _ = decimal.NewFromFloat(checkCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  9001. checkCostPartSelfTotal, _ = decimal.NewFromFloat(checkCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  9002. }
  9003. }
  9004. if item.MedChrgitmType == "04" { //化验费
  9005. laboratoryCostTotal, _ = decimal.NewFromFloat(laboratoryCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  9006. laboratoryCostSelfTotal, _ = decimal.NewFromFloat(laboratoryCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  9007. laboratoryCostPartSelfTotal, _ = decimal.NewFromFloat(laboratoryCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  9008. }
  9009. if item.MedChrgitmType == "05" || item.MedChrgitmType == "1402" || item.MedChrgitmType == "1403" { //治疗费
  9010. treatCostTotal, _ = decimal.NewFromFloat(treatCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  9011. treatCostSelfTotal, _ = decimal.NewFromFloat(treatCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  9012. treatCostPartSelfTotal, _ = decimal.NewFromFloat(treatCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  9013. }
  9014. if item.MedChrgitmType == "06" { //手术费
  9015. operationCostTotal, _ = decimal.NewFromFloat(operationCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  9016. operationCostSelfTotal, _ = decimal.NewFromFloat(operationCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  9017. operationCostPartSelfTotal, _ = decimal.NewFromFloat(operationCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  9018. }
  9019. if item.MedChrgitmType == "08" { //材料费
  9020. materialCostTotal, _ = decimal.NewFromFloat(materialCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  9021. materialCostSelfTotal, _ = decimal.NewFromFloat(materialCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  9022. materialCostPartSelfTotal, _ = decimal.NewFromFloat(materialCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  9023. }
  9024. if item.MedChrgitmType == "09" { //西药费
  9025. westernMedicineCostTotal, _ = decimal.NewFromFloat(westernMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  9026. westernMedicineCostSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  9027. westernMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  9028. }
  9029. if item.MedChrgitmType == "11" { //中成费
  9030. chineseTraditionalMedicineCostTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  9031. chineseTraditionalMedicineCostSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  9032. chineseTraditionalMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  9033. }
  9034. if item.MedChrgitmType == "14" || item.MedChrgitmType == "0" || item.MedChrgitmType == "12" || item.MedChrgitmType == "02" { //其他费
  9035. otherCostTotal, _ = decimal.NewFromFloat(otherCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  9036. otherCostSelfTotal, _ = decimal.NewFromFloat(otherCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  9037. otherCostPartSelfTotal, _ = decimal.NewFromFloat(otherCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  9038. }
  9039. }
  9040. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  9041. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  9042. var user_name string
  9043. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  9044. if role.ID == 0 {
  9045. user_name = "管理员"
  9046. } else {
  9047. user_name = role.UserName
  9048. }
  9049. baseParams := models.BaseParams{
  9050. SecretKey: miConfig.SecretKey,
  9051. FixmedinsCode: miConfig.Code,
  9052. InsuplcAdmdvs: miConfig.InsuplcAdmdvs,
  9053. MdtrtareaAdmvs: miConfig.MdtrtareaAdmvs,
  9054. OrgName: miConfig.OrgName,
  9055. Doctor: user_name,
  9056. }
  9057. businessParams := models.BusinessParams{
  9058. PsnNo: order.PsnNo,
  9059. MdtrtId: order.MdtrtId,
  9060. SetlId: order.SetlId,
  9061. }
  9062. var res ResultEleven
  9063. var resEleven10265 ResultEleven10265
  9064. if config.IsOpen == 1 {
  9065. if miConfig.MdtrtareaAdmvs == "421300" {
  9066. api := "http://192.168.124.4:9532/" + "hbyb/5203?psn_no=" + businessParams.PsnNo + "&mdtrt_id=" + businessParams.MdtrtId + "&setl_id=" + businessParams.SetlId +
  9067. "&org_name=" + miConfig.OrgName + "&doctor=" + baseParams.Doctor + "&fixmedins_code=" + miConfig.Code +
  9068. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  9069. resp, requestErr := http.Get(api)
  9070. if requestErr != nil {
  9071. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9072. return
  9073. }
  9074. body, ioErr := ioutil.ReadAll(resp.Body)
  9075. if ioErr != nil {
  9076. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  9077. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9078. return
  9079. }
  9080. var respJSON map[string]interface{}
  9081. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  9082. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  9083. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9084. return
  9085. }
  9086. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  9087. result, _ := json.Marshal(respJSON)
  9088. fmt.Println("log")
  9089. fmt.Println(string(result))
  9090. if err := json.Unmarshal([]byte(result), &res); err != nil {
  9091. utils.ErrorLog("解析失败:%v", err)
  9092. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9093. return
  9094. }
  9095. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  9096. var api string
  9097. if miConfig.MdtrtareaAdmvs == "320921" {
  9098. api = "http://192.168.3.111:9532/" + "jsyb/5203?psn_no=" + businessParams.PsnNo + "&mdtrt_id=" + businessParams.MdtrtId + "&setl_id=" + businessParams.SetlId +
  9099. "&org_name=" + miConfig.OrgName + "&doctor=" + baseParams.Doctor + "&fixmedins_code=" + miConfig.Code +
  9100. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  9101. //req, _ = http.NewRequest("POST", "http://192.168.3.111:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  9102. } else {
  9103. //req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  9104. api = "http://192.168.5.251: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. }
  9108. resp, requestErr := http.Get(api)
  9109. if requestErr != nil {
  9110. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9111. return
  9112. }
  9113. body, ioErr := ioutil.ReadAll(resp.Body)
  9114. if ioErr != nil {
  9115. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  9116. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9117. return
  9118. }
  9119. var respJSON map[string]interface{}
  9120. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  9121. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  9122. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9123. return
  9124. }
  9125. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  9126. result, _ := json.Marshal(respJSON)
  9127. fmt.Println("log")
  9128. fmt.Println(string(result))
  9129. if err := json.Unmarshal([]byte(result), &resEleven10265); err != nil {
  9130. utils.ErrorLog("解析失败:%v", err)
  9131. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9132. return
  9133. }
  9134. res.InfRefmsgid = resEleven10265.InfRefmsgid
  9135. res.Output = resEleven10265.Output
  9136. res.ErrMsg = resEleven10265.ErrMsg
  9137. res.Cainfo = resEleven10265.Cainfo
  9138. res.WarnMsg = resEleven10265.WarnMsg
  9139. infocode, _ := strconv.ParseInt(resEleven10265.Infcode, 10, 64)
  9140. res.Infcode = infocode
  9141. } else if miConfig.MdtrtareaAdmvs == "150499" {
  9142. fmt.Println("~~~~~~~")
  9143. api := "http://172.16.13.254:9532/" + "nmyb/5203?psn_no=" + businessParams.PsnNo + "&mdtrt_id=" + businessParams.MdtrtId + "&setl_id=" + businessParams.SetlId +
  9144. "&org_name=" + miConfig.OrgName + "&doctor=" + baseParams.Doctor + "&fixmedins_code=" + miConfig.Code +
  9145. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  9146. resp, requestErr := http.Get(api)
  9147. if requestErr != nil {
  9148. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9149. return
  9150. }
  9151. body, ioErr := ioutil.ReadAll(resp.Body)
  9152. if ioErr != nil {
  9153. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  9154. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9155. return
  9156. }
  9157. var respJSON map[string]interface{}
  9158. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  9159. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  9160. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9161. return
  9162. }
  9163. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  9164. result, _ := json.Marshal(respJSON)
  9165. fmt.Println("log")
  9166. fmt.Println(string(result))
  9167. if err := json.Unmarshal([]byte(result), &resEleven10265); err != nil {
  9168. utils.ErrorLog("解析失败:%v", err)
  9169. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9170. return
  9171. }
  9172. res.InfRefmsgid = resEleven10265.InfRefmsgid
  9173. res.Output = resEleven10265.Output
  9174. res.ErrMsg = resEleven10265.ErrMsg
  9175. res.Cainfo = resEleven10265.Cainfo
  9176. res.WarnMsg = resEleven10265.WarnMsg
  9177. infocode, _ := strconv.ParseInt(resEleven10265.Infcode, 10, 64)
  9178. res.Infcode = infocode
  9179. } else {
  9180. result := service.Gdyb5203(baseParams, businessParams)
  9181. //service.Gdyb5204(baseParams, businessParams)
  9182. //service.Gdyb5302(businessParams.PsnNo, baseParams.OrgName, baseParams.Doctor, baseParams.FixmedinsCode, baseParams.InsuplcAdmdvs, baseParams.MdtrtareaAdmvs, baseParams.SecretKey)
  9183. var dat map[string]interface{}
  9184. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  9185. fmt.Println(dat)
  9186. } else {
  9187. fmt.Println(err)
  9188. }
  9189. userJSONBytes, _ := json.Marshal(dat)
  9190. if miConfig.Code == "H15049901371" {
  9191. if err := json.Unmarshal(userJSONBytes, &resEleven10265); err != nil {
  9192. utils.ErrorLog("解析失败:%v", err)
  9193. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9194. return
  9195. }
  9196. res.InfRefmsgid = resEleven10265.InfRefmsgid
  9197. res.Output = resEleven10265.Output
  9198. res.ErrMsg = resEleven10265.ErrMsg
  9199. res.Cainfo = resEleven10265.Cainfo
  9200. res.WarnMsg = resEleven10265.WarnMsg
  9201. infocode, _ := strconv.ParseInt(resEleven10265.Infcode, 10, 64)
  9202. res.Infcode = infocode
  9203. } else {
  9204. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  9205. utils.ErrorLog("解析失败:%v", err)
  9206. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9207. return
  9208. }
  9209. }
  9210. }
  9211. printor_admin, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  9212. charge_admin, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, order.Creator)
  9213. patientPrescription, _ := service.FindPatientPrescriptionInfo(adminUser.CurrentOrgId, order.PatientId, order.SettleAccountsDate)
  9214. adminRole_two, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, patientPrescription.DoctorId)
  9215. doctor_info, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, his_hospital.Doctor)
  9216. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  9217. var doctor_name string
  9218. if roles.ID == 0 {
  9219. doctor_name = "管理员"
  9220. } else {
  9221. doctor_name = roles.UserName
  9222. }
  9223. yiliao_leibie := ""
  9224. switch order.MedType {
  9225. case "11":
  9226. yiliao_leibie = "普通门诊"
  9227. break
  9228. case "12":
  9229. yiliao_leibie = "门诊挂号"
  9230. break
  9231. case "13":
  9232. yiliao_leibie = "急诊"
  9233. break
  9234. case "14":
  9235. yiliao_leibie = "门诊特殊病"
  9236. break
  9237. case "15":
  9238. yiliao_leibie = "门诊统筹"
  9239. break
  9240. case "16":
  9241. yiliao_leibie = "门诊慢性病"
  9242. break
  9243. case "21":
  9244. yiliao_leibie = "普通住院"
  9245. break
  9246. }
  9247. departments, _ := service.GetDepartMentDetail(patientPrescription.Departments)
  9248. if res.Infcode == 0 {
  9249. c.ServeSuccessJSON(map[string]interface{}{
  9250. "diagnosis": name,
  9251. "order_infos": orderInfos,
  9252. "number": order.MdtrtId,
  9253. "date": order.SettleAccountsDate,
  9254. "charge_admin": charge_admin,
  9255. "printor_admin": printor_admin,
  9256. "info": res.Output.Setlinfo,
  9257. "order": order,
  9258. "bedCostTotal": bedCostTotal,
  9259. "bedCostSelfTotal": bedCostSelfTotal,
  9260. "bedCostPartSelfTotal": bedCostPartSelfTotal,
  9261. "operationCostTotal": operationCostTotal,
  9262. "operationCostSelfTotal": operationCostSelfTotal,
  9263. "operationCostPartSelfTotal": operationCostPartSelfTotal,
  9264. "otherCostTotal": otherCostTotal,
  9265. "otherCostSelfTotal": otherCostSelfTotal,
  9266. "otherCostPartSelfTotal": otherCostPartSelfTotal,
  9267. "materialCostTotal": materialCostTotal,
  9268. "materialCostSelfTotal": materialCostSelfTotal,
  9269. "materialCostPartSelfTotal": materialCostPartSelfTotal,
  9270. "westernMedicineCostTotal": westernMedicineCostTotal,
  9271. "westernMedicineCostSelfTotal": westernMedicineCostSelfTotal,
  9272. "westernMedicineCostPartSelfTotal": westernMedicineCostPartSelfTotal,
  9273. "chineseTraditionalMedicineCostTotal": chineseTraditionalMedicineCostTotal,
  9274. "chineseTraditionalMedicineCostSelfTotal": chineseTraditionalMedicineCostSelfTotal,
  9275. "chineseTraditionalMedicineCostPartSelfTotal": chineseTraditionalMedicineCostPartSelfTotal,
  9276. "checkCostTotal": checkCostTotal,
  9277. "checkCostSelfTotal": checkCostSelfTotal,
  9278. "checkCostPartSelfTotal": checkCostPartSelfTotal,
  9279. "laboratoryCostTotal": laboratoryCostTotal,
  9280. "laboratoryCostSelfTotal": laboratoryCostSelfTotal,
  9281. "laboratoryCostPartSelfTotal": laboratoryCostPartSelfTotal,
  9282. "treatCostTotal": treatCostTotal,
  9283. "treatCostSelfTotal": treatCostSelfTotal,
  9284. "treatCostPartSelfTotal": treatCostPartSelfTotal,
  9285. "doctor_info": doctor_info,
  9286. "doctor_code": adminRole_two.DoctorCode,
  9287. "doctor_name": doctor_name,
  9288. "health_card_no": order.PsnNo,
  9289. "department": departments.Name,
  9290. "yiliao_leibie": yiliao_leibie,
  9291. "after_money": order.AccountPrice,
  9292. "patient": patient,
  9293. "org_name": miConfig.OrgName,
  9294. "org_code": miConfig.Code,
  9295. "order_number": order.Number,
  9296. "his_hospital": his_hospital,
  9297. "his": his,
  9298. "dia_config": dia_config,
  9299. //"check_order_info": cus_slice,
  9300. })
  9301. }
  9302. }
  9303. }
  9304. func (c *HisApiController) CheckTreatment() {
  9305. patient_id, _ := c.GetInt64("patient_id")
  9306. id_card_no := c.GetString("id_card_no")
  9307. insutype := c.GetString("insutype")
  9308. med_type := c.GetString("med_type")
  9309. admin_user_id, _ := c.GetInt64("admin_user_id")
  9310. adminUser := c.GetAdminUserInfo()
  9311. patient, _ := service.GetPatientByID(adminUser.CurrentOrgId, patient_id)
  9312. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  9313. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  9314. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  9315. if miConfig.MdtrtareaAdmvs == "421300" {
  9316. var res ResultTwo
  9317. api := "http://192.168.124.4:9532/" + "hbyb/1101?cert_no=" + "" +
  9318. "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  9319. "&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)
  9320. resp, requestErr := http.Get(api)
  9321. if requestErr != nil {
  9322. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9323. return
  9324. }
  9325. body, ioErr := ioutil.ReadAll(resp.Body)
  9326. if ioErr != nil {
  9327. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  9328. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9329. return
  9330. }
  9331. var respJSON map[string]interface{}
  9332. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  9333. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  9334. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9335. return
  9336. }
  9337. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  9338. result, _ := json.Marshal(respJSON)
  9339. if err := json.Unmarshal([]byte(result), &res); err != nil {
  9340. utils.ErrorLog("解析失败:%v", err)
  9341. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9342. return
  9343. }
  9344. if res.Infcode == 0 {
  9345. api := "http://192.168.124.4:9532/" + "hbyb/2001?cert_no=" + "" +
  9346. "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  9347. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&psn_no=" + res.Output.Baseinfo.PsnNo + "&insutype=" + insutype + "&med_type=" + med_type
  9348. resp, requestErr := http.Get(api)
  9349. if requestErr != nil {
  9350. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9351. return
  9352. }
  9353. body, ioErr := ioutil.ReadAll(resp.Body)
  9354. if ioErr != nil {
  9355. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  9356. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9357. return
  9358. }
  9359. var respJSON map[string]interface{}
  9360. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  9361. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  9362. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9363. return
  9364. }
  9365. var res Result2001
  9366. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  9367. result2, _ := json.Marshal(respJSON)
  9368. if err := json.Unmarshal([]byte(result2), &res); err != nil {
  9369. utils.ErrorLog("解析失败:%v", err)
  9370. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9371. return
  9372. }
  9373. if res.Infcode == 0 {
  9374. c.ServeSuccessJSON(map[string]interface{}{
  9375. "msg": res.Output.Trtinfo,
  9376. })
  9377. }
  9378. } else {
  9379. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  9380. return
  9381. }
  9382. } else {
  9383. result := service.Gdyb1101A(id_card_no, miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, patient.Name)
  9384. var dat map[string]interface{}
  9385. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  9386. fmt.Println(dat)
  9387. } else {
  9388. fmt.Println(err)
  9389. }
  9390. userJSONBytes, _ := json.Marshal(dat)
  9391. var res ResultTwo
  9392. var res10265 ResultTwo10265
  9393. if miConfig.Code == "H15049901371" {
  9394. if err := json.Unmarshal(userJSONBytes, &res10265); err != nil {
  9395. utils.ErrorLog("解析失败:%v", err)
  9396. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9397. return
  9398. }
  9399. res.ErrMsg = res10265.ErrMsg
  9400. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  9401. res.Infcode = infocode
  9402. res.Output = res10265.Output
  9403. res.InfRefmsgid = res10265.InfRefmsgid
  9404. } else {
  9405. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  9406. utils.ErrorLog("解析失败:%v", err)
  9407. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9408. return
  9409. }
  9410. }
  9411. var user_name string
  9412. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, adminUser.AdminUser.Id)
  9413. if role.ID == 0 {
  9414. user_name = "xxx"
  9415. } else {
  9416. user_name = role.UserName
  9417. }
  9418. baseParams := models.BaseParams{
  9419. SecretKey: miConfig.SecretKey,
  9420. FixmedinsCode: miConfig.Code,
  9421. InsuplcAdmdvs: miConfig.InsuplcAdmdvs,
  9422. MdtrtareaAdmvs: miConfig.MdtrtareaAdmvs,
  9423. OrgName: miConfig.OrgName,
  9424. Doctor: user_name,
  9425. }
  9426. if config.IsOpen == 1 {
  9427. if miConfig.Code == "H15049901371" {
  9428. if med_type == "14" {
  9429. if insutype == "390" {
  9430. med_type = "9933"
  9431. } else if insutype == "310" {
  9432. med_type = "990502"
  9433. }
  9434. } else if med_type == "11" {
  9435. med_type = "11"
  9436. }
  9437. }
  9438. result := service.Gdyb2001(baseParams, res.Output.Baseinfo.PsnNo, insutype, med_type)
  9439. var dat map[string]interface{}
  9440. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  9441. fmt.Println(dat)
  9442. } else {
  9443. fmt.Println(err)
  9444. }
  9445. var res Result2001
  9446. var res10265 Result2001Org10265
  9447. if miConfig.Code == "H15049901371" {
  9448. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  9449. utils.ErrorLog("解析失败:%v", err)
  9450. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9451. return
  9452. }
  9453. res.ErrMsg = res10265.ErrMsg
  9454. res.Output = res10265.Output
  9455. res.InfRefmsgid = res10265.InfRefmsgid
  9456. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  9457. res.Infcode = infocode
  9458. } else {
  9459. if err := json.Unmarshal([]byte(result), &res); err != nil {
  9460. utils.ErrorLog("解析失败:%v", err)
  9461. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9462. return
  9463. }
  9464. }
  9465. if res.Infcode == 0 {
  9466. c.ServeSuccessJSON(map[string]interface{}{
  9467. "msg": res.Output.Trtinfo,
  9468. })
  9469. }
  9470. }
  9471. }
  9472. }
  9473. //func (c *HisApiController) PutRecord() {
  9474. // id, _ := c.GetInt64("id")
  9475. // record_time := c.GetString("record_time")
  9476. // timeLayout := "2006-01-02"
  9477. // loc, _ := time.LoadLocation("Local")
  9478. // theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  9479. // if err != nil {
  9480. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  9481. // return
  9482. // }
  9483. // recordDateTime := theTime.Unix()
  9484. //
  9485. // adminInfo := c.GetAdminUserInfo()
  9486. // patient, _ := service.GetPatientByID(adminInfo.CurrentOrgId, id)
  9487. // patientPrescription, _ := service.FindPatientPrescriptionInfo(adminInfo.CurrentOrgId, id, recordDateTime)
  9488. //
  9489. // miConfig, _ := service.FindMedicalInsuranceInfo(adminInfo.CurrentOrgId)
  9490. //
  9491. // fmt.Println(miConfig.SecretKey)
  9492. //
  9493. // if patient == nil {
  9494. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodePatientNoExist)
  9495. // return
  9496. // }
  9497. // if len(patient.IdCardNo) == 0 {
  9498. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeIDCartNo)
  9499. // return
  9500. // }
  9501. // config, _ := service.GetMedicalInsuranceConfig(adminInfo.CurrentOrgId)
  9502. // if config.IsOpen == 1 {
  9503. // 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
  9504. // resp, requestErr := http.Get(api)
  9505. // if requestErr != nil {
  9506. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9507. // return
  9508. // }
  9509. // defer resp.Body.Close()
  9510. // body, ioErr := ioutil.ReadAll(resp.Body)
  9511. // if ioErr != nil {
  9512. // utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  9513. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9514. // return
  9515. // }
  9516. // var respJSON map[string]interface{}
  9517. //
  9518. // if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  9519. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  9520. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9521. // return
  9522. // }
  9523. //
  9524. // userJSON := respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  9525. // userJSONBytes, _ := json.Marshal(userJSON)
  9526. // var res ResultTwo
  9527. // if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  9528. // utils.ErrorLog("解析失败:%v", err)
  9529. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9530. // return
  9531. // }
  9532. // Iinfos, _ := json.Marshal(res.Output.Iinfo)
  9533. // Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  9534. // infoStr := string(Iinfos)
  9535. // idetinfoStr := string(Idetinfos)
  9536. //
  9537. // if res.Infcode == 0 {
  9538. // his := models.VMHisPatient{
  9539. // Status: 1,
  9540. // Ctime: time.Now().Unix(),
  9541. // Mtime: time.Now().Unix(),
  9542. // PsnNo: res.Output.Baseinfo.PsnNo,
  9543. // PsnCertType: res.Output.Baseinfo.PsnCertType,
  9544. // Certno: res.Output.Baseinfo.Certno,
  9545. // PsnName: res.Output.Baseinfo.PsnName,
  9546. // Gend: res.Output.Baseinfo.Gend,
  9547. // Naty: res.Output.Baseinfo.Naty,
  9548. // Brdy: res.Output.Baseinfo.Brdy,
  9549. // Age: res.Output.Baseinfo.Age,
  9550. // Iinfo: infoStr,
  9551. // Idetinfo: idetinfoStr,
  9552. // PatientId: patient.ID,
  9553. // RecordDate: theTime.Unix(),
  9554. // UserOrgId: adminInfo.CurrentOrgId,
  9555. // AdminUserId: adminInfo.AdminUser.Id,
  9556. // IsReturn: 1,
  9557. // }
  9558. //
  9559. // //doctor_id := strconv.FormatInt(patientPrescription.DoctorId, 10)
  9560. // //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")
  9561. // //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")
  9562. //
  9563. // //var dat map[string]interface{}
  9564. // //if err := json.Unmarshal([]byte(result), &dat); err == nil {
  9565. // // fmt.Println(dat)
  9566. // //} else {
  9567. // // fmt.Println(err)
  9568. // //}
  9569. //
  9570. // var dat2 map[string]interface{}
  9571. // if err := json.Unmarshal([]byte(result2), &dat2); err == nil {
  9572. // fmt.Println(dat2)
  9573. // } else {
  9574. // fmt.Println(err)
  9575. // }
  9576. //
  9577. // } else {
  9578. // adminUser := c.GetAdminUserInfo()
  9579. // errlog := &models.HisOrderError{
  9580. // UserOrgId: adminUser.CurrentOrgId,
  9581. // Ctime: time.Now().Unix(),
  9582. // Mtime: time.Now().Unix(),
  9583. // ErrMsg: res.ErrMsg,
  9584. // Status: 1,
  9585. // PatientId: id,
  9586. // RecordTime: recordDateTime,
  9587. // Stage: 1,
  9588. // }
  9589. // service.CreateErrMsgLog(errlog)
  9590. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeGdybOneException)
  9591. // return
  9592. // }
  9593. // }
  9594. //
  9595. //}
  9596. //func (c *HisApiController) GetUploadDiag() {
  9597. // id, _ := c.GetInt64("id")
  9598. // record_time := c.GetString("record_time")
  9599. //
  9600. // diagnosis_id, _ := c.GetInt64("diagnosis")
  9601. // sick_type, _ := c.GetInt64("sick_type")
  9602. // reg_type, _ := c.GetInt64("reg_type")
  9603. //
  9604. // timeLayout := "2006-01-02"
  9605. // loc, _ := time.LoadLocation("Local")
  9606. // theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  9607. // if err != nil {
  9608. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  9609. // return
  9610. // }
  9611. //
  9612. // var patientPrescription models.HisPrescriptionInfo
  9613. // recordDateTime := theTime.Unix()
  9614. // adminInfo := c.GetAdminUserInfo()
  9615. // patientPrescription, _ = service.FindPatientPrescriptionInfo(adminInfo.CurrentOrgId, id, recordDateTime)
  9616. //
  9617. // if patientPrescription.ID == 0 {
  9618. // patientPrescription, _ = service.FindLastPatientPrescriptionInfo(adminInfo.CurrentOrgId, id, recordDateTime)
  9619. // }
  9620. //
  9621. // miConfig, _ := service.FindMedicalInsuranceInfo(adminInfo.CurrentOrgId)
  9622. // diagnosisConfig, _ := service.FindDiagnoseById(diagnosis_id)
  9623. // his, _ := service.GetVMHisPatientInfo(adminInfo.CurrentOrgId, id, recordDateTime)
  9624. // sickConfig, _ := service.FindSickById(sick_type)
  9625. // department, _ := service.GetDepartMentDetail(patientPrescription.Departments)
  9626. //
  9627. // api2 := "http://127.0.0.1:9532/" + "gdyb/four?psn_no=" + his.PsnNo +
  9628. // "&mdtrt_id=" + his.Number + "&doctor=" + patientPrescription.Doctor + "&department=" + department.Name +
  9629. // "&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 +
  9630. // "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&sick_code=" + sickConfig.ContentCode + "&sick_name=" + sickConfig.ClassName
  9631. // resp2, requestErr2 := http.Get(api2)
  9632. // if requestErr2 != nil {
  9633. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9634. // return
  9635. // }
  9636. // body2, ioErr2 := ioutil.ReadAll(resp2.Body)
  9637. // if ioErr2 != nil {
  9638. // utils.ErrorLog("接口返回数据读取失败: %v", ioErr2)
  9639. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9640. // return
  9641. // }
  9642. // var respJSON2 map[string]interface{}
  9643. // if err := json.Unmarshal([]byte(string(body2)), &respJSON2); err != nil {
  9644. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  9645. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9646. // return
  9647. // }
  9648. // respJSON2 = respJSON2["data"].(map[string]interface{})["pre"].(map[string]interface{})
  9649. // userJSONBytes2, _ := json.Marshal(respJSON2)
  9650. //
  9651. // var res2 ResultSix
  9652. // if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  9653. // utils.ErrorLog("解析失败:%v", err)
  9654. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9655. // return
  9656. // }
  9657. // if res2.Infcode != 0 {
  9658. // adminUser := c.GetAdminUserInfo()
  9659. // errlog := &models.HisOrderError{
  9660. // UserOrgId: adminUser.CurrentOrgId,
  9661. // Ctime: time.Now().Unix(),
  9662. // Mtime: time.Now().Unix(),
  9663. // ErrMsg: res2.ErrMsg,
  9664. // Status: 1,
  9665. // PatientId: id,
  9666. // RecordTime: recordDateTime,
  9667. // Stage: 3,
  9668. // }
  9669. // service.CreateErrMsgLog(errlog)
  9670. //
  9671. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeRegisterThreeException)
  9672. // return
  9673. // }
  9674. //
  9675. // c.ServeSuccessJSON(map[string]interface{}{
  9676. // "msg": "上传成功",
  9677. // })
  9678. //
  9679. //}
  9680. type QueryResult struct {
  9681. ID int64
  9682. Name string
  9683. Code string
  9684. List_type_code string
  9685. }
  9686. func (c *HisApiController) GetCheckCode() {
  9687. ids_str := c.GetString("ids")
  9688. record_type, _ := c.GetInt64("record_type") //1.药品 2.耗材 3.项目
  9689. ids_arr := strings.Split(ids_str, ",")
  9690. var queryResult []QueryResult
  9691. ids := make([]int64, 0)
  9692. for _, item := range ids_arr {
  9693. id, _ := strconv.ParseInt(item, 10, 64)
  9694. ids = append(ids, id)
  9695. }
  9696. if record_type == 1 {
  9697. drugs, _ := service.GetBatchDrugList(ids)
  9698. for _, item := range drugs {
  9699. result := QueryResult{
  9700. ID: item.ID,
  9701. Name: item.DrugName,
  9702. Code: item.MedicalInsuranceNumber,
  9703. List_type_code: "101",
  9704. }
  9705. queryResult = append(queryResult, result)
  9706. }
  9707. } else if record_type == 2 {
  9708. goods, _ := service.GetBatchGoodInformationList(ids)
  9709. for _, item := range goods {
  9710. result := QueryResult{
  9711. ID: item.ID,
  9712. Name: item.GoodName,
  9713. Code: item.MedicalInsuranceNumber,
  9714. List_type_code: "301",
  9715. }
  9716. queryResult = append(queryResult, result)
  9717. }
  9718. } else if record_type == 3 {
  9719. projects, _ := service.GetBathchMyPorjecgList(ids)
  9720. for _, item := range projects {
  9721. result := QueryResult{
  9722. ID: item.ID,
  9723. Name: item.ProjectName,
  9724. Code: item.MedicalCode,
  9725. List_type_code: "201",
  9726. }
  9727. queryResult = append(queryResult, result)
  9728. }
  9729. }
  9730. admin_user_id, _ := c.GetInt64("admin_user_id")
  9731. adminUser := c.GetAdminUserInfo()
  9732. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  9733. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  9734. var user_name string
  9735. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  9736. if role.ID == 0 {
  9737. user_name = "xxx"
  9738. } else {
  9739. user_name = role.UserName
  9740. }
  9741. baseParams := &models.BaseParams{
  9742. SecretKey: miConfig.SecretKey,
  9743. FixmedinsCode: miConfig.Code,
  9744. InsuplcAdmdvs: miConfig.InsuplcAdmdvs,
  9745. MdtrtareaAdmvs: miConfig.MdtrtareaAdmvs,
  9746. OrgName: miConfig.OrgName,
  9747. Doctor: user_name,
  9748. }
  9749. if config.IsOpen == 1 {
  9750. for _, item := range queryResult {
  9751. var result string
  9752. if record_type == 1 {
  9753. result = service.Gdyb3301(baseParams, item.Name, item.Code, item.List_type_code, "2021-04-26", "", item.List_type_code)
  9754. } else if record_type == 2 {
  9755. result = service.Gdyb3301(baseParams, item.Name, item.Code, item.List_type_code, "2021-04-26", "", item.List_type_code)
  9756. } else if record_type == 3 {
  9757. result = service.Gdyb3301(baseParams, item.Name, item.Code, item.List_type_code, "2021-04-26", "", item.List_type_code)
  9758. }
  9759. var dat map[string]interface{}
  9760. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  9761. fmt.Println(dat)
  9762. } else {
  9763. fmt.Println(err)
  9764. }
  9765. userJSONBytes, _ := json.Marshal(dat)
  9766. var res ResultSix
  9767. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  9768. utils.ErrorLog("解析失败:%v", err)
  9769. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9770. return
  9771. }
  9772. if res.Infcode == 0 {
  9773. if record_type == 1 {
  9774. service.UpdateBaseDrugById(item.ID)
  9775. } else if record_type == 2 {
  9776. service.UpdateGoodInformaitonByDetail(item.ID)
  9777. } else if record_type == 3 {
  9778. service.UpdateProjectById(item.ID)
  9779. }
  9780. c.ServeSuccessJSON(map[string]interface{}{
  9781. "failed_code": 0,
  9782. "msg": "目录对照成功",
  9783. })
  9784. } else {
  9785. c.ServeSuccessJSON(map[string]interface{}{
  9786. "failed_code": -10,
  9787. "msg": res.ErrMsg,
  9788. })
  9789. }
  9790. }
  9791. }
  9792. }
  9793. func (c *HisApiController) UnCheckCode() {
  9794. ids_str := c.GetString("ids")
  9795. record_type, _ := c.GetInt64("record_type") //1.药品 2.耗材 3.项目
  9796. admin_user_id, _ := c.GetInt64("admin_user_id")
  9797. ids_arr := strings.Split(ids_str, ",")
  9798. var queryResult []QueryResult
  9799. ids := make([]int64, 0)
  9800. for _, item := range ids_arr {
  9801. id, _ := strconv.ParseInt(item, 10, 64)
  9802. ids = append(ids, id)
  9803. }
  9804. if record_type == 1 {
  9805. drugs, _ := service.GetBatchDrugList(ids)
  9806. for _, item := range drugs {
  9807. result := QueryResult{
  9808. ID: item.ID,
  9809. Name: item.DrugName,
  9810. Code: item.MedicalInsuranceNumber,
  9811. List_type_code: "101",
  9812. }
  9813. queryResult = append(queryResult, result)
  9814. }
  9815. } else if record_type == 2 {
  9816. goods, _ := service.GetBatchGoodInformationList(ids)
  9817. for _, item := range goods {
  9818. result := QueryResult{
  9819. ID: item.ID,
  9820. Name: item.GoodName,
  9821. Code: item.MedicalInsuranceNumber,
  9822. List_type_code: "301",
  9823. }
  9824. queryResult = append(queryResult, result)
  9825. }
  9826. } else if record_type == 3 {
  9827. projects, _ := service.GetBathchMyPorjecgList(ids)
  9828. for _, item := range projects {
  9829. result := QueryResult{
  9830. ID: item.ID,
  9831. Name: item.ProjectName,
  9832. Code: item.MedicalCode,
  9833. List_type_code: "201",
  9834. }
  9835. queryResult = append(queryResult, result)
  9836. }
  9837. }
  9838. adminUser := c.GetAdminUserInfo()
  9839. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  9840. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  9841. var user_name string
  9842. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  9843. if role.ID == 0 {
  9844. user_name = "xxx"
  9845. } else {
  9846. user_name = role.UserName
  9847. }
  9848. baseParams := &models.BaseParams{
  9849. SecretKey: miConfig.SecretKey,
  9850. FixmedinsCode: miConfig.Code,
  9851. InsuplcAdmdvs: miConfig.InsuplcAdmdvs,
  9852. MdtrtareaAdmvs: miConfig.MdtrtareaAdmvs,
  9853. OrgName: miConfig.OrgName,
  9854. Doctor: user_name,
  9855. }
  9856. if config.IsOpen == 1 {
  9857. for _, item := range queryResult {
  9858. var result string
  9859. if record_type == 1 {
  9860. result = service.Gdyb3302(baseParams, item.Name, item.Code, item.List_type_code)
  9861. } else if record_type == 2 {
  9862. result = service.Gdyb3302(baseParams, item.Name, item.Code, item.List_type_code)
  9863. } else if record_type == 3 {
  9864. result = service.Gdyb3302(baseParams, item.Name, item.Code, item.List_type_code)
  9865. }
  9866. var dat2 map[string]interface{}
  9867. if err := json.Unmarshal([]byte(result), &dat2); err == nil {
  9868. fmt.Println(dat2)
  9869. } else {
  9870. fmt.Println(err)
  9871. }
  9872. userJSONBytes, _ := json.Marshal(dat2)
  9873. var res ResultSix
  9874. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  9875. utils.ErrorLog("解析失败:%v", err)
  9876. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9877. return
  9878. }
  9879. if res.Infcode == 0 {
  9880. if record_type == 1 {
  9881. service.UpdateDrugByIdDetail(item.ID)
  9882. } else if record_type == 2 {
  9883. service.UpdateGoodInfoById(item.ID)
  9884. } else if record_type == 3 {
  9885. service.UpdateMyProjectById(item.ID)
  9886. }
  9887. c.ServeSuccessJSON(map[string]interface{}{
  9888. "failed_code": 0,
  9889. "msg": "撤销目录对照成功",
  9890. })
  9891. } else {
  9892. c.ServeSuccessJSON(map[string]interface{}{
  9893. "failed_code": -10,
  9894. "msg": res.ErrMsg,
  9895. })
  9896. }
  9897. }
  9898. }
  9899. }
  9900. func (c *HisApiController) GetPatientInfo() {
  9901. id_card_no := c.GetString("id_card_no")
  9902. admin_user_id, _ := c.GetInt64("admin_user_id")
  9903. patient, _ := service.GetPatientByIDCard(id_card_no, c.GetAdminUserInfo().CurrentOrgId)
  9904. if patient.ID == 0 {
  9905. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodePatientNoExist)
  9906. return
  9907. }
  9908. role, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  9909. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  9910. config, _ := service.GetMedicalInsuranceConfig(c.GetAdminUserInfo().CurrentOrgId)
  9911. if config.IsOpen == 1 {
  9912. result := service.Gdyb1101A(id_card_no, miConfig.OrgName, role.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, patient.Name)
  9913. var dat map[string]interface{}
  9914. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  9915. fmt.Println(dat)
  9916. } else {
  9917. fmt.Println(err)
  9918. }
  9919. userJSONBytes, _ := json.Marshal(dat)
  9920. var res ResultTwo
  9921. var res10265 ResultTwo10265
  9922. if miConfig.Code == "H15049901371" {
  9923. if err := json.Unmarshal(userJSONBytes, &res10265); err != nil {
  9924. utils.ErrorLog("解析失败:%v", err)
  9925. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9926. return
  9927. }
  9928. res.ErrMsg = res10265.ErrMsg
  9929. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  9930. res.Infcode = infocode
  9931. res.Output = res10265.Output
  9932. res.InfRefmsgid = res10265.InfRefmsgid
  9933. } else {
  9934. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  9935. utils.ErrorLog("解析失败:%v", err)
  9936. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9937. return
  9938. }
  9939. }
  9940. //if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  9941. // utils.ErrorLog("解析失败:%v", err)
  9942. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9943. // return
  9944. //}
  9945. if res.Infcode != 0 {
  9946. c.ServeSuccessJSON(map[string]interface{}{
  9947. "failed_code": -10,
  9948. "msg": res.ErrMsg,
  9949. })
  9950. } else {
  9951. c.ServeSuccessJSON(map[string]interface{}{
  9952. "failed_code": 0,
  9953. "info": res,
  9954. })
  9955. }
  9956. }
  9957. }
  9958. func (c *HisApiController) PsnPutOnRecord() {
  9959. record_type, _ := c.GetInt64("type")
  9960. patient_id, _ := c.GetInt64("patient_id")
  9961. admin_user_id, _ := c.GetInt64("admin_user_id")
  9962. start_time := c.GetString("start_time")
  9963. end_time := c.GetString("end_time")
  9964. adminUser := c.GetAdminUserInfo()
  9965. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  9966. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  9967. var patients []*models.Patients
  9968. if record_type == 1 { //全部备案
  9969. patient, _ := service.GetAllPatient(adminUser.CurrentOrgId)
  9970. patients = append(patients, patient...)
  9971. } else { //单个备案
  9972. patient, _ := service.GetPatientByID(adminUser.CurrentOrgId, patient_id)
  9973. patients = append(patients, patient)
  9974. }
  9975. var user_name string
  9976. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  9977. if role.ID == 0 {
  9978. user_name = "xxx"
  9979. } else {
  9980. user_name = role.UserName
  9981. }
  9982. if config.IsOpen == 1 {
  9983. for _, item := range patients {
  9984. 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
  9985. resp, requestErr := http.Get(api)
  9986. if requestErr != nil {
  9987. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9988. return
  9989. }
  9990. defer resp.Body.Close()
  9991. body, ioErr := ioutil.ReadAll(resp.Body)
  9992. if ioErr != nil {
  9993. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  9994. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9995. return
  9996. }
  9997. var respJSON map[string]interface{}
  9998. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  9999. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  10000. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10001. return
  10002. }
  10003. userJSON := respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  10004. userJSONBytes, _ := json.Marshal(userJSON)
  10005. var res ResultTwo
  10006. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  10007. utils.ErrorLog("解析失败:%v", err)
  10008. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10009. return
  10010. }
  10011. if res.Infcode == 0 {
  10012. result := service.Gdyb2505(res.Output.Baseinfo.PsnNo, user_name, miConfig.OrgName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, start_time, end_time)
  10013. var dat map[string]interface{}
  10014. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  10015. fmt.Println(dat)
  10016. } else {
  10017. fmt.Println(err)
  10018. }
  10019. userJSONBytes, _ := json.Marshal(dat)
  10020. var res2 ResultThirteen
  10021. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  10022. utils.ErrorLog("解析失败:%v", err)
  10023. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10024. return
  10025. }
  10026. if res2.Infcode == 0 {
  10027. psnResult := &models.GdybPsnRecord{
  10028. UserOrgId: adminUser.CurrentOrgId,
  10029. PatientId: item.ID,
  10030. PsnNo: res.Output.Baseinfo.PsnNo,
  10031. Ctime: time.Now().Unix(),
  10032. Mtime: time.Now().Unix(),
  10033. Status: 1,
  10034. IsCancel: 1,
  10035. TrtDclaDetlSn: res2.Output.Result.TrtDclaDetlSn,
  10036. }
  10037. service.CreatePsnRecord(psnResult)
  10038. } else {
  10039. c.ServeSuccessJSON(map[string]interface{}{
  10040. "failed_code": -10,
  10041. "msg": res2.ErrMsg,
  10042. })
  10043. return
  10044. }
  10045. }
  10046. }
  10047. }
  10048. }
  10049. func (c *HisApiController) PsnUnPutOnRecord() {
  10050. id, _ := c.GetInt64("id")
  10051. //record_type, _ := c.GetInt64("type")
  10052. admin_user_id, _ := c.GetInt64("admin_user_id")
  10053. adminUser := c.GetAdminUserInfo()
  10054. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  10055. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  10056. var user_name string
  10057. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  10058. if role.ID == 0 {
  10059. user_name = "xxx"
  10060. } else {
  10061. user_name = role.UserName
  10062. }
  10063. psn_record, _ := service.GetPsnRecordById(id)
  10064. if psn_record.ID == 0 {
  10065. c.ServeFailJSONWithSGJErrorCode(enums.ErrorPsnRecordNoExistWrong)
  10066. return
  10067. }
  10068. if config.IsOpen == 1 {
  10069. result := service.Gdyb2506(psn_record.PsnNo, user_name, miConfig.OrgName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, psn_record.TrtDclaDetlSn)
  10070. var dat map[string]interface{}
  10071. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  10072. fmt.Println(dat)
  10073. } else {
  10074. fmt.Println(err)
  10075. }
  10076. userJSONBytes, _ := json.Marshal(dat)
  10077. var res ResultFourteen
  10078. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  10079. utils.ErrorLog("解析失败:%v", err)
  10080. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10081. return
  10082. }
  10083. if res.Infcode == 0 {
  10084. psn_record.IsCancel = 2
  10085. service.CreatePsnRecord(&psn_record)
  10086. } else {
  10087. c.ServeSuccessJSON(map[string]interface{}{
  10088. "failed_code": -10,
  10089. "msg": res.ErrMsg,
  10090. })
  10091. return
  10092. }
  10093. }
  10094. }
  10095. func (c *HisApiController) PsnPutNCDSOnRecord() {
  10096. patient_id, _ := c.GetInt64("patient_id")
  10097. insutype_two := c.GetString("insutype")
  10098. psn_no := c.GetString("psn_no")
  10099. doctor_id, _ := c.GetInt64("doctor_id")
  10100. sick_id, _ := c.GetInt64("sick_id")
  10101. department_id, _ := c.GetInt64("department_id")
  10102. start_time := c.GetString("start_time")
  10103. end_time := c.GetString("end_time")
  10104. check_time := c.GetString("check_time")
  10105. adminUser := c.GetAdminUserInfo()
  10106. patient, _ := service.GetPatientByID(adminUser.CurrentOrgId, patient_id)
  10107. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  10108. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  10109. sick, _ := service.FindSickById(sick_id)
  10110. doctor, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, doctor_id)
  10111. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, doctor_id)
  10112. var res ResultTwo
  10113. var res10265 ResultTwo10265
  10114. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  10115. psn_info, _ := service.GetPsnByPatientId(patient.ID)
  10116. api := "http://192.168.3.111:9532/" + "hbyb/1101?cert_no=" + "" +
  10117. "&org_name=" + miConfig.OrgName + "&doctor=" + role.UserName + "&fixmedins_code=" + miConfig.Code +
  10118. "&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
  10119. resp, requestErr := http.Get(api)
  10120. if requestErr != nil {
  10121. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10122. return
  10123. }
  10124. body, ioErr := ioutil.ReadAll(resp.Body)
  10125. if ioErr != nil {
  10126. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  10127. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10128. return
  10129. }
  10130. var respJSON map[string]interface{}
  10131. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  10132. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  10133. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10134. return
  10135. }
  10136. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  10137. result, _ := json.Marshal(respJSON)
  10138. fmt.Println("log")
  10139. fmt.Println(string(result))
  10140. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  10141. utils.ErrorLog("解析失败:%v", err)
  10142. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10143. return
  10144. }
  10145. res.ErrMsg = res10265.ErrMsg
  10146. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  10147. res.Infcode = infocode
  10148. res.Output = res10265.Output
  10149. res.InfRefmsgid = res10265.InfRefmsgid
  10150. } else {
  10151. result, _ := service.Gdyb1101(patient.IdCardNo, miConfig.OrgName, role.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, 2, "", "0", patient.Name)
  10152. if miConfig.Code == "H15049901371" {
  10153. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  10154. utils.ErrorLog("解析失败:%v", err)
  10155. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10156. return
  10157. }
  10158. res.ErrMsg = res10265.ErrMsg
  10159. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  10160. res.Infcode = infocode
  10161. res.Output = res10265.Output
  10162. res.InfRefmsgid = res10265.InfRefmsgid
  10163. } else {
  10164. if err := json.Unmarshal([]byte(result), &res); err != nil {
  10165. utils.ErrorLog("解析失败:%v", err)
  10166. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10167. return
  10168. }
  10169. }
  10170. }
  10171. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  10172. infoStr := string(Iinfos)
  10173. var rf []*ResultFive
  10174. json.Unmarshal([]byte(infoStr), &rf)
  10175. var insuplc_admdvs string
  10176. var insutype string
  10177. var is390 int = 0
  10178. var is310 int = 0
  10179. var insutypes []*ResultFive
  10180. for _, item := range rf {
  10181. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  10182. insutypes = append(insutypes, item)
  10183. }
  10184. }
  10185. if len(insutypes) == 1 {
  10186. insutype = insutypes[0].Insutype
  10187. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  10188. } else {
  10189. for _, i := range insutypes {
  10190. if i.Insutype == "390" {
  10191. is390 = 1
  10192. }
  10193. if i.Insutype == "310" {
  10194. is310 = 1
  10195. }
  10196. }
  10197. }
  10198. if is390 == 1 {
  10199. insutype = "390"
  10200. }
  10201. if is310 == 1 {
  10202. insutype = "310"
  10203. }
  10204. if len(insutypes) == 2 {
  10205. insutype = insutype_two
  10206. }
  10207. if len(insutypes) == 0 {
  10208. insutype = "310"
  10209. }
  10210. insutype = insutype_two
  10211. fmt.Println(insutype)
  10212. for _, item := range rf {
  10213. fmt.Println(item.Insutype)
  10214. fmt.Println(insutype)
  10215. if item.Insutype == insutype {
  10216. fmt.Println(item.Insutype)
  10217. fmt.Println(insutype)
  10218. insuplc_admdvs = item.InsuplcAdmdvs
  10219. }
  10220. }
  10221. fmt.Println(insuplc_admdvs)
  10222. var res2 ResultThirteen
  10223. var res10265_2 ResultThirteen10265
  10224. if config.IsOpen == 1 {
  10225. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  10226. } else {
  10227. 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)
  10228. var dat map[string]interface{}
  10229. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  10230. fmt.Println(dat)
  10231. } else {
  10232. fmt.Println(err)
  10233. }
  10234. userJSONBytes, _ := json.Marshal(dat)
  10235. if miConfig.Code == "H15049901371" {
  10236. if err := json.Unmarshal(userJSONBytes, &res10265_2); err != nil {
  10237. utils.ErrorLog("解析失败:%v", err)
  10238. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10239. return
  10240. }
  10241. res2.ErrMsg = res10265_2.ErrMsg
  10242. infocode, _ := strconv.ParseInt(res10265_2.Infcode, 10, 64)
  10243. res2.Infcode = infocode
  10244. res2.Output = res10265_2.Output
  10245. res2.InfRefmsgid = res10265_2.InfRefmsgid
  10246. } else {
  10247. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  10248. utils.ErrorLog("解析失败:%v", err)
  10249. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10250. return
  10251. }
  10252. }
  10253. }
  10254. if res2.Infcode == 0 {
  10255. psnResult := &models.GdybPsnNcdsRecord{
  10256. UserOrgId: adminUser.CurrentOrgId,
  10257. PatientId: patient.ID,
  10258. PsnNo: psn_no,
  10259. DoctorId: doctor.AdminUserId,
  10260. DepartmentId: department_id,
  10261. SickType: sick_id,
  10262. Insutype: insutype,
  10263. Ctime: time.Now().Unix(),
  10264. Mtime: time.Now().Unix(),
  10265. Status: 1,
  10266. IsCancel: 1,
  10267. TrtDclaDetlSn: res2.Output.Result.TrtDclaDetlSn,
  10268. }
  10269. service.CreatePsnNCDSRecord(psnResult)
  10270. c.ServeSuccessJSON(map[string]interface{}{
  10271. "failed_code": 0,
  10272. "msg": "备案成功",
  10273. "result": psnResult,
  10274. })
  10275. } else {
  10276. c.ServeSuccessJSON(map[string]interface{}{
  10277. "failed_code": -10,
  10278. "msg": res2.ErrMsg,
  10279. })
  10280. return
  10281. }
  10282. }
  10283. }
  10284. func (c *HisApiController) PsnPutUnNCDSOnRecord() {
  10285. id, _ := c.GetInt64("id")
  10286. admin_user_id, _ := c.GetInt64("admin_user_id")
  10287. adminUser := c.GetAdminUserInfo()
  10288. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  10289. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  10290. //config, _ := service.Ge(adminUser.CurrentOrgId)
  10291. patient, _ := service.GetPatientByID(c.GetAdminUserInfo().CurrentOrgId, id)
  10292. //role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  10293. //var user_name string
  10294. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  10295. //if role.ID == 0 {
  10296. // user_name = "xxx"
  10297. //} else {
  10298. // user_name = role.UserName
  10299. //}
  10300. psn_record, _ := service.GetPsnNCDSRecordById(id)
  10301. if psn_record.ID == 0 {
  10302. c.ServeFailJSONWithSGJErrorCode(enums.ErrorPsnRecordNoExistWrong)
  10303. return
  10304. }
  10305. result, _ := service.Gdyb1101(patient.IdCardNo, miConfig.OrgName, role.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, 2, "", "0", patient.Name)
  10306. var res ResultTwo
  10307. var res10265 ResultTwo10265
  10308. if miConfig.Code == "H15049901371" {
  10309. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  10310. utils.ErrorLog("解析失败:%v", err)
  10311. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10312. return
  10313. }
  10314. res.ErrMsg = res10265.ErrMsg
  10315. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  10316. res.Infcode = infocode
  10317. res.Output = res10265.Output
  10318. res.InfRefmsgid = res10265.InfRefmsgid
  10319. } else {
  10320. if err := json.Unmarshal([]byte(result), &res); err != nil {
  10321. utils.ErrorLog("解析失败:%v", err)
  10322. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10323. return
  10324. }
  10325. }
  10326. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  10327. infoStr := string(Iinfos)
  10328. var rf []*ResultFive
  10329. json.Unmarshal([]byte(infoStr), &rf)
  10330. var insuplc_admdvs string
  10331. var insutype string
  10332. var is390 int = 0
  10333. var is310 int = 0
  10334. var insutypes []*ResultFive
  10335. for _, item := range rf {
  10336. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  10337. insutypes = append(insutypes, item)
  10338. }
  10339. }
  10340. if len(insutypes) == 1 {
  10341. insutype = insutypes[0].Insutype
  10342. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  10343. } else {
  10344. for _, i := range insutypes {
  10345. if i.Insutype == "390" {
  10346. is390 = 1
  10347. }
  10348. if i.Insutype == "310" {
  10349. is310 = 1
  10350. }
  10351. }
  10352. }
  10353. if is390 == 1 {
  10354. insutype = "390"
  10355. }
  10356. if is310 == 1 {
  10357. insutype = "310"
  10358. }
  10359. if len(insutypes) == 0 {
  10360. insutype = "310"
  10361. }
  10362. insutype = psn_record.Insutype
  10363. for _, item := range rf {
  10364. if item.Insutype == insutype {
  10365. insuplc_admdvs = item.InsuplcAdmdvs
  10366. }
  10367. }
  10368. if config.IsOpen == 1 {
  10369. result := service.Gdyb2504(psn_record.PsnNo, miConfig.OrgName, role.UserName, miConfig.Code, insuplc_admdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, psn_record.TrtDclaDetlSn)
  10370. var dat map[string]interface{}
  10371. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  10372. fmt.Println(dat)
  10373. } else {
  10374. fmt.Println(err)
  10375. }
  10376. userJSONBytes, _ := json.Marshal(dat)
  10377. var res ResultFourteen
  10378. var res10265 ResultFourteen10265
  10379. if miConfig.Code == "H15049901371" {
  10380. if err := json.Unmarshal(userJSONBytes, &res10265); err != nil {
  10381. utils.ErrorLog("解析失败:%v", err)
  10382. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10383. return
  10384. }
  10385. res.ErrMsg = res10265.ErrMsg
  10386. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  10387. res.Infcode = infocode
  10388. res.Output = res10265.Output
  10389. res.InfRefmsgid = res10265.InfRefmsgid
  10390. } else {
  10391. if err := json.Unmarshal([]byte(result), &res); err != nil {
  10392. utils.ErrorLog("解析失败:%v", err)
  10393. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10394. return
  10395. }
  10396. }
  10397. //if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  10398. // utils.ErrorLog("解析失败:%v", err)
  10399. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10400. // return
  10401. //}
  10402. if res.Infcode == 0 {
  10403. psn_record.IsCancel = 2
  10404. service.CreatePsnNCDSRecord(&psn_record)
  10405. c.ServeSuccessJSON(map[string]interface{}{
  10406. "failed_code": 0,
  10407. "msg": "撤销备案成功",
  10408. })
  10409. } else {
  10410. c.ServeSuccessJSON(map[string]interface{}{
  10411. "failed_code": -10,
  10412. "msg": res.ErrMsg,
  10413. })
  10414. return
  10415. }
  10416. }
  10417. }
  10418. func (c *HisApiController) TestTest() {
  10419. patient, _ := service.GetHisPatientInfo(4, 456, 1619712000)
  10420. fmt.Println(patient.Iinfo)
  10421. }
  10422. type CustomData struct {
  10423. MsgId string
  10424. PsnNo string
  10425. Info string
  10426. }
  10427. func (c *HisApiController) ReversalData() {
  10428. var customData []*CustomData
  10429. custom := &CustomData{
  10430. MsgId: "H44022900158202103301714472004",
  10431. PsnNo: "44020000001101329945",
  10432. Info: "2207",
  10433. }
  10434. customData = append(customData, custom)
  10435. custom1 := &CustomData{
  10436. MsgId: "H4402290015820210330172057803",
  10437. PsnNo: "44020000001101161813",
  10438. Info: "2207",
  10439. }
  10440. customData = append(customData, custom1)
  10441. custom2 := &CustomData{
  10442. MsgId: "H44022900158202103301705198813",
  10443. PsnNo: "44190000133097375417",
  10444. Info: "2207",
  10445. }
  10446. customData = append(customData, custom2)
  10447. custom3 := &CustomData{
  10448. MsgId: "H44022900158202103301715524756",
  10449. PsnNo: "44020000001100187221",
  10450. Info: "2207",
  10451. }
  10452. customData = append(customData, custom3)
  10453. custom4 := &CustomData{
  10454. MsgId: "H44022900158202103301730376224",
  10455. PsnNo: "44020000001101959155",
  10456. Info: "2207",
  10457. }
  10458. customData = append(customData, custom4)
  10459. custom5 := &CustomData{
  10460. MsgId: "H44022900158202103301748008725",
  10461. PsnNo: "44020000001104246641",
  10462. Info: "2207",
  10463. }
  10464. customData = append(customData, custom5)
  10465. custom6 := &CustomData{
  10466. MsgId: "H44022900158202103301718096755",
  10467. PsnNo: "44020000001102211860",
  10468. Info: "2207",
  10469. }
  10470. customData = append(customData, custom6)
  10471. custom7 := &CustomData{
  10472. MsgId: "H44022900158202103301736551640",
  10473. PsnNo: "44020000001102687718",
  10474. Info: "2207",
  10475. }
  10476. customData = append(customData, custom7)
  10477. custom8 := &CustomData{
  10478. MsgId: "H44022900158202103301743097676",
  10479. PsnNo: "44020000001102127785",
  10480. Info: "2207",
  10481. }
  10482. customData = append(customData, custom8)
  10483. custom9 := &CustomData{
  10484. MsgId: "H44022900158202103301712304203",
  10485. PsnNo: "44020000001101518097",
  10486. Info: "2207",
  10487. }
  10488. customData = append(customData, custom9)
  10489. custom10 := &CustomData{
  10490. MsgId: "H44022900158202103301738448785",
  10491. PsnNo: "44020000001100500813",
  10492. Info: "2207",
  10493. }
  10494. customData = append(customData, custom10)
  10495. custom11 := &CustomData{
  10496. MsgId: "H44022900158202103301732455843",
  10497. PsnNo: "44020000001102690557",
  10498. Info: "2207",
  10499. }
  10500. customData = append(customData, custom11)
  10501. custom12 := &CustomData{
  10502. MsgId: "H44022900158202103301745421708",
  10503. PsnNo: "44020000001102211928",
  10504. Info: "2207",
  10505. }
  10506. customData = append(customData, custom12)
  10507. custom1212 := &CustomData{
  10508. MsgId: "H440229001582021033017351627",
  10509. PsnNo: "44020000001102481733",
  10510. Info: "2207",
  10511. }
  10512. customData = append(customData, custom1212)
  10513. custom13 := &CustomData{
  10514. MsgId: "H44022900158202103301740327951",
  10515. PsnNo: "44020000001103174866",
  10516. Info: "2207",
  10517. }
  10518. customData = append(customData, custom13)
  10519. custom14 := &CustomData{
  10520. MsgId: "H4402290015820210330174922668",
  10521. PsnNo: "44020000001102927272",
  10522. Info: "2207",
  10523. }
  10524. customData = append(customData, custom14)
  10525. custom15 := &CustomData{
  10526. MsgId: "H44022900158202103301752362273",
  10527. PsnNo: "44020000001102942890",
  10528. Info: "2207",
  10529. }
  10530. customData = append(customData, custom15)
  10531. custom16 := &CustomData{
  10532. MsgId: "H44022900158202103301751082917",
  10533. PsnNo: "44020000001101662162",
  10534. Info: "2207",
  10535. }
  10536. customData = append(customData, custom16)
  10537. custom17 := &CustomData{
  10538. MsgId: "H44022900158202103301754147728",
  10539. PsnNo: "44020000000229014511",
  10540. Info: "2207",
  10541. }
  10542. customData = append(customData, custom17)
  10543. adminUser := c.GetAdminUserInfo()
  10544. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  10545. for _, item := range customData {
  10546. result := service.Gdyb2601(item.PsnNo, item.MsgId, item.Info, miConfig.OrgName, "张俊杰", miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey)
  10547. fmt.Println(result)
  10548. }
  10549. }
  10550. //func (c *HisApiController) GetAllopatry() {
  10551. // year := c.GetString("year")
  10552. // month := c.GetString("month")
  10553. // admin_user_id, _ := c.GetInt64("admin_user_id")
  10554. // adminUser := c.GetAdminUserInfo()
  10555. // miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  10556. // roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  10557. // result, _ := service.Gdyb9001(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, 1669)
  10558. //
  10559. // var dat map[string]interface{}
  10560. // if err := json.Unmarshal([]byte(result), &dat); err == nil {
  10561. // fmt.Println(dat)
  10562. // } else {
  10563. // fmt.Println(err)
  10564. // }
  10565. // userJSONBytes, _ := json.Marshal(dat)
  10566. // var res models.Result9001
  10567. // if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  10568. // utils.ErrorLog("解析失败:%v", err)
  10569. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10570. // return
  10571. // }
  10572. //
  10573. // result2, _ := service.Gdyb3260(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, year, month, res.Output.Signinoutb.SignNo)
  10574. // var dat2 map[string]interface{}
  10575. // if err := json.Unmarshal([]byte(result2), &dat2); err == nil {
  10576. // fmt.Println(dat)
  10577. // } else {
  10578. // fmt.Println(err)
  10579. // }
  10580. // userJSONBytes2, _ := json.Marshal(dat2)
  10581. // var res2 models.Result3260
  10582. // if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  10583. // utils.ErrorLog("解析失败:%v", err)
  10584. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10585. // return
  10586. // }
  10587. // if res2.Infcode == 0 {
  10588. // c.ServeSuccessJSON(map[string]interface{}{
  10589. // "list": res2.Output.Data,
  10590. // })
  10591. // return
  10592. // } else {
  10593. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10594. // return
  10595. // }
  10596. //
  10597. //}
  10598. //func (c *HisApiController) ComfirmAllopatry() {
  10599. // year := c.GetString("year")
  10600. // month := c.GetString("month")
  10601. // admin_user_id, _ := c.GetInt64("admin_user_id")
  10602. // adminUser := c.GetAdminUserInfo()
  10603. // miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  10604. // roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  10605. // result, _ := service.Gdyb9001(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, 1669)
  10606. // var dat map[string]interface{}
  10607. // if err := json.Unmarshal([]byte(result), &dat); err == nil {
  10608. // fmt.Println(dat)
  10609. // } else {
  10610. // fmt.Println(err)
  10611. // }
  10612. // userJSONBytes, _ := json.Marshal(dat)
  10613. // var res models.Result9001
  10614. // if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  10615. // utils.ErrorLog("解析失败:%v", err)
  10616. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10617. // return
  10618. // }
  10619. //
  10620. // result2, _ := service.Gdyb3260(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, year, month, res.Output.Signinoutb.SignNo)
  10621. // var dat2 map[string]interface{}
  10622. // if err := json.Unmarshal([]byte(result2), &dat2); err == nil {
  10623. // fmt.Println(dat)
  10624. // } else {
  10625. // fmt.Println(err)
  10626. // }
  10627. // userJSONBytes2, _ := json.Marshal(dat2)
  10628. // var res2 models.Result3260
  10629. // if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  10630. // utils.ErrorLog("解析失败:%v", err)
  10631. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10632. // return
  10633. // }
  10634. //
  10635. // if res2.Infcode == 0 {
  10636. // result, _, msgId := service.Gdyb3261(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, year, month, res2)
  10637. // var dat map[string]interface{}
  10638. // if err := json.Unmarshal([]byte(result), &dat); err == nil {
  10639. // fmt.Println(dat)
  10640. // } else {
  10641. // fmt.Println(err)
  10642. // }
  10643. // userJSONBytes, _ := json.Marshal(dat)
  10644. // var res3 models.Result3261
  10645. // if err := json.Unmarshal(userJSONBytes, &res3); err != nil {
  10646. // utils.ErrorLog("解析失败:%v", err)
  10647. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10648. // return
  10649. // }
  10650. //
  10651. // if res3.Infcode == 0 {
  10652. // record := &models.HisYidiClearRecord{
  10653. // UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  10654. // Ctime: time.Now().Unix(),
  10655. // Mtime: time.Now().Unix(),
  10656. // Status: 1,
  10657. // MsgId: msgId,
  10658. // }
  10659. // service.SaveClearRecord(record)
  10660. // c.ServeSuccessJSON(map[string]interface{}{
  10661. // "msg": "提取成功",
  10662. // })
  10663. // }
  10664. // }
  10665. //}
  10666. func (c *HisApiController) RefundAllopatry() {
  10667. year := c.GetString("year")
  10668. month := c.GetString("month")
  10669. id, _ := c.GetInt64("id")
  10670. admin_user_id, _ := c.GetInt64("admin_user_id")
  10671. adminUser := c.GetAdminUserInfo()
  10672. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  10673. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  10674. record, _ := service.GetClearRecordById(id)
  10675. result, _ := service.Gdyb3262(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, year, month, record.MsgId)
  10676. var dat map[string]interface{}
  10677. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  10678. fmt.Println(dat)
  10679. } else {
  10680. fmt.Println(err)
  10681. }
  10682. userJSONBytes, _ := json.Marshal(dat)
  10683. var empty ResultFourteen
  10684. if err := json.Unmarshal(userJSONBytes, &empty); err != nil {
  10685. utils.ErrorLog("解析失败:%v", err)
  10686. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10687. return
  10688. }
  10689. if empty.Infcode == 0 {
  10690. c.ServeSuccessJSON(map[string]interface{}{
  10691. "msg": "撤销成功",
  10692. })
  10693. return
  10694. }
  10695. }
  10696. func (c *HisApiController) ReversalOtherData() {
  10697. var customData []*CustomData
  10698. custom := &CustomData{
  10699. MsgId: "H44022900158202103301714472004",
  10700. PsnNo: "44020000001101329945",
  10701. Info: "2208",
  10702. }
  10703. customData = append(customData, custom)
  10704. custom1 := &CustomData{
  10705. MsgId: "H4402290015820210330172057803",
  10706. PsnNo: "44020000001101161813",
  10707. Info: "2208",
  10708. }
  10709. customData = append(customData, custom1)
  10710. custom2 := &CustomData{
  10711. MsgId: "H44022900158202103301705198813",
  10712. PsnNo: "44190000133097375417",
  10713. Info: "2208",
  10714. }
  10715. customData = append(customData, custom2)
  10716. custom3 := &CustomData{
  10717. MsgId: "H44022900158202103301715524756",
  10718. PsnNo: "44020000001100187221",
  10719. Info: "2208",
  10720. }
  10721. customData = append(customData, custom3)
  10722. custom4 := &CustomData{
  10723. MsgId: "H44022900158202103301730376224",
  10724. PsnNo: "44020000001101959155",
  10725. Info: "2208",
  10726. }
  10727. customData = append(customData, custom4)
  10728. custom5 := &CustomData{
  10729. MsgId: "H44022900158202103301748008725",
  10730. PsnNo: "44020000001104246641",
  10731. Info: "2208",
  10732. }
  10733. customData = append(customData, custom5)
  10734. custom6 := &CustomData{
  10735. MsgId: "H44022900158202103301718096755",
  10736. PsnNo: "44020000001102211860",
  10737. Info: "2208",
  10738. }
  10739. customData = append(customData, custom6)
  10740. custom7 := &CustomData{
  10741. MsgId: "H44022900158202103301736551640",
  10742. PsnNo: "44020000001102687718",
  10743. Info: "2208",
  10744. }
  10745. customData = append(customData, custom7)
  10746. custom8 := &CustomData{
  10747. MsgId: "H44022900158202103301743097676",
  10748. PsnNo: "44020000001102127785",
  10749. Info: "2208",
  10750. }
  10751. customData = append(customData, custom8)
  10752. custom9 := &CustomData{
  10753. MsgId: "H44022900158202103301712304203",
  10754. PsnNo: "44020000001101518097",
  10755. Info: "2208",
  10756. }
  10757. customData = append(customData, custom9)
  10758. custom10 := &CustomData{
  10759. MsgId: "H44022900158202103301738448785",
  10760. PsnNo: "44020000001100500813",
  10761. Info: "2208",
  10762. }
  10763. customData = append(customData, custom10)
  10764. custom11 := &CustomData{
  10765. MsgId: "H44022900158202103301732455843",
  10766. PsnNo: "44020000001102690557",
  10767. Info: "2208",
  10768. }
  10769. customData = append(customData, custom11)
  10770. custom12 := &CustomData{
  10771. MsgId: "H44022900158202103301745421708",
  10772. PsnNo: "44020000001102211928",
  10773. Info: "2208",
  10774. }
  10775. customData = append(customData, custom12)
  10776. custom1212 := &CustomData{
  10777. MsgId: "H440229001582021033017351627",
  10778. PsnNo: "44020000001102481733",
  10779. Info: "2208",
  10780. }
  10781. customData = append(customData, custom1212)
  10782. custom13 := &CustomData{
  10783. MsgId: "H44022900158202103301740327951",
  10784. PsnNo: "44020000001103174866",
  10785. Info: "2208",
  10786. }
  10787. customData = append(customData, custom13)
  10788. custom14 := &CustomData{
  10789. MsgId: "H4402290015820210330174922668",
  10790. PsnNo: "44020000001102927272",
  10791. Info: "2208",
  10792. }
  10793. customData = append(customData, custom14)
  10794. custom15 := &CustomData{
  10795. MsgId: "H44022900158202103301752362273",
  10796. PsnNo: "44020000001102942890",
  10797. Info: "2208",
  10798. }
  10799. customData = append(customData, custom15)
  10800. custom16 := &CustomData{
  10801. MsgId: "H44022900158202103301751082917",
  10802. PsnNo: "44020000001101662162",
  10803. Info: "2208",
  10804. }
  10805. customData = append(customData, custom16)
  10806. custom17 := &CustomData{
  10807. MsgId: "H44022900158202103301754147728",
  10808. PsnNo: "44020000000229014511",
  10809. Info: "2208",
  10810. }
  10811. customData = append(customData, custom17)
  10812. adminUser := c.GetAdminUserInfo()
  10813. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  10814. for _, item := range customData {
  10815. result := service.Gdyb2601(item.PsnNo, item.MsgId, item.Info, miConfig.OrgName, "张俊杰", miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey)
  10816. fmt.Println(result)
  10817. }
  10818. }
  10819. func PathExists(path string) (bool, error) {
  10820. _, err := os.Stat(path)
  10821. if err == nil {
  10822. return true, nil
  10823. }
  10824. if os.IsNotExist(err) {
  10825. return false, nil
  10826. }
  10827. return false, err
  10828. }
  10829. //创建文件夹
  10830. func Mkdir(dir string) {
  10831. // 创建文件夹
  10832. exist, err := PathExists(dir)
  10833. if err != nil {
  10834. fmt.Println(err.Error())
  10835. } else {
  10836. if exist {
  10837. fmt.Println(dir + "文件夹已存在!")
  10838. } else {
  10839. // 文件夹名称,权限
  10840. err := os.Mkdir(dir, os.ModePerm)
  10841. if err != nil {
  10842. fmt.Println(dir+"文件夹创建失败:", err.Error())
  10843. } else {
  10844. fmt.Println(dir + "文件夹创建成功!")
  10845. }
  10846. }
  10847. }
  10848. }
  10849. //压缩文件
  10850. func Zip(srcFile string, destZip string) error {
  10851. zipfile, err := os.Create(destZip)
  10852. if err != nil {
  10853. return err
  10854. }
  10855. defer zipfile.Close()
  10856. archive := zip.NewWriter(zipfile)
  10857. defer archive.Close()
  10858. filepath.Walk(srcFile, func(path string, info os.FileInfo, err error) error {
  10859. if err != nil {
  10860. return err
  10861. }
  10862. header, err := zip.FileInfoHeader(info)
  10863. if err != nil {
  10864. return err
  10865. }
  10866. header.Name = strings.TrimPrefix(path, filepath.Dir(srcFile)+"/")
  10867. // header.Name = path
  10868. if info.IsDir() {
  10869. header.Name += "/"
  10870. } else {
  10871. header.Method = zip.Deflate
  10872. }
  10873. writer, err := archive.CreateHeader(header)
  10874. if err != nil {
  10875. return err
  10876. }
  10877. if !info.IsDir() {
  10878. file, err := os.Open(path)
  10879. if err != nil {
  10880. return err
  10881. }
  10882. defer file.Close()
  10883. _, err = io.Copy(writer, file)
  10884. }
  10885. return err
  10886. })
  10887. return err
  10888. }
  10889. func ReadFile(filePath string) []byte {
  10890. f, err := os.Open(filePath)
  10891. if err != nil {
  10892. fmt.Println("read file fail", err)
  10893. return nil
  10894. }
  10895. defer f.Close()
  10896. fd, err := ioutil.ReadAll(f)
  10897. if err != nil {
  10898. fmt.Println("read to fd fail", err)
  10899. return nil
  10900. }
  10901. return fd
  10902. }
  10903. func saveLog(result string, request string, infno string, desc string) {
  10904. org_id, _ := beego.AppConfig.Int64("org_id")
  10905. miConfig, _ := service.FindMedicalInsuranceInfo(org_id)
  10906. dir := miConfig.OrgName + "日志"
  10907. utils.Mkdir(dir)
  10908. month := time.Unix(1557042972, 0).Format("1")
  10909. year := time.Now().Format("2006")
  10910. month = time.Now().Format("01")
  10911. day := time.Now().Format("02")
  10912. hour := time.Now().Format("15")
  10913. min := time.Now().Format("04")
  10914. sec := time.Now().Format("05")
  10915. result_time := year + "-" + month + "-" + day + " " + hour + ":" + min + ":" + sec
  10916. file := strconv.FormatInt(org_id, 10) + "_" + year + month + day + "_log"
  10917. file_name := file + ".txt"
  10918. file_path := miConfig.OrgName + "日志" + "/" + file_name
  10919. exist, _ := utils.PathExists(file_path)
  10920. if exist { //存在
  10921. fmt.Println("存在")
  10922. f, err := os.OpenFile(file_path, os.O_WRONLY, 0644)
  10923. if err != nil {
  10924. fmt.Println("read fail")
  10925. }
  10926. content := "\r\n" + "\r\n" + "\r\n" + result_time + " " + "【 " + desc + infno + "入参" + " 】:" + "\r\n" + request + "\r\n" + result_time + " " + "【 " + desc + infno + "出参" + " 】:" + "\r\n" + result
  10927. n, _ := f.Seek(0, 2)
  10928. _, err = f.WriteAt([]byte(content), n)
  10929. } else { //不存在
  10930. fmt.Println("文件不存在,创建文件")
  10931. f, err := os.Create(miConfig.OrgName + "日志" + "/" + file_name)
  10932. defer f.Close()
  10933. if err != nil {
  10934. } else {
  10935. _, err = f.Write([]byte("记录日志"))
  10936. }
  10937. }
  10938. }
  10939. type Charset string
  10940. const (
  10941. UTF8 = Charset("UTF-8")
  10942. GB18030 = Charset("GB18030")
  10943. )
  10944. func ConvertToString(src string, srcCode string, tagCode string) string {
  10945. srcCoder := mahonia.NewDecoder(srcCode)
  10946. srcResult := srcCoder.ConvertString(src)
  10947. tagCoder := mahonia.NewDecoder(tagCode)
  10948. _, cdata, _ := tagCoder.Translate([]byte(srcResult), true)
  10949. result := string(cdata)
  10950. return result
  10951. }
  10952. func (c *HisApiController) ReadEleCard() {
  10953. id_card_type, _ := c.GetInt64("id_card_type")
  10954. admin_user_id, _ := c.GetInt64("admin_user_id")
  10955. fmt.Println(c.GetAdminUserInfo().CurrentOrgId)
  10956. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  10957. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  10958. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  10959. var api string
  10960. if miConfig.MdtrtareaAdmvs == "320921" {
  10961. api = "http://192.168.3.111:9532/" + "jsyb/readcard?" + "fixmedins_code=" + miConfig.Code + "&secret_key=" + miConfig.SecretKey + "&ak=" + miConfig.AccessKey + "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName +
  10962. "&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
  10963. fmt.Println(api)
  10964. } else {
  10965. 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 +
  10966. "&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)
  10967. }
  10968. resp, requestErr := http.Get(api)
  10969. if requestErr != nil {
  10970. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10971. return
  10972. }
  10973. body, ioErr := ioutil.ReadAll(resp.Body)
  10974. if ioErr != nil {
  10975. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  10976. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10977. return
  10978. }
  10979. var respJSON map[string]interface{}
  10980. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  10981. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  10982. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10983. return
  10984. }
  10985. var status string
  10986. status = respJSON["data"].(map[string]interface{})["status"].(string)
  10987. //card_type := respJSON["data"].(map[string]interface{})["type"].(string)
  10988. var token string
  10989. var res ResultTwo //1101结果
  10990. var res10265 ResultTwo10265 //1101结果
  10991. if status == "0" { //读卡成功
  10992. var card_info string //卡信息
  10993. var busi_card_info string
  10994. token = respJSON["data"].(map[string]interface{})["token"].(string)
  10995. busi_card_info = respJSON["data"].(map[string]interface{})["busi_card_info"].(string)
  10996. card_info = respJSON["data"].(map[string]interface{})["card_info"].(string)
  10997. fmt.Println(card_info)
  10998. fmt.Println(busi_card_info)
  10999. respJSON = respJSON["data"].(map[string]interface{})["result"].(map[string]interface{})
  11000. result, _ := json.Marshal(respJSON)
  11001. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  11002. utils.ErrorLog("解析失败:%v", err)
  11003. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11004. return
  11005. }
  11006. res.ErrMsg = res10265.ErrMsg
  11007. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  11008. res.Infcode = infocode
  11009. res.Output = res10265.Output
  11010. res.InfRefmsgid = res10265.InfRefmsgid
  11011. if res.Infcode == 0 {
  11012. c.ServeSuccessJSON(map[string]interface{}{
  11013. "number": token,
  11014. })
  11015. }
  11016. } else {
  11017. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  11018. return
  11019. }
  11020. } else { //读卡失败
  11021. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  11022. return
  11023. }
  11024. }