12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504250525062507250825092510251125122513251425152516251725182519252025212522252325242525252625272528252925302531253225332534253525362537253825392540254125422543254425452546254725482549255025512552255325542555255625572558255925602561256225632564256525662567256825692570257125722573257425752576257725782579258025812582258325842585258625872588258925902591259225932594259525962597259825992600260126022603260426052606260726082609261026112612261326142615261626172618261926202621262226232624262526262627262826292630263126322633263426352636263726382639264026412642264326442645264626472648264926502651265226532654265526562657265826592660266126622663266426652666266726682669267026712672267326742675267626772678267926802681268226832684268526862687268826892690269126922693269426952696269726982699270027012702270327042705270627072708270927102711271227132714271527162717271827192720272127222723272427252726272727282729273027312732273327342735273627372738273927402741274227432744274527462747274827492750275127522753275427552756275727582759276027612762276327642765276627672768276927702771277227732774277527762777277827792780278127822783278427852786278727882789279027912792279327942795279627972798279928002801280228032804280528062807280828092810281128122813281428152816281728182819282028212822282328242825282628272828282928302831283228332834283528362837283828392840284128422843284428452846284728482849285028512852285328542855285628572858285928602861286228632864286528662867286828692870287128722873287428752876287728782879288028812882288328842885288628872888288928902891289228932894289528962897289828992900290129022903290429052906290729082909291029112912291329142915291629172918291929202921292229232924292529262927292829292930293129322933293429352936293729382939294029412942294329442945294629472948294929502951295229532954295529562957295829592960296129622963296429652966296729682969297029712972297329742975297629772978297929802981298229832984298529862987298829892990299129922993299429952996299729982999300030013002300330043005300630073008300930103011301230133014301530163017301830193020302130223023302430253026302730283029303030313032303330343035303630373038303930403041304230433044304530463047304830493050305130523053305430553056305730583059306030613062306330643065306630673068306930703071307230733074307530763077307830793080308130823083308430853086308730883089309030913092309330943095309630973098309931003101310231033104310531063107310831093110311131123113311431153116311731183119312031213122312331243125312631273128312931303131313231333134313531363137313831393140314131423143314431453146314731483149315031513152315331543155315631573158315931603161316231633164316531663167316831693170317131723173317431753176317731783179318031813182318331843185318631873188318931903191319231933194319531963197319831993200320132023203320432053206320732083209321032113212321332143215321632173218321932203221322232233224322532263227322832293230323132323233323432353236323732383239324032413242324332443245324632473248324932503251325232533254325532563257325832593260326132623263326432653266326732683269327032713272327332743275327632773278327932803281328232833284328532863287328832893290329132923293329432953296329732983299330033013302330333043305330633073308330933103311331233133314331533163317331833193320332133223323332433253326332733283329333033313332333333343335333633373338333933403341334233433344334533463347334833493350335133523353335433553356335733583359336033613362336333643365336633673368336933703371337233733374337533763377337833793380338133823383338433853386338733883389339033913392339333943395339633973398339934003401340234033404340534063407340834093410341134123413341434153416341734183419342034213422342334243425342634273428342934303431343234333434343534363437343834393440344134423443344434453446344734483449345034513452345334543455345634573458345934603461346234633464346534663467346834693470347134723473347434753476347734783479348034813482348334843485348634873488348934903491349234933494349534963497349834993500350135023503350435053506350735083509351035113512351335143515351635173518351935203521352235233524352535263527352835293530353135323533353435353536353735383539354035413542354335443545354635473548354935503551355235533554355535563557355835593560356135623563356435653566356735683569357035713572357335743575357635773578357935803581358235833584358535863587358835893590359135923593359435953596359735983599360036013602360336043605360636073608360936103611361236133614361536163617361836193620362136223623362436253626362736283629363036313632363336343635363636373638363936403641364236433644364536463647364836493650365136523653365436553656365736583659366036613662366336643665366636673668366936703671367236733674367536763677367836793680368136823683368436853686368736883689369036913692369336943695369636973698369937003701370237033704370537063707370837093710371137123713371437153716371737183719372037213722372337243725372637273728372937303731373237333734373537363737373837393740374137423743374437453746374737483749375037513752375337543755375637573758375937603761376237633764376537663767376837693770377137723773377437753776377737783779378037813782378337843785378637873788378937903791379237933794379537963797379837993800380138023803380438053806380738083809381038113812381338143815381638173818381938203821382238233824382538263827382838293830383138323833383438353836383738383839384038413842384338443845384638473848384938503851385238533854385538563857385838593860386138623863386438653866386738683869387038713872387338743875387638773878387938803881388238833884388538863887388838893890389138923893389438953896389738983899390039013902390339043905390639073908390939103911391239133914391539163917391839193920392139223923392439253926392739283929393039313932393339343935393639373938393939403941394239433944394539463947394839493950395139523953395439553956395739583959396039613962396339643965396639673968396939703971397239733974397539763977397839793980398139823983398439853986398739883989399039913992399339943995399639973998399940004001400240034004400540064007400840094010401140124013401440154016401740184019402040214022402340244025402640274028402940304031403240334034403540364037403840394040404140424043404440454046404740484049405040514052405340544055405640574058405940604061406240634064406540664067406840694070407140724073407440754076407740784079408040814082408340844085408640874088408940904091409240934094409540964097409840994100410141024103410441054106410741084109411041114112411341144115411641174118411941204121412241234124412541264127412841294130413141324133413441354136413741384139414041414142414341444145414641474148414941504151415241534154415541564157415841594160416141624163416441654166416741684169417041714172417341744175417641774178417941804181418241834184418541864187418841894190419141924193419441954196419741984199420042014202420342044205420642074208420942104211421242134214421542164217421842194220422142224223422442254226422742284229423042314232423342344235423642374238423942404241424242434244424542464247424842494250425142524253425442554256425742584259426042614262426342644265426642674268426942704271427242734274427542764277427842794280428142824283428442854286428742884289429042914292429342944295429642974298429943004301430243034304430543064307430843094310431143124313431443154316431743184319432043214322432343244325432643274328432943304331433243334334433543364337433843394340434143424343434443454346434743484349435043514352435343544355435643574358435943604361436243634364436543664367436843694370437143724373437443754376437743784379438043814382438343844385438643874388438943904391439243934394439543964397439843994400440144024403440444054406440744084409441044114412441344144415441644174418441944204421442244234424442544264427442844294430443144324433443444354436443744384439444044414442444344444445444644474448444944504451445244534454445544564457445844594460446144624463446444654466446744684469447044714472447344744475447644774478447944804481448244834484448544864487448844894490449144924493449444954496449744984499450045014502450345044505450645074508450945104511451245134514451545164517451845194520452145224523452445254526452745284529453045314532453345344535453645374538453945404541454245434544454545464547454845494550455145524553455445554556455745584559456045614562456345644565456645674568456945704571457245734574457545764577457845794580458145824583458445854586458745884589459045914592459345944595459645974598459946004601460246034604460546064607460846094610461146124613461446154616461746184619462046214622462346244625462646274628462946304631463246334634463546364637463846394640464146424643464446454646464746484649465046514652465346544655465646574658465946604661466246634664466546664667466846694670467146724673467446754676467746784679468046814682468346844685468646874688468946904691469246934694469546964697469846994700470147024703470447054706470747084709471047114712471347144715471647174718471947204721472247234724472547264727472847294730473147324733473447354736473747384739474047414742474347444745474647474748474947504751475247534754475547564757475847594760476147624763476447654766476747684769477047714772477347744775477647774778477947804781478247834784478547864787478847894790479147924793479447954796479747984799480048014802480348044805480648074808480948104811481248134814481548164817481848194820482148224823482448254826482748284829483048314832483348344835483648374838483948404841484248434844484548464847484848494850485148524853485448554856485748584859486048614862486348644865486648674868486948704871487248734874487548764877487848794880488148824883488448854886488748884889489048914892489348944895489648974898489949004901490249034904490549064907490849094910491149124913491449154916491749184919492049214922492349244925492649274928492949304931493249334934493549364937493849394940494149424943494449454946494749484949495049514952495349544955495649574958495949604961496249634964496549664967496849694970497149724973497449754976497749784979498049814982498349844985498649874988498949904991499249934994499549964997499849995000500150025003500450055006500750085009501050115012501350145015501650175018501950205021502250235024502550265027502850295030503150325033503450355036503750385039504050415042504350445045504650475048504950505051505250535054505550565057505850595060506150625063506450655066506750685069507050715072507350745075507650775078507950805081508250835084508550865087508850895090509150925093509450955096509750985099510051015102510351045105510651075108510951105111511251135114511551165117511851195120512151225123512451255126512751285129513051315132513351345135513651375138513951405141514251435144514551465147514851495150515151525153515451555156515751585159516051615162516351645165516651675168516951705171517251735174517551765177517851795180518151825183518451855186518751885189519051915192519351945195519651975198519952005201520252035204520552065207520852095210521152125213521452155216521752185219522052215222522352245225522652275228522952305231523252335234523552365237523852395240524152425243524452455246524752485249525052515252525352545255525652575258525952605261526252635264526552665267526852695270527152725273527452755276527752785279528052815282528352845285528652875288528952905291529252935294529552965297529852995300530153025303530453055306530753085309531053115312531353145315531653175318531953205321532253235324532553265327532853295330533153325333533453355336533753385339534053415342534353445345534653475348534953505351535253535354535553565357535853595360536153625363536453655366536753685369537053715372537353745375537653775378537953805381538253835384538553865387538853895390539153925393539453955396539753985399540054015402540354045405540654075408540954105411541254135414541554165417541854195420542154225423542454255426542754285429543054315432543354345435543654375438543954405441544254435444544554465447544854495450545154525453545454555456545754585459546054615462546354645465546654675468546954705471547254735474547554765477547854795480548154825483548454855486548754885489549054915492549354945495549654975498549955005501550255035504550555065507550855095510551155125513551455155516551755185519552055215522552355245525552655275528552955305531553255335534553555365537553855395540554155425543554455455546554755485549555055515552555355545555555655575558555955605561556255635564556555665567556855695570557155725573557455755576557755785579558055815582558355845585558655875588558955905591559255935594559555965597559855995600560156025603560456055606560756085609561056115612561356145615561656175618561956205621562256235624562556265627562856295630563156325633563456355636563756385639564056415642564356445645564656475648564956505651565256535654565556565657565856595660566156625663566456655666566756685669567056715672567356745675567656775678567956805681568256835684568556865687568856895690569156925693569456955696569756985699570057015702570357045705570657075708570957105711571257135714571557165717571857195720572157225723572457255726572757285729573057315732573357345735573657375738573957405741574257435744574557465747574857495750575157525753575457555756575757585759576057615762576357645765576657675768576957705771577257735774577557765777577857795780578157825783578457855786578757885789579057915792579357945795579657975798579958005801580258035804580558065807580858095810581158125813581458155816581758185819582058215822582358245825582658275828582958305831583258335834583558365837583858395840584158425843584458455846584758485849585058515852585358545855585658575858585958605861586258635864586558665867586858695870587158725873587458755876587758785879588058815882588358845885588658875888588958905891589258935894589558965897589858995900590159025903590459055906590759085909591059115912591359145915591659175918591959205921592259235924592559265927592859295930593159325933593459355936593759385939594059415942594359445945594659475948594959505951595259535954595559565957595859595960596159625963596459655966596759685969597059715972597359745975597659775978597959805981598259835984598559865987598859895990599159925993599459955996599759985999600060016002600360046005600660076008600960106011601260136014601560166017601860196020602160226023602460256026602760286029603060316032603360346035603660376038603960406041604260436044604560466047604860496050605160526053605460556056605760586059606060616062606360646065606660676068606960706071607260736074607560766077607860796080608160826083608460856086608760886089609060916092609360946095609660976098609961006101610261036104610561066107610861096110611161126113611461156116611761186119612061216122612361246125612661276128612961306131613261336134613561366137613861396140614161426143614461456146614761486149615061516152615361546155615661576158615961606161616261636164616561666167616861696170617161726173617461756176617761786179618061816182618361846185618661876188618961906191619261936194619561966197619861996200620162026203620462056206620762086209621062116212621362146215621662176218621962206221622262236224622562266227622862296230623162326233623462356236623762386239624062416242624362446245624662476248624962506251625262536254625562566257625862596260626162626263626462656266626762686269627062716272627362746275627662776278627962806281628262836284628562866287628862896290629162926293629462956296629762986299630063016302630363046305630663076308630963106311631263136314631563166317631863196320632163226323632463256326632763286329633063316332633363346335633663376338633963406341634263436344634563466347634863496350635163526353635463556356635763586359636063616362636363646365636663676368636963706371637263736374637563766377637863796380638163826383638463856386638763886389639063916392639363946395639663976398639964006401640264036404640564066407640864096410641164126413641464156416641764186419642064216422642364246425642664276428642964306431643264336434643564366437643864396440644164426443644464456446644764486449645064516452645364546455645664576458645964606461646264636464646564666467646864696470647164726473647464756476647764786479648064816482648364846485648664876488648964906491649264936494649564966497649864996500650165026503650465056506650765086509651065116512651365146515651665176518651965206521652265236524652565266527652865296530653165326533653465356536653765386539654065416542654365446545654665476548654965506551655265536554655565566557655865596560656165626563656465656566656765686569657065716572657365746575657665776578657965806581658265836584658565866587658865896590659165926593659465956596659765986599660066016602660366046605660666076608660966106611661266136614661566166617661866196620662166226623662466256626662766286629663066316632663366346635663666376638663966406641664266436644664566466647664866496650665166526653665466556656665766586659666066616662666366646665666666676668666966706671667266736674667566766677667866796680668166826683668466856686668766886689669066916692669366946695669666976698669967006701670267036704670567066707670867096710671167126713671467156716671767186719672067216722672367246725672667276728672967306731673267336734673567366737673867396740674167426743674467456746674767486749675067516752675367546755675667576758675967606761676267636764676567666767676867696770677167726773677467756776677767786779678067816782678367846785678667876788678967906791679267936794679567966797679867996800680168026803680468056806680768086809681068116812681368146815681668176818681968206821682268236824682568266827682868296830683168326833683468356836683768386839684068416842684368446845684668476848684968506851685268536854685568566857685868596860686168626863686468656866686768686869687068716872687368746875687668776878687968806881688268836884688568866887688868896890689168926893689468956896689768986899690069016902690369046905690669076908690969106911691269136914691569166917691869196920692169226923692469256926692769286929693069316932693369346935693669376938693969406941694269436944694569466947694869496950695169526953695469556956695769586959696069616962696369646965696669676968696969706971697269736974697569766977697869796980 |
- package mobile_api_controllers
-
- import (
- "encoding/json"
- "fmt"
- "math"
- "strings"
-
- "XT_New/enums"
- "XT_New/models"
- "XT_New/service"
- "XT_New/utils"
- // "fmt"
- "reflect"
- "strconv"
- "time"
- )
-
- type PatientApiController struct {
- MobileBaseAPIAuthController
- }
-
- func (c *PatientApiController) GetPatientInfoWithDiseases() {
- id, _ := c.GetInt64("patient", 0)
-
- if id <= 0 {
- c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
- return
- }
- adminUserInfo := c.GetMobileAdminUserInfo()
- patient, _ := service.FindPatientByIdWithDiseases(adminUserInfo.Org.Id, id)
- if patient.ID == 0 {
- c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodePatientNoExist)
- return
- }
- Registrars, err := service.GetAdminUser(adminUserInfo.Org.Id, adminUserInfo.App.Id, patient.RegistrarsId)
- if err != nil {
- c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
- return
- }
-
- if Registrars != nil {
- patient.Registrars = Registrars.Name
- }
-
- c.ServeSuccessJSON(map[string]interface{}{
- "patient": patient,
- })
- return
-
- }
-
- func (c *PatientApiController) CreateDialysisSolution() {
- id, _ := c.GetInt64("patient", 0)
- if id <= 0 {
- c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
- return
- }
-
- adminUserInfo := c.GetMobileAdminUserInfo()
- patient, _ := service.FindPatientById(adminUserInfo.Org.Id, id)
- if patient.ID == 0 {
- c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodePatientNoExist)
- return
- }
-
- //根据路由来做权限
- //appRole, _ := service.FindAdminRoleTypeById(adminUserInfo.Org.Id, adminUserInfo.AdminUser.Id, adminUserInfo.App.Id)
- //template, _ := service.GetOrgInfoTemplate(adminUserInfo.Org.Id)
-
- //if template.TemplateId == 2 || template.TemplateId == 6 {
- // if appRole.UserType == 3 {
- // headNursePermission, getPermissionErr := service.GetAdminUserSpecialPermission(adminUserInfo.Org.Id, adminUserInfo.App.Id, adminUserInfo.AdminUser.Id, models.SpecialPermissionTypeHeadNurse)
- // if getPermissionErr != nil {
- // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
- // return
- // } else if headNursePermission == nil {
- // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDialysisPermissionDeniedModify)
- // return
- // }
- // }
- //}
-
- var solution models.DialysisSolution
-
- code := defaultSolutionFormData(&solution, c.Ctx.Input.RequestBody, "create")
- if code > 0 {
- c.ServeFailJSONWithSGJErrorCode(code)
- return
- }
-
- solution.RegistrarsId = adminUserInfo.AdminUser.Id
- solution.Doctor = adminUserInfo.AdminUser.Id
- solution.Status = 1
- solution.PatientId = id
- solution.CreatedTime = time.Now().Unix()
- solution.UserOrgId = adminUserInfo.Org.Id
- solution.UpdatedTime = time.Now().Unix()
- solution.SubName = ""
- solution.ParentId = 0
-
- err := service.CreatePatientDialysisSolution(&solution)
- if err != nil {
- c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDialysisSolutionCreate)
- return
- }
-
- c.ServeSuccessJSON(map[string]interface{}{
- "msg": "ok",
- "solution": solution,
- })
- return
- }
-
- func (c *PatientApiController) EditDialysisSolution() {
- id, _ := c.GetInt64("id", 0)
- if id <= 0 {
- c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
- return
- }
-
- adminUserInfo := c.GetMobileAdminUserInfo()
- solution, _ := service.FindPatientDialysisSolution(adminUserInfo.Org.Id, id)
- if solution.ID == 0 {
- c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDialysisSolutionNotExist)
- return
- }
-
- //if solution.Doctor != adminUserInfo.AdminUser.Id {
- // headNursePermission, getPermissionErr := service.GetAdminUserSpecialPermission(adminUserInfo.Org.Id, adminUserInfo.App.Id, adminUserInfo.AdminUser.Id, models.SpecialPermissionTypeHeadNurse)
- // if getPermissionErr != nil {
- // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
- // return
- // } else if headNursePermission == nil {
- // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDialysisPermissionDeniedModify)
- // return
- // }
- //}
-
- code := defaultSolutionFormData(&solution, c.Ctx.Input.RequestBody, "update")
- if code > 0 {
- c.ServeFailJSONWithSGJErrorCode(code)
- return
- }
-
- // solution.RegistrarsId = adminUserInfo.AdminUser.Id
- solution.Doctor = adminUserInfo.AdminUser.Id
- solution.Status = 1
- // solution.PatientId = id
- // solution.CreatedTime = time.Now().Unix()
- // solution.UserOrgId = adminUserInfo.Org.Id
- solution.UpdatedTime = time.Now().Unix()
- // solution.SubName = ""
- // solution.ParentId = 0
-
- err := service.UpdatePatientDialysisSolution(&solution)
- if err != nil {
- c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDialysisSolutionUpdate)
- return
- }
-
- c.ServeSuccessJSON(map[string]interface{}{
- "msg": "ok",
- "solution": solution,
- })
- return
- }
-
- func (c *PatientApiController) CreateDoctorAdvice() {
-
- patient, _ := c.GetInt64("id", 0)
- if patient <= 0 {
- c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
- return
- }
-
- adminUserInfo := c.GetMobileAdminUserInfo()
- patientInfo, _ := service.FindPatientById(adminUserInfo.Org.Id, patient)
- if patientInfo.ID == 0 {
- c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodePatientNoExist)
- return
- }
- //appRole, _ := service.FindAdminRoleTypeById(adminUserInfo.Org.Id, adminUserInfo.AdminUser.Id, adminUserInfo.App.Id)
-
- //if appRole.UserType == 3{
- // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeAdvicePermissionDeniedModify)
- // return
- //}
-
- //appRole, _ := service.FindAdminRoleTypeById(adminUserInfo.Org.Id, adminUserInfo.AdminUser.Id, adminUserInfo.App.Id)
- //
- //if appRole.UserType == 3 {
- // headNursePermission, getPermissionErr := service.GetAdminUserSpecialPermission(adminUserInfo.Org.Id, adminUserInfo.App.Id, adminUserInfo.AdminUser.Id, models.SpecialPermissionTypeHeadNurse)
- // if getPermissionErr != nil {
- // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
- // return
- // } else if headNursePermission == nil {
- // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDialysisPermissionDeniedModify)
- // return
- // }
- //}
-
- var advice models.DoctorAdvice
- code := adviceFormData(&advice, c.Ctx.Input.RequestBody, "create")
- if code > 0 {
- c.ServeFailJSONWithSGJErrorCode(code)
- return
- }
-
- if advice.ParentId > 0 {
- old, _ := service.FindDoctorAdvice(adminUserInfo.Org.Id, advice.ParentId)
- if old.ID == 0 || old.PatientId != patient {
- c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParentAdviceNotExist)
- return
- }
-
- if old.StopState == 1 || old.ExecutionState == 1 {
- c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeAdviceStoped)
- return
- }
-
- if old.ParentId > 0 {
- advice.ParentId = old.ParentId
- }
- advice.StartTime = old.StartTime
- advice.AdviceDoctor = old.AdviceDoctor
- advice.DeliveryWay = old.DeliveryWay
- advice.ExecutionFrequency = old.ExecutionFrequency
- advice.GroupNo = old.GroupNo
-
- }
-
- advice.Status = 1
- advice.CreatedTime = time.Now().Unix()
- advice.UpdatedTime = time.Now().Unix()
- advice.StopState = 2
- advice.ExecutionState = 2
- advice.UserOrgId = adminUserInfo.Org.Id
- advice.PatientId = patient
- advice.AdviceDoctor = adminUserInfo.AdminUser.Id
-
- err := service.CreateDoctorAdvice(&advice)
- key := strconv.FormatInt(adminUserInfo.Org.Id, 10) + ":" + strconv.FormatInt(patient, 10) + ":" + strconv.FormatInt(advice.AdviceDate, 10) + ":doctor_advices"
- redis := service.RedisClient()
- defer redis.Close()
- redis.Set(key, "", time.Second)
- keyOne := strconv.FormatInt(adminUserInfo.Org.Id, 10) + ":" + strconv.FormatInt(advice.AdviceDate, 10) + ":advice_list_all"
- redis.Set(keyOne, "", time.Second)
- if err != nil {
- c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCreateDoctorAdviceFail)
- return
- }
-
- c.ServeSuccessJSON(map[string]interface{}{
- "msg": "ok",
- "advice": advice,
- })
- return
- }
-
- func (c *PatientApiController) EditDoctorAdvice() {
- id, _ := c.GetInt64("id", 0)
- patient_id, _ := c.GetInt64("patient_id")
- doc_advice_date, _ := c.GetInt64("advice_date")
- if id <= 0 {
- c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
- return
- }
- redis := service.RedisClient()
- adminUserInfo := c.GetMobileAdminUserInfo()
-
- //appRole, _ := service.FindAdminRoleTypeById(adminUserInfo.Org.Id, adminUserInfo.AdminUser.Id, adminUserInfo.App.Id)
-
- //appRole, _ := service.FindAdminRoleTypeById(adminUserInfo.Org.Id, adminUserInfo.AdminUser.Id, adminUserInfo.App.Id)
- //
- //if appRole.UserType == 3 {
- // headNursePermission, getPermissionErr := service.GetAdminUserSpecialPermission(adminUserInfo.Org.Id, adminUserInfo.App.Id, adminUserInfo.AdminUser.Id, models.SpecialPermissionTypeHeadNurse)
- // if getPermissionErr != nil {
- // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
- // return
- // } else if headNursePermission == nil {
- // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDialysisPermissionDeniedModify)
- // return
- // }
- //}
-
- advice, _ := service.FindDoctorAdvice(adminUserInfo.Org.Id, id)
- if advice.ID == 0 {
- c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDoctorAdviceNotExist)
- return
- }
-
- code := adviceFormData(&advice, c.Ctx.Input.RequestBody, "update")
- if code > 0 {
- c.ServeFailJSONWithSGJErrorCode(code)
- return
- }
-
- advice.Status = 1
- advice.UpdatedTime = time.Now().Unix()
- advice.UserOrgId = adminUserInfo.Org.Id
- advice.Modifier = adminUserInfo.AdminUser.Id
-
- //处理修改医嘱开始时间逻辑(不包括子医嘱)
- //1.一组医嘱内只有一条医嘱(不包括子医嘱)的情况下,只需要直接修改医嘱开始时间,不需要重新分配组号
- //2.一组医嘱内有多条医嘱(不包括子医嘱)的情况下,需要为修改的那条医嘱重新分配组号,并修改医嘱开始时间
- var err error
- var isChangeGroup bool
- if advice.ParentId == 0 {
- adviceSlice, _ := service.FindAdviceByGoroupNo(adminUserInfo.Org.Id, advice.GroupNo)
- sourceAdvice, _ := service.FindOldDoctorAdvice(adminUserInfo.Org.Id, advice.ID)
- if len(adviceSlice) == 1 {
-
- // 查询信息规挡的设置天数
-
- infor, _ := service.GetDialysisInformationSetting(adminUserInfo.Org.Id)
- if infor.ID > 0 && infor.WeekDay > 0 {
-
- var cha_time int64
-
- timeNowStr := time.Now().Format("2006-01-02")
- timeNewDate, _ := utils.ParseTimeStringToTime("2006-01-02", timeNowStr)
-
- //今日的日期减去设置的日期
- cha_time = timeNewDate.Unix() - infor.WeekDay*86400
-
- if cha_time >= sourceAdvice.AdviceDate {
- //查询审核是否允许
- infor, _ := service.GetDialysisInformationByRecordDate(id, sourceAdvice.AdviceDate, adminUserInfo.Org.Id, 4)
- //申请状态不允许的情况 拒绝修改
- if infor.ApplicationStatus != 1 {
- c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeInformationExist)
- return
- }
-
- }
- }
- //判断前端上传上来的开始时间和数据库中想要修改的那条医嘱的开始时间是否相同,如果不同,需要修改子医嘱的开始时间,如果相同直接修改,不需要修改子医嘱的开始时间
- if advice.StartTime == sourceAdvice.StartTime {
- err = service.UpdateDoctorAdvice(&advice)
- key := strconv.FormatInt(adminUserInfo.Org.Id, 10) + ":" + strconv.FormatInt(patient_id, 10) + ":" + strconv.FormatInt(doc_advice_date, 10) + ":doctor_advices"
-
- defer redis.Close()
- redis.Set(key, "", time.Second)
- keyOne := strconv.FormatInt(adminUserInfo.Org.Id, 10) + ":" + ":advice_list_all"
- redis.Set(keyOne, "", time.Second)
- isChangeGroup = false
- } else {
- err = service.UpdateDoctorAdviceAndSubAdvice(&advice)
- isChangeGroup = false
- key := strconv.FormatInt(adminUserInfo.Org.Id, 10) + ":" + strconv.FormatInt(patient_id, 10) + ":" + strconv.FormatInt(doc_advice_date, 10) + ":doctor_advices"
-
- defer redis.Close()
- redis.Set(key, "", time.Second)
- keyOne := strconv.FormatInt(adminUserInfo.Org.Id, 10) + ":" + strconv.FormatInt(doc_advice_date, 10) + ":advice_list_all"
- redis.Set(keyOne, "", time.Second)
- }
- } else if len(adviceSlice) > 1 {
- infor, _ := service.GetDialysisInformationSetting(adminUserInfo.Org.Id)
- if infor.ID > 0 {
-
- var cha_time int64
-
- timeNowStr := time.Now().Format("2006-01-02")
- timeNewDate, _ := utils.ParseTimeStringToTime("2006-01-02", timeNowStr)
-
- //今日的日期减去设置的日期
- cha_time = timeNewDate.Unix() - infor.WeekDay*86400
-
- if cha_time >= sourceAdvice.AdviceDate {
- //查询审核是否允许
- infor, _ := service.GetDialysisInformationByRecordDate(id, sourceAdvice.AdviceDate, adminUserInfo.Org.Id, 4)
- //申请状态不允许的情况 拒绝修改
- if infor.ApplicationStatus != 1 {
- c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeInformationExist)
- return
- }
-
- }
- }
- //判断前端上传上来的开始时间和数据库中想要修改的那条医嘱的开始时间是否相同,如果不同,需要重新分配组,如果相同直接修改,不需要分配组
- if advice.StartTime == sourceAdvice.StartTime {
- err = service.UpdateDoctorAdvice(&advice)
- key := strconv.FormatInt(adminUserInfo.Org.Id, 10) + ":" + strconv.FormatInt(patient_id, 10) + ":" + strconv.FormatInt(doc_advice_date, 10) + ":doctor_advices"
-
- defer redis.Close()
- redis.Set(key, "", time.Second)
- keyOne := strconv.FormatInt(adminUserInfo.Org.Id, 10) + ":" + strconv.FormatInt(doc_advice_date, 10) + ":advice_list_all"
- redis.Set(keyOne, "", time.Second)
- isChangeGroup = false
-
- } else {
- gruopNo := service.GetMaxAdviceGroupID(adminUserInfo.Org.Id)
- gruopNo = gruopNo + 1
- advice.GroupNo = gruopNo
- err = service.UpdateDoctorAdviceAndSubAdvice(&advice)
- key := strconv.FormatInt(adminUserInfo.Org.Id, 10) + ":" + strconv.FormatInt(patient_id, 10) + ":" + strconv.FormatInt(doc_advice_date, 10) + ":doctor_advices"
-
- defer redis.Close()
- redis.Set(key, "", time.Second)
- keyOne := strconv.FormatInt(adminUserInfo.Org.Id, 10) + ":" + strconv.FormatInt(doc_advice_date, 10) + ":advice_list_all"
- redis.Set(keyOne, "", time.Second)
- isChangeGroup = true
-
- }
- }
- } else {
- infor, _ := service.GetDialysisInformationSetting(adminUserInfo.Org.Id)
- if infor.ID > 0 {
-
- var cha_time int64
-
- timeNowStr := time.Now().Format("2006-01-02")
- timeNewDate, _ := utils.ParseTimeStringToTime("2006-01-02", timeNowStr)
-
- //今日的日期减去设置的日期
- cha_time = timeNewDate.Unix() - infor.WeekDay*86400
-
- if cha_time >= advice.AdviceDate {
- //查询审核是否允许
- infor, _ := service.GetDialysisInformationByRecordDate(id, advice.AdviceDate, adminUserInfo.Org.Id, 4)
- //申请状态不允许的情况 拒绝修改
- if infor.ApplicationStatus != 1 {
- c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeInformationExist)
- return
- }
-
- }
- }
- isChangeGroup = false
- err = service.UpdateDoctorAdvice(&advice)
- redis := service.RedisClient()
- defer redis.Close()
- key := strconv.FormatInt(adminUserInfo.Org.Id, 10) + ":" + strconv.FormatInt(doc_advice_date, 10) + ":advice_list_all"
- redis.Set(key, "", time.Second)
- keyOne := strconv.FormatInt(adminUserInfo.Org.Id, 10) + ":" + strconv.FormatInt(patient_id, 10) + ":" + strconv.FormatInt(doc_advice_date, 10) + ":doctor_advices"
- redis.Set(keyOne, "", time.Second)
-
- }
- if err != nil {
- c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeUpdateDoctorAdviceFail)
- return
- }
-
- if !isChangeGroup {
- c.ServeSuccessJSON(map[string]interface{}{
- "msg": "ok",
- "advice": advice,
- "isChange": isChangeGroup, //方便前端处理数据
- })
-
- } else {
-
- newGroupAdvice, err := service.FindAllDoctorAdviceByGoroupNo(adminUserInfo.Org.Id, advice.GroupNo)
- if err != nil {
- c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
- return
- }
-
- c.ServeSuccessJSON(map[string]interface{}{
- "msg": "ok",
- "advice": newGroupAdvice,
- "isChange": isChangeGroup, //方便前端处理数据
- })
-
- }
- return
- }
-
- func (c *PatientApiController) StopDoctorAdvice() {
- id, _ := c.GetInt64("id", 0)
- if id <= 0 {
- c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
- return
- }
-
- adminUserInfo := c.GetMobileAdminUserInfo()
- advice, _ := service.FindDoctorAdvice(adminUserInfo.Org.Id, id)
- if advice.ID == 0 {
- c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDoctorAdviceNotExist)
- return
- }
-
- //if advice.AdviceDoctor != adminUserInfo.AdminUser.Id {
- // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDialysisPermissionDeniedModify)
- // return
- //}
-
- //appRole, _ := service.FindAdminRoleTypeById(adminUserInfo.Org.Id, adminUserInfo.AdminUser.Id, adminUserInfo.App.Id)
- //
- //if appRole.UserType == 3 {
- // headNursePermission, getPermissionErr := service.GetAdminUserSpecialPermission(adminUserInfo.Org.Id, adminUserInfo.App.Id, adminUserInfo.AdminUser.Id, models.SpecialPermissionTypeHeadNurse)
- // if getPermissionErr != nil {
- // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
- // return
- // } else if headNursePermission == nil {
- // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDialysisPermissionDeniedModify)
- // return
- // }
- //}
-
- if advice.StopState == 1 {
- c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeAdviceStoped)
- return
- }
-
- dataBody := make(map[string]interface{}, 0)
- err := json.Unmarshal(c.Ctx.Input.RequestBody, &dataBody)
- if err != nil {
- c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
- return
- }
-
- timeLayout := "2006-01-02"
- loc, _ := time.LoadLocation("Local")
- if dataBody["stop_time"] == nil || reflect.TypeOf(dataBody["stop_time"]).String() != "string" {
- utils.ErrorLog("stop_time")
- c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
- return
- }
- stopTime, _ := dataBody["stop_time"].(string)
- if len(stopTime) == 0 {
- utils.ErrorLog("len(stop_time) == 0")
- c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
- return
- }
- theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", stopTime, loc)
- if err != nil {
- utils.ErrorLog(err.Error())
- c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
- return
- }
- advice.StopTime = theTime.Unix()
-
- if dataBody["stop_reason"] == nil || reflect.TypeOf(dataBody["stop_reason"]).String() != "string" {
- utils.ErrorLog("stop_reason")
- c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
- return
- }
- stopReason, _ := dataBody["stop_reason"].(string)
- if len(stopReason) == 0 {
- utils.ErrorLog("len(stop_reason) == 0")
- c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
- return
- }
- advice.StopReason = stopReason
-
- advice.Status = 1
- advice.UpdatedTime = time.Now().Unix()
- advice.StopDoctor = adminUserInfo.AdminUser.Id
- advice.StopState = 1
- advice.StopTime = time.Now().Unix()
- advice.Modifier = adminUserInfo.AdminUser.Id
-
- err = service.StopDoctorAdvice(&advice)
- if err != nil {
- c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeStopAdviceFail)
- return
- }
-
- c.ServeSuccessJSON(map[string]interface{}{
- "msg": "ok",
- "advice": advice,
- })
- return
- }
-
- func (c *PatientApiController) DeleteDoctorAdvice() {
- id, _ := c.GetInt64("id", 0)
- if id <= 0 {
- c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
- return
- }
-
- adminUserInfo := c.GetMobileAdminUserInfo()
-
- advice, _ := service.FindDoctorAdvice(adminUserInfo.Org.Id, id)
- if advice.ID == 0 {
- c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDoctorAdviceNotExist)
- return
- }
-
- //自备药
- selfPrescriptionOutOpenOne, _ := service.GetSelfPrescriptionOutOpen(adminUserInfo.Org.Id)
-
- if selfPrescriptionOutOpenOne.IsOpen == 1 {
- //查询库存是否是自备药
- selfBasedrug, _ := service.GetSelfBasedrugByIdTwo(advice.DrugId, advice.UserOrgId)
-
- if selfBasedrug.IsSelfDrug == 1 {
- creater := adminUserInfo.AdminUser.Id
- //退库
- service.SelfDrugAutoAddCancelInfoOne(&advice, creater)
- }
- }
-
- //if !adminUserInfo.AdminUser.IsSuperAdmin && advice.AdviceDoctor != adminUserInfo.AdminUser.Id {
- // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDialysisPermissionDeniedModify)
- // return
- //}
-
- //appRole, _ := service.FindAdminRoleTypeById(adminUserInfo.Org.Id, adminUserInfo.AdminUser.Id, adminUserInfo.App.Id)
- //
- //if appRole.UserType == 3 {
- // headNursePermission, getPermissionErr := service.GetAdminUserSpecialPermission(adminUserInfo.Org.Id, adminUserInfo.App.Id, adminUserInfo.AdminUser.Id, models.SpecialPermissionTypeHeadNurse)
- // if getPermissionErr != nil {
- // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
- // return
- // } else if headNursePermission == nil {
- // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDialysisPermissionDeniedModify)
- // return
- // }
- //}
-
- advice.UpdatedTime = time.Now().Unix()
- advice.Status = 0
- advice.Modifier = adminUserInfo.AdminUser.Id
-
- err := service.DeleteDoctorAdvice(&advice)
- if err != nil {
- c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDeleteAdviceFail)
- return
- }
-
- c.ServeSuccessJSON(map[string]interface{}{
- "msg": "ok",
- })
- return
- }
-
- func (c *PatientApiController) ExecDoctorAdvice() {
-
- execution_time := c.GetString("execution_time")
-
- origin, _ := c.GetInt64("origin", 0)
- groupno, _ := c.GetInt64("groupno", -1)
-
- record_date, _ := c.GetInt64("record_date")
-
- if origin != 2 {
- adminUserInfo := c.GetMobileAdminUserInfo()
- execution_staff := adminUserInfo.AdminUser.Id
- var ids []string
- advice_ids := c.GetString("advice_id")
- if groupno == 0 {
- ids = strings.Split(advice_ids, ",")
- }
- if groupno < 0 {
- c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
- return
- }
-
- if len(execution_time) <= 0 {
- utils.ErrorLog("execution_time")
- c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
- return
- }
-
- timeLayout2 := "2006-01-02 15:04:05"
- loc, _ := time.LoadLocation("Local")
-
- theTime, errs := time.ParseInLocation(timeLayout2, execution_time, loc)
- if errs != nil {
- utils.ErrorLog(errs.Error())
- c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
- return
- }
- var advice models.DoctorAdvice
-
- if groupno > 0 {
- advices, _ := service.FindAllDoctorAdviceByGoroupNo(adminUserInfo.Org.Id, groupno)
-
- for _, item := range advices {
-
- //自备药
- selfPrescriptionOutOpenOne, _ := service.GetSelfPrescriptionOutOpen(adminUserInfo.Org.Id)
-
- if selfPrescriptionOutOpenOne.IsOpen == 1 {
- //查询库存是否
- selfBasedrug, _ := service.GetSelfBasedrugByIdTwo(advice.DrugId, advice.UserOrgId)
-
- if selfBasedrug.IsSelfDrug == 1 {
- selfDrugStockCount, _ := service.GetSelfDrugStockCountByPatientId(advice.DrugId, advice.PatientId, advice.UserOrgId)
- var prescribing_number_total_one int64
- //判断单位是否相等
- if selfBasedrug.MaxUnit == advice.PrescribingNumberUnit && selfBasedrug.MaxUnit != selfBasedrug.MinUnit {
- prescribingNumber_temp := strconv.FormatFloat(math.Abs(advice.PrescribingNumber), 'f', 0, 64)
- count, _ := strconv.ParseInt(prescribingNumber_temp, 10, 64)
- //转化为最小单位
- prescribing_number_total_one = count * selfBasedrug.MinNumber
- }
-
- if selfBasedrug.MinUnit == advice.PrescribingNumberUnit && selfBasedrug.MaxUnit != selfBasedrug.MinUnit {
- prescribingNumber_temp := strconv.FormatFloat(math.Abs(advice.PrescribingNumber), 'f', 0, 64)
- count, _ := strconv.ParseInt(prescribingNumber_temp, 10, 64)
- prescribing_number_total_one = count
-
- }
-
- if selfBasedrug.MinUnit == advice.PrescribingNumberUnit && selfBasedrug.MaxUnit == selfBasedrug.MinUnit {
- prescribingNumber_temp := strconv.FormatFloat(math.Abs(advice.PrescribingNumber), 'f', 0, 64)
- count, _ := strconv.ParseInt(prescribingNumber_temp, 10, 64)
- prescribing_number_total_one = count
- }
- if prescribing_number_total_one > selfDrugStockCount.FlushCount {
- c.ServeSuccessJSON(map[string]interface{}{
- "msg": "2",
- "advice": advice,
- "ids": ids,
- })
- return
-
- }
- }
-
- }
-
- //恒泰中医院
- if item.UserOrgId == 10490 || item.UserOrgId == 10602 || item.UserOrgId == 10697 {
- if item.DrugId == 0 || item.DrugNameId == 0 {
- //从字典里面查找
- drug, _ := service.GetBaseDrugByName(item.AdviceName, item.UserOrgId)
- service.UpdateDoctorAdviceByGoroupNo(item.ID, drug.ID)
-
- }
- }
- if item.ExecutionState == 2 {
- advice = item
- }
-
- //记录日志
- byterequest, _ := json.Marshal(item)
- adviceLog := models.XtDoctorAdviceLog{
- UserOrgId: item.UserOrgId,
- PatientId: item.PatientId,
- AdminUserId: adminUserInfo.AdminUser.Id,
- Module: 2,
- ErrLog: string(byterequest),
- Status: 1,
- Ctime: time.Now().Unix(),
- Mtime: 0,
- Source: "手机端执行医嘱",
- RecordDate: item.AdviceDate,
- }
-
- service.CreateDoctorAdviceLog(adviceLog)
- }
- advicesOne, _ := service.FindAllDoctorAdviceByGoroupNoOne(adminUserInfo.Org.Id, groupno)
- for _, item := range advicesOne {
-
- //自备药
- selfPrescriptionOutOpen, _ := service.GetSelfPrescriptionOutOpen(adminUserInfo.Org.Id)
-
- if selfPrescriptionOutOpen.IsOpen == 1 {
-
- db := service.XTWriteDB()
- tx := db.Begin()
- defer func() {
- if r := recover(); r != nil {
- tx.Rollback()
- } else {
- tx.Commit()
- }
- }()
-
- selfBasedrug, _ := service.GetSelfBasedrugById(item.DrugId, item.UserOrgId, tx)
-
- if selfBasedrug.IsSelfDrug == 1 {
-
- //查询是否有库存
- infoList, _ := service.GetSelfWarehouseInfoByWarehouseInfoTwo(item.DrugId, item.PatientId, item.UserOrgId, tx)
-
- var total_count int64
- var prescribing_number_total int64
- for _, items := range infoList {
- if items.MaxUnit == selfBasedrug.MaxUnit && selfBasedrug.MaxUnit != selfBasedrug.MinUnit {
- items.StockMaxNumber = items.StockMaxNumber * selfBasedrug.MinNumber
- }
-
- total_count += items.StockMaxNumber + items.StockMinNumber
- }
-
- if total_count == 0 {
- c.ServeSuccessJSON(map[string]interface{}{
- "msg": "2",
- "advice": item,
- "ids": ids,
- })
- return
- }
-
- //判断单位是否相等
- if selfBasedrug.MaxUnit == item.PrescribingNumberUnit && selfBasedrug.MaxUnit != selfBasedrug.MinUnit {
- prescribingNumber_temp := strconv.FormatFloat(math.Abs(item.PrescribingNumber), 'f', 0, 64)
- count, _ := strconv.ParseInt(prescribingNumber_temp, 10, 64)
- //转化为最小单位
- prescribing_number_total = count * selfBasedrug.MinNumber
- }
-
- if selfBasedrug.MinUnit == item.PrescribingNumberUnit && selfBasedrug.MaxUnit != selfBasedrug.MinUnit {
- prescribingNumber_temp := strconv.FormatFloat(math.Abs(item.PrescribingNumber), 'f', 0, 64)
- count, _ := strconv.ParseInt(prescribingNumber_temp, 10, 64)
- prescribing_number_total = count
-
- }
-
- if selfBasedrug.MinUnit == item.PrescribingNumberUnit && selfBasedrug.MaxUnit == selfBasedrug.MinUnit {
- prescribingNumber_temp := strconv.FormatFloat(math.Abs(item.PrescribingNumber), 'f', 0, 64)
- count, _ := strconv.ParseInt(prescribingNumber_temp, 10, 64)
- prescribing_number_total = count
-
- }
-
- if prescribing_number_total > total_count {
- c.ServeSuccessJSON(map[string]interface{}{
- "msg": "3",
- "advice": item,
- })
- return
- }
- var warehousingOutInfo []*models.XtSelfDrugWarehouseOutInfo
- //出库
- if prescribing_number_total <= total_count {
- timeStr := time.Now().Format("2006-01-02")
- timeArr := strings.Split(timeStr, "-")
- total, _ := service.FindAllSelfDrugWarehouseOut(adminUserInfo.Org.Id, tx)
-
- total = total + 1
- warehousing_out_order := strconv.FormatInt(adminUserInfo.Org.Id, 10) + timeArr[0] + timeArr[1] + timeArr[2] + "000"
- number, _ := strconv.ParseInt(warehousing_out_order, 10, 64)
- number = number + total
- warehousing_out_order = "YPCKD" + strconv.FormatInt(number, 10)
- operation_time := time.Now().Unix()
-
- creater := c.GetMobileAdminUserInfo().AdminUser.Id
- //创建一个出库单
- drugWarehouseOut := models.XtSelfDrugWarehouseOut{
- WarehouseOutOrderNumber: warehousing_out_order,
- OperationTime: operation_time,
- OrgId: adminUserInfo.Org.Id,
- Creater: creater,
- Ctime: time.Now().Unix(),
- Status: 1,
- WarehouseOutTime: item.AdviceDate,
- Type: 0,
- PatientId: advice.PatientId,
- IsCheck: 1,
- IsSys: 1,
- }
-
- //查询今日是否有出库数据
- lastWarehouseOut, _ := service.GetSelfDrugLastWarehouseOutTwety(adminUserInfo.Org.Id, item.AdviceDate, tx, 1)
-
- if lastWarehouseOut.ID == 0 {
- service.AddSelfSigleDrugWarehouseOut(&drugWarehouseOut, tx)
- }
-
- //查询今日是否有出库数据
- lastWarehouseOutOne, _ := service.GetSelfDrugLastWarehouseOutTwety(adminUserInfo.Org.Id, item.AdviceDate, tx, 1)
-
- var warehousing_out_order_str string
- if lastWarehouseOut.ID == 0 {
- warehousing_out_order_str = warehousing_out_order
- } else {
- warehousing_out_order_str = lastWarehouseOut.WarehouseOutOrderNumber
- }
-
- //出库
- warehouseOutInfo := &models.XtSelfDrugWarehouseOutInfo{
- WarehouseOutId: lastWarehouseOutOne.ID,
- WarehouseOutOrderNumber: warehousing_out_order_str,
- DrugId: item.DrugId,
- Count: prescribing_number_total,
- Price: 0,
- TotalPrice: 0,
- Status: 1,
- Ctime: item.AdviceDate,
- Mtime: item.AdviceDate,
- Remark: "",
- OrgId: item.UserOrgId,
- Type: 0,
- Manufacturer: selfBasedrug.Manufacturer,
- Dealer: selfBasedrug.Dealer,
- RetailPrice: 0,
- RetailTotalPrice: 0,
- CountUnit: selfBasedrug.MinUnit,
- ExpiryDate: 0,
- ProductDate: 0,
- Number: "",
- BatchNumber: "",
- IsSys: 0,
- WarehouseInfoId: 0,
- AdminUserId: 0,
- StockCount: "",
- IsCheck: 1,
- SysRecordTime: item.AdviceDate,
- PatientId: item.PatientId,
- AdviceId: item.ID,
- ClassType: "",
- }
- warehousingOutInfo = append(warehousingOutInfo, warehouseOutInfo)
-
- for _, it := range warehousingOutInfo {
-
- medical, _ := service.GetSelfBaseDrugMedical(it.DrugId, tx)
- drup, _ := service.FindSelfBaseDrugLibRecord(it.OrgId, it.DrugId, tx)
- //出库逻辑
- service.AutoSelfDrugDeliverInfoFourtyTwo(adminUserInfo.Org.Id, it.Count, &lastWarehouseOut, &drup, it, it.CountUnit, tx)
-
- //查询剩余库存
- stockInfo, _ := service.GetSelfDrugAllStockInfo(it.PatientId, it.OrgId, it.DrugId, tx)
- var sum_count int64
- for _, its := range stockInfo {
- if its.MaxUnit == medical.MaxUnit {
- its.StockMaxNumber = its.StockMaxNumber * medical.MinNumber
- }
- sum_count += its.StockMaxNumber + its.StockMinNumber
- }
- service.UpdateSelfDrugStockCount(it.DrugId, it.OrgId, it.PatientId, sum_count, tx)
- }
- }
-
- }
-
- }
-
- }
-
- } else {
- advices, _ := service.FindDoctorAdviceByIds(adminUserInfo.Org.Id, ids)
-
- for _, item := range advices {
- //自备药
- selfPrescriptionOutOpenOne, _ := service.GetSelfPrescriptionOutOpen(adminUserInfo.Org.Id)
-
- if selfPrescriptionOutOpenOne.IsOpen == 1 {
- //查询库存是否
- selfBasedrug, _ := service.GetSelfBasedrugByIdTwo(advice.DrugId, advice.UserOrgId)
-
- if selfBasedrug.IsSelfDrug == 1 {
- selfDrugStockCount, _ := service.GetSelfDrugStockCountByPatientId(advice.DrugId, advice.PatientId, advice.UserOrgId)
- var prescribing_number_total_one int64
- //判断单位是否相等
- if selfBasedrug.MaxUnit == advice.PrescribingNumberUnit && selfBasedrug.MaxUnit != selfBasedrug.MinUnit {
- prescribingNumber_temp := strconv.FormatFloat(math.Abs(advice.PrescribingNumber), 'f', 0, 64)
- count, _ := strconv.ParseInt(prescribingNumber_temp, 10, 64)
- //转化为最小单位
- prescribing_number_total_one = count * selfBasedrug.MinNumber
- }
-
- if selfBasedrug.MinUnit == advice.PrescribingNumberUnit && selfBasedrug.MaxUnit != selfBasedrug.MinUnit {
- prescribingNumber_temp := strconv.FormatFloat(math.Abs(advice.PrescribingNumber), 'f', 0, 64)
- count, _ := strconv.ParseInt(prescribingNumber_temp, 10, 64)
- prescribing_number_total_one = count
-
- }
-
- if selfBasedrug.MinUnit == advice.PrescribingNumberUnit && selfBasedrug.MaxUnit == selfBasedrug.MinUnit {
- prescribingNumber_temp := strconv.FormatFloat(math.Abs(advice.PrescribingNumber), 'f', 0, 64)
- count, _ := strconv.ParseInt(prescribingNumber_temp, 10, 64)
- prescribing_number_total_one = count
- }
- if prescribing_number_total_one > selfDrugStockCount.FlushCount {
- c.ServeSuccessJSON(map[string]interface{}{
- "msg": "2",
- "advice": advice,
- "ids": ids,
- })
- return
- }
- }
-
- }
- //恒泰中医院
- if item.UserOrgId == 10490 || item.UserOrgId == 10602 {
- if item.DrugId == 0 || item.DrugNameId == 0 {
- //从字典里面查找
- drug, _ := service.GetBaseDrugByName(item.AdviceName, item.UserOrgId)
- service.UpdateDoctorAdviceByGoroupNo(item.ID, drug.ID)
-
- }
- }
- if item.ExecutionState == 2 {
- advice = item
- }
- }
-
- advicesOne, _ := service.FindDoctorAdviceByIdsOne(adminUserInfo.Org.Id, ids)
- for _, item := range advicesOne {
-
- //自备药
- selfPrescriptionOutOpen, _ := service.GetSelfPrescriptionOutOpen(adminUserInfo.Org.Id)
-
- if selfPrescriptionOutOpen.IsOpen == 1 {
-
- db := service.XTWriteDB()
- tx := db.Begin()
- defer func() {
- if r := recover(); r != nil {
- tx.Rollback()
- } else {
- tx.Commit()
- }
- }()
-
- selfBasedrug, _ := service.GetSelfBasedrugById(item.DrugId, item.UserOrgId, tx)
-
- if selfBasedrug.IsSelfDrug == 1 {
-
- //查询是否有库存
- infoList, _ := service.GetSelfWarehouseInfoByWarehouseInfoTwo(item.DrugId, item.PatientId, item.UserOrgId, tx)
-
- var total_count int64
- var prescribing_number_total int64
- for _, items := range infoList {
- if items.MaxUnit == selfBasedrug.MaxUnit && selfBasedrug.MaxUnit != selfBasedrug.MinUnit {
- items.StockMaxNumber = items.StockMaxNumber * selfBasedrug.MinNumber
- }
-
- total_count += items.StockMaxNumber + items.StockMinNumber
- }
-
- if total_count == 0 {
- c.ServeSuccessJSON(map[string]interface{}{
- "msg": "2",
- "advice": item,
- "ids": ids,
- })
- return
- }
-
- //判断单位是否相等
- if selfBasedrug.MaxUnit == item.PrescribingNumberUnit && selfBasedrug.MaxUnit != selfBasedrug.MinUnit {
- prescribingNumber_temp := strconv.FormatFloat(math.Abs(item.PrescribingNumber), 'f', 0, 64)
- count, _ := strconv.ParseInt(prescribingNumber_temp, 10, 64)
- //转化为最小单位
- prescribing_number_total = count * selfBasedrug.MinNumber
- }
-
- if selfBasedrug.MinUnit == item.PrescribingNumberUnit && selfBasedrug.MaxUnit != selfBasedrug.MinUnit {
- prescribingNumber_temp := strconv.FormatFloat(math.Abs(item.PrescribingNumber), 'f', 0, 64)
- count, _ := strconv.ParseInt(prescribingNumber_temp, 10, 64)
- prescribing_number_total = count
-
- }
-
- if selfBasedrug.MinUnit == item.PrescribingNumberUnit && selfBasedrug.MaxUnit == selfBasedrug.MinUnit {
- prescribingNumber_temp := strconv.FormatFloat(math.Abs(item.PrescribingNumber), 'f', 0, 64)
- count, _ := strconv.ParseInt(prescribingNumber_temp, 10, 64)
- prescribing_number_total = count
-
- }
-
- if prescribing_number_total > total_count {
- c.ServeSuccessJSON(map[string]interface{}{
- "msg": "3",
- "advice": item,
- })
- return
- }
- var warehousingOutInfo []*models.XtSelfDrugWarehouseOutInfo
- //出库
- if prescribing_number_total <= total_count {
- timeStr := time.Now().Format("2006-01-02")
- timeArr := strings.Split(timeStr, "-")
- total, _ := service.FindAllSelfDrugWarehouseOut(adminUserInfo.Org.Id, tx)
-
- total = total + 1
- warehousing_out_order := strconv.FormatInt(adminUserInfo.Org.Id, 10) + timeArr[0] + timeArr[1] + timeArr[2] + "000"
- number, _ := strconv.ParseInt(warehousing_out_order, 10, 64)
- number = number + total
- warehousing_out_order = "YPCKD" + strconv.FormatInt(number, 10)
- operation_time := time.Now().Unix()
-
- creater := c.GetMobileAdminUserInfo().AdminUser.Id
-
- //创建一个出库单
- drugWarehouseOut := models.XtSelfDrugWarehouseOut{
- WarehouseOutOrderNumber: warehousing_out_order,
- OperationTime: operation_time,
- OrgId: adminUserInfo.Org.Id,
- Creater: creater,
- Ctime: time.Now().Unix(),
- Status: 1,
- WarehouseOutTime: item.AdviceDate,
- Type: 0,
- PatientId: advice.PatientId,
- IsCheck: 1,
- IsSys: 1,
- }
-
- //查询今日是否有出库数据
- lastWarehouseOut, _ := service.GetSelfDrugLastWarehouseOutTwety(adminUserInfo.Org.Id, item.AdviceDate, tx, 1)
-
- if lastWarehouseOut.ID == 0 {
- service.AddSelfSigleDrugWarehouseOut(&drugWarehouseOut, tx)
- }
-
- //查询今日是否有出库数据
- lastWarehouseOutOne, _ := service.GetSelfDrugLastWarehouseOutTwety(adminUserInfo.Org.Id, item.AdviceDate, tx, 1)
-
- var warehousing_out_order_str string
- if lastWarehouseOut.ID == 0 {
- warehousing_out_order_str = warehousing_out_order
- } else {
- warehousing_out_order_str = lastWarehouseOut.WarehouseOutOrderNumber
- }
-
- //出库
- warehouseOutInfo := &models.XtSelfDrugWarehouseOutInfo{
- WarehouseOutId: lastWarehouseOutOne.ID,
- WarehouseOutOrderNumber: warehousing_out_order_str,
- DrugId: item.DrugId,
- Count: prescribing_number_total,
- Price: 0,
- TotalPrice: 0,
- Status: 1,
- Ctime: item.AdviceDate,
- Mtime: item.AdviceDate,
- Remark: "",
- OrgId: item.UserOrgId,
- Type: 0,
- Manufacturer: selfBasedrug.Manufacturer,
- Dealer: selfBasedrug.Dealer,
- RetailPrice: 0,
- RetailTotalPrice: 0,
- CountUnit: selfBasedrug.MinUnit,
- ExpiryDate: 0,
- ProductDate: 0,
- Number: "",
- BatchNumber: "",
- IsSys: 0,
- WarehouseInfoId: 0,
- AdminUserId: 0,
- StockCount: "",
- IsCheck: 1,
- SysRecordTime: item.AdviceDate,
- PatientId: item.PatientId,
- AdviceId: item.ID,
- ClassType: "",
- }
- warehousingOutInfo = append(warehousingOutInfo, warehouseOutInfo)
-
- for _, it := range warehousingOutInfo {
-
- medical, _ := service.GetSelfBaseDrugMedical(it.DrugId, tx)
- drup, _ := service.FindSelfBaseDrugLibRecord(it.OrgId, it.DrugId, tx)
- //出库逻辑
- service.AutoSelfDrugDeliverInfoFourtyTwo(adminUserInfo.Org.Id, it.Count, &lastWarehouseOut, &drup, it, it.CountUnit, tx)
-
- //查询剩余库存
- stockInfo, _ := service.GetSelfDrugAllStockInfo(it.PatientId, it.OrgId, it.DrugId, tx)
- var sum_count int64
- for _, its := range stockInfo {
- if its.MaxUnit == medical.MaxUnit {
- its.StockMaxNumber = its.StockMaxNumber * medical.MinNumber
- }
- sum_count += its.StockMaxNumber + its.StockMinNumber
- }
- service.UpdateSelfDrugStockCount(it.DrugId, it.OrgId, it.PatientId, sum_count, tx)
- }
- }
-
- }
-
- }
-
- }
- }
-
- if advice.ExecutionState == 1 {
- c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeAdviceExced)
- return
- }
-
- if advice.Checker >= 0 && advice.Checker == adminUserInfo.AdminUser.Id {
- c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeExceAndCheckNotOneUser)
- return
- }
-
- //针对普宁
- if adminUserInfo.Org.Id != 10599 {
- if advice.StartTime > theTime.Unix() {
- c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeAdviceExceBeforeStart)
- return
- }
- }
-
- advices := models.DoctorAdvice{
- ExecutionStaff: execution_staff,
- ExecutionTime: theTime.Unix(),
- UpdatedTime: time.Now().Unix(),
- }
- var err error
-
- if groupno > 0 {
-
- // 查询信息规挡的设置天数
-
- infor, _ := service.GetDialysisInformationSetting(adminUserInfo.Org.Id)
- if infor.ID > 0 && infor.WeekDay > 0 {
-
- var cha_time int64
-
- timeNowStr := time.Now().Format("2006-01-02")
- timeNewDate, _ := utils.ParseTimeStringToTime("2006-01-02", timeNowStr)
-
- //今日的日期减去设置的日期
- cha_time = timeNewDate.Unix() - infor.WeekDay*86400
-
- if cha_time >= record_date {
- //查询审核是否允许
- infor, _ := service.GetDialysisInformationByRecordDate(advices.PatientId, advices.AdviceDate, adminUserInfo.Org.Id, 4)
- //申请状态不允许的情况 拒绝修改
- if infor.ApplicationStatus != 1 {
- c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeInformationExist)
- return
- }
-
- }
- }
- err = service.ExceDoctorAdviceByGroupNo(&advices, groupno, adminUserInfo.Org.Id)
-
- key := strconv.FormatInt(adminUserInfo.Org.Id, 10) + ":" + strconv.FormatInt(advice.PatientId, 10) + ":" + strconv.FormatInt(advice.AdviceDate, 10) + ":doctor_advices"
- redis := service.RedisClient()
- //清空key 值
- redis.Set(key, "", time.Second)
- keyTwo := strconv.FormatInt(adminUserInfo.Org.Id, 10) + ":" + strconv.FormatInt(advice.AdviceDate, 10) + ":advice_list_all"
-
- redis.Set(keyTwo, "", time.Second)
- keyThree := strconv.FormatInt(adminUserInfo.Org.Id, 10) + ":" + strconv.FormatInt(advice.PatientId, 10) + ":" + strconv.FormatInt(advice.AdviceDate, 10) + ":his_doctor_advice"
- redis.Set(keyThree, "", time.Second)
- toTime, _ := utils.ParseTimeStringToTime("2006-01-02 15:04:05", execution_time)
- theTime := toTime.Format("2006-01-02")
-
- fmt.Println("theTIME", theTime)
- keyFour := "scheduals_" + theTime + "_" + strconv.FormatInt(adminUserInfo.Org.Id, 10)
-
- redis.Set(keyFour, "", time.Second)
- keyFive := strconv.FormatInt(adminUserInfo.Org.Id, 10) + ":" + strconv.FormatInt(advice.AdviceDate, 10) + ":his_advices_list_all"
- redis.Set(keyFive, "", time.Second)
-
- defer redis.Close()
- } else {
- // 查询信息规挡的设置天数
-
- infor, _ := service.GetDialysisInformationSetting(adminUserInfo.Org.Id)
- if infor.ID > 0 {
-
- var cha_time int64
-
- timeNowStr := time.Now().Format("2006-01-02")
- timeNewDate, _ := utils.ParseTimeStringToTime("2006-01-02", timeNowStr)
-
- //今日的日期减去设置的日期
- cha_time = timeNewDate.Unix() - infor.WeekDay*86400
-
- if cha_time >= record_date {
- //查询审核是否允许
- infor, _ := service.GetDialysisInformationByRecordDate(advices.PatientId, advices.AdviceDate, adminUserInfo.Org.Id, 4)
- //申请状态不允许的情况 拒绝修改
- if infor.ApplicationStatus != 1 {
- c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeInformationExist)
- return
- }
-
- }
- }
- err = service.BatchExceOldDoctorAdvice(&advices, ids)
-
- //记录日志
- byterequest, _ := json.Marshal(advice)
- adviceLog := models.XtDoctorAdviceLog{
- UserOrgId: advice.UserOrgId,
- PatientId: advice.PatientId,
- AdminUserId: adminUserInfo.AdminUser.Id,
- Module: 2,
- ErrLog: string(byterequest),
- Status: 1,
- Ctime: time.Now().Unix(),
- Mtime: 0,
- Source: "手机端执行医嘱",
- RecordDate: advices.RecordDate,
- }
-
- service.CreateDoctorAdviceLog(adviceLog)
- key := strconv.FormatInt(adminUserInfo.Org.Id, 10) + ":" + strconv.FormatInt(advice.PatientId, 10) + ":" + strconv.FormatInt(advice.AdviceDate, 10) + ":doctor_advices"
- redis := service.RedisClient()
- keyTwo := strconv.FormatInt(adminUserInfo.Org.Id, 10) + ":" + strconv.FormatInt(advice.AdviceDate, 10) + ":advice_list_all"
-
- redis.Set(keyTwo, "", time.Second)
- keyThree := strconv.FormatInt(adminUserInfo.Org.Id, 10) + ":" + strconv.FormatInt(advice.PatientId, 10) + ":" + strconv.FormatInt(advice.AdviceDate, 10) + ":his_doctor_advice"
- redis.Set(keyThree, "", time.Second)
- toTime, _ := utils.ParseTimeStringToTime("2006-01-02 15:04:05", execution_time)
- theTime := toTime.Format("2006-01-02")
- fmt.Println("theTIME", theTime)
- keyFour := "scheduals_" + theTime + "_" + strconv.FormatInt(adminUserInfo.Org.Id, 10)
- redis.Set(keyFour, "", time.Second)
- keySix := strconv.FormatInt(adminUserInfo.Org.Id, 10) + ":" + strconv.FormatInt(advice.AdviceDate, 10) + ":his_advices_list_all"
- redis.Set(keySix, "", time.Second)
- defer redis.Close()
- //清空key 值
- redis.Set(key, "", time.Second)
-
- }
-
- if err != nil {
- c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeUpdateDoctorAdviceFail)
- return
- }
-
- advice.ExecutionStaff = execution_staff
- advice.ExecutionTime = theTime.Unix()
- advice.ExecutionState = 1
- advice.Modifier = adminUserInfo.AdminUser.Id
-
- //处理出库相关逻辑
-
- //1.判断是否启用药品管理和自备药出库功能
-
- //药品管理信息
- _, drugStockConfig := service.FindDrugStockAutomaticReduceRecordByOrgId(adminUserInfo.Org.Id)
-
- //自备药信息
- //privateDrugConfig, _ := service.GetDrugSetByUserOrgId(adminUserInfo.Org.Id)
-
- storeHouseConfig, _ := service.GetAllStoreHouseConfig(adminUserInfo.Org.Id)
-
- if drugStockConfig.IsOpen == 1 {
- if groupno > 0 {
- advices, _ := service.FindAllDoctorAdviceByGoroupNoTwety(adminUserInfo.Org.Id, groupno)
-
- if len(advices) > 0 {
- var total int64
- var prescribing_number_total int64
-
- //出库
- for _, item := range advices {
- if item.Way == 1 {
-
- houseConfig, _ := service.GetAllStoreHouseConfig(item.UserOrgId)
- //查询该药品的剩余库存
- list, _ := service.GetDrugTotalCount(item.DrugId, item.UserOrgId, houseConfig.DrugStorehouseOut)
-
- //查询改药品信息
- medical, _ := service.GetBaseDrugMedical(item.DrugId)
- //判断单位是否相等
- if medical.MaxUnit == item.PrescribingNumberUnit {
- prescribingNumber_temp := strconv.FormatFloat(math.Abs(item.PrescribingNumber), 'f', 0, 64)
- count, _ := strconv.ParseInt(prescribingNumber_temp, 10, 64)
- //转化为最小单位
- total = list.Count * medical.MinNumber
- prescribing_number_total = count * medical.MinNumber
- }
- if medical.MinUnit == item.PrescribingNumberUnit {
- prescribingNumber_temp := strconv.FormatFloat(math.Abs(item.PrescribingNumber), 'f', 0, 64)
- count, _ := strconv.ParseInt(prescribingNumber_temp, 10, 64)
- total = list.Count*medical.MinNumber + list.StockMinNumber
- prescribing_number_total = count
- }
-
- if medical.IsUse == 1 {
-
- c.ServeSuccessJSON(map[string]interface{}{
- "msg": "1",
- "advice": advice,
- "ids": ids,
- })
- return
- }
-
- if medical.IsUse != 1 {
- if (list.Count*medical.MinNumber + list.StockMinNumber) == 0 {
- if advice.UserOrgId != 10278 {
- service.UpdateDoctorAdviceByExcecute(advice.ID, advice.UserOrgId)
- advice.ExecutionTime = 0
- advice.ExecutionState = 2
- advice.ExecutionStaff = 0
- }
-
- c.ServeSuccessJSON(map[string]interface{}{
- "msg": "3",
- "advice": advice,
- "ids": ids,
- })
- return
-
- }
- if prescribing_number_total > total {
- if advice.UserOrgId != 10278 {
- service.UpdateDoctorAdviceByExcecute(advice.ID, advice.UserOrgId)
- advice.ExecutionTime = 0
- advice.ExecutionState = 2
- advice.ExecutionStaff = 0
- }
- c.ServeSuccessJSON(map[string]interface{}{
- "msg": "2",
- "advice": advice,
- "ids": ids,
- })
- return
- }
- }
- //查询是否出库按钮开启
- adviceSetting, _ := service.FindAdviceSettingById(item.UserOrgId)
- if adviceSetting.IsAdviceOpen == 1 {
- //查询是否出库按钮开启
- prescriptionConfig, _ := service.FindPrescriptionConfigById(item.UserOrgId)
- //患者发药
- pharmacyConfig, _ := service.FindPharmacyConfig(item.UserOrgId)
- if prescriptionConfig.IsOpen == 1 {
- if medical.IsUse == 2 {
- if pharmacyConfig.IsOpen == 1 && medical.IsPharmacy == 0 {
- //查询今日是否出库
- drugOutInfo, _ := service.GetAdviceIsOut(item.ID, item.UserOrgId, item.PatientId, item.AdviceDate, item.DrugId)
- if drugOutInfo.ID == 0 {
- service.DrugsDelivery(item.UserOrgId, item.ExecutionStaff, &item)
- }
-
- }
- if pharmacyConfig.IsOpen != 1 {
- drugOutInfo, _ := service.GetAdviceIsOut(item.ID, item.UserOrgId, item.PatientId, item.AdviceDate, item.DrugId)
- if drugOutInfo.ID == 0 {
- service.DrugsDelivery(item.UserOrgId, item.ExecutionStaff, &item)
- }
- }
-
- //更新字典里面的库存
- stockInfo, _ := service.GetDrugAllStockInfo(storeHouseConfig.DrugStorehouseOut, item.UserOrgId, item.DrugId)
- var sum_count int64
- for _, its := range stockInfo {
- if its.MaxUnit == medical.MaxUnit {
- its.StockMaxNumber = its.StockMaxNumber * medical.MinNumber
- }
- sum_count += its.StockMaxNumber + its.StockMinNumber
- }
- service.UpdateBaseDrugSumTwo(item.DrugId, sum_count, item.UserOrgId)
- //剩余库存
- service.UpdateDrugStockCount(item.DrugId, item.UserOrgId, storeHouseConfig.DrugStorehouseOut, sum_count)
- }
- }
- } else {
- pharmacyConfig, _ := service.FindPharmacyConfig(item.UserOrgId)
- if medical.IsUse == 2 {
- if pharmacyConfig.IsOpen == 1 && medical.IsPharmacy == 0 {
- drugOutInfo, _ := service.GetAdviceIsOut(item.ID, item.UserOrgId, item.PatientId, item.AdviceDate, item.DrugId)
- if drugOutInfo.ID == 0 {
- service.DrugsDelivery(item.UserOrgId, item.ExecutionStaff, &item)
- }
- }
- if pharmacyConfig.IsOpen != 1 {
- drugError := models.XtDrugError{
- ID: 0,
- UserOrgId: item.UserOrgId,
- DrugId: item.DrugId,
- RecordDate: item.AdviceDate,
- PatientId: item.PatientId,
- Remark: "恒泰中医院出库开始",
- Status: 1,
- Ctime: time.Now().Unix(),
- Mtime: 0,
- Prescribingnumber: item.PrescribingNumber,
- PrescribingNumberUnit: item.PrescribingNumberUnit,
- SumCount: 0,
- }
- service.CreateDrugError(drugError)
- drugOutInfo, _ := service.GetAdviceIsOut(item.ID, item.UserOrgId, item.PatientId, item.AdviceDate, item.DrugId)
- if drugOutInfo.ID == 0 {
-
- service.DrugsDelivery(item.UserOrgId, item.ExecutionStaff, &item)
- }
- }
-
- stockInfo, _ := service.GetDrugAllStockInfo(storeHouseConfig.DrugStorehouseOut, item.UserOrgId, item.DrugId)
- var sum_count int64
- for _, its := range stockInfo {
- if its.MaxUnit == medical.MaxUnit {
- its.StockMaxNumber = its.StockMaxNumber * medical.MinNumber
- }
- sum_count += its.StockMaxNumber + its.StockMinNumber
- }
- service.UpdateBaseDrugSumTwo(item.DrugId, sum_count, item.UserOrgId)
- //剩余库存
- service.UpdateDrugStockCount(item.DrugId, item.UserOrgId, storeHouseConfig.DrugStorehouseOut, sum_count)
- }
- }
- }
-
- }
-
- }
-
- c.ServeSuccessJSON(map[string]interface{}{
- "msg": "1",
- "advice": advice,
- "ids": ids,
- })
- return
-
- } else {
-
- advices, _ := service.FindDoctorAdviceByIdsTwety(adminUserInfo.Org.Id, ids)
-
- if len(advices) > 0 {
- var total int64
- var prescribing_number_total int64
-
- for _, item := range advices {
- if item.Way == 1 {
- //查询改药品信息
- medical, _ := service.GetBaseDrugMedical(item.DrugId)
- pharmacyConfig, _ := service.FindPharmacyConfig(item.UserOrgId)
-
- houseConfig, _ := service.GetAllStoreHouseConfig(item.UserOrgId)
- //查询该药品的剩余库存
- list, _ := service.GetDrugTotalCount(item.DrugId, item.UserOrgId, houseConfig.DrugStorehouseOut)
-
- //判断单位是否相等
- if medical.MaxUnit == item.PrescribingNumberUnit {
- prescribingNumber_temp := strconv.FormatFloat(math.Abs(item.PrescribingNumber), 'f', 0, 64)
- count, _ := strconv.ParseInt(prescribingNumber_temp, 10, 64)
- //转化为最小单位
- total = list.Count*medical.MinNumber + list.StockMinNumber
-
- prescribing_number_total = count * medical.MinNumber
- }
-
- if medical.MinUnit == item.PrescribingNumberUnit {
- prescribingNumber_temp := strconv.FormatFloat(math.Abs(item.PrescribingNumber), 'f', 0, 64)
- count, _ := strconv.ParseInt(prescribingNumber_temp, 10, 64)
- total = list.Count*medical.MinNumber + list.StockMinNumber
- prescribing_number_total = count
- }
-
- if medical.IsUse == 1 {
-
- c.ServeSuccessJSON(map[string]interface{}{
- "msg": "1",
- "advice": advice,
- "ids": ids,
- })
- return
- }
- if medical.IsUse != 1 {
- if (list.Count*medical.MinNumber + list.StockMinNumber) == 0 {
- if advice.UserOrgId != 10278 {
- service.UpdateDoctorAdviceByExcecute(advice.ID, advice.UserOrgId)
- advice.ExecutionTime = 0
- advice.ExecutionState = 2
- advice.ExecutionStaff = 0
- }
- c.ServeSuccessJSON(map[string]interface{}{
- "msg": "3",
- "advice": advice,
- "ids": ids,
- })
- return
- }
- if prescribing_number_total > total {
- if advice.UserOrgId != 10278 {
- service.UpdateDoctorAdviceByExcecute(advice.ID, advice.UserOrgId)
- advice.ExecutionTime = 0
- advice.ExecutionState = 2
- advice.ExecutionStaff = 0
- }
- c.ServeSuccessJSON(map[string]interface{}{
- "msg": "2",
- "advice": advice,
- "ids": ids,
- })
- return
- }
- }
- if medical.IsUse == 2 {
- if pharmacyConfig.IsOpen == 1 && medical.IsPharmacy == 0 {
- //查询今日是否出库
- drugOutInfo, _ := service.GetAdviceIsOut(item.ID, item.UserOrgId, item.PatientId, item.AdviceDate, item.DrugId)
- if drugOutInfo.ID == 0 {
- service.DrugsDelivery(item.UserOrgId, item.ExecutionStaff, &item)
- }
- }
- if pharmacyConfig.IsOpen != 1 {
- //查询今日是否出库
- drugOutInfo, _ := service.GetAdviceIsOut(item.ID, item.UserOrgId, item.PatientId, item.AdviceDate, item.DrugId)
- if drugOutInfo.ID == 0 {
- service.DrugsDelivery(item.UserOrgId, item.ExecutionStaff, &item)
- }
- }
-
- //更新字典里面的库存
- stockInfo, _ := service.GetDrugAllStockInfo(storeHouseConfig.DrugStorehouseOut, item.UserOrgId, item.DrugId)
- var sum_count int64
- for _, its := range stockInfo {
- baseDrug, _ := service.GetBaseDrugMedical(its.DrugId)
- if its.MaxUnit == baseDrug.MaxUnit {
- its.StockMaxNumber = its.StockMaxNumber * baseDrug.MinNumber
- }
- sum_count += its.StockMaxNumber + its.StockMinNumber
- }
- service.UpdateBaseDrugSumTwo(item.DrugId, sum_count, item.UserOrgId)
- //剩余库存
- service.UpdateDrugStockCount(item.DrugId, item.UserOrgId, storeHouseConfig.DrugStorehouseOut, sum_count)
- }
- if medical.IsUse == 1 {
- c.ServeSuccessJSON(map[string]interface{}{
- "msg": "1",
- "advice": advice,
- "ids": ids,
- })
- return
- }
-
- }
-
- }
- }
- c.ServeSuccessJSON(map[string]interface{}{
- "msg": "1",
- "advice": advice,
- "ids": ids,
- })
- return
- }
- }
-
- //if privateDrugConfig != nil && privateDrugConfig.DrugStart == 1 {
- // if groupno > 0 {
- // advices, _ := service.FindAllDoctorAdviceByGoroupNo(adminUserInfo.Org.Id, groupno)
- // for _, item := range advices {
- //
- // if item.ExecutionState == 1 && item.Way == 2 {
- // prescribingNumber := strconv.FormatFloat(math.Abs(item.PrescribingNumber), 'f', 0, 64)
- // count, _ := strconv.ParseInt(prescribingNumber, 10, 64)
- //
- // timeStr := time.Now().Format("2006-01-02")
- // timeArr := strings.Split(timeStr, "-")
- // total, _ := service.FindAllDrugWarehouseOut(adminUserInfo.Org.Id)
- //
- // total = total + 1
- // warehousing_out_order := strconv.FormatInt(adminUserInfo.Org.Id, 10) + timeArr[0] + timeArr[1] + timeArr[2] + "000"
- // number, _ := strconv.ParseInt(warehousing_out_order, 10, 64)
- // number = number + total
- // warehousing_out_order = "CKD" + strconv.FormatInt(number, 10)
- // //插入自备药出库单
- // outStock := models.XtSelfOutStock{
- // DrugName: item.AdviceName,
- // DrugNameId: item.DrugNameId,
- // DrugSpec: item.AdviceDesc,
- // OutstoreNumber: count,
- // AdminUserId: adminUserInfo.AdminUser.Id,
- // StorckTime: item.AdviceDate,
- // UserOrgId: adminUserInfo.Org.Id,
- // CreatedTime: time.Now().Unix(),
- // Status: 1,
- // PatientId: item.PatientId,
- // ExitMode: 2,
- // MedicId: item.DrugId,
- // StockOutNumber: warehousing_out_order,
- // }
- // //查询 该患者是否已出库
- // out, errcode := service.GetSelfOutStock(adminUserInfo.Org.Id, item.AdviceDate, item.PatientId, item.AdviceName, item.AdviceDesc)
- //
- // if errcode == gorm.ErrRecordNotFound {
- // service.CreateOutStock(&outStock)
- // } else if errcode == nil {
- // err := service.UpdatedSelfOutSatock(out.ID, &outStock)
- // fmt.Println("err", err)
- // }
- // }
- // }
- // } else {
- //
- // advices, _ := service.FindDoctorAdviceByIds(adminUserInfo.Org.Id, ids)
- // for _, item := range advices {
- //
- // if item.ExecutionState == 1 && item.Way == 2 {
- //
- // prescribingNumber := strconv.FormatFloat(math.Abs(item.PrescribingNumber), 'f', 0, 64)
- // count, _ := strconv.ParseInt(prescribingNumber, 10, 64)
- //
- // timeStr := time.Now().Format("2006-01-02")
- // timeArr := strings.Split(timeStr, "-")
- // total, _ := service.FindAllDrugWarehouseOut(adminUserInfo.Org.Id)
- //
- // total = total + 1
- // warehousing_out_order := strconv.FormatInt(adminUserInfo.Org.Id, 10) + timeArr[0] + timeArr[1] + timeArr[2] + "000"
- // number, _ := strconv.ParseInt(warehousing_out_order, 10, 64)
- // number = number + total
- // warehousing_out_order = "CKD" + strconv.FormatInt(number, 10)
- //
- // //插入自备药出库单
- // outStock := models.XtSelfOutStock{
- // DrugName: item.AdviceName,
- // DrugNameId: item.DrugNameId,
- // DrugSpec: item.AdviceDesc,
- // OutstoreNumber: count,
- // AdminUserId: adminUserInfo.AdminUser.Id,
- // StorckTime: item.AdviceDate,
- // UserOrgId: adminUserInfo.Org.Id,
- // CreatedTime: time.Now().Unix(),
- // Status: 1,
- // PatientId: item.PatientId,
- // ExitMode: 2,
- // MedicId: item.DrugId,
- // StockOutNumber: warehousing_out_order,
- // }
- //
- // //查询 该患者是否已出库
- // out, errcode := service.GetSelfOutStock(adminUserInfo.Org.Id, item.AdviceDate, item.PatientId, item.AdviceName, item.AdviceDesc)
- //
- // if errcode == gorm.ErrRecordNotFound {
- // service.CreateOutStock(&outStock)
- // } else if errcode == nil {
- // err := service.UpdatedSelfOutSatock(out.ID, &outStock)
- // fmt.Println("err", err)
- // }
- // }
- // }
- // c.ServeSuccessJSON(map[string]interface{}{
- // "msg": "1",
- // "advice": advice,
- // "ids": ids,
- // })
- // return
- // }
- //}
-
- c.ServeSuccessJSON(map[string]interface{}{
- "msg": "1",
- "advice": advice,
- "ids": ids,
- })
- return
- } else if origin == 2 {
-
- // 开始主事务
- db := service.XTWriteDB()
- tx := db.Begin()
-
- // 在函数结束时处理事务回滚
- defer func() {
- if r := recover(); r != nil {
- tx.Rollback()
- }
- }()
- adminInfo := c.GetMobileAdminUserInfo()
- creater := c.GetMobileAdminUserInfo().AdminUser.Id
- var ids []string
- advice_ids := c.GetString("advice_id")
- ids = strings.Split(advice_ids, ",")
- if len(execution_time) <= 0 {
- utils.ErrorLog("execution_time")
- tx.Rollback()
- c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
- return
- }
- timeLayout2 := "2006-01-02 15:04:05"
- loc, _ := time.LoadLocation("Local")
- theTime, errs := time.ParseInLocation(timeLayout2, execution_time, loc)
-
- if errs != nil {
- utils.ErrorLog(errs.Error())
- tx.Rollback()
- c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
- return
- }
- advices, _ := service.FindHisDoctorAdviceByIds(adminInfo.Org.Id, ids)
- var err error
- for _, item := range advices {
- if item.ExecutionState == 1 {
- tx.Rollback()
- c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeAdviceExced)
- return
- }
-
- if item.Checker >= 0 && item.Checker == adminInfo.AdminUser.Id {
- tx.Rollback()
- c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeExceAndCheckNotOneUser)
- return
- }
-
- if item.StartTime > theTime.Unix() {
- tx.Rollback()
- c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeAdviceExceBeforeStart)
- return
- }
-
- item.ExecutionState = 1
- item.ExecutionStaff = adminInfo.AdminUser.Id
- item.ExecutionTime = theTime.Unix()
- item.IsMobile = 1
-
- // 查询信息规挡的设置天数
-
- infor, _ := service.GetDialysisInformationSetting(item.UserOrgId)
- if infor.ID > 0 {
-
- var cha_time int64
-
- timeNowStr := time.Now().Format("2006-01-02")
- timeNewDate, _ := utils.ParseTimeStringToTime("2006-01-02", timeNowStr)
-
- //今日的日期减去设置的日期
- cha_time = timeNewDate.Unix() - infor.WeekDay*86400
-
- if cha_time >= item.AdviceDate {
- //查询审核是否允许
- infor, _ := service.GetDialysisInformationByRecordDate(item.PatientId, item.AdviceDate, item.UserOrgId, 4)
- //申请状态不允许的情况 拒绝修改
- if infor.ApplicationStatus != 1 {
- tx.Rollback()
- c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeInformationExist)
- return
- }
-
- }
- }
-
- service.SaveHisDoctorAdviceOne(item, tx)
-
- //记录日志
- byterequest, _ := json.Marshal(item)
- adviceLog := models.XtDoctorAdviceLog{
- UserOrgId: item.UserOrgId,
- PatientId: item.PatientId,
- AdminUserId: item.ExecutionStaff,
- Module: 2,
- ErrLog: string(byterequest),
- Status: 1,
- Ctime: time.Now().Unix(),
- Mtime: 0,
- Source: "手机端执行his医嘱",
- RecordDate: item.AdviceDate,
- }
- service.CreateDoctorAdviceLog(adviceLog)
-
- if err == nil {
- drugError := models.XtDrugError{
- UserOrgId: adminInfo.Org.Id,
- DrugId: item.DrugId,
- RecordDate: item.AdviceDate,
- PatientId: item.PatientId,
- Remark: "执行成功",
- Status: 1,
- Ctime: time.Now().Unix(),
- Mtime: 0,
- SumCount: 0,
- Prescribingnumber: item.PrescribingNumber,
- PrescribingNumberUnit: item.PrescribingNumberUnit,
- }
- service.CreateDrugError(drugError)
- }
-
- key := strconv.FormatInt(adminInfo.Org.Id, 10) + ":" + strconv.FormatInt(item.PatientId, 10) + ":" + strconv.FormatInt(item.AdviceDate, 10) + ":doctor_advices"
- redis := service.RedisClient()
- //清空key 值
- redis.Set(key, "", time.Second)
- keyTwo := strconv.FormatInt(adminInfo.Org.Id, 10) + ":" + strconv.FormatInt(item.AdviceDate, 10) + ":advice_list_all"
- redis.Set(keyTwo, "", time.Second)
- keyThree := strconv.FormatInt(adminInfo.Org.Id, 10) + ":" + strconv.FormatInt(item.PatientId, 10) + ":" + strconv.FormatInt(item.AdviceDate, 10) + ":his_doctor_advice"
- redis.Set(keyThree, "", time.Second)
- recordDate := theTime.Format("2006-01-02")
- keyFour := "scheduals_" + recordDate + "_" + strconv.FormatInt(adminInfo.Org.Id, 10)
-
- redis.Set(keyFour, "", time.Second)
- keyFive := strconv.FormatInt(adminInfo.Org.Id, 10) + ":" + strconv.FormatInt(item.AdviceDate, 10) + ":his_advices_list_all"
- redis.Set(keyFive, "", time.Second)
-
- defer redis.Close()
- }
-
- //药品管理信息
- _, drugStockConfig := service.FindDrugStockAutomaticReduceRecordByOrgId(adminInfo.Org.Id)
-
- storeHouseConfig, _ := service.GetAllStoreHouseConfig(adminInfo.Org.Id)
- if drugStockConfig.IsOpen == 1 {
- for _, item := range advices {
- //查询改药品信息
- medical, _ := service.GetBaseDrugMedicalOne(item.DrugId, tx)
-
- //判断单位是否合格
- if item.PrescribingNumberUnit != medical.MaxUnit && item.PrescribingNumberUnit != medical.MinUnit {
- //查询该药品是否有出库记录
- flowMap, _ := service.GetDrugFLowByAdviceByIdOne(item.DrugId, item.PatientId, item.UserOrgId, item.AdviceDate, tx)
- if len(flowMap) == 0 {
- errs := service.UpdateHisAdviceByIdOne(item.ID, tx)
- if errs != nil {
- drugError := models.XtDrugError{
- UserOrgId: adminInfo.Org.Id,
- DrugId: item.DrugId,
- RecordDate: item.AdviceDate,
- PatientId: item.PatientId,
- Remark: "单位不统一,执行失败",
- Status: 1,
- Ctime: time.Now().Unix(),
- Mtime: 0,
- SumCount: 0,
- Prescribingnumber: item.PrescribingNumber,
- PrescribingNumberUnit: item.PrescribingNumberUnit,
- }
- service.CreateDrugError(drugError)
- }
- }
- advice, _ := service.FindHisDoctorAdviceByIdTwo(adminInfo.Org.Id, item.ID, tx)
- tx.Rollback()
- c.ServeSuccessJSON(map[string]interface{}{
- "msg": "7",
- "advice": advice,
- "ids": ids,
- })
- return
- }
-
- //查询这个患者这个患者这个药已经出库的所有数量
- advicelist, _ := service.GetAllHisDoctorAdviceByIdOne(item.DrugId, item.PatientId, item.AdviceDate, item.UserOrgId, tx)
- drugoutlist, _ := service.GetAllDrugFlowByIdOne(item.DrugId, item.PatientId, item.AdviceDate, item.UserOrgId, tx)
- var total_count int64
- var drug_count int64
- for _, it := range advicelist {
- if it.PrescribingNumberUnit == medical.MaxUnit {
- prescribingNumber_temp := strconv.FormatFloat(math.Abs(it.PrescribingNumber), 'f', 0, 64)
- prenumber, _ := strconv.ParseInt(prescribingNumber_temp, 10, 64)
- total_count += prenumber * medical.MinNumber
- }
- if it.PrescribingNumberUnit == medical.MinUnit {
- prescribingNumber_temp := strconv.FormatFloat(math.Abs(it.PrescribingNumber), 'f', 0, 64)
- prenumber, _ := strconv.ParseInt(prescribingNumber_temp, 10, 64)
- total_count += prenumber
- }
-
- }
-
- for _, its := range drugoutlist {
- if its.CountUnit == medical.MaxUnit {
- drug_count += its.Count * medical.MinNumber
- }
- if its.CountUnit == medical.MinUnit {
- drug_count += its.Count
- }
- }
-
- if total_count == drug_count {
- advice, _ := service.FindHisDoctorAdviceByIdTwo(adminInfo.Org.Id, item.ID, tx)
- tx.Commit()
- c.ServeSuccessJSON(map[string]interface{}{
- "msg": "1",
- "advice": advice,
- "ids": ids,
- })
- return
- }
-
- advice, _ := service.FindHisDoctorAdviceByIdTwo(adminInfo.Org.Id, item.ID, tx)
-
- var total int64
- var prescribing_number_total int64
-
- //保存处方出库
- config, _ := service.GetDrugOpenConfigOne(adminInfo.Org.Id)
-
- if config.IsOpen != 1 {
- //查询该药品是否有库存
- houseConfig, _ := service.GetAllStoreHouseConfig(advice.UserOrgId)
- list, _ := service.GetDrugTotalCountTwoTwety(advice.DrugId, advice.UserOrgId, houseConfig.DrugStorehouseOut, tx)
-
- //判断单位是否相等
- if medical.MaxUnit == advice.PrescribingNumberUnit && medical.MaxUnit != medical.MinUnit {
- prescribingNumber_temp := strconv.FormatFloat(math.Abs(advice.PrescribingNumber), 'f', 0, 64)
- count, _ := strconv.ParseInt(prescribingNumber_temp, 10, 64)
- //转化为最小单位
- total = list.Count*medical.MinNumber + list.StockMinNumber
- prescribing_number_total = count * medical.MinNumber
- }
-
- if medical.MinUnit == advice.PrescribingNumberUnit && medical.MaxUnit != medical.MinUnit {
- prescribingNumber_temp := strconv.FormatFloat(math.Abs(advice.PrescribingNumber), 'f', 0, 64)
- count, _ := strconv.ParseInt(prescribingNumber_temp, 10, 64)
- total = list.Count*medical.MinNumber + list.StockMinNumber
- prescribing_number_total = count
- }
-
- if medical.MinUnit == advice.PrescribingNumberUnit && medical.MaxUnit == medical.MinUnit {
- prescribingNumber_temp := strconv.FormatFloat(math.Abs(advice.PrescribingNumber), 'f', 0, 64)
- count, _ := strconv.ParseInt(prescribingNumber_temp, 10, 64)
- total = list.Count*medical.MinNumber + list.StockMinNumber
- prescribing_number_total = count
- }
-
- if medical.IsUse == 1 {
-
- if (list.Count*medical.MinNumber + list.StockMinNumber) == 0 {
- drugError := models.XtDrugError{
- UserOrgId: adminInfo.Org.Id,
- DrugId: item.DrugId,
- RecordDate: item.AdviceDate,
- PatientId: item.PatientId,
- Remark: "零用药品库存不足",
- Status: 1,
- Ctime: time.Now().Unix(),
- Mtime: 0,
- SumCount: list.Count*medical.MinNumber + list.StockMinNumber,
- Prescribingnumber: advice.PrescribingNumber,
- PrescribingNumberUnit: advice.PrescribingNumberUnit,
- }
- service.CreateDrugError(drugError)
- tx.Rollback()
- c.ServeSuccessJSON(map[string]interface{}{
- "msg": "1",
- "advice": advice,
- "ids": ids,
- })
- return
- }
- }
- if medical.IsUse != 1 {
-
- if (list.Count*medical.MinNumber + list.StockMinNumber) == 0 {
- drugError := models.XtDrugError{
- UserOrgId: adminInfo.Org.Id,
- DrugId: item.DrugId,
- RecordDate: item.AdviceDate,
- PatientId: item.PatientId,
- Remark: "药品库存不足",
- Status: 1,
- Ctime: time.Now().Unix(),
- Mtime: 0,
- SumCount: list.Count*medical.MinNumber + list.StockMinNumber,
- Prescribingnumber: advice.PrescribingNumber,
- PrescribingNumberUnit: advice.PrescribingNumberUnit,
- }
- service.CreateDrugError(drugError)
- tx.Rollback()
- c.ServeSuccessJSON(map[string]interface{}{
- "msg": "3",
- "advice": advice,
- "ids": ids,
- })
- return
- }
- if prescribing_number_total > total {
- drugError := models.XtDrugError{
- UserOrgId: adminInfo.Org.Id,
- DrugId: item.DrugId,
- RecordDate: item.AdviceDate,
- PatientId: item.PatientId,
- Remark: "出库数量大于库存",
- Status: 1,
- Ctime: time.Now().Unix(),
- Mtime: 0,
- SumCount: list.Count*medical.MinNumber + list.StockMinNumber,
- Prescribingnumber: advice.PrescribingNumber,
- PrescribingNumberUnit: advice.PrescribingNumberUnit,
- }
- service.CreateDrugError(drugError)
- tx.Rollback()
- c.ServeSuccessJSON(map[string]interface{}{
- "msg": "2",
- "advice": advice,
- "ids": ids,
- })
- return
- }
- }
-
- if prescribing_number_total <= total {
-
- pharmacyConfig, _ := service.FindPharmacyConfig(advice.UserOrgId)
- //判断药品是否零用
- if medical.IsUse == 2 {
-
- if config.IsOpen != 1 {
- if pharmacyConfig.IsOpen == 1 && medical.IsPharmacy == 0 {
-
- if adminInfo.Org.Id == 3877 || adminInfo.Org.Id == 10265 {
- //查询该药品是否有出库记录
- flowMap, _ := service.GetDrugFLowByAdviceByIdOne(advice.DrugId, advice.PatientId, advice.UserOrgId, advice.AdviceDate, tx)
- if len(flowMap) == 0 {
- errs := service.UpdateHisAdviceByIdOne(advice.ID, tx)
- if errs != nil {
- drugError := models.XtDrugError{
- UserOrgId: adminInfo.Org.Id,
- DrugId: item.DrugId,
- RecordDate: item.AdviceDate,
- PatientId: item.PatientId,
- Remark: "出库记录为空,更新执行人失败",
- Status: 1,
- Ctime: time.Now().Unix(),
- Mtime: 0,
- SumCount: list.Count*medical.MinNumber + list.StockMinNumber,
- Prescribingnumber: advice.PrescribingNumber,
- PrescribingNumberUnit: advice.PrescribingNumberUnit,
- }
- service.CreateDrugError(drugError)
- }
- tx.Rollback()
- c.ServeSuccessJSON(map[string]interface{}{
- "msg": "6",
- "advice": advice,
- "ids": ids,
- })
- return
- }
- }
- }
- if pharmacyConfig.IsOpen != 1 {
-
- //查询已经出库数量
-
- outListExport, _ := service.GetWarehouseOutListExport(advice.DrugId, advice.PatientId, advice.AdviceDate, advice.ID)
-
- var out_count int64
- if len(outListExport) > 0 {
- for _, item := range outListExport {
- if item.CountUnit == medical.MaxUnit && medical.MaxUnit != medical.MinUnit {
- out_count = item.Count * medical.MinNumber
- }
- if item.CountUnit == medical.MinUnit && medical.MaxUnit != medical.MinUnit {
- out_count = item.Count
- }
- if item.CountUnit == medical.MaxUnit && medical.MaxUnit == medical.MinUnit {
- out_count = item.Count * medical.MinNumber
- }
-
- }
- }
-
- newadviceInfo := &models.HisDoctorAdviceInfo{
- ID: advice.ID,
- UserOrgId: advice.UserOrgId,
- PatientId: advice.PatientId,
- HisPatientId: advice.HisPatientId,
- AdviceType: advice.AdviceType,
- AdviceDate: advice.AdviceDate,
- StartTime: advice.StartTime,
- AdviceName: advice.AdviceName,
- AdviceDesc: advice.AdviceDesc,
- ReminderDate: advice.ReminderDate,
- SingleDose: advice.SingleDose,
- SingleDoseUnit: advice.SingleDoseUnit,
- PrescribingNumber: advice.PrescribingNumber,
- PrescribingNumberUnit: advice.PrescribingNumberUnit,
- DeliveryWay: advice.DeliveryWay,
- ExecutionFrequency: advice.ExecutionFrequency,
- AdviceDoctor: advice.AdviceDoctor,
- Status: advice.Status,
- CreatedTime: advice.CreatedTime,
- UpdatedTime: advice.UpdatedTime,
- AdviceAffirm: advice.AdviceAffirm,
- Remark: advice.Remark,
- StopTime: advice.StopTime,
- StopReason: advice.StopReason,
- StopDoctor: advice.StopDoctor,
- StopState: advice.StopState,
- ParentId: advice.ParentId,
- ExecutionTime: advice.ExecutionTime,
- ExecutionStaff: advice.ExecutionStaff,
- ExecutionState: advice.ExecutionState,
- Checker: advice.Checker,
- RecordDate: advice.RecordDate,
- DialysisOrderId: advice.DialysisOrderId,
- CheckTime: advice.CheckTime,
- CheckState: advice.CheckState,
- DrugSpec: advice.DrugSpec,
- DrugSpecUnit: advice.DrugSpecUnit,
- Groupno: advice.Groupno,
- RemindType: advice.RemindType,
- FrequencyType: advice.FrequencyType,
- DayCount: advice.DayCount,
- WeekDay: advice.WeekDay,
- TemplateId: advice.TemplateId,
- Modifier: advice.Modifier,
- DrugId: advice.DrugId,
- Price: advice.Price,
- PrescriptionId: advice.PrescriptionId,
- MedListCodg: advice.MedListCodg,
- FeedetlSn: advice.FeedetlSn,
- Day: advice.DayCount,
- ChildDoctorAdvice: nil,
- Drug: models.Drug{},
- Diagnosis: advice.Diagnosis,
- Way: advice.Way,
- HospApprFlag: advice.HospApprFlag,
- LmtUsedFlag: advice.LmtUsedFlag,
- HisOrderInfo: models.HisOrderInfo{},
- IsMedicine: advice.IsMedicine,
- ExecutionFrequencyId: advice.ExecutionFrequencyId,
- Child: nil,
- IsSettle: advice.IsSettle,
- IsMobile: advice.IsMobile,
- IsSelfDrug: advice.IsSelfDrug,
- DrugWayCount: advice.DrugWayCount,
- }
-
- //如果当前医嘱数量大于历史出库数据则需要出库
- if prescribing_number_total > out_count {
-
- //按最小单位出库
- var cha_count = prescribing_number_total - out_count
-
- newadviceInfo.PrescribingNumber = float64(cha_count)
- newadviceInfo.PrescribingNumberUnit = medical.MinUnit
-
- service.NewHisDrugsDelivery(advice.UserOrgId, creater, newadviceInfo, tx)
-
- }
-
- //如果当前医嘱数量小于历史出库数据则需要退库
- if prescribing_number_total < out_count {
- var cha_count = out_count - prescribing_number_total
- drug, _ := service.FindBaseDrugLibRecordSeven(advice.UserOrgId, advice.DrugId)
- service.NewHisDrugCancelInfo(advice.UserOrgId, creater, newadviceInfo, cha_count, drug, tx)
- service.NewHisDrugAutoCancelInfo(advice.UserOrgId, creater, newadviceInfo, cha_count, drug, tx)
-
- }
-
- if prescribing_number_total == out_count {
- if out_count == 0 {
- service.NewHisDrugsDelivery(advice.UserOrgId, creater, newadviceInfo, tx)
- }
-
- }
-
- if adminInfo.Org.Id == 3877 || adminInfo.Org.Id == 10265 {
- //查询该药品是否有出库记录
- flowMap, _ := service.GetDrugFLowByAdviceByIdOne(advice.DrugId, advice.PatientId, advice.UserOrgId, advice.AdviceDate, tx)
-
- if len(flowMap) == 0 {
-
- errs := service.UpdateHisAdviceByIdOne(advice.ID, tx)
- if errs != nil {
- drugError := models.XtDrugError{
- UserOrgId: adminInfo.Org.Id,
- DrugId: item.DrugId,
- RecordDate: item.AdviceDate,
- PatientId: item.PatientId,
- Remark: "出库记录为空,更新执行人失败",
- Status: 1,
- Ctime: time.Now().Unix(),
- Mtime: 0,
- SumCount: list.Count*medical.MinNumber + list.StockMinNumber,
- Prescribingnumber: advice.PrescribingNumber,
- PrescribingNumberUnit: advice.PrescribingNumberUnit,
- }
- service.CreateDrugError(drugError)
- }
- tx.Rollback()
- c.ServeSuccessJSON(map[string]interface{}{
- "msg": "6",
- "advice": advice,
- "ids": ids,
- })
-
- return
- }
- }
- }
-
- //更新字典里面的库存
- stockInfo, _ := service.GetNewDrugAllStockInfo(storeHouseConfig.DrugStorehouseOut, item.UserOrgId, item.DrugId, tx)
- var sum_count int64
- for _, its := range stockInfo {
- if its.MaxUnit == medical.MaxUnit {
- its.StockMaxNumber = its.StockMaxNumber * medical.MinNumber
- }
- sum_count += its.StockMaxNumber + its.StockMinNumber
- }
- service.UpdateNewBaseDrugSumTwo(item.DrugId, sum_count, item.UserOrgId, tx)
- //剩余库存
- service.UpdateNewDrugStockCount(item.DrugId, item.UserOrgId, storeHouseConfig.DrugStorehouseOut, sum_count, tx)
-
- }
-
- }
- }
- }
-
- //自备药
- selfPrescriptionOutOpen, _ := service.GetSelfPrescriptionOutOpen(adminInfo.Org.Id)
-
- if selfPrescriptionOutOpen.IsOpen == 1 {
-
- selfBasedrug, _ := service.GetSelfBasedrugById(advice.DrugId, advice.UserOrgId, tx)
-
- if selfBasedrug.IsSelfDrug == 1 {
-
- //查询是否有库存
- info, _ := service.GetSelfWarehouseInfoByWarehouseInfoTwo(advice.DrugId, advice.PatientId, advice.UserOrgId, tx)
-
- if len(info) > 0 {
- var total_count int64
- var prescribing_number_total int64
- for _, item := range info {
- if item.MaxUnit == selfBasedrug.MaxUnit && selfBasedrug.MaxUnit != selfBasedrug.MinUnit {
- item.StockMaxNumber = item.StockMaxNumber * selfBasedrug.MinNumber
- }
-
- total_count += item.StockMaxNumber + item.StockMinNumber
- }
-
- //判断单位是否相等
- if selfBasedrug.MaxUnit == advice.PrescribingNumberUnit && selfBasedrug.MaxUnit != selfBasedrug.MinUnit {
- prescribingNumber_temp := strconv.FormatFloat(math.Abs(advice.PrescribingNumber), 'f', 0, 64)
- count, _ := strconv.ParseInt(prescribingNumber_temp, 10, 64)
- //转化为最小单位
- prescribing_number_total = count * selfBasedrug.MinNumber
- }
-
- if selfBasedrug.MinUnit == advice.PrescribingNumberUnit && selfBasedrug.MaxUnit != selfBasedrug.MinUnit {
- prescribingNumber_temp := strconv.FormatFloat(math.Abs(advice.PrescribingNumber), 'f', 0, 64)
- count, _ := strconv.ParseInt(prescribingNumber_temp, 10, 64)
- prescribing_number_total = count
-
- }
-
- if selfBasedrug.MinUnit == advice.PrescribingNumberUnit && selfBasedrug.MaxUnit == selfBasedrug.MinUnit {
- prescribingNumber_temp := strconv.FormatFloat(math.Abs(advice.PrescribingNumber), 'f', 0, 64)
- count, _ := strconv.ParseInt(prescribingNumber_temp, 10, 64)
- prescribing_number_total = count
-
- }
-
- if prescribing_number_total > total_count {
- c.ServeSuccessJSON(map[string]interface{}{
- "msg": "3",
- "advice": advice,
- })
- return
- }
- var warehousingOutInfo []*models.XtSelfDrugWarehouseOutInfo
- //出库
- if prescribing_number_total <= total_count {
- timeStr := time.Now().Format("2006-01-02")
- timeArr := strings.Split(timeStr, "-")
- total, _ := service.FindAllSelfDrugWarehouseOut(adminInfo.Org.Id, tx)
-
- total = total + 1
- warehousing_out_order := strconv.FormatInt(adminInfo.Org.Id, 10) + timeArr[0] + timeArr[1] + timeArr[2] + "000"
- number, _ := strconv.ParseInt(warehousing_out_order, 10, 64)
- number = number + total
- warehousing_out_order = "YPCKD" + strconv.FormatInt(number, 10)
- operation_time := time.Now().Unix()
-
- creater := c.GetMobileAdminUserInfo().AdminUser.Id
- //创建一个出库单
- drugWarehouseOut := models.XtSelfDrugWarehouseOut{
- WarehouseOutOrderNumber: warehousing_out_order,
- OperationTime: operation_time,
- OrgId: adminInfo.Org.Id,
- Creater: creater,
- Ctime: time.Now().Unix(),
- Status: 1,
- WarehouseOutTime: advice.AdviceDate,
- Type: 0,
- PatientId: advice.PatientId,
- IsCheck: 1,
- IsSys: 1,
- }
-
- //查询今日是否有出库数据
- lastWarehouseOut, _ := service.GetSelfDrugLastWarehouseOutTwety(adminInfo.Org.Id, advice.AdviceDate, tx, 1)
-
- if lastWarehouseOut.ID == 0 {
- service.AddSelfSigleDrugWarehouseOut(&drugWarehouseOut, tx)
- }
- //查询今日是否有出库数据
- lastWarehouseOutOne, _ := service.GetSelfDrugLastWarehouseOutTwety(adminInfo.Org.Id, advice.AdviceDate, tx, 1)
- //出库
- warehouseOutInfo := &models.XtSelfDrugWarehouseOutInfo{
- WarehouseOutId: lastWarehouseOutOne.ID,
- WarehouseOutOrderNumber: warehousing_out_order,
- DrugId: advice.DrugId,
- Count: prescribing_number_total,
- Price: 0,
- TotalPrice: 0,
- Status: 1,
- Ctime: advice.AdviceDate,
- Mtime: advice.AdviceDate,
- Remark: "",
- OrgId: advice.UserOrgId,
- Type: 0,
- Manufacturer: selfBasedrug.Manufacturer,
- Dealer: selfBasedrug.Dealer,
- RetailPrice: 0,
- RetailTotalPrice: 0,
- CountUnit: selfBasedrug.MinUnit,
- ExpiryDate: 0,
- ProductDate: 0,
- Number: "",
- BatchNumber: "",
- IsSys: 0,
- WarehouseInfoId: 0,
- AdminUserId: 0,
- StockCount: "",
- IsCheck: 1,
- SysRecordTime: advice.AdviceDate,
- PatientId: advice.PatientId,
- AdviceId: advice.ID,
- ClassType: "",
- }
- warehousingOutInfo = append(warehousingOutInfo, warehouseOutInfo)
-
- for _, it := range warehousingOutInfo {
-
- medical, _ := service.GetSelfBaseDrugMedical(it.DrugId, tx)
- drup, _ := service.FindSelfBaseDrugLibRecord(it.OrgId, it.DrugId, tx)
- //出库逻辑
- service.AutoSelfDrugDeliverInfoFourtyTwo(adminInfo.Org.Id, it.Count, &lastWarehouseOut, &drup, it, it.CountUnit, tx)
-
- //查询剩余库存
- stockInfo, _ := service.GetSelfDrugAllStockInfo(it.PatientId, it.OrgId, it.DrugId, tx)
- var sum_count int64
- for _, its := range stockInfo {
- if its.MaxUnit == medical.MaxUnit {
- its.StockMaxNumber = its.StockMaxNumber * medical.MinNumber
- }
- sum_count += its.StockMaxNumber + its.StockMinNumber
- }
- service.UpdateSelfDrugStockCount(it.DrugId, it.OrgId, it.PatientId, sum_count, tx)
- }
- }
-
- } else {
- c.ServeSuccessJSON(map[string]interface{}{
- "msg": "3",
- "advice": advice,
- })
- return
- }
-
- }
-
- }
-
- //针对异常未出库问题的脚本
- //if adminInfo.Org.Id == 10265 {
- //
- // newadviceInfo := &models.HisDoctorAdviceInfo{
- // ID: advice.ID,
- // UserOrgId: advice.UserOrgId,
- // PatientId: advice.PatientId,
- // HisPatientId: advice.HisPatientId,
- // AdviceType: advice.AdviceType,
- // AdviceDate: advice.AdviceDate,
- // StartTime: advice.StartTime,
- // AdviceName: advice.AdviceName,
- // AdviceDesc: advice.AdviceDesc,
- // ReminderDate: advice.ReminderDate,
- // SingleDose: advice.SingleDose,
- // SingleDoseUnit: advice.SingleDoseUnit,
- // PrescribingNumber: advice.PrescribingNumber,
- // PrescribingNumberUnit: advice.PrescribingNumberUnit,
- // DeliveryWay: advice.DeliveryWay,
- // ExecutionFrequency: advice.ExecutionFrequency,
- // AdviceDoctor: advice.AdviceDoctor,
- // Status: advice.Status,
- // CreatedTime: advice.CreatedTime,
- // UpdatedTime: advice.UpdatedTime,
- // AdviceAffirm: advice.AdviceAffirm,
- // Remark: advice.Remark,
- // StopTime: advice.StopTime,
- // StopReason: advice.StopReason,
- // StopDoctor: advice.StopDoctor,
- // StopState: advice.StopState,
- // ParentId: advice.ParentId,
- // ExecutionTime: advice.ExecutionTime,
- // ExecutionStaff: advice.ExecutionStaff,
- // ExecutionState: advice.ExecutionState,
- // Checker: advice.Checker,
- // RecordDate: advice.RecordDate,
- // DialysisOrderId: advice.DialysisOrderId,
- // CheckTime: advice.CheckTime,
- // CheckState: advice.CheckState,
- // DrugSpec: advice.DrugSpec,
- // DrugSpecUnit: advice.DrugSpecUnit,
- // Groupno: advice.Groupno,
- // RemindType: advice.RemindType,
- // FrequencyType: advice.FrequencyType,
- // DayCount: advice.DayCount,
- // WeekDay: advice.WeekDay,
- // TemplateId: advice.TemplateId,
- // Modifier: advice.Modifier,
- // DrugId: advice.DrugId,
- // Price: advice.Price,
- // PrescriptionId: advice.PrescriptionId,
- // MedListCodg: advice.MedListCodg,
- // FeedetlSn: advice.FeedetlSn,
- // Day: advice.DayCount,
- // ChildDoctorAdvice: nil,
- // Drug: models.Drug{},
- // Diagnosis: advice.Diagnosis,
- // Way: advice.Way,
- // HospApprFlag: advice.HospApprFlag,
- // LmtUsedFlag: advice.LmtUsedFlag,
- // HisOrderInfo: models.HisOrderInfo{},
- // IsMedicine: advice.IsMedicine,
- // ExecutionFrequencyId: advice.ExecutionFrequencyId,
- // Child: nil,
- // IsSettle: advice.IsSettle,
- // IsMobile: advice.IsMobile,
- // IsSelfDrug: advice.IsSelfDrug,
- // DrugWayCount: advice.DrugWayCount,
- // }
- // outListExport, _ := service.GetWarehouseOutListExport(advice.DrugId, advice.PatientId, advice.AdviceDate, advice.ID)
- // fmt.Println(outListExport)
- // //var out_count int64
- // //if len(outListExport) > 0 {
- // // for _, item := range outListExport {
- // // if item.CountUnit == medical.MaxUnit && medical.MaxUnit != medical.MinUnit {
- // // out_count = item.Count * medical.MinNumber
- // // }
- // // if item.CountUnit == medical.MinUnit && medical.MaxUnit != medical.MinUnit {
- // // out_count = item.Count
- // // }
- // // if item.CountUnit == medical.MaxUnit && medical.MaxUnit == medical.MinUnit {
- // // out_count = item.Count * medical.MinNumber
- // // }
- // //
- // // }
- // //}
- // //按最小单位出库
- // //var cha_count = total_count - out_count
- //
- // var cha_count = 40
- //
- // newadviceInfo.PrescribingNumber = float64(cha_count)
- // newadviceInfo.PrescribingNumberUnit = medical.MinUnit
- // service.NewHisDrugsDelivery(advice.UserOrgId, creater, newadviceInfo, tx)
- //
- // //查询剩余库存
- // stockInfo, _ := service.GetSelfDrugAllStockInfo(newadviceInfo.PatientId, newadviceInfo.UserOrgId, newadviceInfo.DrugId, tx)
- // var sum_count int64
- // for _, its := range stockInfo {
- // if its.MaxUnit == medical.MaxUnit {
- // its.StockMaxNumber = its.StockMaxNumber * medical.MinNumber
- // }
- // sum_count += its.StockMaxNumber + its.StockMinNumber
- // }
- // service.UpdateSelfDrugStockCount(newadviceInfo.DrugId, newadviceInfo.UserOrgId, newadviceInfo.PatientId, sum_count, tx)
- //}
-
- }
- }
-
- tx.Commit()
- for _, item := range advices {
- advice, _ := service.FindHisDoctorAdviceById(adminInfo.Org.Id, item.ID)
-
- c.ServeSuccessJSON(map[string]interface{}{
- "msg": "1",
- "advice": advice,
- "ids": ids,
- })
- }
-
- }
- }
-
- func (c *PatientApiController) ModifyExecDoctorAdvice() {
- execution_time := c.GetString("execution_time")
- fmt.Println("execution_time", execution_time)
- groupno, _ := c.GetInt64("groupno", -1)
- //patient_id, _ := c.GetInt64("patient_id")
- advice_date, _ := c.GetInt64("advice_date")
- var ids []string
- if groupno == 0 {
- advice_ids := c.GetString("advice_id")
- ids = strings.Split(advice_ids, ",")
- }
- if groupno < 0 {
- c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
- return
- }
-
- if len(execution_time) <= 0 {
- utils.ErrorLog("execution_time")
- c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
- return
- }
-
- timeLayout2 := "2006-01-02 15:04:05"
- loc, _ := time.LoadLocation("Local")
-
- theTime, errs := time.ParseInLocation(timeLayout2, execution_time, loc)
- if errs != nil {
- utils.ErrorLog(errs.Error())
- c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
- return
- }
-
- adminUserInfo := c.GetMobileAdminUserInfo()
-
- var advice models.DoctorAdvice
-
- if groupno > 0 {
- advices, _ := service.FindAllDoctorAdviceByGoroupNo(adminUserInfo.Org.Id, groupno)
- for _, item := range advices {
- if item.ExecutionState == 1 {
- advice = item
-
- }
- }
- } else {
- advices, _ := service.FindDoctorAdviceByIds(adminUserInfo.Org.Id, ids)
- for _, item := range advices {
- if item.ExecutionState == 1 {
- advice = item
- }
- }
- }
-
- //if advice.ExecutionStaff != adminUserInfo.AdminUser.Id {
- // headNursePermission, getPermissionErr := service.GetAdminUserSpecialPermission(adminUserInfo.Org.Id, adminUserInfo.App.Id, adminUserInfo.AdminUser.Id, models.SpecialPermissionTypeHeadNurse)
- // if getPermissionErr != nil {
- // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
- // return
- // } else if headNursePermission == nil {
- // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDialysisPermissionDeniedModify)
- // return
- // }
- //}
-
- if advice.StartTime > theTime.Unix() {
- c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeAdviceExceBeforeStart)
- return
- }
-
- advices := models.DoctorAdvice{
- ExecutionTime: theTime.Unix(),
- UpdatedTime: time.Now().Unix(),
- }
- var err error
- if groupno > 0 {
-
- // 查询信息规挡的设置天数
-
- infor, _ := service.GetDialysisInformationSetting(adminUserInfo.Org.Id)
- if infor.ID > 0 {
-
- var cha_time int64
-
- timeNowStr := time.Now().Format("2006-01-02")
- timeNewDate, _ := utils.ParseTimeStringToTime("2006-01-02", timeNowStr)
-
- //今日的日期减去设置的日期
- cha_time = timeNewDate.Unix() - infor.WeekDay*86400
-
- if cha_time >= advices.AdviceDate {
- //查询审核是否允许
- infor, _ := service.GetDialysisInformationByRecordDate(advice.PatientId, advices.AdviceDate, adminUserInfo.Org.Id, 4)
- //申请状态不允许的情况 拒绝修改
- if infor.ApplicationStatus != 1 {
- c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeInformationExist)
- return
- }
-
- }
- }
- err = service.ModifyExceDoctorAdviceByGroupNo(&advices, groupno, adminUserInfo.Org.Id)
- //记录日志
- byterequest, _ := json.Marshal(advices)
- adviceLog := models.XtDoctorAdviceLog{
- UserOrgId: adminUserInfo.Org.Id,
- PatientId: advices.PatientId,
- AdminUserId: adminUserInfo.AdminUser.Id,
- Module: 1,
- ErrLog: string(byterequest),
- Status: 1,
- Ctime: time.Now().Unix(),
- Mtime: 0,
- Source: "手机端编辑医嘱",
- RecordDate: advices.AdviceDate,
- }
-
- service.CreateDoctorAdviceLog(adviceLog)
-
- redis := service.RedisClient()
- key := strconv.FormatInt(adminUserInfo.Org.Id, 10) + ":" + strconv.FormatInt(advice.PatientId, 10) + ":" + strconv.FormatInt(advice.AdviceDate, 10) + ":doctor_advices"
-
- redis.Set(key, "", time.Second)
- keyOne := strconv.FormatInt(adminUserInfo.Org.Id, 10) + ":" + strconv.FormatInt(advice.AdviceDate, 10) + ":advice_list_all"
- redis.Set(keyOne, "", time.Second)
-
- defer redis.Close()
-
- } else {
- infor, _ := service.GetDialysisInformationSetting(adminUserInfo.Org.Id)
- if infor.ID > 0 {
-
- var cha_time int64
-
- timeNowStr := time.Now().Format("2006-01-02")
- timeNewDate, _ := utils.ParseTimeStringToTime("2006-01-02", timeNowStr)
-
- //今日的日期减去设置的日期
- cha_time = timeNewDate.Unix() - infor.WeekDay*86400
-
- if cha_time >= advices.AdviceDate {
- //查询审核是否允许
- infor, _ := service.GetDialysisInformationByRecordDate(advice.PatientId, advices.AdviceDate, adminUserInfo.Org.Id, 4)
- //申请状态不允许的情况 拒绝修改
- if infor.ApplicationStatus != 1 {
- c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeInformationExist)
- return
- }
-
- }
- }
- err = service.BatchModifyExceOldDoctorAdvice(&advices, ids)
- err = service.ModifyExceDoctorAdviceByGroupNoOne(&advices, ids)
-
- //记录日志
- byterequest, _ := json.Marshal(advices)
- adviceLog := models.XtDoctorAdviceLog{
- UserOrgId: adminUserInfo.Org.Id,
- PatientId: advices.PatientId,
- AdminUserId: adminUserInfo.AdminUser.Id,
- Module: 1,
- ErrLog: string(byterequest),
- Status: 1,
- Ctime: time.Now().Unix(),
- Mtime: 0,
- Source: "手机端编辑执行医嘱",
- RecordDate: advices.AdviceDate,
- }
-
- service.CreateDoctorAdviceLog(adviceLog)
- redis := service.RedisClient()
- key := strconv.FormatInt(adminUserInfo.Org.Id, 10) + ":" + strconv.FormatInt(advice.PatientId, 10) + ":" + strconv.FormatInt(advice.AdviceDate, 10) + ":doctor_advices"
-
- redis.Set(key, "", time.Second)
- keyOne := strconv.FormatInt(adminUserInfo.Org.Id, 10) + ":" + strconv.FormatInt(advice_date, 10) + ":advice_list_all"
- redis.Set(keyOne, "", time.Second)
-
- defer redis.Close()
- }
-
- //判断是否开启his
- errs, config := service.FindXTHisRecordByOrgId(adminUserInfo.Org.Id)
- //如果开启去修改执行时间
- if config.IsOpen == 1 {
- advicesinfo := models.HisDoctorAdviceInfo{
- ExecutionTime: theTime.Unix(),
- UpdatedTime: time.Now().Unix(),
- }
- var advicehis models.HisDoctorAdviceInfo
- service.ModifyExceDoctorAdviceById(&advicesinfo, ids)
- //记录日志
- byterequest, _ := json.Marshal(advicesinfo)
- adviceLog := models.XtDoctorAdviceLog{
- UserOrgId: adminUserInfo.Org.Id,
- PatientId: advices.PatientId,
- AdminUserId: adminUserInfo.AdminUser.Id,
- Module: 1,
- ErrLog: string(byterequest),
- Status: 1,
- Ctime: time.Now().Unix(),
- Mtime: 0,
- Source: "手机端his编辑医嘱",
- RecordDate: advices.AdviceDate,
- }
-
- service.CreateDoctorAdviceLog(adviceLog)
- his_advices, _ := service.FindHisDoctorAdviceByIdOne(adminUserInfo.Org.Id, ids)
- for _, item := range his_advices {
- if item.ExecutionState == 1 {
- advicehis = item
- }
- }
- redis := service.RedisClient()
- keyThree := strconv.FormatInt(adminUserInfo.Org.Id, 10) + ":" + strconv.FormatInt(advicehis.PatientId, 10) + ":" + strconv.FormatInt(advicehis.AdviceDate, 10) + ":his_doctor_advice"
- redis.Set(keyThree, "", time.Second)
- recordDate := theTime.Format("2006-01-02")
- keyFour := "scheduals_" + recordDate + "_" + strconv.FormatInt(adminUserInfo.Org.Id, 10)
-
- redis.Set(keyFour, "", time.Second)
- keyFive := strconv.FormatInt(adminUserInfo.Org.Id, 10) + ":" + strconv.FormatInt(advicehis.AdviceDate, 10) + ":his_advices_list_all"
- redis.Set(keyFive, "", time.Second)
- defer redis.Close()
- project := models.HisPrescriptionProject{
- ExecutionTime: theTime.Unix(),
- Mtime: time.Now().Unix(),
- }
- service.ModifyHisPrescriptionProject(&project, ids)
- //记录日志
- projectquerst, _ := json.Marshal(project)
- projectLog := models.XtDoctorAdviceLog{
- UserOrgId: adminUserInfo.Org.Id,
- PatientId: advices.PatientId,
- AdminUserId: adminUserInfo.AdminUser.Id,
- Module: 1,
- ErrLog: string(projectquerst),
- Status: 1,
- Ctime: time.Now().Unix(),
- Mtime: 0,
- Source: "手机端his编辑项目医嘱",
- RecordDate: advices.AdviceDate,
- }
- service.CreateDoctorAdviceLog(projectLog)
- keyEnd := strconv.FormatInt(adminUserInfo.Org.Id, 10) + ":" + strconv.FormatInt(advicesinfo.PatientId, 10) + ":" + strconv.FormatInt(advicesinfo.AdviceDate, 10) + ":his_doctor_advice"
- redis.Set(keyEnd, "", time.Second)
- keyFours := "scheduals_" + recordDate + "_" + strconv.FormatInt(adminUserInfo.Org.Id, 10)
-
- redis.Set(keyFours, "", time.Second)
- keyFives := strconv.FormatInt(adminUserInfo.Org.Id, 10) + ":" + strconv.FormatInt(advicesinfo.AdviceDate, 10) + ":his_advices_list_all"
- redis.Set(keyFives, "", time.Second)
- defer redis.Close()
- }
- if err != nil {
- c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeUpdateDoctorAdviceFail)
- return
- }
- advice.ExecutionTime = theTime.Unix()
- c.ServeSuccessJSON(map[string]interface{}{
- "msg": "ok",
- "advice": advice,
- "ids": ids,
- })
- return
-
- }
-
- func (c *PatientApiController) CheckMobileDoctorAdvice() {
- origin, _ := c.GetInt64("origin", 0)
- record_date, _ := c.GetInt64("record_date")
- patient_id, _ := c.GetInt64("patient_id")
- check_time := c.GetString("check_time")
- if len(check_time) <= 0 {
- utils.ErrorLog("check_time")
- c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
- return
- }
- timeLayout2 := "2006-01-02 15:04:05"
- loc, _ := time.LoadLocation("Local")
-
- theTime, errs := time.ParseInLocation(timeLayout2, check_time, loc)
- fmt.Println("theTimewowowow", theTime)
- if errs != nil {
- utils.ErrorLog(errs.Error())
- c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
- return
- }
- if origin != 2 {
- groupno, _ := c.GetInt64("groupno", -1)
- var ids []string
- if groupno == 0 {
- advice_ids := c.GetString("advice_id")
- if advice_ids == "" {
- c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
- return
- } else {
- ids = strings.Split(advice_ids, ",")
- if len(ids) <= 0 {
- c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
- return
- }
- }
- }
- if groupno < 0 {
- c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
- return
- }
-
- adminUserInfo := c.GetMobileAdminUserInfo()
-
- var advice models.DoctorAdvice
-
- if groupno > 0 {
- advices, _ := service.FindAllDoctorAdviceByGoroupNo(adminUserInfo.Org.Id, groupno)
- for _, item := range advices {
- if item.CheckState == 0 {
- advice = item
- }
-
- //记录日志
- byterequest, _ := json.Marshal(advices)
- adviceLog := models.XtDoctorAdviceLog{
- UserOrgId: adminUserInfo.Org.Id,
- PatientId: item.PatientId,
- AdminUserId: adminUserInfo.AdminUser.Id,
- Module: 3,
- ErrLog: string(byterequest),
- Status: 1,
- Ctime: time.Now().Unix(),
- Mtime: 0,
- Source: "手机端核对医嘱",
- RecordDate: item.AdviceDate,
- }
- service.CreateDoctorAdviceLog(adviceLog)
- }
- if advice.CheckState == 1 {
- c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeAdviceChecked)
- return
- }
- if advice.ExecutionStaff >= 0 && advice.ExecutionStaff == adminUserInfo.AdminUser.Id {
- c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeExceAndCheckNotOneUser)
- return
- }
-
- } else {
- advices, _ := service.FindDoctorAdviceByIds(adminUserInfo.Org.Id, ids)
- for _, item := range advices {
- if item.CheckState == 0 {
- advice = item
-
- }
-
- //记录日志
- byterequest, _ := json.Marshal(advices)
- adviceLog := models.XtDoctorAdviceLog{
- UserOrgId: adminUserInfo.Org.Id,
- PatientId: item.PatientId,
- AdminUserId: adminUserInfo.AdminUser.Id,
- Module: 3,
- ErrLog: string(byterequest),
- Status: 1,
- Ctime: time.Now().Unix(),
- Mtime: 0,
- Source: "手机端核对医嘱",
- RecordDate: item.AdviceDate,
- }
- service.CreateDoctorAdviceLog(adviceLog)
- }
- if advice.CheckState == 1 {
- c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeAdviceChecked)
- return
- }
- if advice.ExecutionStaff >= 0 && advice.ExecutionStaff == adminUserInfo.AdminUser.Id {
- c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeExceAndCheckNotOneUser)
- return
- }
- }
-
- checker := adminUserInfo.AdminUser.Id
-
- advices := models.DoctorAdvice{
- CheckTime: theTime.Unix(),
- Checker: checker,
- UpdatedTime: time.Now().Unix(),
- }
- fmt.Println("groupnowowowowoowowow", groupno)
- var err error
- if groupno > 0 {
-
- // 查询信息规挡的设置天数
-
- infor, _ := service.GetDialysisInformationSetting(adminUserInfo.Org.Id)
- if infor.ID > 0 && infor.WeekDay > 0 {
-
- var cha_time int64
-
- timeNowStr := time.Now().Format("2006-01-02")
- timeNewDate, _ := utils.ParseTimeStringToTime("2006-01-02", timeNowStr)
-
- //今日的日期减去设置的日期
- cha_time = timeNewDate.Unix() - infor.WeekDay*86400
-
- if cha_time >= record_date {
- //查询审核是否允许
- infor, _ := service.GetDialysisInformationByRecordDate(patient_id, record_date, adminUserInfo.Org.Id, 4)
- //申请状态不允许的情况 拒绝修改
- if infor.ApplicationStatus != 1 {
- c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeInformationExist)
- return
- }
-
- }
- }
- err = service.CheckDoctorAdviceByGroupNoOne(&advices, groupno, adminUserInfo.Org.Id)
-
- key := strconv.FormatInt(adminUserInfo.Org.Id, 10) + ":" + strconv.FormatInt(advice.PatientId, 10) + ":" + strconv.FormatInt(advice.AdviceDate, 10) + ":doctor_advices"
- redis := service.RedisClient()
- //清空key 值
- redis.Set(key, "", time.Second)
- keyTwo := strconv.FormatInt(adminUserInfo.Org.Id, 10) + ":" + strconv.FormatInt(advice.AdviceDate, 10) + ":advice_list_all"
- redis.Set(keyTwo, "", time.Second)
- keyThree := strconv.FormatInt(adminUserInfo.Org.Id, 10) + ":" + strconv.FormatInt(advice.PatientId, 10) + ":" + strconv.FormatInt(advice.AdviceDate, 10) + ":his_doctor_advice"
- redis.Set(keyThree, "", time.Second)
- recordDate := theTime.Format("2006-01-02")
- keyFour := "scheduals_" + recordDate + "_" + strconv.FormatInt(adminUserInfo.Org.Id, 10)
-
- redis.Set(keyFour, "", time.Second)
- keyFive := strconv.FormatInt(adminUserInfo.Org.Id, 10) + ":" + strconv.FormatInt(advice.AdviceDate, 10) + ":his_advices_list_all"
- redis.Set(keyFive, "", time.Second)
- defer redis.Close()
- } else {
-
- if len(ids[0]) <= 0 {
- c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeUpdateDoctorAdviceFail)
- return
- } else {
- //t := time.Now().Format("2006-01-02")/**/
- //timeLayout2 := "2006-01-02"
- //loc, _ := time.LoadLocation("Local")
- //theTime, _ := time.ParseInLocation(timeLayout2, t, loc)
- // 查询信息规挡的设置天数
-
- infor, _ := service.GetDialysisInformationSetting(adminUserInfo.Org.Id)
- if infor.ID > 0 {
-
- var cha_time int64
-
- timeNowStr := time.Now().Format("2006-01-02")
- timeNewDate, _ := utils.ParseTimeStringToTime("2006-01-02", timeNowStr)
-
- //今日的日期减去设置的日期
- cha_time = timeNewDate.Unix() - infor.WeekDay*86400
-
- if cha_time >= advices.AdviceDate {
- //查询审核是否允许
- infor, _ := service.GetDialysisInformationByRecordDate(advices.PatientId, advices.AdviceDate, adminUserInfo.Org.Id, 4)
- //申请状态不允许的情况 拒绝修改
- if infor.ApplicationStatus != 1 {
- c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeInformationExist)
- return
- }
-
- }
- }
- err = service.BatchCheckOldDoctorAdvice(&advices, ids, adminUserInfo.Org.Id, advice.AdviceDate)
- //记录日志
- byterequest, _ := json.Marshal(advices)
- adviceLog := models.XtDoctorAdviceLog{
- UserOrgId: adminUserInfo.Org.Id,
- PatientId: advices.PatientId,
- AdminUserId: advices.Checker,
- Module: 3,
- ErrLog: string(byterequest),
- Status: 1,
- Ctime: time.Now().Unix(),
- Mtime: 0,
- Source: "手机端核对医嘱",
- RecordDate: advices.AdviceDate,
- }
- service.CreateDoctorAdviceLog(adviceLog)
- key := strconv.FormatInt(adminUserInfo.Org.Id, 10) + ":" + strconv.FormatInt(advice.PatientId, 10) + ":" + strconv.FormatInt(advice.AdviceDate, 10) + ":doctor_advices"
- redis := service.RedisClient()
- //清空key 值
- redis.Set(key, "", time.Second)
- keyTwo := strconv.FormatInt(adminUserInfo.Org.Id, 10) + ":" + strconv.FormatInt(advice.AdviceDate, 10) + ":advice_list_all"
- redis.Set(keyTwo, "", time.Second)
- keyThree := strconv.FormatInt(adminUserInfo.Org.Id, 10) + ":" + strconv.FormatInt(advice.PatientId, 10) + ":" + strconv.FormatInt(advice.AdviceDate, 10) + ":his_doctor_advice"
- redis.Set(keyThree, "", time.Second)
- recordDate := theTime.Format("2006-01-02")
- keyFour := "scheduals_" + recordDate + "_" + strconv.FormatInt(adminUserInfo.Org.Id, 10)
-
- redis.Set(keyFour, "", time.Second)
- keyFive := strconv.FormatInt(adminUserInfo.Org.Id, 10) + ":" + strconv.FormatInt(advice.AdviceDate, 10) + ":his_advices_list_all"
- redis.Set(keyFive, "", time.Second)
- defer redis.Close()
- }
- }
-
- if err != nil {
- c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeUpdateDoctorAdviceFail)
- return
- }
-
- advice.Checker = checker
- advice.CheckTime = theTime.Unix()
- advice.CheckState = 1
- c.ServeSuccessJSON(map[string]interface{}{
- "msg": "ok",
- "advice": advice,
- })
- }
- return
- }
-
- func (c *PatientApiController) CheckDoctorAdvice() {
- origin, _ := c.GetInt64("origin", 0)
- record_date, _ := c.GetInt64("record_date")
- patient_id, _ := c.GetInt64("patient_id")
- if origin != 2 {
- groupno, _ := c.GetInt64("groupno", -1)
- var ids []string
- if groupno == 0 {
- advice_ids := c.GetString("advice_id")
- if advice_ids == "" {
- c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
- return
- } else {
- ids = strings.Split(advice_ids, ",")
- if len(ids) <= 0 {
- c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
- return
- }
- }
- }
- if groupno < 0 {
- c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
- return
- }
-
- adminUserInfo := c.GetMobileAdminUserInfo()
-
- var advice models.DoctorAdvice
-
- if groupno > 0 {
- advices, _ := service.FindAllDoctorAdviceByGoroupNo(adminUserInfo.Org.Id, groupno)
- for _, item := range advices {
- if item.CheckState == 0 {
- advice = item
- }
-
- //记录日志
- byterequest, _ := json.Marshal(advices)
- adviceLog := models.XtDoctorAdviceLog{
- UserOrgId: adminUserInfo.Org.Id,
- PatientId: item.PatientId,
- AdminUserId: adminUserInfo.AdminUser.Id,
- Module: 3,
- ErrLog: string(byterequest),
- Status: 1,
- Ctime: time.Now().Unix(),
- Mtime: 0,
- Source: "手机端核对医嘱",
- RecordDate: item.AdviceDate,
- }
- service.CreateDoctorAdviceLog(adviceLog)
- }
- if advice.CheckState == 1 {
- c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeAdviceChecked)
- return
- }
- if advice.ExecutionStaff >= 0 && advice.ExecutionStaff == adminUserInfo.AdminUser.Id {
- c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeExceAndCheckNotOneUser)
- return
- }
-
- } else {
- advices, _ := service.FindDoctorAdviceByIds(adminUserInfo.Org.Id, ids)
- for _, item := range advices {
- if item.CheckState == 0 {
- advice = item
-
- }
-
- //记录日志
- byterequest, _ := json.Marshal(advices)
- adviceLog := models.XtDoctorAdviceLog{
- UserOrgId: adminUserInfo.Org.Id,
- PatientId: item.PatientId,
- AdminUserId: adminUserInfo.AdminUser.Id,
- Module: 3,
- ErrLog: string(byterequest),
- Status: 1,
- Ctime: time.Now().Unix(),
- Mtime: 0,
- Source: "手机端核对医嘱",
- RecordDate: item.AdviceDate,
- }
- service.CreateDoctorAdviceLog(adviceLog)
- }
- if advice.CheckState == 1 {
- c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeAdviceChecked)
- return
- }
- if advice.ExecutionStaff >= 0 && advice.ExecutionStaff == adminUserInfo.AdminUser.Id {
- c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeExceAndCheckNotOneUser)
- return
- }
- }
-
- checker := adminUserInfo.AdminUser.Id
- theTime := time.Now()
-
- advices := models.DoctorAdvice{
- CheckTime: theTime.Unix(),
- Checker: checker,
- UpdatedTime: time.Now().Unix(),
- }
- var err error
- if groupno > 0 {
-
- // 查询信息规挡的设置天数
-
- infor, _ := service.GetDialysisInformationSetting(adminUserInfo.Org.Id)
- if infor.ID > 0 && infor.WeekDay > 0 {
-
- var cha_time int64
-
- timeNowStr := time.Now().Format("2006-01-02")
- timeNewDate, _ := utils.ParseTimeStringToTime("2006-01-02", timeNowStr)
-
- //今日的日期减去设置的日期
- cha_time = timeNewDate.Unix() - infor.WeekDay*86400
-
- if cha_time >= record_date {
- //查询审核是否允许
- infor, _ := service.GetDialysisInformationByRecordDate(patient_id, record_date, adminUserInfo.Org.Id, 4)
- //申请状态不允许的情况 拒绝修改
- if infor.ApplicationStatus != 1 {
- c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeInformationExist)
- return
- }
-
- }
- }
- err = service.CheckDoctorAdviceByGroupNo(&advices, groupno, adminUserInfo.Org.Id)
-
- key := strconv.FormatInt(adminUserInfo.Org.Id, 10) + ":" + strconv.FormatInt(advice.PatientId, 10) + ":" + strconv.FormatInt(advice.AdviceDate, 10) + ":doctor_advices"
- redis := service.RedisClient()
- //清空key 值
- redis.Set(key, "", time.Second)
- keyTwo := strconv.FormatInt(adminUserInfo.Org.Id, 10) + ":" + strconv.FormatInt(advice.AdviceDate, 10) + ":advice_list_all"
- redis.Set(keyTwo, "", time.Second)
- keyThree := strconv.FormatInt(adminUserInfo.Org.Id, 10) + ":" + strconv.FormatInt(advice.PatientId, 10) + ":" + strconv.FormatInt(advice.AdviceDate, 10) + ":his_doctor_advice"
- redis.Set(keyThree, "", time.Second)
- recordDate := theTime.Format("2006-01-02")
- keyFour := "scheduals_" + recordDate + "_" + strconv.FormatInt(adminUserInfo.Org.Id, 10)
-
- redis.Set(keyFour, "", time.Second)
- keyFive := strconv.FormatInt(adminUserInfo.Org.Id, 10) + ":" + strconv.FormatInt(advice.AdviceDate, 10) + ":his_advices_list_all"
- redis.Set(keyFive, "", time.Second)
- defer redis.Close()
- } else {
-
- if len(ids[0]) <= 0 {
- c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeUpdateDoctorAdviceFail)
- return
- } else {
- //t := time.Now().Format("2006-01-02")/**/
- //timeLayout2 := "2006-01-02"
- //loc, _ := time.LoadLocation("Local")
- //theTime, _ := time.ParseInLocation(timeLayout2, t, loc)
- // 查询信息规挡的设置天数
-
- infor, _ := service.GetDialysisInformationSetting(adminUserInfo.Org.Id)
- if infor.ID > 0 {
-
- var cha_time int64
-
- timeNowStr := time.Now().Format("2006-01-02")
- timeNewDate, _ := utils.ParseTimeStringToTime("2006-01-02", timeNowStr)
-
- //今日的日期减去设置的日期
- cha_time = timeNewDate.Unix() - infor.WeekDay*86400
-
- if cha_time >= advices.AdviceDate {
- //查询审核是否允许
- infor, _ := service.GetDialysisInformationByRecordDate(advices.PatientId, advices.AdviceDate, adminUserInfo.Org.Id, 4)
- //申请状态不允许的情况 拒绝修改
- if infor.ApplicationStatus != 1 {
- c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeInformationExist)
- return
- }
-
- }
- }
- err = service.BatchCheckOldDoctorAdvice(&advices, ids, adminUserInfo.Org.Id, advice.AdviceDate)
- //记录日志
- byterequest, _ := json.Marshal(advices)
- adviceLog := models.XtDoctorAdviceLog{
- UserOrgId: adminUserInfo.Org.Id,
- PatientId: advices.PatientId,
- AdminUserId: advices.Checker,
- Module: 3,
- ErrLog: string(byterequest),
- Status: 1,
- Ctime: time.Now().Unix(),
- Mtime: 0,
- Source: "手机端核对医嘱",
- RecordDate: advices.AdviceDate,
- }
- service.CreateDoctorAdviceLog(adviceLog)
- key := strconv.FormatInt(adminUserInfo.Org.Id, 10) + ":" + strconv.FormatInt(advice.PatientId, 10) + ":" + strconv.FormatInt(advice.AdviceDate, 10) + ":doctor_advices"
- redis := service.RedisClient()
- //清空key 值
- redis.Set(key, "", time.Second)
- keyTwo := strconv.FormatInt(adminUserInfo.Org.Id, 10) + ":" + strconv.FormatInt(advice.AdviceDate, 10) + ":advice_list_all"
- redis.Set(keyTwo, "", time.Second)
- keyThree := strconv.FormatInt(adminUserInfo.Org.Id, 10) + ":" + strconv.FormatInt(advice.PatientId, 10) + ":" + strconv.FormatInt(advice.AdviceDate, 10) + ":his_doctor_advice"
- redis.Set(keyThree, "", time.Second)
- recordDate := theTime.Format("2006-01-02")
- keyFour := "scheduals_" + recordDate + "_" + strconv.FormatInt(adminUserInfo.Org.Id, 10)
-
- redis.Set(keyFour, "", time.Second)
- keyFive := strconv.FormatInt(adminUserInfo.Org.Id, 10) + ":" + strconv.FormatInt(advice.AdviceDate, 10) + ":his_advices_list_all"
- redis.Set(keyFive, "", time.Second)
- defer redis.Close()
- }
- }
-
- if err != nil {
- c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeUpdateDoctorAdviceFail)
- return
- }
-
- advice.Checker = checker
- advice.CheckTime = theTime.Unix()
- advice.CheckState = 1
- c.ServeSuccessJSON(map[string]interface{}{
- "msg": "ok",
- "advice": advice,
- })
- } else if origin == 2 {
- adminInfo := c.GetMobileAdminUserInfo()
- var ids []string
- advice_ids := c.GetString("advice_id")
- ids = strings.Split(advice_ids, ",")
- advices, _ := service.FindHisDoctorAdviceByIds(adminInfo.Org.Id, ids)
- var err error
- for _, item := range advices {
- if item.CheckState == 1 {
- c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeAdviceChecked)
- return
- }
- if item.ExecutionStaff >= 0 && item.ExecutionStaff == adminInfo.AdminUser.Id {
- c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeExceAndCheckNotOneUser)
- return
- }
- item.Checker = adminInfo.AdminUser.Id
- item.CheckTime = time.Now().Unix()
- item.CheckState = 1
- // 查询信息规挡的设置天数
-
- infor, _ := service.GetDialysisInformationSetting(adminInfo.Org.Id)
- if infor.ID > 0 {
-
- var cha_time int64
-
- timeNowStr := time.Now().Format("2006-01-02")
- timeNewDate, _ := utils.ParseTimeStringToTime("2006-01-02", timeNowStr)
-
- //今日的日期减去设置的日期
- cha_time = timeNewDate.Unix() - infor.WeekDay*86400
-
- if cha_time >= record_date {
- //查询审核是否允许
- infor, _ := service.GetDialysisInformationByRecordDate(patient_id, record_date, adminInfo.Org.Id, 4)
- //申请状态不允许的情况 拒绝修改
- if infor.ApplicationStatus != 1 {
- c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeInformationExist)
- return
- }
-
- }
- }
- err = service.SaveHisDoctorAdvice(item)
- //记录日志
- byterequest, _ := json.Marshal(advices)
- adviceLog := models.XtDoctorAdviceLog{
- UserOrgId: adminInfo.Org.Id,
- PatientId: item.PatientId,
- AdminUserId: item.Checker,
- Module: 3,
- ErrLog: string(byterequest),
- Status: 1,
- Ctime: time.Now().Unix(),
- Mtime: 0,
- Source: "手机端核对His医嘱",
- RecordDate: item.AdviceDate,
- }
- service.CreateDoctorAdviceLog(adviceLog)
- redis := service.RedisClient()
- key := strconv.FormatInt(adminInfo.Org.Id, 10) + ":" + strconv.FormatInt(item.PatientId, 10) + ":" + strconv.FormatInt(item.AdviceDate, 10) + ":doctor_advices"
- //清空key 值
- redis.Set(key, "", time.Second)
- keyTwo := strconv.FormatInt(adminInfo.Org.Id, 10) + ":" + strconv.FormatInt(item.AdviceDate, 10) + ":advice_list_all"
- redis.Set(keyTwo, "", time.Second)
- keyThree := strconv.FormatInt(adminInfo.Org.Id, 10) + ":" + strconv.FormatInt(item.PatientId, 10) + ":" + strconv.FormatInt(item.AdviceDate, 10) + ":his_doctor_advice"
- redis.Set(keyThree, "", time.Second)
- theTime := time.Now()
-
- recordDate := theTime.Format("2006-01-02")
- keyFour := "scheduals_" + recordDate + "_" + strconv.FormatInt(adminInfo.Org.Id, 10)
-
- redis.Set(keyFour, "", time.Second)
- keyFive := strconv.FormatInt(adminInfo.Org.Id, 10) + ":" + strconv.FormatInt(item.AdviceDate, 10) + ":his_advices_list_all"
- redis.Set(keyFive, "", time.Second)
- defer redis.Close()
- }
- if err == nil {
- c.ServeSuccessJSON(map[string]interface{}{
- "msg": "ok",
- "advice": advices,
- })
- } else {
- c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
- return
- }
- }
- return
- }
-
- func (c *PatientApiController) EditAssessmentBeforeDislysis() {
- id, _ := c.GetInt64("patient", 0)
- assessmentDate := c.GetString("assessment_date", "")
- if id <= 0 || len(assessmentDate) != 10 {
- c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
- return
- }
-
- timeLayout := "2006-01-02"
- loc, _ := time.LoadLocation("Local")
-
- theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", assessmentDate+" 00:00:00", loc)
- if err != nil {
- c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
- return
- }
- theAssessmentDateTime := theTime.Unix()
-
- adminUserInfo := c.GetMobileAdminUserInfo()
- patient, _ := service.FindPatientById(adminUserInfo.Org.Id, id)
- if patient.ID == 0 {
- c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodePatientNoExist)
- return
- }
-
- theEvaluation, getPEErr := service.MobileGetPredialysisEvaluationSeven(adminUserInfo.Org.Id, id, theAssessmentDateTime)
- if getPEErr != nil {
- c.ErrorLog("获取透前评估失败:%v", getPEErr)
- c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
- return
- }
- template, _ := service.GetOrgInfoTemplate(adminUserInfo.Org.Id)
- //templateInfo,_ := service.GetOrgInfoTemplate(adminUserInfo.Org.Id)
- appRole, _ := service.FindAdminRoleTypeById(adminUserInfo.Org.Id, adminUserInfo.AdminUser.Id, adminUserInfo.App.Id)
- var evaluation models.PredialysisEvaluation
- if theEvaluation != nil {
- evaluation = *theEvaluation
- }
-
- code := predialysisEvaluationFormData(&evaluation, c.Ctx.Input.RequestBody)
- if code > 0 {
- c.ServeFailJSONWithSGJErrorCode(code)
- return
- }
-
- if theEvaluation == nil {
- evaluation.CreatedTime = time.Now().Unix()
- evaluation.Status = 1
- evaluation.AssessmentDate = theAssessmentDateTime
- evaluation.PatientId = id
- evaluation.UserOrgId = adminUserInfo.Org.Id
- if appRole.UserType == 2 || appRole.UserType == 1 {
- evaluation.AssessmentDoctor = adminUserInfo.AdminUser.Id
- evaluation.AssessmentTime = time.Now().Unix()
- } else {
- evaluation.Creater = adminUserInfo.AdminUser.Id
- }
- } else {
- evaluation.UpdatedTime = time.Now().Unix()
- evaluation.Evaluator = adminUserInfo.AdminUser.Id
- if appRole.UserType == 2 || appRole.UserType == 1 {
- evaluation.AssessmentDoctor = adminUserInfo.AdminUser.Id
- evaluation.AssessmentTime = time.Now().Unix()
- } else {
- evaluation.Modifier = adminUserInfo.AdminUser.Id
- if evaluation.Creater == 0 {
- evaluation.Creater = adminUserInfo.AdminUser.Id
- }
- }
- }
-
- //新增逻辑
-
- var dewater_amount float64
- dewater_amount = 0
- if evaluation.DryWeight > 0 {
- dewater_amount = evaluation.WeightBefore - evaluation.DryWeight - evaluation.AdditionalWeight
-
- if template.TemplateId == 17 || template.TemplateId == 22 || template.TemplateId == 21 || template.TemplateId == 26 || template.TemplateId == 34 || template.TemplateId == 32 || adminUserInfo.Org.Id == 10469 || adminUserInfo.Org.Id == 3877 || adminUserInfo.Org.Id == 10551 || adminUserInfo.Org.Id == 10579 || adminUserInfo.Org.Id == 10580 || adminUserInfo.Org.Id == 10585 {
-
- if adminUserInfo.Org.Id != 10551 && adminUserInfo.Org.Id != 10579 && adminUserInfo.Org.Id != 10580 && adminUserInfo.Org.Id != 10585 {
- dewater_amount = dewater_amount * 1000
- }
-
- }
-
- if dewater_amount <= 0 {
- dewater_amount = 0
- }
- } else {
- dewater_amount = 0
- }
- // 计算透析处方的相关超滤量
- schedual, _ := service.MobileGetSchedualDetailSix(adminUserInfo.Org.Id, patient.ID, theAssessmentDateTime)
- lastDialysisPrescription, _ := service.MobileGetLastDialysisPrescription(patient.ID, adminUserInfo.Org.Id)
-
- var lastDialysisPrescribe *models.DialysisPrescription
- var dialysisSolution *models.DialysisSolution
- var dialysisPrescribe *models.DialysisPrescription
- var system_dialysisPrescribe *models.SystemPrescription
-
- var mode_id int64
-
- dialysisPrescribe, _ = service.MobileGetDialysisPrescribe(adminUserInfo.Org.Id, id, theAssessmentDateTime)
- lastDialysisPrescribe, _ = service.MobileGetLastDialysisPrescribeByModeIdSix(adminUserInfo.Org.Id, id, schedual.ModeId)
-
- if schedual != nil {
- // 获取透析模版
- dialysisSolution, _ = service.MobileGetDialysisSolutionByModeIdSix(adminUserInfo.Org.Id, id, schedual.ModeId)
- system_dialysisPrescribe, _ = service.MobileGetSystemDialysisPrescribeByModeIdSix(adminUserInfo.Org.Id, schedual.ModeId)
-
- mode_id = schedual.ModeId
- } else {
- // 获取透析模版
- dialysisSolution, _ = service.MobileGetDialysisSolution(adminUserInfo.Org.Id, id)
-
- if dialysisPrescribe == nil && dialysisSolution != nil {
- mode_id = dialysisSolution.ModeId
- }
-
- if dialysisPrescribe == nil && dialysisSolution == nil {
- mode_id = 0
- }
- }
-
- // 插入透析处方
- if dialysisPrescribe == nil && dialysisSolution != nil {
- var newprescribe models.DialysisPrescription
- newprescribe.UserOrgId = adminUserInfo.Org.Id
- newprescribe.PatientId = id
- newprescribe.Anticoagulant = dialysisSolution.Anticoagulant
- newprescribe.AnticoagulantShouji = dialysisSolution.AnticoagulantShouji
- newprescribe.AnticoagulantWeichi = dialysisSolution.AnticoagulantWeichi
- newprescribe.AnticoagulantZongliang = dialysisSolution.AnticoagulantZongliang
- newprescribe.AnticoagulantGaimingcheng = dialysisSolution.AnticoagulantGaimingcheng
- newprescribe.AnticoagulantGaijiliang = dialysisSolution.AnticoagulantGaijiliang
- newprescribe.ModeId = dialysisSolution.ModeId
- newprescribe.DialysisDuration = dialysisSolution.DialysisDuration
- newprescribe.ReplacementWay = dialysisSolution.ReplacementWay
- newprescribe.HemodialysisMachine = dialysisSolution.HemodialysisMachine
- newprescribe.BloodFilter = dialysisSolution.BloodFilter
- newprescribe.PerfusionApparatus = dialysisSolution.PerfusionApparatus
- newprescribe.BloodFlowVolume = dialysisSolution.BloodFlowVolume
- newprescribe.DisplaceLiqui = dialysisSolution.DisplaceLiqui
- newprescribe.Glucose = dialysisSolution.Glucose
- newprescribe.DialysateFlow = dialysisSolution.DialysateFlow
- newprescribe.Kalium = dialysisSolution.Kalium
- newprescribe.Sodium = dialysisSolution.Sodium
- newprescribe.Calcium = dialysisSolution.Calcium
- newprescribe.Bicarbonate = dialysisSolution.Bicarbonate
- newprescribe.DialysateTemperature = dialysisSolution.DialysateTemperature
- newprescribe.Conductivity = dialysisSolution.Conductivity
- newprescribe.BodyFluid = dialysisSolution.BodyFluid
- newprescribe.SpecialMedicine = dialysisSolution.SpecialMedicine
- newprescribe.SpecialMedicineOther = dialysisSolution.SpecialMedicineOther
- newprescribe.DisplaceLiquiPart = dialysisSolution.DisplaceLiquiPart
- newprescribe.DisplaceLiquiValue = dialysisSolution.DisplaceLiquiValue
- newprescribe.BloodAccess = dialysisSolution.BloodAccess
- newprescribe.Ultrafiltration = dialysisSolution.Ultrafiltration
- newprescribe.DialysisDurationHour = dialysisSolution.DialysisDurationHour
- newprescribe.DialysisDurationMinute = dialysisSolution.DialysisDurationMinute
- newprescribe.TargetUltrafiltration = dialysisSolution.TargetUltrafiltration
- newprescribe.DialysateFormulation = dialysisSolution.DialysateFormulation
- newprescribe.Dialyzer = dialysisSolution.Dialyzer
- newprescribe.ReplacementTotal = dialysisSolution.ReplacementTotal
- newprescribe.DialyzerPerfusionApparatus = dialysisSolution.DialyzerPerfusionApparatus
- newprescribe.BodyFluidOther = dialysisSolution.BodyFluidOther
- newprescribe.TargetKtv = dialysisSolution.TargetKtv
-
- newprescribe.CreatedTime = time.Now().Unix()
- newprescribe.UpdatedTime = time.Now().Unix()
- newprescribe.RecordDate = theAssessmentDateTime
- newprescribe.DewaterAmount = dewater_amount
- newprescribe.TargetUltrafiltration = dewater_amount
- newprescribe.PrescriptionWater = dewater_amount
- newprescribe.Status = 1
- newprescribe.DialysisDialyszers = dialysisSolution.DialysisDialyszers
- newprescribe.DialysisIrrigation = dialysisSolution.DialysisIrrigation
- newprescribe.DialysisStrainer = dialysisSolution.DialysisStrainer
- newprescribe.Remark = lastDialysisPrescription.Remark
- newprescribe.Chaptalization = lastDialysisPrescribe.Chaptalization
-
- _, dialysisPrescription := service.FindDialysisPrescriptionByReordDate(id, theAssessmentDateTime, adminUserInfo.Org.Id)
- newprescribe.ID = dialysisPrescription.ID
-
- if dialysisPrescription.ID == 0 {
- if adminUserInfo.Org.Id == 10340 || adminUserInfo.Org.Id == 10679 {
- newprescribe.Sodium = 138
- newprescribe.Bicarbonate = 31.1
- newprescribe.DialysateFlow = 500
- newprescribe.PrescribingNumber = 1
-
- }
- if adminUserInfo.Org.Id == 10579 {
- newprescribe.Modifier = 0
- newprescribe.Creater = 0
- newprescribe.PrescriptionDoctor = 0
- }
- err := service.AddSigleRecord(&newprescribe)
- //记录日志
- byterequest, _ := json.Marshal(newprescribe)
- prescriptionLog := models.XtDialysisPrescriptionLog{
- UserOrgId: adminUserInfo.Org.Id,
- Ctime: time.Now().Unix(),
- Mtime: 0,
- ErrLog: string(byterequest),
- AdminUserId: adminUserInfo.AdminUser.Id,
- RecordDate: newprescribe.RecordDate,
- PatientId: id,
- Source: "手机端新增透前评估插入处方",
- Status: 1,
- }
-
- service.CreatePrescriptionLog(prescriptionLog)
-
- //获取key,清空redis
- key := strconv.FormatInt(adminUserInfo.Org.Id, 10) + ":" + strconv.FormatInt(id, 10) + ":" + strconv.FormatInt(theAssessmentDateTime, 10) + ":" + strconv.FormatInt(mode_id, 10) + ":dialysis_prescribe"
- redis := service.RedisClient()
-
- //清空key 值
- redis.Set(key, "", time.Second)
-
- keyOne := "scheduals_" + assessmentDate + "_" + strconv.FormatInt(adminUserInfo.Org.Id, 10)
- //清空key 值
- redis.Set(keyOne, "", time.Second)
-
- keyTwo := strconv.FormatInt(adminUserInfo.Org.Id, 10) + ":" + strconv.FormatInt(id, 10) + ":" + strconv.FormatInt(mode_id, 10) + ":dialysis_solution"
- //清空key 值
- redis.Set(keyTwo, "", time.Second)
-
- keySix := strconv.FormatInt(adminUserInfo.Org.Id, 10) + ":" + strconv.FormatInt(theAssessmentDateTime, 10) + ":prescriptions_list_all"
- redis.Set(keySix, "", time.Second)
-
- keySeven := strconv.FormatInt(adminUserInfo.Org.Id, 10) + ":" + strconv.FormatInt(id, 10) + ":" + strconv.FormatInt(theAssessmentDateTime, 10) + ":dialysis_prescribe_by_mode"
- redis.Set(keySeven, "", time.Second)
- if err != nil {
- c.ServeFailJSONWithSGJErrorCode(enums.ErrorCommitFail)
- }
- } else {
- if adminUserInfo.Org.Id == 10340 {
- newprescribe.Sodium = 138
- newprescribe.Bicarbonate = 31.1
- newprescribe.DialysateFlow = 500
- }
- appRole, _ := service.FindAdminRoleTypeById(adminUserInfo.Org.Id, adminUserInfo.AdminUser.Id, adminUserInfo.App.Id)
- //
- if appRole.UserType == 2 || appRole.UserType == 1 {
- newprescribe.PrescriptionDoctor = adminUserInfo.AdminUser.Id
- if adminUserInfo.Org.Id == 9882 {
- newprescribe.Creater = adminUserInfo.AdminUser.Id
- }
- }
- err := service.UpDateDialysisPrescription(&newprescribe)
-
- //记录日志
- byterequest, _ := json.Marshal(newprescribe)
- prescriptionLog := models.XtDialysisPrescriptionLog{
- UserOrgId: adminUserInfo.Org.Id,
- Ctime: time.Now().Unix(),
- Mtime: 0,
- ErrLog: string(byterequest),
- AdminUserId: adminUserInfo.AdminUser.Id,
- RecordDate: newprescribe.RecordDate,
- PatientId: id,
- Source: "手机端新增透前评估插入处方",
- Status: 1,
- }
-
- service.CreatePrescriptionLog(prescriptionLog)
- //获取key,清空redis
- key := strconv.FormatInt(adminUserInfo.Org.Id, 10) + ":" + strconv.FormatInt(id, 10) + ":" + strconv.FormatInt(theAssessmentDateTime, 10) + ":" + strconv.FormatInt(mode_id, 10) + ":dialysis_prescribe"
- redis := service.RedisClient()
-
- //清空key 值
- redis.Set(key, "", time.Second)
-
- keyOne := "scheduals_" + assessmentDate + "_" + strconv.FormatInt(adminUserInfo.Org.Id, 10)
- //清空key 值
- redis.Set(keyOne, "", time.Second)
-
- keyTwo := strconv.FormatInt(adminUserInfo.Org.Id, 10) + ":" + strconv.FormatInt(id, 10) + ":" + strconv.FormatInt(mode_id, 10) + ":dialysis_solution"
- //清空key 值
- redis.Set(keyTwo, "", time.Second)
-
- keySix := strconv.FormatInt(adminUserInfo.Org.Id, 10) + ":" + strconv.FormatInt(theAssessmentDateTime, 10) + ":prescriptions_list_all"
- redis.Set(keySix, "", time.Second)
-
- keySeven := strconv.FormatInt(adminUserInfo.Org.Id, 10) + ":" + strconv.FormatInt(id, 10) + ":" + strconv.FormatInt(theAssessmentDateTime, 10) + ":dialysis_prescribe_by_mode"
- redis.Set(keySeven, "", time.Second)
- if err != nil {
- c.ServeFailJSONWithSGJErrorCode(enums.ErrorCommitFail)
- }
- }
-
- }
-
- if dialysisPrescribe == nil && dialysisSolution == nil {
- if lastDialysisPrescribe != nil {
- var newprescribe models.DialysisPrescription
- newprescribe.UserOrgId = adminUserInfo.Org.Id
- newprescribe.PatientId = id
- newprescribe.Anticoagulant = lastDialysisPrescribe.Anticoagulant
- newprescribe.AnticoagulantShouji = lastDialysisPrescribe.AnticoagulantShouji
- newprescribe.AnticoagulantWeichi = lastDialysisPrescribe.AnticoagulantWeichi
- newprescribe.AnticoagulantZongliang = lastDialysisPrescribe.AnticoagulantZongliang
- newprescribe.AnticoagulantGaimingcheng = lastDialysisPrescribe.AnticoagulantGaimingcheng
- newprescribe.AnticoagulantGaijiliang = lastDialysisPrescribe.AnticoagulantGaijiliang
- newprescribe.ModeId = lastDialysisPrescribe.ModeId
- newprescribe.DialysisDuration = lastDialysisPrescribe.DialysisDuration
- newprescribe.ReplacementWay = lastDialysisPrescribe.ReplacementWay
- newprescribe.HemodialysisMachine = lastDialysisPrescribe.HemodialysisMachine
- newprescribe.BloodFilter = lastDialysisPrescribe.BloodFilter
- newprescribe.PerfusionApparatus = lastDialysisPrescribe.PerfusionApparatus
- newprescribe.BloodFlowVolume = lastDialysisPrescribe.BloodFlowVolume
- newprescribe.DisplaceLiqui = lastDialysisPrescribe.DisplaceLiqui
- newprescribe.Glucose = lastDialysisPrescribe.Glucose
- newprescribe.DialysateFlow = lastDialysisPrescribe.DialysateFlow
- newprescribe.Kalium = lastDialysisPrescribe.Kalium
- newprescribe.Sodium = lastDialysisPrescribe.Sodium
- newprescribe.Calcium = lastDialysisPrescribe.Calcium
- newprescribe.Bicarbonate = lastDialysisPrescribe.Bicarbonate
- newprescribe.DialysateTemperature = lastDialysisPrescribe.DialysateTemperature
- newprescribe.Conductivity = lastDialysisPrescribe.Conductivity
- newprescribe.BodyFluid = lastDialysisPrescribe.BodyFluid
- newprescribe.SpecialMedicine = lastDialysisPrescribe.SpecialMedicine
- newprescribe.SpecialMedicineOther = lastDialysisPrescribe.SpecialMedicineOther
- newprescribe.DisplaceLiquiPart = lastDialysisPrescribe.DisplaceLiquiPart
- newprescribe.DisplaceLiquiValue = lastDialysisPrescribe.DisplaceLiquiValue
- newprescribe.BloodAccess = lastDialysisPrescribe.BloodAccess
- newprescribe.Ultrafiltration = lastDialysisPrescribe.Ultrafiltration
- newprescribe.DialysisDurationHour = lastDialysisPrescribe.DialysisDurationHour
- newprescribe.DialysisDurationMinute = lastDialysisPrescribe.DialysisDurationMinute
- newprescribe.DialysateFormulation = lastDialysisPrescribe.DialysateFormulation
- newprescribe.Dialyzer = lastDialysisPrescribe.Dialyzer
- newprescribe.ReplacementTotal = lastDialysisPrescribe.ReplacementTotal
- newprescribe.DialyzerPerfusionApparatus = lastDialysisPrescribe.DialyzerPerfusionApparatus
- newprescribe.BodyFluidOther = lastDialysisPrescribe.BodyFluidOther
- newprescribe.TargetKtv = lastDialysisPrescribe.TargetKtv
- newprescribe.CreatedTime = time.Now().Unix()
- newprescribe.UpdatedTime = time.Now().Unix()
- newprescribe.RecordDate = theAssessmentDateTime
- newprescribe.DewaterAmount = dewater_amount
- newprescribe.TargetUltrafiltration = dewater_amount
- newprescribe.PrescriptionWater = dewater_amount
- newprescribe.Status = 1
- newprescribe.DialysisIrrigation = lastDialysisPrescribe.DialysisIrrigation
- newprescribe.DialysisDialyszers = lastDialysisPrescribe.DialysisDialyszers
-
- if dialysisSolution != nil && dialysisSolution.DialysisStrainer != "" {
- newprescribe.DialysisStrainer = dialysisSolution.DialysisStrainer
- }
-
- newprescribe.Remark = lastDialysisPrescription.Remark
- newprescribe.Chaptalization = lastDialysisPrescribe.Chaptalization
- _, dialysisPrescription := service.FindDialysisPrescriptionByReordDate(id, theAssessmentDateTime, adminUserInfo.Org.Id)
- newprescribe.ID = dialysisPrescription.ID
- if dialysisPrescription.ID == 0 {
- if adminUserInfo.Org.Id == 10340 || adminUserInfo.Org.Id == 10679 {
- newprescribe.Sodium = 138
- newprescribe.Bicarbonate = 31.1
- newprescribe.DialysateFlow = 500
- }
- if adminUserInfo.Org.Id == 10579 {
- newprescribe.Modifier = 0
- newprescribe.Creater = 0
- newprescribe.PrescriptionDoctor = 0
- }
- err := service.AddSigleRecord(&newprescribe)
-
- //记录日志
- byterequest, _ := json.Marshal(newprescribe)
- prescriptionLog := models.XtDialysisPrescriptionLog{
- UserOrgId: adminUserInfo.Org.Id,
- Ctime: time.Now().Unix(),
- Mtime: 0,
- ErrLog: string(byterequest),
- AdminUserId: adminUserInfo.AdminUser.Id,
- RecordDate: newprescribe.RecordDate,
- PatientId: id,
- Source: "手机端新增透前评估插入处方",
- Status: 1,
- }
-
- service.CreatePrescriptionLog(prescriptionLog)
- //获取key,清空redis
- key := strconv.FormatInt(adminUserInfo.Org.Id, 10) + ":" + strconv.FormatInt(id, 10) + ":" + strconv.FormatInt(theAssessmentDateTime, 10) + ":" + strconv.FormatInt(mode_id, 10) + ":dialysis_prescribe"
- redis := service.RedisClient()
-
- //清空key 值
- redis.Set(key, "", time.Second)
-
- keyOne := "scheduals_" + assessmentDate + "_" + strconv.FormatInt(adminUserInfo.Org.Id, 10)
- //清空key 值
- redis.Set(keyOne, "", time.Second)
-
- keyTwo := strconv.FormatInt(adminUserInfo.Org.Id, 10) + ":" + strconv.FormatInt(id, 10) + ":" + strconv.FormatInt(mode_id, 10) + ":dialysis_solution"
- //清空key 值
- redis.Set(keyTwo, "", time.Second)
-
- keySix := strconv.FormatInt(adminUserInfo.Org.Id, 10) + ":" + strconv.FormatInt(theAssessmentDateTime, 10) + ":prescriptions_list_all"
- redis.Set(keySix, "", time.Second)
-
- keySeven := strconv.FormatInt(adminUserInfo.Org.Id, 10) + ":" + strconv.FormatInt(id, 10) + ":" + strconv.FormatInt(theAssessmentDateTime, 10) + ":dialysis_prescribe_by_mode"
- redis.Set(keySeven, "", time.Second)
-
- if err != nil {
- c.ServeFailJSONWithSGJErrorCode(enums.ErrorCommitFail)
- }
- } else {
- appRole, _ := service.FindAdminRoleTypeById(adminUserInfo.Org.Id, adminUserInfo.AdminUser.Id, adminUserInfo.App.Id)
- //
- if appRole.UserType == 2 || appRole.UserType == 1 {
- if adminUserInfo.Org.Id == 10579 {
- newprescribe.Modifier = 0
- newprescribe.Creater = 0
- newprescribe.PrescriptionDoctor = 0
- } else {
- newprescribe.PrescriptionDoctor = adminUserInfo.AdminUser.Id
- }
-
- if adminUserInfo.Org.Id == 9882 {
- newprescribe.Creater = adminUserInfo.AdminUser.Id
- }
- }
- err := service.UpDateDialysisPrescription(&newprescribe)
-
- //记录日志
- byterequest, _ := json.Marshal(newprescribe)
- prescriptionLog := models.XtDialysisPrescriptionLog{
- UserOrgId: adminUserInfo.Org.Id,
- Ctime: time.Now().Unix(),
- Mtime: 0,
- ErrLog: string(byterequest),
- AdminUserId: adminUserInfo.AdminUser.Id,
- RecordDate: newprescribe.RecordDate,
- PatientId: id,
- Source: "手机端新增透前评估插入处方",
- Status: 1,
- }
-
- service.CreatePrescriptionLog(prescriptionLog)
- //获取key,清空redis
- key := strconv.FormatInt(adminUserInfo.Org.Id, 10) + ":" + strconv.FormatInt(id, 10) + ":" + strconv.FormatInt(theAssessmentDateTime, 10) + ":" + strconv.FormatInt(mode_id, 10) + ":dialysis_prescribe"
- redis := service.RedisClient()
-
- //清空key 值
- redis.Set(key, "", time.Second)
-
- keyOne := "scheduals_" + assessmentDate + "_" + strconv.FormatInt(adminUserInfo.Org.Id, 10)
- //清空key 值
- redis.Set(keyOne, "", time.Second)
-
- keyTwo := strconv.FormatInt(adminUserInfo.Org.Id, 10) + ":" + strconv.FormatInt(id, 10) + ":" + strconv.FormatInt(mode_id, 10) + ":dialysis_solution"
- //清空key 值
- redis.Set(keyTwo, "", time.Second)
-
- keySix := strconv.FormatInt(adminUserInfo.Org.Id, 10) + ":" + strconv.FormatInt(theAssessmentDateTime, 10) + ":prescriptions_list_all"
- redis.Set(keySix, "", time.Second)
-
- keySeven := strconv.FormatInt(adminUserInfo.Org.Id, 10) + ":" + strconv.FormatInt(id, 10) + ":" + strconv.FormatInt(theAssessmentDateTime, 10) + ":dialysis_prescribe_by_mode"
- redis.Set(keySeven, "", time.Second)
- if err != nil {
- c.ServeFailJSONWithSGJErrorCode(enums.ErrorCommitFail)
- }
- }
- if err != nil {
- c.ServeFailJSONWithSGJErrorCode(enums.ErrorCommitFail)
- }
- } else if system_dialysisPrescribe != nil {
-
- var newprescribe models.DialysisPrescription
- newprescribe.UserOrgId = adminUserInfo.Org.Id
- newprescribe.PatientId = id
- newprescribe.Anticoagulant = system_dialysisPrescribe.Anticoagulant
- newprescribe.AnticoagulantShouji = system_dialysisPrescribe.AnticoagulantShouji
- newprescribe.AnticoagulantWeichi = system_dialysisPrescribe.AnticoagulantWeichi
- newprescribe.AnticoagulantZongliang = system_dialysisPrescribe.AnticoagulantZongliang
- newprescribe.AnticoagulantGaimingcheng = system_dialysisPrescribe.AnticoagulantGaimingcheng
- newprescribe.AnticoagulantGaijiliang = system_dialysisPrescribe.AnticoagulantGaijiliang
- newprescribe.ModeId = system_dialysisPrescribe.ModeId
- newprescribe.DialysisDuration = system_dialysisPrescribe.DialysisDuration
- newprescribe.ReplacementWay = system_dialysisPrescribe.ReplacementWay
- newprescribe.HemodialysisMachine = system_dialysisPrescribe.HemodialysisMachine
- newprescribe.BloodFilter = system_dialysisPrescribe.BloodFilter
- newprescribe.PerfusionApparatus = system_dialysisPrescribe.PerfusionApparatus
- newprescribe.BloodFlowVolume = system_dialysisPrescribe.BloodFlowVolume
- newprescribe.DisplaceLiqui = system_dialysisPrescribe.DisplaceLiqui
- newprescribe.Glucose = system_dialysisPrescribe.Glucose
- newprescribe.DialysateFlow = system_dialysisPrescribe.DialysateFlow
- newprescribe.Kalium = system_dialysisPrescribe.Kalium
- newprescribe.Sodium = system_dialysisPrescribe.Sodium
- newprescribe.Calcium = system_dialysisPrescribe.Calcium
- newprescribe.Bicarbonate = system_dialysisPrescribe.Bicarbonate
- newprescribe.DialysateTemperature = system_dialysisPrescribe.DialysateTemperature
- newprescribe.Conductivity = system_dialysisPrescribe.Conductivity
- newprescribe.BodyFluid = system_dialysisPrescribe.BodyFluid
- newprescribe.SpecialMedicine = system_dialysisPrescribe.SpecialMedicine
- newprescribe.SpecialMedicineOther = system_dialysisPrescribe.SpecialMedicineOther
- newprescribe.DisplaceLiquiPart = system_dialysisPrescribe.DisplaceLiquiPart
- newprescribe.DisplaceLiquiValue = system_dialysisPrescribe.DisplaceLiquiValue
- newprescribe.BloodAccess = system_dialysisPrescribe.BloodAccess
- newprescribe.Ultrafiltration = system_dialysisPrescribe.Ultrafiltration
- newprescribe.DialysisDurationHour = system_dialysisPrescribe.DialysisDurationHour
- newprescribe.DialysisDurationMinute = system_dialysisPrescribe.DialysisDurationMinute
- newprescribe.DialysateFormulation = system_dialysisPrescribe.DialysateFormulation
- newprescribe.Dialyzer = system_dialysisPrescribe.Dialyzer
- newprescribe.ReplacementTotal = system_dialysisPrescribe.ReplacementTotal
- newprescribe.DialyzerPerfusionApparatus = system_dialysisPrescribe.DialyzerPerfusionApparatus
- newprescribe.BodyFluidOther = system_dialysisPrescribe.BodyFluidOther
- newprescribe.TargetKtv = system_dialysisPrescribe.TargetKtv
- newprescribe.CreatedTime = time.Now().Unix()
- newprescribe.UpdatedTime = time.Now().Unix()
- newprescribe.RecordDate = theAssessmentDateTime
- newprescribe.DewaterAmount = dewater_amount
- newprescribe.TargetUltrafiltration = dewater_amount
- newprescribe.PrescriptionWater = dewater_amount
- newprescribe.Status = 1
- newprescribe.DialysisDialyszers = system_dialysisPrescribe.DialysisDialyszers
- newprescribe.DialysisIrrigation = system_dialysisPrescribe.DialysisIrrigation
- newprescribe.DialysisStrainer = dialysisSolution.DialysisStrainer
- newprescribe.Remark = lastDialysisPrescription.Remark
- newprescribe.Chaptalization = lastDialysisPrescribe.Chaptalization
- _, dialysisPrescription := service.FindDialysisPrescriptionByReordDate(id, theAssessmentDateTime, adminUserInfo.Org.Id)
- newprescribe.ID = dialysisPrescription.ID
- if dialysisPrescription.ID == 0 {
- if adminUserInfo.Org.Id == 10340 || adminUserInfo.Org.Id == 10679 {
- newprescribe.Sodium = 138
- newprescribe.Bicarbonate = 31.1
- newprescribe.DialysateFlow = 500
- }
- if adminUserInfo.Org.Id == 10579 {
- newprescribe.Modifier = 0
- newprescribe.Creater = 0
- newprescribe.PrescriptionDoctor = 0
- }
- err := service.AddSigleRecord(&newprescribe)
- //记录日志
- byterequest, _ := json.Marshal(newprescribe)
- prescriptionLog := models.XtDialysisPrescriptionLog{
- UserOrgId: adminUserInfo.Org.Id,
- Ctime: time.Now().Unix(),
- Mtime: 0,
- ErrLog: string(byterequest),
- AdminUserId: adminUserInfo.AdminUser.Id,
- RecordDate: newprescribe.RecordDate,
- PatientId: id,
- Source: "手机端新增透前评估插入处方",
- Status: 1,
- }
-
- service.CreatePrescriptionLog(prescriptionLog)
- //获取key,清空redis
- key := strconv.FormatInt(adminUserInfo.Org.Id, 10) + ":" + strconv.FormatInt(id, 10) + ":" + strconv.FormatInt(theAssessmentDateTime, 10) + ":" + strconv.FormatInt(mode_id, 10) + ":dialysis_prescribe"
- redis := service.RedisClient()
-
- //清空key 值
- redis.Set(key, "", time.Second)
-
- keyOne := "scheduals_" + assessmentDate + "_" + strconv.FormatInt(adminUserInfo.Org.Id, 10)
- //清空key 值
- redis.Set(keyOne, "", time.Second)
-
- keyTwo := strconv.FormatInt(adminUserInfo.Org.Id, 10) + ":" + strconv.FormatInt(id, 10) + ":" + strconv.FormatInt(mode_id, 10) + ":dialysis_solution"
- //清空key 值
- redis.Set(keyTwo, "", time.Second)
-
- keySix := strconv.FormatInt(adminUserInfo.Org.Id, 10) + ":" + strconv.FormatInt(theAssessmentDateTime, 10) + ":prescriptions_list_all"
- redis.Set(keySix, "", time.Second)
-
- keySeven := strconv.FormatInt(adminUserInfo.Org.Id, 10) + ":" + strconv.FormatInt(id, 10) + ":" + strconv.FormatInt(theAssessmentDateTime, 10) + ":dialysis_prescribe_by_mode"
- redis.Set(keySeven, "", time.Second)
- if err != nil {
- c.ServeFailJSONWithSGJErrorCode(enums.ErrorCommitFail)
- }
- } else {
- if adminUserInfo.Org.Id == 10340 {
- newprescribe.Sodium = 138
- newprescribe.Bicarbonate = 31.1
- newprescribe.DialysateFlow = 500
- }
- appRole, _ := service.FindAdminRoleTypeById(adminUserInfo.Org.Id, adminUserInfo.AdminUser.Id, adminUserInfo.App.Id)
- //
- if appRole.UserType == 2 || appRole.UserType == 1 {
- newprescribe.PrescriptionDoctor = adminUserInfo.AdminUser.Id
- if adminUserInfo.Org.Id == 9882 {
- newprescribe.Creater = adminUserInfo.AdminUser.Id
- }
- }
- err := service.UpDateDialysisPrescription(&newprescribe)
- //记录日志
- byterequest, _ := json.Marshal(newprescribe)
- prescriptionLog := models.XtDialysisPrescriptionLog{
- UserOrgId: adminUserInfo.Org.Id,
- Ctime: time.Now().Unix(),
- Mtime: 0,
- ErrLog: string(byterequest),
- AdminUserId: adminUserInfo.AdminUser.Id,
- RecordDate: newprescribe.RecordDate,
- PatientId: id,
- Source: "手机端新增透前评估插入处方",
- Status: 1,
- }
-
- service.CreatePrescriptionLog(prescriptionLog)
- //获取key,清空redis
- key := strconv.FormatInt(adminUserInfo.Org.Id, 10) + ":" + strconv.FormatInt(id, 10) + ":" + strconv.FormatInt(theAssessmentDateTime, 10) + ":" + strconv.FormatInt(mode_id, 10) + ":dialysis_prescribe"
- redis := service.RedisClient()
-
- //清空key 值
- redis.Set(key, "", time.Second)
-
- keyOne := "scheduals_" + assessmentDate + "_" + strconv.FormatInt(adminUserInfo.Org.Id, 10)
- //清空key 值
- redis.Set(keyOne, "", time.Second)
-
- keyTwo := strconv.FormatInt(adminUserInfo.Org.Id, 10) + ":" + strconv.FormatInt(id, 10) + ":" + strconv.FormatInt(mode_id, 10) + ":dialysis_solution"
- //清空key 值
- redis.Set(keyTwo, "", time.Second)
-
- keySix := strconv.FormatInt(adminUserInfo.Org.Id, 10) + ":" + strconv.FormatInt(theAssessmentDateTime, 10) + ":prescriptions_list_all"
- redis.Set(keySix, "", time.Second)
-
- keySeven := strconv.FormatInt(adminUserInfo.Org.Id, 10) + ":" + strconv.FormatInt(id, 10) + ":" + strconv.FormatInt(theAssessmentDateTime, 10) + ":dialysis_prescribe_by_mode"
- redis.Set(keySeven, "", time.Second)
- if err != nil {
- c.ServeFailJSONWithSGJErrorCode(enums.ErrorCommitFail)
- }
- }
- if err != nil {
- c.ServeFailJSONWithSGJErrorCode(enums.ErrorCommitFail)
- }
-
- } else {
- var newprescribe models.DialysisPrescription
- newprescribe.UserOrgId = adminUserInfo.Org.Id
- newprescribe.PatientId = id
- newprescribe.ModeId = mode_id
- newprescribe.CreatedTime = time.Now().Unix()
- newprescribe.UpdatedTime = time.Now().Unix()
- newprescribe.RecordDate = theAssessmentDateTime
- newprescribe.DewaterAmount = dewater_amount
- newprescribe.TargetUltrafiltration = dewater_amount
- newprescribe.Status = 1
-
- _, dialysisPrescription := service.FindDialysisPrescriptionByReordDate(id, theAssessmentDateTime, adminUserInfo.Org.Id)
- if dialysisPrescription.ID > 0 {
- newprescribe.ID = dialysisPrescription.ID
- }
-
- if dialysisPrescription.ID == 0 {
- if adminUserInfo.Org.Id == 10340 || adminUserInfo.Org.Id == 10679 {
- newprescribe.Sodium = 138
- newprescribe.Bicarbonate = 31.1
- newprescribe.DialysateFlow = 500
- }
- if adminUserInfo.Org.Id == 10579 {
-
- newprescribe.Modifier = 0
- newprescribe.Creater = 0
- newprescribe.PrescriptionDoctor = 0
- }
- err := service.AddSigleRecord(&newprescribe)
-
- //获取key,清空redis
- key := strconv.FormatInt(adminUserInfo.Org.Id, 10) + ":" + strconv.FormatInt(id, 10) + ":" + strconv.FormatInt(theAssessmentDateTime, 10) + ":" + strconv.FormatInt(mode_id, 10) + ":dialysis_prescribe"
- redis := service.RedisClient()
-
- //清空key 值
- redis.Set(key, "", time.Second)
-
- keyOne := "scheduals_" + assessmentDate + "_" + strconv.FormatInt(adminUserInfo.Org.Id, 10)
- //清空key 值
- redis.Set(keyOne, "", time.Second)
-
- keyTwo := strconv.FormatInt(adminUserInfo.Org.Id, 10) + ":" + strconv.FormatInt(id, 10) + ":" + strconv.FormatInt(mode_id, 10) + ":dialysis_solution"
- //清空key 值
- redis.Set(keyTwo, "", time.Second)
-
- keySix := strconv.FormatInt(adminUserInfo.Org.Id, 10) + ":" + strconv.FormatInt(theAssessmentDateTime, 10) + ":prescriptions_list_all"
- redis.Set(keySix, "", time.Second)
-
- keySeven := strconv.FormatInt(adminUserInfo.Org.Id, 10) + ":" + strconv.FormatInt(id, 10) + ":" + strconv.FormatInt(theAssessmentDateTime, 10) + ":dialysis_prescribe_by_mode"
- redis.Set(keySeven, "", time.Second)
- if err != nil {
- c.ServeFailJSONWithSGJErrorCode(enums.ErrorCommitFail)
- }
- } else {
- if adminUserInfo.Org.Id == 10340 {
- newprescribe.Sodium = 138
- newprescribe.Bicarbonate = 31.1
- newprescribe.DialysateFlow = 500
- }
- appRole, _ := service.FindAdminRoleTypeById(adminUserInfo.Org.Id, adminUserInfo.AdminUser.Id, adminUserInfo.App.Id)
- //
- if appRole.UserType == 2 || appRole.UserType == 1 {
- newprescribe.PrescriptionDoctor = adminUserInfo.AdminUser.Id
- if adminUserInfo.Org.Id == 9882 {
- newprescribe.Creater = adminUserInfo.AdminUser.Id
- }
- }
- if adminUserInfo.Org.Id == 10579 {
- newprescribe.Modifier = 0
- newprescribe.Creater = 0
- newprescribe.PrescriptionDoctor = 0
- }
- err := service.UpDateDialysisPrescription(&newprescribe)
-
- //记录日志
- byterequest, _ := json.Marshal(newprescribe)
- prescriptionLog := models.XtDialysisPrescriptionLog{
- UserOrgId: adminUserInfo.Org.Id,
- Ctime: time.Now().Unix(),
- Mtime: 0,
- ErrLog: string(byterequest),
- AdminUserId: adminUserInfo.AdminUser.Id,
- RecordDate: newprescribe.RecordDate,
- PatientId: id,
- Source: "手机端新增透前评估插入处方",
- Status: 1,
- }
-
- service.CreatePrescriptionLog(prescriptionLog)
- //获取key,清空redis
- key := strconv.FormatInt(adminUserInfo.Org.Id, 10) + ":" + strconv.FormatInt(id, 10) + ":" + strconv.FormatInt(theAssessmentDateTime, 10) + ":" + strconv.FormatInt(mode_id, 10) + ":dialysis_prescribe"
- redis := service.RedisClient()
-
- //清空key 值
- redis.Set(key, "", time.Second)
-
- keyOne := "scheduals_" + assessmentDate + "_" + strconv.FormatInt(adminUserInfo.Org.Id, 10)
- //清空key 值
- redis.Set(keyOne, "", time.Second)
-
- keyTwo := strconv.FormatInt(adminUserInfo.Org.Id, 10) + ":" + strconv.FormatInt(id, 10) + ":" + strconv.FormatInt(mode_id, 10) + ":dialysis_solution"
- //清空key 值
- redis.Set(keyTwo, "", time.Second)
-
- keySix := strconv.FormatInt(adminUserInfo.Org.Id, 10) + ":" + strconv.FormatInt(theAssessmentDateTime, 10) + ":prescriptions_list_all"
- redis.Set(keySix, "", time.Second)
-
- keySeven := strconv.FormatInt(adminUserInfo.Org.Id, 10) + ":" + strconv.FormatInt(id, 10) + ":" + strconv.FormatInt(theAssessmentDateTime, 10) + ":dialysis_prescribe_by_mode"
- redis.Set(keySeven, "", time.Second)
- if err != nil {
- c.ServeFailJSONWithSGJErrorCode(enums.ErrorCommitFail)
- }
- }
- if err != nil {
- c.ServeFailJSONWithSGJErrorCode(enums.ErrorCommitFail)
- }
- }
- }
-
- // 手动修改透前评估的时候,如果透析处方已经存在,则不修改对应的透析处方
- // if dialysisPrescribe != nil {
- // dialysisPrescribe.UpdatedTime = time.Now().Unix()
- // dialysisPrescribe.RecordDate = theAssessmentDateTime
- // dialysisPrescribe.DewaterAmount = dewater_amount
- // dialysisPrescribe.TargetUltrafiltration = dewater_amount
- // dialysisPrescribe.Status = 1
- // updateErr := service.UpDateDialysisPrescription(dialysisPrescribe)
- // if updateErr != nil {
- // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCommitFail)
- // }
- // }
-
- // 查询信息规挡的设置天数
-
- infor, _ := service.GetDialysisInformationSetting(adminUserInfo.Org.Id)
- if infor.ID > 0 && infor.WeekDay > 0 {
-
- var cha_time int64
-
- timeNowStr := time.Now().Format("2006-01-02")
- timeNewDate, _ := utils.ParseTimeStringToTime("2006-01-02", timeNowStr)
-
- //今日的日期减去设置的日期
- cha_time = timeNewDate.Unix() - infor.WeekDay*86400
-
- if cha_time >= evaluation.AssessmentDate {
- //查询审核是否允许
- infor, _ := service.GetDialysisInformationByRecordDate(id, evaluation.AssessmentDate, adminUserInfo.Org.Id, 3)
- //申请状态不允许的情况 拒绝修改
- if infor.ApplicationStatus != 1 {
- c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeInformationExist)
- return
- }
-
- }
- }
- //针对长沙南雅的问题
- if adminUserInfo.Org.Id == 10340 || adminUserInfo.Org.Id == 10164 {
- if len(evaluation.SymptomBeforeDialysis) == 0 {
- predialysisEvaluation, _ := service.GetPredialysisEvaluation(id, adminUserInfo.Org.Id)
- evaluation.SymptomBeforeDialysis = predialysisEvaluation.SymptomBeforeDialysis
- }
-
- }
-
- //针对孝昌康桥超滤率计算问题
- if adminUserInfo.Org.Id == 10702 || adminUserInfo.Org.Id == 10635 {
- if evaluation.ID == 0 {
- dialysisPrescribeOne, _ := service.MobileGetDialysisPrescribeOne(adminUserInfo.Org.Id, id, theAssessmentDateTime)
- if dialysisPrescribeOne.ID > 0 && evaluation.ID > 0 {
- dewater_amount = evaluation.WeightBefore - evaluation.DryWeight - evaluation.AdditionalWeight
- service.UpdateMobileGetDialysisPrescribe(dialysisPrescribeOne.ID, dewater_amount)
- }
- }
-
- if evaluation.ID > 0 {
- dialysisPrescribeOne, _ := service.MobileGetDialysisPrescribeOne(adminUserInfo.Org.Id, id, theAssessmentDateTime)
- if dialysisPrescribeOne.ID > 0 && evaluation.ID > 0 {
- dewater_amount = evaluation.WeightBefore - evaluation.DryWeight - evaluation.AdditionalWeight
- service.UpdateMobileGetDialysisPrescribeOne(dialysisPrescribeOne.ID, dewater_amount)
- }
- }
-
- }
-
- err = service.UpadatePredialysisEvaluation(&evaluation)
-
- //记录日志
- byterequest, _ := json.Marshal(evaluation)
- beforeDislysisLog := models.XtAssessmentBeforeDislysisLog{
-
- UserOrgId: evaluation.UserOrgId,
- AdminUserId: adminUserInfo.AdminUser.Id,
- ErrLog: string(byterequest),
- PatientId: evaluation.PatientId,
- RecordDate: evaluation.AssessmentDate,
- Ctime: time.Now().Unix(),
- Mtime: 0,
- Status: 1,
- Source: "手机端保存透前评估",
- }
- service.CreateBeforLog(beforeDislysisLog)
-
- finish := models.XtDialysisFinish{
- IsFinish: 1,
- UserOrgId: adminUserInfo.Org.Id,
- Status: 1,
- Ctime: time.Now().Unix(),
- Mtime: 0,
- Module: 3,
- RecordDate: evaluation.AssessmentDate,
- Sourse: 1,
- PatientId: id,
- }
-
- dialysisFinish, _ := service.GetDialysisFinish(adminUserInfo.Org.Id, evaluation.AssessmentDate, 3, id)
- if dialysisFinish.ID == 0 {
- service.CreateDialysisFinish(finish)
- }
- key := strconv.FormatInt(adminUserInfo.Org.Id, 10) + ":" + strconv.FormatInt(id, 10) + ":" + strconv.FormatInt(theAssessmentDateTime, 10) + ":assessment_before_dislysis"
- redis := service.RedisClient()
- defer redis.Close()
- //清空key 值
- redis.Set(key, "", time.Second)
- keyOne := strconv.FormatInt(adminUserInfo.Org.Id, 10) + ":" + strconv.FormatInt(theAssessmentDateTime, 10) + ":assessment_befores_list_all"
- redis.Set(keyOne, "", time.Second)
- keyTwo := "scheduals_" + assessmentDate + "_" + strconv.FormatInt(adminUserInfo.Org.Id, 10)
- redis.Set(keyTwo, "", time.Second)
- if err != nil {
- c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDBUpdate)
- return
- }
-
- c.ServeSuccessJSON(map[string]interface{}{
- "msg": "ok",
- "evaluation": evaluation,
- })
- return
- }
-
- func defaultSolutionFormData(solution *models.DialysisSolution, data []byte, method string) (code int) {
- dataBody := make(map[string]interface{}, 0)
- err := json.Unmarshal(data, &dataBody)
- utils.InfoLog(string(data))
- if err != nil {
- utils.ErrorLog(err.Error())
- code = enums.ErrorCodeParamWrong
- return
- }
-
- // if method == "create" {
- if dataBody["mode"] == nil || reflect.TypeOf(dataBody["mode"]).String() != "float64" {
- utils.ErrorLog("mode")
- code = enums.ErrorCodeParamWrong
- return
- }
- mode := int64(dataBody["mode"].(float64))
- if mode <= 0 {
- utils.ErrorLog("mode <= 0")
- code = enums.ErrorCodeParamWrong
- return
- }
- solution.ModeId = mode
-
- if dataBody["mode_name"] == nil || reflect.TypeOf(dataBody["mode_name"]).String() != "string" {
- utils.ErrorLog("mode_name")
- code = enums.ErrorCodeParamWrong
- return
- }
- modeName, _ := dataBody["mode_name"].(string)
- if len(modeName) == 0 {
- utils.ErrorLog("len(mode_name) == 0")
- code = enums.ErrorCodeParamWrong
- return
- }
- solution.ModeName = modeName
- solution.Name = modeName
-
- // }
-
- if dataBody["dialysis_duration"] != nil && reflect.TypeOf(dataBody["dialysis_duration"]).String() == "string" {
- dialysisDuration, _ := strconv.ParseFloat(dataBody["dialysis_duration"].(string), 64)
- solution.DialysisDuration = dialysisDuration
- }
- if dataBody["dialysis_duration"] != nil {
- if reflect.TypeOf(dataBody["dialysis_duration"]).String() == "string" {
- dialysisDuration, _ := strconv.ParseFloat(dataBody["dialysis_duration"].(string), 64)
- solution.DialysisDuration = dialysisDuration
- } else if reflect.TypeOf(dataBody["dialysis_duration"]).String() == "float64" {
- dialysisDuration := dataBody["dialysis_duration"].(float64)
- solution.DialysisDuration = dialysisDuration
- }
- }
-
- if dataBody["dialyzer"] != nil && reflect.TypeOf(dataBody["dialyzer"]).String() == "float64" {
- dialyzer := int64(dataBody["dialyzer"].(float64))
- solution.Dialyzer = dialyzer
- }
-
- if dataBody["perfusion_apparatus"] != nil && reflect.TypeOf(dataBody["perfusion_apparatus"]).String() == "float64" {
- perfusionApparatus := int64(dataBody["perfusion_apparatus"].(float64))
- solution.PerfusionApparatus = perfusionApparatus
- }
-
- if dataBody["blood_flow_volume"] != nil {
- if reflect.TypeOf(dataBody["blood_flow_volume"]).String() == "string" {
- bloodFlowVolume, _ := strconv.ParseFloat(dataBody["blood_flow_volume"].(string), 64)
- solution.BloodFlowVolume = bloodFlowVolume
- } else if reflect.TypeOf(dataBody["blood_flow_volume"]).String() == "float64" {
- bloodFlowVolume := dataBody["blood_flow_volume"].(float64)
- solution.BloodFlowVolume = bloodFlowVolume
- }
- }
-
- if dataBody["hemodialysis_machine"] != nil && reflect.TypeOf(dataBody["hemodialysis_machine"]).String() == "float64" {
- hemodialysisMachine := int64(dataBody["hemodialysis_machine"].(float64))
- solution.HemodialysisMachine = hemodialysisMachine
- }
-
- if dataBody["dewater"] != nil {
- if reflect.TypeOf(dataBody["dewater"]).String() == "string" {
- dewater, _ := strconv.ParseFloat(dataBody["dewater"].(string), 64)
- solution.Dewater = dewater
- } else if reflect.TypeOf(dataBody["dewater"]).String() == "float64" {
- dewater := dataBody["dewater"].(float64)
- solution.Dewater = dewater
- }
- }
-
- if dataBody["replacement_total"] != nil {
- if reflect.TypeOf(dataBody["replacement_total"]).String() == "string" {
- replacementTotal, _ := strconv.ParseFloat(dataBody["replacement_total"].(string), 64)
- solution.ReplacementTotal = replacementTotal
- } else if reflect.TypeOf(dataBody["replacement_total"]).String() == "float64" {
- replacementTotal := dataBody["replacement_total"].(float64)
- solution.ReplacementTotal = replacementTotal
- }
- }
-
- if dataBody["displace_liqui"] != nil {
- if reflect.TypeOf(dataBody["displace_liqui"]).String() == "string" {
- displaceLiqui, _ := strconv.ParseFloat(dataBody["displace_liqui"].(string), 64)
- solution.DisplaceLiqui = displaceLiqui
- } else if reflect.TypeOf(dataBody["displace_liqui"]).String() == "float64" {
- displaceLiqui := dataBody["displace_liqui"].(float64)
- solution.DisplaceLiqui = displaceLiqui
- }
- }
-
- if dataBody["replacement_way"] != nil && reflect.TypeOf(dataBody["replacement_way"]).String() == "float64" {
- replacementWay := int64(dataBody["replacement_way"].(float64))
- solution.ReplacementWay = replacementWay
- }
-
- if dataBody["anticoagulant"] != nil && reflect.TypeOf(dataBody["anticoagulant"]).String() == "float64" {
- anticoagulant := int64(dataBody["anticoagulant"].(float64))
- solution.Anticoagulant = anticoagulant
- }
-
- if dataBody["anticoagulant_shouji"] != nil {
- if reflect.TypeOf(dataBody["anticoagulant_shouji"]).String() == "string" {
- anticoagulantShouji, _ := strconv.ParseFloat(dataBody["anticoagulant_shouji"].(string), 64)
- solution.AnticoagulantShouji = anticoagulantShouji
- } else if reflect.TypeOf(dataBody["anticoagulant_shouji"]).String() == "float64" {
- anticoagulantShouji := dataBody["anticoagulant_shouji"].(float64)
- solution.AnticoagulantShouji = anticoagulantShouji
- }
- }
-
- if dataBody["anticoagulant_weichi"] != nil {
- if reflect.TypeOf(dataBody["anticoagulant_weichi"]).String() == "string" {
- anticoagulantWeichi, _ := strconv.ParseFloat(dataBody["anticoagulant_weichi"].(string), 64)
- solution.AnticoagulantWeichi = anticoagulantWeichi
- } else if reflect.TypeOf(dataBody["anticoagulant_weichi"]).String() == "float64" {
- anticoagulantWeichi := dataBody["anticoagulant_weichi"].(float64)
- solution.AnticoagulantWeichi = anticoagulantWeichi
- }
- }
-
- if dataBody["anticoagulant_zongliang"] != nil {
- if reflect.TypeOf(dataBody["anticoagulant_zongliang"]).String() == "string" {
- anticoagulantZongliang, _ := strconv.ParseFloat(dataBody["anticoagulant_zongliang"].(string), 64)
- solution.AnticoagulantZongliang = anticoagulantZongliang
- } else if reflect.TypeOf(dataBody["anticoagulant_zongliang"]).String() == "float64" {
- anticoagulantZongliang := dataBody["anticoagulant_zongliang"].(float64)
- solution.AnticoagulantZongliang = anticoagulantZongliang
- }
- }
-
- if dataBody["anticoagulant_gaimingcheng"] != nil && reflect.TypeOf(dataBody["anticoagulant_gaimingcheng"]).String() == "string" {
- anticoagulantGaimingcheng, _ := dataBody["anticoagulant_gaimingcheng"].(string)
- solution.AnticoagulantGaimingcheng = anticoagulantGaimingcheng
- }
-
- if dataBody["anticoagulant_gaijiliang"] != nil && reflect.TypeOf(dataBody["anticoagulant_gaijiliang"]).String() == "string" {
- anticoagulantGaijiliang, _ := dataBody["anticoagulant_gaijiliang"].(string)
- solution.AnticoagulantGaijiliang = anticoagulantGaijiliang
- }
-
- if dataBody["kalium"] != nil {
- if reflect.TypeOf(dataBody["kalium"]).String() == "string" {
- kalium, _ := strconv.ParseFloat(dataBody["kalium"].(string), 64)
- solution.Kalium = kalium
- } else if reflect.TypeOf(dataBody["kalium"]).String() == "float64" {
- kalium := dataBody["kalium"].(float64)
- solution.Kalium = kalium
- }
- }
-
- if dataBody["sodium"] != nil {
- if reflect.TypeOf(dataBody["sodium"]).String() == "string" {
- sodium, _ := strconv.ParseFloat(dataBody["sodium"].(string), 64)
- solution.Sodium = sodium
- } else if reflect.TypeOf(dataBody["sodium"]).String() == "float64" {
- sodium := dataBody["sodium"].(float64)
- solution.Sodium = sodium
- }
- }
-
- if dataBody["calcium"] != nil && reflect.TypeOf(dataBody["calcium"]).String() == "string" {
- if reflect.TypeOf(dataBody["calcium"]).String() == "string" {
- calcium, _ := strconv.ParseFloat(dataBody["calcium"].(string), 64)
- solution.Calcium = calcium
- } else if reflect.TypeOf(dataBody["calcium"]).String() == "float64" {
- calcium := dataBody["calcium"].(float64)
- solution.Calcium = calcium
- }
- }
-
- if dataBody["bicarbonate"] != nil {
- if reflect.TypeOf(dataBody["bicarbonate"]).String() == "string" {
- bicarbonate, _ := strconv.ParseFloat(dataBody["bicarbonate"].(string), 64)
- solution.Bicarbonate = bicarbonate
- } else if reflect.TypeOf(dataBody["bicarbonate"]).String() == "float64" {
- bicarbonate := dataBody["bicarbonate"].(float64)
- solution.Bicarbonate = bicarbonate
- }
- }
-
- if dataBody["glucose"] != nil {
- if reflect.TypeOf(dataBody["glucose"]).String() == "string" {
- glucose, _ := strconv.ParseFloat(dataBody["glucose"].(string), 64)
- solution.Glucose = glucose
- } else if reflect.TypeOf(dataBody["glucose"]).String() == "float64" {
- glucose := dataBody["glucose"].(float64)
- solution.Glucose = glucose
- }
- }
-
- // if dataBody["dry_weight"] != nil {
- // if reflect.TypeOf(dataBody["dry_weight"]).String() == "string" {
- // dryWeight, _ := strconv.ParseFloat(dataBody["dry_weight"].(string), 64)
- // solution.DryWeight = dryWeight
- // } else if reflect.TypeOf(dataBody["dry_weight"]).String() == "float64" {
- // dryWeight := dataBody["dry_weight"].(float64)
- // solution.DryWeight = dryWeight
- // }
- // }
-
- if dataBody["dialysate_flow"] != nil {
- if reflect.TypeOf(dataBody["dialysate_flow"]).String() == "string" {
- dialysateFlow, _ := strconv.ParseFloat(dataBody["dialysate_flow"].(string), 64)
- solution.DialysateFlow = dialysateFlow
- } else if reflect.TypeOf(dataBody["dialysate_flow"]).String() == "float64" {
- dialysateFlow := dataBody["dialysate_flow"].(float64)
- solution.DialysateFlow = dialysateFlow
- }
- }
-
- if dataBody["dialysate_temperature"] != nil {
- if reflect.TypeOf(dataBody["dialysate_temperature"]).String() == "string" {
- dialysateTemperature, _ := strconv.ParseFloat(dataBody["dialysate_temperature"].(string), 64)
- solution.DialysateTemperature = dialysateTemperature
- } else if reflect.TypeOf(dataBody["dialysate_temperature"]).String() == "float64" {
- dialysateTemperature := dataBody["dialysate_temperature"].(float64)
- solution.DialysateTemperature = dialysateTemperature
- }
- }
-
- if dataBody["conductivity"] != nil {
- if reflect.TypeOf(dataBody["conductivity"]).String() == "string" {
- conductivity, _ := strconv.ParseFloat(dataBody["conductivity"].(string), 64)
- solution.Conductivity = conductivity
- } else if reflect.TypeOf(dataBody["conductivity"]).String() == "float64" {
- conductivity := dataBody["conductivity"].(float64)
- solution.Conductivity = conductivity
- }
- }
-
- if dataBody["remark"] != nil && reflect.TypeOf(dataBody["remark"]).String() == "string" {
- remark := dataBody["remark"].(string)
- solution.Remark = remark
- }
-
- if dataBody["dialysis_duration_hour"] != nil {
- if reflect.TypeOf(dataBody["dialysis_duration_hour"]).String() == "string" {
- dialysisDurationHour, _ := strconv.ParseInt(dataBody["dialysis_duration_hour"].(string), 10, 64)
- solution.DialysisDurationHour = dialysisDurationHour
- } else if reflect.TypeOf(dataBody["dialysis_duration_hour"]).String() == "float64" {
- dialysisDurationHour := dataBody["dialysis_duration_hour"].(float64)
- solution.DialysisDurationHour = int64(dialysisDurationHour)
- }
- }
-
- if dataBody["dialysis_duration_minute"] != nil {
- if reflect.TypeOf(dataBody["dialysis_duration_minute"]).String() == "string" {
- dialysisDurationMinute, _ := strconv.ParseInt(dataBody["dialysis_duration_minute"].(string), 10, 64)
- solution.DialysisDurationMinute = dialysisDurationMinute
- } else if reflect.TypeOf(dataBody["dialysis_duration_minute"]).String() == "float64" {
- dialysisDurationMinute := dataBody["dialysis_duration_minute"].(float64)
- solution.DialysisDurationMinute = int64(dialysisDurationMinute)
- }
- }
- if dataBody["target_ultrafiltration"] != nil {
- if reflect.TypeOf(dataBody["target_ultrafiltration"]).String() == "string" {
- targetUltrafiltration, _ := strconv.ParseFloat(dataBody["target_ultrafiltration"].(string), 64)
- solution.TargetUltrafiltration = targetUltrafiltration
- } else if reflect.TypeOf(dataBody["target_ultrafiltration"]).String() == "float64" {
- targetUltrafiltration := dataBody["target_ultrafiltration"].(float64)
- solution.TargetUltrafiltration = targetUltrafiltration
- }
- }
-
- if dataBody["dialysate_formulation"] != nil {
- if reflect.TypeOf(dataBody["dialysate_formulation"]).String() == "string" {
- dialysateFormulation, _ := strconv.ParseInt(dataBody["dialysate_formulation"].(string), 10, 64)
- solution.DialysateFormulation = dialysateFormulation
- } else if reflect.TypeOf(dataBody["dialysate_formulation"]).String() == "float64" {
- dialysateFormulation := dataBody["dialysate_formulation"].(float64)
- solution.DialysateFormulation = int64(dialysateFormulation)
- }
- }
-
- return
- }
-
- func predialysisEvaluationFormData(evaluation *models.PredialysisEvaluation, data []byte) (code int) {
- dataBody := make(map[string]interface{}, 0)
- err := json.Unmarshal(data, &dataBody)
- utils.InfoLog(string(data))
- if err != nil {
- utils.ErrorLog(err.Error())
- code = enums.ErrorCodeParamWrong
- return
- }
-
- if dataBody["weight_before"] != nil && reflect.TypeOf(dataBody["weight_before"]).String() == "string" {
- weightVefore, _ := strconv.ParseFloat(dataBody["weight_before"].(string), 64)
- evaluation.WeightBefore = weightVefore
- }
- // fmt.Println(dataBody["dry_weight"])
- // fmt.Println(reflect.TypeOf(dataBody["dry_weight"]).String())
-
- if dataBody["dry_weight"] != nil && reflect.TypeOf(dataBody["dry_weight"]).String() == "string" {
- additionalWeight, _ := strconv.ParseFloat(dataBody["dry_weight"].(string), 64)
- fmt.Println(additionalWeight)
- evaluation.DryWeight = additionalWeight
- }
-
- if dataBody["additional_weight"] != nil && reflect.TypeOf(dataBody["additional_weight"]).String() == "string" {
- additionalWeight, _ := strconv.ParseFloat(dataBody["additional_weight"].(string), 64)
- fmt.Println(additionalWeight)
- evaluation.AdditionalWeight = additionalWeight
- }
-
- if dataBody["temperature"] != nil && reflect.TypeOf(dataBody["temperature"]).String() == "string" {
- Temperature, _ := strconv.ParseFloat(dataBody["temperature"].(string), 64)
- evaluation.Temperature = Temperature
- }
-
- if dataBody["systolic_blood_pressure"] != nil && reflect.TypeOf(dataBody["systolic_blood_pressure"]).String() == "string" {
- systolicBloodPressure, _ := strconv.ParseFloat(dataBody["systolic_blood_pressure"].(string), 64)
- evaluation.SystolicBloodPressure = systolicBloodPressure
- }
-
- if dataBody["diastolic_blood_pressure"] != nil && reflect.TypeOf(dataBody["diastolic_blood_pressure"]).String() == "string" {
- diastolicBloodPressure, _ := strconv.ParseFloat(dataBody["diastolic_blood_pressure"].(string), 64)
- evaluation.DiastolicBloodPressure = diastolicBloodPressure
- }
-
- if dataBody["pulse_frequency"] != nil && reflect.TypeOf(dataBody["pulse_frequency"]).String() == "string" {
- pulseFrequency, _ := strconv.ParseFloat(dataBody["pulse_frequency"].(string), 64)
- evaluation.PulseFrequency = pulseFrequency
- }
-
- if dataBody["breathing_rate"] != nil && reflect.TypeOf(dataBody["breathing_rate"]).String() == "string" {
- breathingRate := dataBody["breathing_rate"].(string)
- evaluation.BreathingRate = breathingRate
- }
-
- if dataBody["last_post_dialysis"] != nil && reflect.TypeOf(dataBody["last_post_dialysis"]).String() == "string" {
- lastPostDialysis, _ := dataBody["last_post_dialysis"].(string)
- evaluation.LastPostDialysis = lastPostDialysis
- }
-
- if dataBody["dialysis_interphase"] != nil && reflect.TypeOf(dataBody["dialysis_interphase"]).String() == "string" {
- dialysisInterphase, _ := dataBody["dialysis_interphase"].(string)
- evaluation.DialysisInterphase = dialysisInterphase
- }
-
- if dataBody["symptom_before_dialysis"] != nil && reflect.TypeOf(dataBody["symptom_before_dialysis"]).String() == "string" {
- symptomBeforeDialysis, _ := dataBody["symptom_before_dialysis"].(string)
- evaluation.SymptomBeforeDialysis = symptomBeforeDialysis
- }
-
- if dataBody["catheter"] != nil && reflect.TypeOf(dataBody["catheter"]).String() == "string" {
- catheter, _ := dataBody["catheter"].(string)
- evaluation.Catheter = catheter
- }
-
- if dataBody["catheter_bend"] != nil && reflect.TypeOf(dataBody["catheter_bend"]).String() == "float64" {
- catheter_bend := int(dataBody["catheter_bend"].(float64))
- evaluation.CatheterBend = catheter_bend
- }
-
- if dataBody["complication"] != nil && reflect.TypeOf(dataBody["complication"]).String() == "string" {
- Complication, _ := dataBody["complication"].(string)
- evaluation.Complication = Complication
- }
-
- if dataBody["remark"] != nil && reflect.TypeOf(dataBody["remark"]).String() == "string" {
- remark := dataBody["remark"].(string)
- evaluation.Remark = remark
- }
-
- if dataBody["machine_type"] != nil && reflect.TypeOf(dataBody["machine_type"]).String() == "string" {
- machine_type := dataBody["machine_type"].(string)
- evaluation.MachineType = machine_type
- }
-
- if dataBody["blood_access_part_id"] != nil && reflect.TypeOf(dataBody["blood_access_part_id"]).String() == "string" {
- blood_access_part_id := dataBody["blood_access_part_id"].(string)
- evaluation.BloodAccessPartId = blood_access_part_id
- }
- //if dataBody["blood_access_part_id"] != nil && reflect.TypeOf(dataBody["blood_access_part_id"]).String() == "float64" {
- // blood_access_part_id := int64(dataBody["blood_access_part_id"].(float64))
- // evaluation.BloodAccessPartId = blood_access_part_id
- //}
- if dataBody["blood_access_part_opera_id"] != nil && reflect.TypeOf(dataBody["blood_access_part_opera_id"]).String() == "float64" {
- blood_access_part_opera_id := int64(dataBody["blood_access_part_opera_id"].(float64))
- evaluation.BloodAccessPartOperaId = blood_access_part_opera_id
- }
-
- if dataBody["internal_fistula"] != nil && reflect.TypeOf(dataBody["internal_fistula"]).String() == "string" {
- internal_fistula, _ := dataBody["internal_fistula"].(string)
- evaluation.InternalFistula = internal_fistula
- }
- if dataBody["internal_fistula_skin"] != nil && reflect.TypeOf(dataBody["internal_fistula_skin"]).String() == "string" {
- internal_fistula_skin := dataBody["internal_fistula_skin"].(string)
- evaluation.InternalFistulaSkin = internal_fistula_skin
- }
- if dataBody["is_hemorrhage"] != nil && reflect.TypeOf(dataBody["is_hemorrhage"]).String() == "string" {
- ishemorrhage, _ := dataBody["is_hemorrhage"].(string)
- is_hemorrhage, _ := strconv.ParseInt(ishemorrhage, 10, 64)
- evaluation.IsHemorrhage = is_hemorrhage
-
- //if dataBody["is_hemorrhage"] != nil && reflect.TypeOf(dataBody["is_hemorrhage"]).String() == "float64" {
- // is_hemorrhage := int64(dataBody["is_hemorrhage"].(float64))
- // fmt.Println("is_hemorrhage2222222222222222",is_hemorrhage)
- if is_hemorrhage != 1 && is_hemorrhage != 2 {
- is_hemorrhage = 0
- }
- evaluation.IsHemorrhage = is_hemorrhage
- if is_hemorrhage == 1 {
- if dataBody["hemorrhage"] != nil && reflect.TypeOf(dataBody["hemorrhage"]).String() == "string" {
- hemorrhage, _ := dataBody["hemorrhage"].(string)
- evaluation.Hemorrhage = hemorrhage
- }
- if dataBody["hemorrhage_other"] != nil && reflect.TypeOf(dataBody["hemorrhage_other"]).String() == "string" {
- hemorrhage_other, _ := dataBody["hemorrhage_other"].(string)
- evaluation.HemorrhageOther = hemorrhage_other
- }
- }
- } else {
- evaluation.IsHemorrhage = 0
- }
-
- if dataBody["blood_access_internal_fistula"] != nil && reflect.TypeOf(dataBody["blood_access_internal_fistula"]).String() == "string" {
- blood_access_internal_fistula, _ := dataBody["blood_access_internal_fistula"].(string)
- evaluation.BloodAccessInternalFistula = blood_access_internal_fistula
- }
-
- if dataBody["internal_fistula_other"] != nil && reflect.TypeOf(dataBody["internal_fistula_other"]).String() == "string" {
- internal_fistula_other, _ := dataBody["internal_fistula_other"].(string)
- evaluation.InternalFistulaOther = internal_fistula_other
- }
-
- if dataBody["blood_access_noise"] != nil && reflect.TypeOf(dataBody["blood_access_noise"]).String() == "float64" {
- blood_access_noise := int64(dataBody["blood_access_noise"].(float64))
- evaluation.BloodAccessNoise = blood_access_noise
- }
-
- if dataBody["puncture_way"] != nil && reflect.TypeOf(dataBody["puncture_way"]).String() == "string" {
- //puncture_way := int64(dataBody["puncture_way"].(float64))
- puncture_way := dataBody["puncture_way"].(string)
- evaluation.PunctureWay = puncture_way
- }
-
- if dataBody["venous_catheterization"] != nil && reflect.TypeOf(dataBody["venous_catheterization"]).String() == "float64" {
- venous_catheterization := int64(dataBody["venous_catheterization"].(float64))
- evaluation.VenousCatheterization = venous_catheterization
- }
-
- if dataBody["venous_catheterization_part"] != nil && reflect.TypeOf(dataBody["venous_catheterization_part"]).String() == "float64" {
- venous_catheterization_part := int64(dataBody["venous_catheterization_part"].(float64))
- evaluation.VenousCatheterizationPart = venous_catheterization_part
- }
-
- if dataBody["venous_catheterization_part_other"] != nil && reflect.TypeOf(dataBody["venous_catheterization_part_other"]).String() == "string" {
- venous_catheterization_part_other, _ := dataBody["venous_catheterization_part_other"].(string)
- evaluation.VenousCatheterizationPartOther = venous_catheterization_part_other
- }
-
- if dataBody["ductus_arantii"] != nil && reflect.TypeOf(dataBody["ductus_arantii"]).String() == "string" {
- ductus_arantii, _ := dataBody["ductus_arantii"].(string)
- evaluation.DuctusArantii = ductus_arantii
- }
-
- if dataBody["emergency_treatment"] != nil && reflect.TypeOf(dataBody["emergency_treatment"]).String() == "float64" {
- emergency_treatment := int64(dataBody["emergency_treatment"].(float64))
- evaluation.EmergencyTreatment = emergency_treatment
- }
- if dataBody["emergency_treatment_other"] != nil && reflect.TypeOf(dataBody["emergency_treatment_other"]).String() == "string" {
- emergency_treatment_other, _ := dataBody["emergency_treatment_other"].(string)
- evaluation.EmergencyTreatmentOther = emergency_treatment_other
- }
-
- if dataBody["dialysis_count"] != nil && reflect.TypeOf(dataBody["dialysis_count"]).String() == "string" {
- dialysis_count, _ := dataBody["dialysis_count"].(string)
- //count, _ := strconv.ParseInt(dialysis_count, 10, 64)
- evaluation.DialysisCount = dialysis_count
- }
-
- if dataBody["is_infect"] != nil && reflect.TypeOf(dataBody["is_infect"]).String() == "string" {
- is_infect, _ := dataBody["is_infect"].(string)
- infect, _ := strconv.ParseInt(is_infect, 10, 64)
- evaluation.IsInfect = infect
- }
-
- if dataBody["exposed"] != nil && reflect.TypeOf(dataBody["exposed"]).String() == "string" {
- exposed, _ := strconv.ParseFloat(dataBody["exposed"].(string), 64)
- evaluation.Exposed = exposed
- }
-
- if dataBody["skin"] != nil && reflect.TypeOf(dataBody["skin"]).String() == "string" {
- skin, _ := dataBody["skin"].(string)
- //skins, _ := strconv.ParseInt(skin, 10, 64)
- evaluation.Skin = skin
- }
-
- if dataBody["skin_other"] != nil && reflect.TypeOf(dataBody["skin_other"]).String() == "string" {
- skin_other, _ := dataBody["skin_other"].(string)
- evaluation.SkinOther = skin_other
- }
-
- if dataBody["infect_other"] != nil && reflect.TypeOf(dataBody["infect_other"]).String() == "string" {
- infect_other, _ := dataBody["infect_other"].(string)
- evaluation.InfectOther = infect_other
- }
-
- if dataBody["ductus_arantii_other"] != nil && reflect.TypeOf(dataBody["ductus_arantii_other"]).String() == "string" {
- ductus_arantii_other, _ := dataBody["ductus_arantii_other"].(string)
- evaluation.DuctusArantiiOther = ductus_arantii_other
- }
-
- if dataBody["puncture_needle"] != nil && reflect.TypeOf(dataBody["puncture_needle"]).String() == "string" {
- punctureNeedle, _ := dataBody["puncture_needle"].(string)
- evaluation.PunctureNeedle = punctureNeedle
- }
-
- if dataBody["humor_excessive_symptom"] != nil && reflect.TypeOf(dataBody["humor_excessive_symptom"]).String() == "string" {
-
- humor_excessive_symptom, _ := dataBody["humor_excessive_symptom"].(string)
-
- evaluation.HumorExcessiveSymptom = humor_excessive_symptom
- }
-
- if dataBody["pinholing"] != nil && reflect.TypeOf(dataBody["pinholing"]).String() == "string" {
- pinholing := dataBody["pinholing"].(string)
- evaluation.Phinholing = pinholing
- }
-
- if dataBody["catheter_suture"] != nil && reflect.TypeOf(dataBody["catheter_suture"]).String() == "string" {
- catheter_suture := dataBody["catheter_suture"].(string)
- evaluation.CatheterSuture = catheter_suture
- }
-
- if dataBody["catheter_suture_other"] != nil && reflect.TypeOf(dataBody["catheter_suture_other"]).String() == "string" {
- catheter_suture_other := dataBody["catheter_suture_other"].(string)
- evaluation.CatheterSutureOther = catheter_suture_other
- }
-
- if dataBody["urine_volume"] != nil && reflect.TypeOf(dataBody["urine_volume"]).String() == "string" {
- urine_volume, _ := strconv.ParseFloat(dataBody["urine_volume"].(string), 64)
- evaluation.UrineVolume = urine_volume
- }
-
- if dataBody["edema"] != nil && reflect.TypeOf(dataBody["edema"]).String() == "string" {
- edema := dataBody["edema"].(string)
- evaluation.Edema = edema
- }
-
- if dataBody["special_treatment"] != nil && reflect.TypeOf(dataBody["special_treatment"]).String() == "string" {
- specialTreatment := dataBody["special_treatment"].(string)
- evaluation.SpecialTreatment = specialTreatment
- }
-
- if dataBody["catheter_maintenance"] != nil && reflect.TypeOf(dataBody["catheter_maintenance"]).String() == "string" {
- catheter_maintenance := dataBody["catheter_maintenance"].(string)
- evaluation.CatheterMaintenance = catheter_maintenance
- }
-
- if dataBody["thromubus_type"] != nil && reflect.TypeOf(dataBody["thromubus_type"]).String() == "float64" {
-
- thromubusType := int64(dataBody["thromubus_type"].(float64))
-
- evaluation.ThromubusType = thromubusType
- }
-
- if dataBody["thrombus_av"] != nil && reflect.TypeOf(dataBody["thrombus_av"]).String() == "string" {
- thrombus_av := dataBody["thrombus_av"].(string)
- evaluation.ThrombusAv = thrombus_av
- }
-
- if dataBody["thromubus_a"] != nil && reflect.TypeOf(dataBody["thromubus_a"]).String() == "string" {
- thromubus_a := dataBody["thromubus_a"].(string)
- evaluation.ThromubusA = thromubus_a
- }
-
- if dataBody["thromubus_v"] != nil && reflect.TypeOf(dataBody["thromubus_v"]).String() == "string" {
- thromubus_v := dataBody["thromubus_v"].(string)
- evaluation.ThromubusV = thromubus_v
- }
-
- if dataBody["dehydration"] != nil && reflect.TypeOf(dataBody["dehydration"]).String() == "string" {
- dehydration := dataBody["dehydration"].(string)
- evaluation.Dehydration = dehydration
- }
-
- if dataBody["period"] != nil && reflect.TypeOf(dataBody["period"]).String() == "float64" {
- period := int64(dataBody["period"].(float64))
- evaluation.Period = period
- }
-
- if dataBody["estimated_food_intake"] != nil && reflect.TypeOf(dataBody["estimated_food_intake"]).String() == "string" {
- estimated_food_intake := dataBody["estimated_food_intake"].(string)
- evaluation.EstimatedFoodIntake = estimated_food_intake
- }
-
- if dataBody["blood_pressure_during_dialysis"] != nil && reflect.TypeOf(dataBody["blood_pressure_during_dialysis"]).String() == "string" {
- blood_pressure_during_dialysis := dataBody["blood_pressure_during_dialysis"].(string)
- evaluation.BloodPressureDuringDialysis = blood_pressure_during_dialysis
- }
-
- if dataBody["pre_dialysis_drugs"] != nil && reflect.TypeOf(dataBody["pre_dialysis_drugs"]).String() == "string" {
- pre_dialysis_drugs := dataBody["pre_dialysis_drugs"].(string)
- evaluation.PreDialysisDrugs = pre_dialysis_drugs
- }
-
- if dataBody["urea_befor"] != nil && reflect.TypeOf(dataBody["urea_befor"]).String() == "string" {
- urea_befor := dataBody["urea_befor"].(string)
- evaluation.UreaBefor = urea_befor
- }
-
- if dataBody["suction"] != nil && reflect.TypeOf(dataBody["suction"]).String() == "string" {
- suction := dataBody["suction"].(string)
-
- evaluation.Suction = suction
- }
- if dataBody["weight_befor_remake"] != nil && reflect.TypeOf(dataBody["weight_befor_remake"]).String() == "string" {
- weight_befor_remake := dataBody["weight_befor_remake"].(string)
-
- evaluation.WeightBeforRemake = weight_befor_remake
- }
-
- if dataBody["height"] != nil && reflect.TypeOf(dataBody["height"]).String() == "string" {
- height := dataBody["height"].(string)
-
- evaluation.Height = height
- }
-
- if dataBody["age"] != nil && reflect.TypeOf(dataBody["age"]).String() == "string" {
- age := dataBody["age"].(string)
-
- evaluation.Age = age
- }
-
- if dataBody["his_department"] != nil && reflect.TypeOf(dataBody["his_department"]).String() == "string" {
- his_department := dataBody["his_department"].(string)
-
- evaluation.HisDepartment = his_department
- }
-
- if dataBody["his_bed"] != nil && reflect.TypeOf(dataBody["his_bed"]).String() == "string" {
- his_bed := dataBody["his_bed"].(string)
-
- evaluation.HisBed = his_bed
- }
-
- if dataBody["point_puncture"] != nil && reflect.TypeOf(dataBody["point_puncture"]).String() == "string" {
- point_puncture := dataBody["point_puncture"].(string)
-
- evaluation.PointPuncture = point_puncture
- }
-
- if dataBody["catheter_evaluation_program"] != nil && reflect.TypeOf(dataBody["catheter_evaluation_program"]).String() == "string" {
- catheter_evaluation_program := dataBody["catheter_evaluation_program"].(string)
-
- evaluation.CatheterEvaluationProgram = catheter_evaluation_program
- }
-
- if dataBody["skin_site_catheterization"] != nil && reflect.TypeOf(dataBody["skin_site_catheterization"]).String() == "string" {
- skin_site_catheterization := dataBody["skin_site_catheterization"].(string)
-
- evaluation.SkinSiteCatheterization = skin_site_catheterization
- }
-
- if dataBody["whether_unobstructed"] != nil && reflect.TypeOf(dataBody["whether_unobstructed"]).String() == "float64" {
- whether_unobstructed := int64(dataBody["whether_unobstructed"].(float64))
- evaluation.WhetherUnobstructed = whether_unobstructed
- }
-
- if dataBody["lien_necessary"] != nil && reflect.TypeOf(dataBody["lien_necessary"]).String() == "float64" {
- lien_necessary := int64(dataBody["lien_necessary"].(float64))
- evaluation.LienNecessary = lien_necessary
- }
-
- if dataBody["pathway_formation_time"] != nil && reflect.TypeOf(dataBody["pathway_formation_time"]).String() == "string" {
- pathway_formation_time := dataBody["pathway_formation_time"].(string)
- timeLayout := "2006-01-02"
- loc, _ := time.LoadLocation("Local")
- var startTime int64
- if len(pathway_formation_time) > 0 {
- theTime, _ := time.ParseInLocation(timeLayout+" 15:04:05", pathway_formation_time+" 00:00:00", loc)
-
- startTime = theTime.Unix()
- }
-
- evaluation.PathwayFormationTime = startTime
- }
-
- if dataBody["befor_symptoms"] != nil && reflect.TypeOf(dataBody["befor_symptoms"]).String() == "string" {
- befor_symptoms := dataBody["befor_symptoms"].(string)
- evaluation.BeforSymptoms = befor_symptoms
-
- }
-
- if dataBody["washing_time"] != nil && reflect.TypeOf(dataBody["washing_time"]).String() == "string" {
- washing_time, _ := dataBody["washing_time"].(string)
- evaluation.WashingTime = washing_time
- }
-
- if dataBody["warsh_count"] != nil && reflect.TypeOf(dataBody["warsh_count"]).String() == "string" {
- warsh_count, _ := dataBody["warsh_count"].(string)
- evaluation.WarshCount = warsh_count
- }
-
- if dataBody["puncture_needle_direction"] != nil && reflect.TypeOf(dataBody["puncture_needle_direction"]).String() == "string" {
- puncture_needle_direction, _ := dataBody["puncture_needle_direction"].(string)
- evaluation.PunctureNeedleDirection = puncture_needle_direction
- }
-
- if dataBody["symptom_before_dialysis_other"] != nil && reflect.TypeOf(dataBody["symptom_before_dialysis_other"]).String() == "string" {
- symptom_before_dialysis_other, _ := dataBody["symptom_before_dialysis_other"].(string)
- evaluation.SymptomBeforeDialysisOther = symptom_before_dialysis_other
- }
- return
- }
-
- func adviceFormData(advice *models.DoctorAdvice, data []byte, action string) (code int) {
- dataBody := make(map[string]interface{}, 0)
- err := json.Unmarshal(data, &dataBody)
- if err != nil {
- utils.ErrorLog(err.Error())
- code = enums.ErrorCodeParamWrong
- return
- }
-
- timeLayout := "2006-01-02"
- loc, _ := time.LoadLocation("Local")
- isChild := false
-
- if action == "create" {
- if dataBody["advice_type"] == nil || reflect.TypeOf(dataBody["advice_type"]).String() != "float64" {
- utils.ErrorLog("advice_type")
- code = enums.ErrorCodeParamWrong
- return
- }
- adviceType := int64(dataBody["advice_type"].(float64))
- if adviceType != 1 && adviceType != 2 {
- utils.ErrorLog("advice_type != 1&&2")
- code = enums.ErrorCodeParamWrong
- return
- }
- advice.AdviceType = adviceType
-
- if dataBody["advice_date"] == nil || reflect.TypeOf(dataBody["advice_date"]).String() != "string" {
- utils.ErrorLog("advice_date")
- code = enums.ErrorCodeParamWrong
- return
- }
- adviceDate, _ := dataBody["advice_date"].(string)
- if len(adviceDate) == 0 {
- utils.ErrorLog("len(adviceDate) == 0")
- code = enums.ErrorCodeParamWrong
- return
- }
- theTime, err := time.ParseInLocation(timeLayout, adviceDate, loc)
- if err != nil {
- utils.ErrorLog(err.Error())
- code = enums.ErrorCodeParamWrong
- return
- }
- advice.AdviceDate = theTime.Unix()
- advice.RecordDate = theTime.Unix()
-
- if dataBody["parent_id"] != nil && reflect.TypeOf(dataBody["parent_id"]).String() == "float64" {
- parentId := int64(dataBody["parent_id"].(float64))
- advice.ParentId = parentId
- if parentId > 0 {
- isChild = true
- }
- }
-
- } else {
- isChild = advice.ParentId > 0
- }
-
- if !isChild {
-
- if dataBody["start_time"] == nil || reflect.TypeOf(dataBody["start_time"]).String() != "string" {
- utils.ErrorLog("start_time")
- code = enums.ErrorCodeParamWrong
- return
- }
- startTime, _ := dataBody["start_time"].(string)
- if len(startTime) == 0 {
- utils.ErrorLog("len(start_time) == 0")
- code = enums.ErrorCodeParamWrong
- return
- }
- theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", startTime, loc)
- if err != nil {
- utils.ErrorLog(err.Error())
- code = enums.ErrorCodeParamWrong
- return
- }
- advice.StartTime = theTime.Unix()
-
- if dataBody["delivery_way"] != nil && reflect.TypeOf(dataBody["delivery_way"]).String() == "string" {
- deliveryWay, _ := dataBody["delivery_way"].(string)
- advice.DeliveryWay = deliveryWay
- }
-
- if dataBody["execution_frequency"] != nil && reflect.TypeOf(dataBody["execution_frequency"]).String() == "string" {
- executionFrequency, _ := dataBody["execution_frequency"].(string)
- advice.ExecutionFrequency = executionFrequency
- }
- }
-
- if dataBody["delivery_way"] != nil && reflect.TypeOf(dataBody["delivery_way"]).String() == "string" {
- deliveryWay, _ := dataBody["delivery_way"].(string)
- advice.DeliveryWay = deliveryWay
- }
-
- if dataBody["execution_frequency"] != nil && reflect.TypeOf(dataBody["execution_frequency"]).String() == "string" {
- executionFrequency, _ := dataBody["execution_frequency"].(string)
- advice.ExecutionFrequency = executionFrequency
- }
-
- if dataBody["advice_name"] == nil || reflect.TypeOf(dataBody["advice_name"]).String() != "string" {
- utils.ErrorLog("advice_name")
- code = enums.ErrorCodeParamWrong
- return
- }
- adviceName, _ := dataBody["advice_name"].(string)
- if len(adviceName) == 0 {
- utils.ErrorLog("len(advice_name) == 0")
- code = enums.ErrorCodeParamWrong
- return
- }
- advice.AdviceName = adviceName
-
- if dataBody["advice_desc"] != nil && reflect.TypeOf(dataBody["advice_desc"]).String() == "string" {
- adviceDsc, _ := dataBody["advice_desc"].(string)
- advice.AdviceDesc = adviceDsc
- }
-
- if dataBody["way"] == nil {
- advice.Way = 0
-
- } else {
- if dataBody["way"] != nil || reflect.TypeOf(dataBody["way"]).String() == "float64" {
- way := int64(dataBody["way"].(float64))
- advice.Way = way
- }
-
- }
-
- if dataBody["drug_id"] == nil {
- advice.DrugId = 0
- } else {
- if dataBody["drug_id"] != nil || reflect.TypeOf(dataBody["drug_id"]).String() == "float64" {
- drug_id := int64(dataBody["drug_id"].(float64))
- advice.DrugId = drug_id
- }
- }
-
- if dataBody["drug_name_id"] == nil {
- advice.DrugNameId = 0
- } else {
- if dataBody["drug_name_id"] != nil || reflect.TypeOf(dataBody["drug_name_id"]).String() == "float64" {
- drug_name_id := int64(dataBody["drug_name_id"].(float64))
- advice.DrugNameId = drug_name_id
-
- }
- }
-
- if dataBody["single_dose"] != nil && reflect.TypeOf(dataBody["single_dose"]).String() == "string" {
- singleDose, _ := strconv.ParseFloat(dataBody["single_dose"].(string), 64)
- advice.SingleDose = singleDose
- }
-
- if dataBody["single_dose_unit"] != nil && reflect.TypeOf(dataBody["single_dose_unit"]).String() == "string" {
- singleDoseUnit, _ := dataBody["single_dose_unit"].(string)
- advice.SingleDoseUnit = singleDoseUnit
- }
-
- if dataBody["drug_spec"] != nil && reflect.TypeOf(dataBody["drug_spec"]).String() == "string" {
- drugSpec, _ := strconv.ParseFloat(dataBody["drug_spec"].(string), 64)
- advice.DrugSpec = drugSpec
- }
-
- if dataBody["drug_spec_unit"] != nil && reflect.TypeOf(dataBody["drug_spec_unit"]).String() == "string" {
- drugSpecUnit, _ := dataBody["drug_spec_unit"].(string)
- advice.DrugSpecUnit = drugSpecUnit
- }
-
- if dataBody["prescribing_number"] != nil && reflect.TypeOf(dataBody["prescribing_number"]).String() == "string" {
- prescribingNumber, _ := strconv.ParseFloat(dataBody["prescribing_number"].(string), 64)
- advice.PrescribingNumber = prescribingNumber
- }
-
- if dataBody["prescribing_number_unit"] != nil && reflect.TypeOf(dataBody["prescribing_number_unit"]).String() == "string" {
- prescribingNumberUnit, _ := dataBody["prescribing_number_unit"].(string)
- advice.PrescribingNumberUnit = prescribingNumberUnit
- }
-
- if dataBody["remark"] != nil && reflect.TypeOf(dataBody["remark"]).String() == "string" {
- remark, _ := dataBody["remark"].(string)
- advice.Remark = remark
- }
-
- return
- }
-
- func (c *PatientApiController) GetPatientEducation() {
- patientID, _ := c.GetInt64("patient_id", 0)
- page, _ := c.GetInt64("page", 0)
- limit, _ := c.GetInt64("limit", 0)
- startTime := c.GetString("start_time", "")
- endTime := c.GetString("end_time", "")
-
- if page <= 0 {
- page = 1
- }
- if limit <= 0 {
- limit = 10
- }
- if patientID <= 0 {
- c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
- return
- }
-
- timeLayout := "2006-01-02"
- loc, _ := time.LoadLocation("Local")
-
- var theStartTIme int64
- if len(startTime) > 0 {
- theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", startTime+" 00:00:00", loc)
- if err != nil {
- theStartTIme = 0
- }
- theStartTIme = theTime.Unix()
- }
- var theEndtTIme int64
- if len(endTime) > 0 {
- theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", endTime+" 23:59:59", loc)
- if err != nil {
- theEndtTIme = 0
- }
- theEndtTIme = theTime.Unix()
- }
-
- adminUserInfo := c.GetMobileAdminUserInfo()
- edus, total, _ := service.GetPatientTreatmentSummaryList(adminUserInfo.Org.Id, patientID, page, limit, theStartTIme, theEndtTIme)
- c.ServeSuccessJSON(map[string]interface{}{
- "total": total,
- "edus": edus,
- })
- return
-
- }
-
- func (c *PatientApiController) GetPatientSchedulesList() {
- patientID, _ := c.GetInt64("patient_id", 0)
- page, _ := c.GetInt64("page", 0)
- limit, _ := c.GetInt64("limit", 0)
- if patientID <= 0 {
- c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
- return
- }
- adminUserInfo := c.GetMobileAdminUserInfo()
- todayTime := time.Now().Format("2006-01-02")
-
- timeLayout := "2006-01-02 15:04:05"
- loc, _ := time.LoadLocation("Local")
-
- var theStartTime int64
- theTime, _ := time.ParseInLocation(timeLayout, todayTime+" 00:00:00", loc)
- theStartTime = theTime.Unix()
-
- schedules, _ := service.GetPatientScheduleList(adminUserInfo.Org.Id, patientID, page, limit, theStartTime)
- if len(schedules) > 0 {
- for index, item := range schedules {
- _, week := time.Unix(item.ScheduleDate, 0).ISOWeek()
- schedules[index].Week = int64(week)
- }
- }
- c.ServeSuccessJSON(map[string]interface{}{
- "schedules": schedules,
- })
- return
- }
-
- func (c *PatientApiController) GetRecords() {
-
- patientID, _ := c.GetInt64("patient_id", 0)
- page, _ := c.GetInt64("page", 0)
- limit, _ := c.GetInt64("limit", 0)
- startTime := c.GetString("start_time", "")
- endTime := c.GetString("end_time", "")
- mode_id, _ := c.GetInt64("mode_id", 0)
-
- if page <= 0 {
- page = 1
- }
- if limit <= 0 {
- limit = 10
- }
- if patientID <= 0 {
- c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
- return
- }
-
- timeLayout := "2006-01-02"
- loc, _ := time.LoadLocation("Local")
-
- var theStartTIme int64
- if len(startTime) > 0 {
- theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", startTime+" 00:00:00", loc)
- if err != nil {
- theStartTIme = 0
- }
- theStartTIme = theTime.Unix()
- }
- var theEndtTIme int64
- if len(endTime) > 0 {
- theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", endTime+" 23:59:59", loc)
- if err != nil {
- theEndtTIme = 0
- }
- theEndtTIme = theTime.Unix()
- }
-
- adminUserInfo := c.GetMobileAdminUserInfo()
-
- records, total, _ := service.GetPatientDialysisRecord(adminUserInfo.Org.Id, patientID, page, limit, theStartTIme, theEndtTIme, mode_id)
-
- c.ServeSuccessJSON(map[string]interface{}{
- "total": total,
- "records": records,
- })
- return
- }
-
- func (c *PatientApiController) GetPatientMonitor() {
- partition, _ := c.GetInt64("partition")
- monitorDate := c.GetString("date")
- patient_id, _ := c.GetInt64("patient_id")
-
- timeLayout := "2006-01-02"
- loc, _ := time.LoadLocation("Local")
-
- var theStartTime int64
- if len(monitorDate) > 0 {
- theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", monitorDate+" 00:00:00", loc)
- if err != nil {
- theStartTime = 0
- }
- theStartTime = theTime.Unix()
- }
- adminInfo := c.GetMobileAdminUserInfo()
- orgID := adminInfo.Org.Id
- monitor, err := service.GetMonitorRecord(orgID, theStartTime, partition, patient_id)
-
- if err != nil {
- c.ErrorLog("获取排班信息失败:%v", err)
- c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
- } else {
- if len(monitor) > 0 {
- //获取所有床位
- numberList, _ := service.GetAllDeviceNumberByList(orgID)
- //获取所有分区
- zoneList, _ := service.GetAllZoneByList(orgID)
- //获取透析处方
- prescriptions, _ := service.GetAllPrescriptionByListSix(orgID, theStartTime)
- //获取透前评估
- assessmentBefores, _ := service.GetAllAssessmentBeforesByListOne(orgID, theStartTime)
- //获取上机
- dialysisOrders, _ := service.GetAllDialysisOrdersByListSix(orgID, theStartTime)
- //获取透后
- AssessmentAfterDislysis, _ := service.GetAllAssessmentAfterDislysisByListSix(orgID, theStartTime)
-
- //获取透后监测
- monitorlist, _ := service.GetAllMonitorList(orgID, theStartTime)
-
- //获取所有的患者
- patients, _ := service.GetAllPatientListByListOne(orgID)
-
- for _, it := range patients {
- if orgID == 10445 {
- if theStartTime <= 1703952000 {
- listOne, _ := service.GetDialysisOrderCountTwentyEight(orgID, it.ID, theStartTime)
- it.TotalDialysis = listOne.Count
-
- }
-
- if theStartTime >= 1704038400 {
- listOrder, _ := service.GetDialysisOrderCountTenEight(it.ID, theStartTime)
- it.TotalDialysis = listOrder.Count
- }
- }
- }
-
- //获取所有透析模式
- treatments, _ := service.GetAllTreatModeByList(orgID)
-
- for key, item := range monitor {
- // 获取床位信息
- for _, it := range numberList {
- if item.BedId == it.ID {
- monitor[key].DeviceNumber = it
- break
- }
- }
-
- //获取分区信息
- for _, it := range zoneList {
- if item.PartitionId == it.ID {
- monitor[key].DeviceZone = it
- }
- }
-
- for _, prescription := range prescriptions {
- if item.PatientId == prescription.PatientId {
- monitor[key].Prescription = prescription
- break
- }
- }
-
- // 透前评估
- for _, assessmentBefore := range assessmentBefores {
- if item.PatientId == assessmentBefore.PatientId {
- monitor[key].AssessmentBeforeDislysis = assessmentBefore
- break
- }
- }
-
- // 透析上下机
- for _, dialysisOrder := range dialysisOrders {
- if item.PatientId == dialysisOrder.PatientId {
- monitor[key].DialysisOrder = dialysisOrder
- break
- }
- }
-
- // 治疗小节
- for _, afterDislysis := range AssessmentAfterDislysis {
- if item.PatientId == afterDislysis.PatientId {
- monitor[key].AssessmentAfterDislysis = afterDislysis
- break
- }
- }
-
- for _, it := range monitorlist {
- if item.PatientId == it.PatientId {
- monitor[key].MonitoringRecord = append(monitor[key].MonitoringRecord, it)
- }
- }
-
- for _, patient := range patients {
- if item.PatientId == patient.ID {
- monitor[key].MonitorPatients = patient
- break
- }
- }
-
- for _, treatment := range treatments {
- if item.ModeId == treatment.ID {
- monitor[key].TreatmentMode = treatment
- break
- }
- }
- }
- }
-
- }
-
- //获取患者的透析次数
- //count, err := service.GetDialysisCount(orgID, partition)
-
- patients, err := service.GetAllpatientFourty(orgID)
- if err == nil {
- c.ServeSuccessJSON(map[string]interface{}{
- "monitor": monitor,
- //"patientCount": count,
- "patients": patients,
- })
- } else {
- c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
- }
- }
-
- // /m/api/monitor/patient [get] 搜索病人的测量记录
- // @param keyword:string 病人姓名或透析号
- // @param page:int
- func (this *PatientApiController) SearchMonitorPatient() {
- keyword := this.GetString("keyword")
- page, _ := this.GetInt("page")
- if page <= 0 {
- page = 1
- }
- if len(keyword) == 0 {
- this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
- return
- }
-
- adminUserInfo := this.GetMobileAdminUserInfo()
- monitors, getMonitorErr := service.MobileGetMonitorsWithPatient(adminUserInfo.Org.Id, keyword, page)
- if getMonitorErr != nil {
- this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
- return
- } else {
- this.ServeSuccessJSON(map[string]interface{}{
- "monitor": monitors,
- })
- }
- }
-
- func (c *PatientApiController) GetPatientDialysisSolutionList() {
- id, _ := c.GetInt64("id", 0)
- page, _ := c.GetInt64("page", 0)
- limit, _ := c.GetInt64("limit", 0)
- if id <= 0 {
- c.ServeSuccessJSON(map[string]interface{}{
- "solutions": nil,
- })
- return
- }
- if page <= 0 {
- page = 1
- }
- if limit <= 0 {
- limit = 10
- }
-
- adminInfo := c.GetMobileAdminUserInfo()
-
- solutions, total, _ := service.GetPatientDialysisSolutionList(adminInfo.Org.Id, id, page, limit)
- c.ServeSuccessJSON(map[string]interface{}{
- "solutions": solutions,
- "total": total,
- })
- return
- }
-
- // GetDoctorAdvices 医嘱列表
- func (c *PatientApiController) GetDoctorAdvices() {
- id, _ := c.GetInt64("id", 0)
- adviceType, _ := c.GetInt64("advice_type", 0)
- stopType, _ := c.GetInt64("stop_state", 0)
- startTime := c.GetString("start_time", "")
- endTime := c.GetString("end_time", "")
- keywords := c.GetString("keywords", "")
-
- need, _ := c.GetInt64("need_doctor", 0)
-
- adminUserInfo := c.GetMobileAdminUserInfo()
-
- timeLayout := "2006-01-02"
- loc, _ := time.LoadLocation("Local")
-
- var theStartTIme int64
- if len(startTime) > 0 {
- theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", startTime+" 00:00:00", loc)
- if err != nil {
- c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
- return
- }
- theStartTIme = theTime.Unix()
- }
- var theEndtTIme int64
- if len(endTime) > 0 {
- theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", endTime+" 23:59:59", loc)
- if err != nil {
- utils.ErrorLog(err.Error())
- c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
- return
- }
- theEndtTIme = theTime.Unix()
- }
-
- advices, total, _ := service.GetDoctorAdviceList(adminUserInfo.Org.Id, id, adviceType, stopType, theStartTIme, theEndtTIme, keywords)
-
- if need == 1 {
- users, _ := service.GetAllAdminUsers(adminUserInfo.Org.Id, adminUserInfo.App.Id)
- c.ServeSuccessJSON(map[string]interface{}{
- "advices": advices,
- "total": total,
- "users": users,
- })
- } else {
- c.ServeSuccessJSON(map[string]interface{}{
- "advices": advices,
- "total": total,
- "users": []string{},
- })
- }
- return
-
- }
-
- func (c *PatientApiController) GetPrintDialysisOrder() {
- xtno := c.GetString("xtno")
- xtdate := c.GetString("xtdate")
-
- timeLayout := "2006-01-02"
- loc, _ := time.LoadLocation("Local")
- theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", xtdate+" 00:00:00", loc)
- if err != nil {
- c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
- return
- }
- xttime := theTime.Unix()
- //获取当前日期月份的第一天
- firstmonth := service.GetFirstDateOfMonth(theTime)
- firstMonthDate := firstmonth.Unix()
- operatorIDs := make([]int64, 0)
-
- adminUserInfo := c.GetMobileAdminUserInfo()
-
- adminUser, _ := service.GetAllAdminUsers(adminUserInfo.Org.Id, adminUserInfo.App.Id)
-
- patientInfo, _ := service.FindPatientWithDeviceByNo(adminUserInfo.Org.Id, xtno, xttime)
-
- //透析单
- dialysisOrder, _ := service.MobileGetSchedualDialysisRecord(adminUserInfo.Org.Id, patientInfo.ID, xttime)
- if dialysisOrder != nil {
- if dialysisOrder.FinishNurse > 0 {
- operatorIDs = append(operatorIDs, dialysisOrder.FinishNurse)
- }
- if dialysisOrder.StartNurse > 0 {
- operatorIDs = append(operatorIDs, dialysisOrder.StartNurse)
- }
- }
-
- last_order, _ := service.GetLastTimeOrder(adminUserInfo.Org.Id, patientInfo.ID, xttime)
-
- //透前评估
- PredialysisEvaluation, _ := service.FindPredialysisEvaluationById(adminUserInfo.Org.Id, patientInfo.ID, xttime)
-
- //透后评估
- AssessmentAfterDislysis, _ := service.FindAssessmentAfterDislysisById(adminUserInfo.Org.Id, patientInfo.ID, xttime)
- if AssessmentAfterDislysis.Modifier > 0 {
- operatorIDs = append(operatorIDs, AssessmentAfterDislysis.Modifier)
- }
- //透析处方
- dialysisPrescription, _ := service.FindPatientPrescribeWidyDevideById(adminUserInfo.Org.Id, patientInfo.ID, xttime)
- if dialysisPrescription.PrescriptionDoctor > 0 {
- operatorIDs = append(operatorIDs, dialysisPrescription.PrescriptionDoctor)
- }
-
- dialysis_count, _ := service.GetDialysisOrderCount(adminUserInfo.Org.Id, patientInfo.ID, xttime)
- patientInfo.TotalDialysis = dialysis_count
-
- //临时医嘱
- DoctorAdvice, _ := service.FindDoctorAdviceOrderById(adminUserInfo.Org.Id, patientInfo.ID, xttime)
-
- hisAdvice, err := service.GetHisDoctorPatientById(adminUserInfo.Org.Id, patientInfo.ID, xttime)
- config, err := service.GetHisDoctorConfig(adminUserInfo.Org.Id)
-
- project_config, _ := service.GetHisProjectConfig(adminUserInfo.Org.Id)
-
- lastSchedule, _ := service.FindLastSchedule(adminUserInfo.Org.Id, patientInfo.ID, xttime)
- projects, _ := service.FindAllHisProjectById(adminUserInfo.Org.Id, patientInfo.ID, xttime)
-
- if adminUserInfo.Org.Id != 10489 {
-
- if config.IsOpen == 1 && project_config.IsOpen == 1 && len(projects) > 0 {
- for _, item := range projects {
- cnt, _ := strconv.ParseFloat(item.Count, 64)
- var advice models.HisDoctorAdviceInfo
- advice.ID = item.ID
- advice.Checker = item.Checker
- advice.CheckTime = item.CheckTime
- advice.CheckState = item.CheckState
- advice.ExecutionState = item.ExecutionState
- advice.ExecutionStaff = item.ExecutionStaff
- //advice.PrescribingNumber = float64(item.Count)
- advice.PrescribingNumber = cnt
- advice.PrescribingNumberUnit = item.Unit
- advice.AdviceDoctor = item.Doctor
- if item.Type == 3 {
- advice.AdviceName = item.GoodInfo.GoodName
- advice.PrescribingNumberUnit = item.GoodInfo.PackingUnit
- } else if item.Type == 2 {
- advice.AdviceName = item.HisProject.ProjectName
- }
- advice.StartTime = item.StartTime
- hisAdvice = append(hisAdvice, &advice)
- }
-
- }
- }
-
- if len(DoctorAdvice) > 0 {
- for _, item := range DoctorAdvice {
- if item.AdviceDoctor > 0 {
- operatorIDs = append(operatorIDs, item.AdviceDoctor)
- }
- if item.ExecutionStaff > 0 {
- operatorIDs = append(operatorIDs, item.ExecutionStaff)
- }
- if item.Checker > 0 {
- operatorIDs = append(operatorIDs, item.Checker)
- }
- }
- }
-
- //DoctorAdvice, _ := service.FindDoctorAdviceOrderById(adminUserInfo.Org.Id, patientInfo.ID, xttime)
-
- //透析监测
- Record, _ := service.FindAllMonitorRecord(adminUserInfo.Org.Id, patientInfo.ID, xttime)
- //透析小结
- TreatmentSummary, _ := service.FindTreatmentSummaryById(adminUserInfo.Org.Id, patientInfo.ID, xttime)
-
- //接诊评估
- receiverTreatmentAccess, _ := service.FindReceiverTreatmentAccessRecordById(adminUserInfo.Org.Id, patientInfo.ID, xttime)
-
- //相关操作对应的操作人
- //operators, _ := service.GetAdminUserES(adminUserInfo.Org.Id, adminUserInfo.App.Id, operatorIDs)
- operators, err := service.GetAllStarfEs(adminUserInfo.Org.Id)
- templateInfo, _ := service.GetOrgInfoTemplate(adminUserInfo.Org.Id)
- check, _ := service.FindDoubleCheckById(adminUserInfo.Org.Id, patientInfo.ID, xttime)
-
- dialysiscount, err := service.GetDialysisCountByPatientId(firstMonthDate, xttime, patientInfo.ID, adminUserInfo.Org.Id)
- lastWeight, _ := service.MobileGetLast(adminUserInfo.Org.Id, patientInfo.ID, xttime)
- if config.IsOpen == 1 {
- c.ServeSuccessJSON(map[string]interface{}{
- "users": adminUser,
- "patientInfo": patientInfo,
- "PredialysisEvaluation": PredialysisEvaluation,
- "AssessmentAfterDislysis": AssessmentAfterDislysis,
- "dialysisPrescription": dialysisPrescription,
- "advices": hisAdvice,
- "monitors": Record,
- "summary": TreatmentSummary,
- "receiverTreatmentAccess": receiverTreatmentAccess,
- "dialysisOrder": dialysisOrder,
- "operators": operators,
- "org_template_info": templateInfo,
- "check": check,
- "dialysiscount": dialysiscount,
- "last_order": last_order,
- "projects": projects,
- "project_config": project_config,
- "lastWeight": lastWeight,
- "lastSchedule": lastSchedule,
- "DoctorAdvice": DoctorAdvice,
- "hisAdvice": hisAdvice,
- })
- }
-
- if config.IsOpen == 0 || config.IsOpen == 2 {
- c.ServeSuccessJSON(map[string]interface{}{
- "users": adminUser,
- "patientInfo": patientInfo,
- "PredialysisEvaluation": PredialysisEvaluation,
- "AssessmentAfterDislysis": AssessmentAfterDislysis,
- "dialysisPrescription": dialysisPrescription,
- "advices": DoctorAdvice,
- "monitors": Record,
- "summary": TreatmentSummary,
- "receiverTreatmentAccess": receiverTreatmentAccess,
- "dialysisOrder": dialysisOrder,
- "operators": operators,
- "org_template_info": templateInfo,
- "check": check,
- "dialysiscount": dialysiscount,
- "last_order": last_order,
- "projects": projects,
- "project_config": project_config,
- "lastWeight": lastWeight,
- "lastSchedule": lastSchedule,
- "DoctorAdvice": DoctorAdvice,
- "hisAdvice": hisAdvice,
- })
- }
-
- }
-
- func (c *PatientApiController) CreateGroupAdvice() {
- is_child, _ := c.GetInt64("is_child", 0)
-
- if is_child == 1 {
- patient, _ := c.GetInt64("id", 0)
- if patient <= 0 {
- c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
- return
- }
- adminUserInfo := c.GetMobileAdminUserInfo()
-
- patientInfo, _ := service.FindPatientById(adminUserInfo.Org.Id, patient)
- if patientInfo.ID == 0 {
- c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodePatientNoExist)
- return
- }
-
- group_no, _ := c.GetInt64("group_no")
- if group_no <= 0 {
- group_no = 0
- }
-
- dataBody := make(map[string]interface{}, 0)
- err := json.Unmarshal(c.Ctx.Input.RequestBody, &dataBody)
- if err != nil {
- utils.ErrorLog(err.Error())
- c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
- return
- }
-
- timeLayout := "2006-01-02"
- loc, _ := time.LoadLocation("Local")
-
- if dataBody["advice_type"] == nil || reflect.TypeOf(dataBody["advice_type"]).String() != "float64" {
- utils.ErrorLog("advice_type")
- c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
- return
- }
- adviceType := int64(dataBody["advice_type"].(float64))
- if adviceType != 1 && adviceType != 2 {
- utils.ErrorLog("advice_type != 1&&2")
- c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
- return
- }
-
- if dataBody["start_time"] == nil || reflect.TypeOf(dataBody["start_time"]).String() != "string" {
- utils.ErrorLog("start_time")
- c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
- return
- }
-
- startTime2, _ := dataBody["start_time"].(string)
- time_arr := strings.Split(startTime2, " ")
- if len(time_arr) > 0 {
- startTime2 = time_arr[0]
- }
- if dataBody["advice_date"] == nil || reflect.TypeOf(dataBody["advice_date"]).String() != "string" {
- utils.ErrorLog("advice_date")
- c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
- return
- }
- advice_date, _ := dataBody["advice_date"].(string)
-
- var advicedateunix int64
- if len(advice_date) > 0 {
- theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", advice_date+" 00:00:00", loc)
- if err != nil {
- fmt.Println(err)
- c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
- return
- }
- advicedateunix = theTime.Unix()
- }
-
- adviceDate := startTime2
- if len(adviceDate) == 0 {
- utils.ErrorLog("len(adviceDate) == 0")
- c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
- return
- }
- theTime, err := time.ParseInLocation(timeLayout, adviceDate, loc)
- if err != nil {
- utils.ErrorLog(err.Error())
- c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
- return
- }
- AdviceDate := advicedateunix
- RecordDate := advicedateunix
-
- if dataBody["start_time"] == nil || reflect.TypeOf(dataBody["start_time"]).String() != "string" {
- utils.ErrorLog("start_time")
- c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
- return
- }
- startTime, _ := dataBody["start_time"].(string)
-
- if len(startTime) == 0 {
- utils.ErrorLog("len(start_time) == 0")
- c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
- return
- }
- theTime, err = time.ParseInLocation(timeLayout+" 15:04:05", startTime, loc)
-
- theTimeOne, _ := time.ParseInLocation("2006-01-02 15:04:05", startTime2+" 00:00:00", loc)
-
- if err != nil {
- utils.ErrorLog(err.Error())
- c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
- return
- }
- StartTime := theTime.Unix()
-
- Remark := ""
- if dataBody["remark"] != nil && reflect.TypeOf(dataBody["remark"]).String() == "string" {
- remark, _ := dataBody["remark"].(string)
- Remark = remark
- }
-
- Startdate := int64(dataBody["record_date"].(float64))
-
- var advices []*models.GroupAdvice
- if dataBody["adviceNames"] == nil || reflect.TypeOf(dataBody["adviceNames"]).String() != "[]interface {}" {
- utils.ErrorLog("adviceNames")
- c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
- return
- }
- adviceNames := dataBody["adviceNames"].([]interface{})
- for _, adviceNameMap := range adviceNames {
- adviceNameM := adviceNameMap.(map[string]interface{})
- var advice models.GroupAdvice
- advice.Remark = Remark
- advice.AdviceType = adviceType
- advice.StartTime = StartTime
- if adminUserInfo.Org.Id == 10340 {
- advice.AdviceDate = AdviceDate
- advice.RecordDate = RecordDate
- }
- if adminUserInfo.Org.Id != 10340 {
- advice.AdviceDate = theTimeOne.Unix()
- advice.RecordDate = theTimeOne.Unix()
- }
-
- advice.Status = 1
- advice.CreatedTime = time.Now().Unix()
- advice.UpdatedTime = time.Now().Unix()
- advice.StopState = 2
- advice.ExecutionState = 2
- advice.UserOrgId = adminUserInfo.Org.Id
- advice.PatientId = patientInfo.ID
- advice.AdviceDoctor = adminUserInfo.AdminUser.Id
- advice.IsSettle = 2
- //入口
- errcode := c.setAdviceWithJSON(&advice, adviceNameM)
- if errcode > 0 {
- c.ServeFailJSONWithSGJErrorCode(errcode)
- return
- }
-
- if adviceNameM["subdrugs"] != nil && reflect.TypeOf(adviceNameM["subdrugs"]).String() == "[]interface {}" {
- subdrugs := adviceNameM["subdrugs"].([]interface{})
- if len(subdrugs) > 0 {
- for _, subdrug := range subdrugs {
-
- var s models.GroupAdvice
- s.Remark = Remark
- s.AdviceType = adviceType
- s.StartTime = StartTime
- s.AdviceDate = AdviceDate
- s.RecordDate = RecordDate
- s.Status = 1
- s.CreatedTime = time.Now().Unix()
- s.UpdatedTime = time.Now().Unix()
- s.StopState = 2
- s.ExecutionState = 2
- s.UserOrgId = adminUserInfo.Org.Id
- s.PatientId = patientInfo.ID
- s.AdviceDoctor = adminUserInfo.AdminUser.Id
- s.IsSettle = 2
-
- errcode := c.setAdviceWithJSON(&s, subdrug.(map[string]interface{}))
- if errcode > 0 {
- c.ServeFailJSONWithSGJErrorCode(errcode)
- return
- }
-
- advice.Children = append(advice.Children, &s)
- }
- }
- }
-
- //长沙南雅
- if adminUserInfo.Org.Id == 3877 || adminUserInfo.Org.Id == 10340 || adminUserInfo.Org.Id == 9671 {
-
- //查询该患者今日有没有双人核对
- check, _ := service.MobileGetDoubleCheckSix(adminUserInfo.Org.Id, patientInfo.ID, RecordDate)
-
- if check.ID > 0 {
- advice.Checker = check.Modifier
- advice.CheckState = 1
- advice.CheckTime = time.Now().Unix()
- }
- }
- advices = append(advices, &advice)
- }
-
- // 查询信息规挡的设置天数
-
- infor, _ := service.GetDialysisInformationSetting(adminUserInfo.Org.Id)
- if infor.ID > 0 && infor.WeekDay > 0 {
-
- var cha_time int64
-
- timeNowStr := time.Now().Format("2006-01-02")
- timeNewDate, _ := utils.ParseTimeStringToTime("2006-01-02", timeNowStr)
-
- //今日的日期减去设置的日期
- cha_time = timeNewDate.Unix() - infor.WeekDay*86400
-
- if cha_time >= Startdate {
- //查询审核是否允许
- infor, _ := service.GetDialysisInformationByRecordDate(patient, Startdate, adminUserInfo.Org.Id, 5)
- //申请状态不允许的情况 拒绝修改
- if infor.ApplicationStatus != 1 {
- c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeInformationExist)
- return
- }
-
- }
- }
-
- newAdvices, createErr := service.CreateMGroupAdvice(adminUserInfo.Org.Id, advices, group_no)
-
- for _, item := range advices {
- //记录日志
- byterequest, _ := json.Marshal(item)
- adviceLog := models.XtDoctorAdviceLog{
- UserOrgId: item.UserOrgId,
- PatientId: item.PatientId,
- AdminUserId: adminUserInfo.AdminUser.Id,
- Module: 1,
- ErrLog: string(byterequest),
- Status: 1,
- Ctime: time.Now().Unix(),
- Mtime: 0,
- Source: "手机端新增医嘱",
- RecordDate: item.AdviceDate,
- }
- service.CreateDoctorAdviceLog(adviceLog)
- }
-
- finish := models.XtDialysisFinish{
- IsFinish: 1,
- UserOrgId: adminUserInfo.Org.Id,
- Status: 1,
- Ctime: time.Now().Unix(),
- Mtime: 0,
- Module: 4,
- RecordDate: advicedateunix,
- Sourse: 1,
- PatientId: patient,
- }
-
- dialysisFinish, err := service.GetDialysisFinish(adminUserInfo.Org.Id, advicedateunix, 4, patient)
- if dialysisFinish.ID == 0 {
- service.CreateDialysisFinish(finish)
- }
- key := strconv.FormatInt(adminUserInfo.Org.Id, 10) + ":" + strconv.FormatInt(patient, 10) + ":" + strconv.FormatInt(AdviceDate, 10) + ":doctor_advices"
- redis := service.RedisClient()
- //清空key 值
- redis.Set(key, "", time.Second)
- keyOne := strconv.FormatInt(adminUserInfo.Org.Id, 10) + ":" + strconv.FormatInt(AdviceDate, 10) + ":advice_list_all"
- redis.Set(keyOne, "", time.Second)
-
- defer redis.Close()
- if createErr != nil {
- c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCreateDoctorAdviceFail)
- return
- }
-
- c.ServeSuccessJSON(map[string]interface{}{
- "msg": "ok",
- "advices": newAdvices,
- })
- return
-
- } else if is_child == 2 {
-
- patient, _ := c.GetInt64("id", 0)
- if patient <= 0 {
- c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
- return
- }
-
- adminUserInfo := c.GetMobileAdminUserInfo()
- patientInfo, _ := service.FindPatientById(adminUserInfo.Org.Id, patient)
- if patientInfo.ID == 0 {
- c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodePatientNoExist)
- return
- }
- var advice models.DoctorAdvice
- code := adviceFormData(&advice, c.Ctx.Input.RequestBody, "create")
- if code > 0 {
- c.ServeFailJSONWithSGJErrorCode(code)
- return
- }
-
- if advice.ParentId > 0 {
- old, _ := service.FindDoctorAdvice(adminUserInfo.Org.Id, advice.ParentId)
- if old.ID == 0 || old.PatientId != patient {
- c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParentAdviceNotExist)
- return
- }
-
- if old.StopState == 1 || old.ExecutionState == 1 {
- c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeAdviceStoped)
- return
- }
-
- if old.ParentId > 0 {
- advice.ParentId = old.ParentId
- }
- advice.StartTime = old.StartTime
- advice.AdviceDoctor = old.AdviceDoctor
- advice.DeliveryWay = old.DeliveryWay
- advice.ExecutionFrequency = old.ExecutionFrequency
- advice.GroupNo = old.GroupNo
-
- }
-
- advice.Status = 1
- advice.CreatedTime = time.Now().Unix()
- advice.UpdatedTime = time.Now().Unix()
- advice.StopState = 2
- advice.ExecutionState = 2
- advice.UserOrgId = adminUserInfo.Org.Id
- advice.PatientId = patient
- advice.AdviceDoctor = adminUserInfo.AdminUser.Id
- advice.IsSettle = 2
-
- if adminUserInfo.Org.Id == 3877 || adminUserInfo.Org.Id == 10340 || adminUserInfo.Org.Id == 9671 {
- if advice.PrescribingNumber == 0 {
- advice.PrescribingNumber = 1
- }
- //查询该患者今日有没有双人核对
- check, _ := service.MobileGetDoubleCheckSix(adminUserInfo.Org.Id, patientInfo.ID, advice.AdviceDate)
-
- if check.ID > 0 {
- advice.Checker = check.Modifier
- advice.CheckState = 1
- advice.CheckTime = time.Now().Unix()
- }
- }
-
- infor, _ := service.GetDialysisInformationSetting(adminUserInfo.Org.Id)
- if infor.ID > 0 {
-
- var cha_time int64
-
- timeNowStr := time.Now().Format("2006-01-02")
- timeNewDate, _ := utils.ParseTimeStringToTime("2006-01-02", timeNowStr)
-
- //今日的日期减去设置的日期
- cha_time = timeNewDate.Unix() - infor.WeekDay*86400
-
- if cha_time >= advice.RecordDate {
- //查询审核是否允许
- infor, _ := service.GetDialysisInformationByRecordDate(patient, advice.RecordDate, adminUserInfo.Org.Id, 4)
- //申请状态不允许的情况 拒绝修改
- if infor.ApplicationStatus != 1 {
- c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeInformationExist)
- return
- }
-
- }
- }
- err := service.CreateDoctorAdvice(&advice)
-
- //记录日志
- byterequest, _ := json.Marshal(advice)
- adviceLog := models.XtDoctorAdviceLog{
- UserOrgId: advice.UserOrgId,
- PatientId: advice.PatientId,
- AdminUserId: adminUserInfo.Org.Id,
- Module: 1,
- ErrLog: string(byterequest),
- Status: 1,
- Ctime: time.Now().Unix(),
- Mtime: 0,
- Source: "手机端新增医嘱",
- RecordDate: advice.AdviceDate,
- }
-
- service.CreateDoctorAdviceLog(adviceLog)
-
- key := strconv.FormatInt(adminUserInfo.Org.Id, 10) + ":" + strconv.FormatInt(patient, 10) + ":" + strconv.FormatInt(advice.AdviceDate, 10) + ":doctor_advices"
- redis := service.RedisClient()
- //清空key 值
- redis.Set(key, "", time.Second)
- keyOne := strconv.FormatInt(adminUserInfo.Org.Id, 10) + ":" + strconv.FormatInt(advice.AdviceDate, 10) + ":advice_list_all"
- redis.Set(keyOne, "", time.Second)
- defer redis.Close()
- if err != nil {
- c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCreateDoctorAdviceFail)
- return
- }
-
- c.ServeSuccessJSON(map[string]interface{}{
- "msg": "ok",
- "advice": advice,
- })
- return
-
- }
-
- }
-
- func (c *PatientApiController) setAdviceWithJSON(advice *models.GroupAdvice, json map[string]interface{}) int {
-
- if json["advice_name"] == nil || reflect.TypeOf(json["advice_name"]).String() != "string" {
- utils.ErrorLog("advice_name")
- return enums.ErrorCodeParamWrong
- }
- adviceName, _ := json["advice_name"].(string)
- if len(adviceName) == 0 {
- utils.ErrorLog("len(advice_name) == 0")
- return enums.ErrorCodeParamWrong
- }
- advice.AdviceName = adviceName
-
- adviceDesc, _ := json["advice_desc"].(string)
- advice.AdviceDesc = adviceDesc
-
- if json["drug_spec"] != nil && reflect.TypeOf(json["drug_spec"]).String() == "string" {
- drugSpec, _ := strconv.ParseFloat(json["drug_spec"].(string), 64)
- advice.DrugSpec = drugSpec
- }
-
- if json["remark"] != nil && reflect.TypeOf(json["remark"]).String() == "string" {
- remark, _ := json["remark"].(string)
- advice.Remark = remark
- }
-
- //if json["src_type"] != nil || reflect.TypeOf(json["src_type"]).String() == "float64" {
- // src_type, _ := strconv.ParseInt(json["src_type"].(string),10)
- // advice.Way = src_type
- //}
- if json["way"] == nil {
- advice.Way = 0
-
- } else {
- if json["way"] != nil || reflect.TypeOf(json["way"]).String() == "float64" {
- way := int64(json["way"].(float64))
- advice.Way = way
- }
-
- }
-
- if json["drug_id"] == nil {
- advice.DrugId = 0
- } else {
- if json["drug_id"] != nil || reflect.TypeOf(json["drug_id"]).String() == "float64" {
- drug_id := int64(json["drug_id"].(float64))
- advice.DrugId = drug_id
- }
- }
-
- if json["drug_name_id"] == nil {
- advice.DrugNameId = 0
- } else {
- if json["drug_name_id"] != nil || reflect.TypeOf(json["drug_name_id"]).String() == "float64" {
- drug_name_id := int64(json["drug_name_id"].(float64))
- advice.DrugNameId = drug_name_id
- }
- }
-
- if json["drug_spec_unit"] != nil && reflect.TypeOf(json["drug_spec_unit"]).String() == "string" {
- drugSpecUnit, _ := json["drug_spec_unit"].(string)
- advice.DrugSpecUnit = drugSpecUnit
- }
-
- if json["single_dose"] != nil && reflect.TypeOf(json["single_dose"]).String() == "string" {
- singleDose, _ := strconv.ParseFloat(json["single_dose"].(string), 64)
- advice.SingleDose = singleDose
- }
-
- if json["single_dose_unit"] != nil && reflect.TypeOf(json["single_dose_unit"]).String() == "string" {
- singleDoseUnit, _ := json["single_dose_unit"].(string)
- advice.SingleDoseUnit = singleDoseUnit
- }
-
- if json["prescribing_number"] != nil && reflect.TypeOf(json["prescribing_number"]).String() == "string" {
- prescribingNumber, _ := strconv.ParseFloat(json["prescribing_number"].(string), 64)
- advice.PrescribingNumber = prescribingNumber
- }
-
- if json["prescribing_number_unit"] != nil && reflect.TypeOf(json["prescribing_number_unit"]).String() == "string" {
- prescribingNumberUnit, _ := json["prescribing_number_unit"].(string)
- advice.PrescribingNumberUnit = prescribingNumberUnit
- }
- if json["delivery_way"] != nil && reflect.TypeOf(json["delivery_way"]).String() == "string" {
- deliveryWay, _ := json["delivery_way"].(string)
- advice.DeliveryWay = deliveryWay
- }
-
- if json["execution_frequency"] != nil && reflect.TypeOf(json["execution_frequency"]).String() == "string" {
- executionFrequency, _ := json["execution_frequency"].(string)
- advice.ExecutionFrequency = executionFrequency
- }
- return 0
- }
-
- func (c *PatientApiController) DelDoctorAdvice() {
- groupno, _ := c.GetInt64("groupno", -1)
- is_sub, _ := c.GetInt64("is_sub", -1) //是否子药
- patient_id, _ := c.GetInt64("patient_id")
- doc_advice_date, _ := c.GetInt64("advice_date")
- redis := service.RedisClient()
- if is_sub == 1 { //是
-
- advice_id, _ := c.GetInt64("advice_id")
- adminUserInfo := c.GetMobileAdminUserInfo()
- advice, _ := service.FindOldDoctorAdvice(adminUserInfo.Org.Id, advice_id)
- if advice.ID == 0 {
- c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDoctorAdviceNotExist)
- return
- }
-
- advice.Status = 0
- advice.UpdatedTime = time.Now().Unix()
- advice.Modifier = adminUserInfo.AdminUser.Id
-
- // 查询信息规挡的设置天数
-
- infor, _ := service.GetDialysisInformationSetting(adminUserInfo.Org.Id)
- if infor.ID > 0 && infor.WeekDay > 0 {
-
- var cha_time int64
-
- timeNowStr := time.Now().Format("2006-01-02")
- timeNewDate, _ := utils.ParseTimeStringToTime("2006-01-02", timeNowStr)
-
- //今日的日期减去设置的日期
- cha_time = timeNewDate.Unix() - infor.WeekDay*86400
-
- if cha_time >= advice.AdviceDate {
- //查询审核是否允许
- infor, _ := service.GetDialysisInformationByRecordDate(advice.PatientId, advice.AdviceDate, adminUserInfo.Org.Id, 4)
- //申请状态不允许的情况 拒绝修改
- if infor.ApplicationStatus != 1 {
- c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeInformationExist)
- return
- }
-
- }
- }
-
- //自备药
- selfPrescriptionOutOpenOne, _ := service.GetSelfPrescriptionOutOpen(adminUserInfo.Org.Id)
-
- if selfPrescriptionOutOpenOne.IsOpen == 1 {
- //查询库存是否是自备药
- selfBasedrug, _ := service.GetSelfBasedrugByIdTwo(advice.DrugId, advice.UserOrgId)
-
- if selfBasedrug.IsSelfDrug == 1 {
- creater := adminUserInfo.AdminUser.Id
- //退库
- service.SelfDrugAutoAddCancelInfoOne(&advice, creater)
- }
- }
- err := service.DeleteDoctorAdvice(&advice)
- //记录日志
- byterequest, _ := json.Marshal(advice)
- adviceLog := models.XtDoctorAdviceLog{
- UserOrgId: advice.UserOrgId,
- PatientId: advice.PatientId,
- AdminUserId: adminUserInfo.AdminUser.Id,
- Module: 4,
- ErrLog: string(byterequest),
- Status: 1,
- Ctime: time.Now().Unix(),
- Mtime: 0,
- Source: "手机端删除医嘱",
- RecordDate: advice.RecordDate,
- }
- service.CreateDoctorAdviceLog(adviceLog)
-
- key := strconv.FormatInt(adminUserInfo.Org.Id, 10) + ":" + strconv.FormatInt(patient_id, 10) + ":" + strconv.FormatInt(doc_advice_date, 10) + ":doctor_advices"
-
- redis.Set(key, "", time.Second)
-
- keyTwo := strconv.FormatInt(adminUserInfo.Org.Id, 10) + ":" + strconv.FormatInt(doc_advice_date, 10) + ":advice_list_all"
- redis.Set(keyTwo, "", time.Second)
- keyThree := strconv.FormatInt(adminUserInfo.Org.Id, 10) + ":" + strconv.FormatInt(patient_id, 10) + ":" + strconv.FormatInt(doc_advice_date, 10) + ":his_doctor_advice"
- redis.Set(keyThree, "", time.Second)
- redis.Close()
- if err != nil {
- c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDeleteAdviceFail)
- return
- }
-
- c.ServeSuccessJSON(map[string]interface{}{
- "msg": "ok",
- })
-
- return
-
- } else { //
-
- var ids []string
- if groupno == 0 {
- advice_id := c.GetString("advice_id")
- ids = strings.Split(advice_id, ",")
- if len(ids) <= 0 {
- c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
- return
- }
- }
- if groupno < 0 {
- c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
- return
- }
-
- adminUserInfo := c.GetMobileAdminUserInfo()
- var advice models.DoctorAdvice
- if groupno > 0 {
- advice, _ = service.FindDoctorAdviceByGoroupNo(adminUserInfo.Org.Id, groupno)
- if advice.ID == 0 {
- c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDoctorAdviceNotExist)
- return
- }
- } else {
- advices, _ := service.FindDoctorAdviceByIds(adminUserInfo.Org.Id, ids)
- for _, item := range advices {
- if item.ID == 0 {
- c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDoctorAdviceNotExist)
- return
- }
- }
- }
-
- advice.UpdatedTime = time.Now().Unix()
- advice.Status = 0
- advice.GroupNo = groupno
- advice.Modifier = adminUserInfo.AdminUser.Id
-
- var err error
- if groupno > 0 {
- // 查询信息规挡的设置天数
-
- infor, _ := service.GetDialysisInformationSetting(adminUserInfo.Org.Id)
- if infor.ID > 0 {
-
- var cha_time int64
-
- timeNowStr := time.Now().Format("2006-01-02")
- timeNewDate, _ := utils.ParseTimeStringToTime("2006-01-02", timeNowStr)
-
- //今日的日期减去设置的日期
- cha_time = timeNewDate.Unix() - infor.WeekDay*86400
-
- if cha_time >= advice.AdviceDate {
- //查询审核是否允许
- infor, _ := service.GetDialysisInformationByRecordDate(advice.PatientId, advice.AdviceDate, adminUserInfo.Org.Id, 4)
- //申请状态不允许的情况 拒绝修改
- if infor.ApplicationStatus != 1 {
- c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeInformationExist)
- return
- }
-
- }
- }
-
- //自备药
- selfPrescriptionOutOpenOne, _ := service.GetSelfPrescriptionOutOpen(adminUserInfo.Org.Id)
-
- if selfPrescriptionOutOpenOne.IsOpen == 1 {
- //查询库存是否是自备药
- selfBasedrug, _ := service.GetSelfBasedrugByIdTwo(advice.DrugId, advice.UserOrgId)
-
- if selfBasedrug.IsSelfDrug == 1 {
- creater := adminUserInfo.AdminUser.Id
- //退库
- service.SelfDrugAutoAddCancelInfoOne(&advice, creater)
- }
- }
-
- err = service.DeleteDoctorAdviceByGroupNo(&advice)
- //记录日志
- byterequest, _ := json.Marshal(advice)
- adviceLog := models.XtDoctorAdviceLog{
- UserOrgId: advice.UserOrgId,
- PatientId: advice.PatientId,
- AdminUserId: adminUserInfo.AdminUser.Id,
- Module: 4,
- ErrLog: string(byterequest),
- Status: 1,
- Ctime: time.Now().Unix(),
- Mtime: 0,
- Source: "手机端删除医嘱",
- RecordDate: advice.RecordDate,
- }
- service.CreateDoctorAdviceLog(adviceLog)
-
- key := strconv.FormatInt(adminUserInfo.Org.Id, 10) + ":" + strconv.FormatInt(patient_id, 10) + ":" + strconv.FormatInt(doc_advice_date, 10) + ":doctor_advices"
-
- redis.Set(key, "", time.Second)
-
- keyTwo := strconv.FormatInt(adminUserInfo.Org.Id, 10) + ":" + strconv.FormatInt(doc_advice_date, 10) + ":advice_list_all"
-
- redis.Set(keyTwo, "", time.Second)
- keyThree := strconv.FormatInt(adminUserInfo.Org.Id, 10) + ":" + strconv.FormatInt(patient_id, 10) + ":" + strconv.FormatInt(doc_advice_date, 10) + ":his_doctor_advice"
- redis.Set(keyThree, "", time.Second)
- } else {
- // 查询信息规挡的设置天数
-
- infor, _ := service.GetDialysisInformationSetting(adminUserInfo.Org.Id)
- if infor.ID > 0 {
-
- var cha_time int64
-
- timeNowStr := time.Now().Format("2006-01-02")
- timeNewDate, _ := utils.ParseTimeStringToTime("2006-01-02", timeNowStr)
-
- //今日的日期减去设置的日期
- cha_time = timeNewDate.Unix() - infor.WeekDay*86400
-
- if cha_time >= advice.AdviceDate {
- //查询审核是否允许
- infor, _ := service.GetDialysisInformationByRecordDate(advice.PatientId, advice.AdviceDate, adminUserInfo.Org.Id, 4)
- //申请状态不允许的情况 拒绝修改
- if infor.ApplicationStatus != 1 {
- c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeInformationExist)
- return
- }
-
- }
- }
- err = service.BatchDeleteDoctorAdvice(ids, adminUserInfo.AdminUser.Id)
-
- advicelist, _ := service.GetBatchDoctorAdviceList(ids, adminUserInfo.Org.Id)
-
- for _, item := range advicelist {
-
- //自备药
- selfPrescriptionOutOpenOne, _ := service.GetSelfPrescriptionOutOpen(adminUserInfo.Org.Id)
-
- if selfPrescriptionOutOpenOne.IsOpen == 1 {
- //查询库存是否是自备药
- selfBasedrug, _ := service.GetSelfBasedrugByIdTwo(item.DrugId, item.UserOrgId)
-
- if selfBasedrug.IsSelfDrug == 1 {
- creater := adminUserInfo.AdminUser.Id
- //退库
- service.SelfDrugAutoAddCancelInfoOne(item, creater)
- }
- }
-
- //记录日志
- byterequest, _ := json.Marshal(item)
- adviceLog := models.XtDoctorAdviceLog{
- UserOrgId: item.UserOrgId,
- PatientId: item.PatientId,
- AdminUserId: adminUserInfo.AdminUser.Id,
- Module: 4,
- ErrLog: string(byterequest),
- Status: 1,
- Ctime: time.Now().Unix(),
- Mtime: 0,
- Source: "手机端批量删除医嘱",
- RecordDate: item.RecordDate,
- }
- service.CreateDoctorAdviceLog(adviceLog)
- }
-
- key := strconv.FormatInt(adminUserInfo.Org.Id, 10) + ":" + strconv.FormatInt(patient_id, 10) + ":" + strconv.FormatInt(doc_advice_date, 10) + ":doctor_advices"
-
- redis.Set(key, "", time.Second)
-
- keyTwo := strconv.FormatInt(adminUserInfo.Org.Id, 10) + ":" + strconv.FormatInt(doc_advice_date, 10) + ":advice_list_all"
-
- redis.Set(keyTwo, "", time.Second)
- keyThree := strconv.FormatInt(adminUserInfo.Org.Id, 10) + ":" + strconv.FormatInt(patient_id, 10) + ":" + strconv.FormatInt(doc_advice_date, 10) + ":his_doctor_advice"
- redis.Set(keyThree, "", time.Second)
- redis.Close()
- }
-
- if err != nil {
- c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDeleteAdviceFail)
- return
- }
-
- c.ServeSuccessJSON(map[string]interface{}{
- "msg": "ok",
- })
- return
-
- }
-
- }
-
- // /m/api/advice/group/modify_starttime [post]
- // @param group_no:int
- // @param start_time:string yyyy-MM-dd hh:mm:ss
- func (this *PatientApiController) ModifyAdviceGroupStartTime() {
- group_no, _ := this.GetInt64("group_no")
- start_time_str := this.GetString("start_time")
- if group_no <= 0 || len(start_time_str) == 0 {
- this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
- return
- }
-
- startTime, parseTimeErr := utils.ParseTimeStringToTime("2006-01-02 15:04:05", start_time_str)
- if parseTimeErr != nil {
- this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamFormatWrong)
- return
- }
-
- adminUserInfo := this.GetMobileAdminUserInfo()
- updateStartTimeErr := service.UpdateAdviceGroupStartTime(adminUserInfo.Org.Id, group_no, startTime.Unix(), adminUserInfo.AdminUser.Id)
- if updateStartTimeErr != nil {
- utils.ErrorLog("修改医嘱分组的开始时间失败:%v", updateStartTimeErr)
- this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
- return
- }
- this.ServeSuccessJSON(map[string]interface{}{
- "start_time": startTime.Unix(),
- })
- }
-
- func (this *PatientApiController) DelSubDoctorAdvice() {
- advice_id, _ := this.GetInt64("advice_id")
- adminUserInfo := this.GetMobileAdminUserInfo()
- advice, _ := service.FindOldDoctorAdvice(adminUserInfo.Org.Id, advice_id)
- if advice.ID == 0 {
- this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDoctorAdviceNotExist)
- return
- }
- //if !adminUserInfo.AdminUser.IsSuperAdmin && advice.AdviceDoctor != adminUserInfo.AdminUser.Id {
- // this.ServeFailJSONWithSGJErrorCode(enums. bh)
- // return
- //}
-
- advice.Status = 0
- advice.UpdatedTime = time.Now().Unix()
- advice.Modifier = adminUserInfo.AdminUser.Id
-
- err := service.DeleteDoctorAdvice(&advice)
- if err != nil {
- this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDeleteAdviceFail)
- return
- }
-
- this.ServeSuccessJSON(map[string]interface{}{
- "msg": "ok",
- })
- return
- }
-
- func (this *PatientApiController) GetAdviceUnReadMessage() {
- //adminUserInfo := this.GetMobileAdminUserInfo()
- //service.FindUnReadDoctorAdviceMessage()
-
- }
-
- func (this *PatientApiController) GetPatientsByKeyWord() {
- keyWord := this.GetString("keyword")
- adminUserInfo := this.GetMobileAdminUserInfo()
- today := utils.ZeroHourTimeOfDay(time.Now())
- patient, err := service.GetSchedualPatientByKeyWord(adminUserInfo.Org.Id, keyWord, today.Unix())
- if err != nil {
- utils.ErrorLog(err.Error())
- this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
- return
- }
- this.ServeSuccessJSON(map[string]interface{}{
- "patient": patient,
- })
- }
-
- func (this *PatientApiController) GetSearchPatient() {
-
- keyWord := this.GetString("keyword")
- adminUserInfo := this.GetMobileAdminUserInfo()
- patient, err := service.GetPatientsByKey(adminUserInfo.Org.Id, keyWord)
- if err != nil {
- utils.ErrorLog(err.Error())
- this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
- return
- }
- this.ServeSuccessJSON(map[string]interface{}{
- "patient": patient,
- })
- }
-
- func (c *PatientApiController) ExecProject() {
- execution_time := c.GetString("execution_time")
- project_id, _ := c.GetInt64("project_id")
- team_id, _ := c.GetInt64("team_id")
- is_check_team, _ := c.GetInt64("is_check_team")
-
- if len(execution_time) <= 0 {
- utils.ErrorLog("execution_time")
- c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
- return
- }
- timeLayout2 := "2006-01-02 15:04:05"
- loc, _ := time.LoadLocation("Local")
- theTime, errs := time.ParseInLocation(timeLayout2, execution_time, loc)
- if errs != nil {
- utils.ErrorLog(errs.Error())
- c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
- return
- }
- adminInfo := c.GetMobileAdminUserInfo()
-
- project, _ := service.FindHisProjectById(adminInfo.Org.Id, project_id)
-
- //针对舒和
- if adminInfo.Org.Id == 10644 {
- if project.StartTime > theTime.Unix() {
- c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeAdviceExceBeforeStart)
- return
- }
- }
-
- if project.Type == 3 {
- good, _ := service.GetGoodInformationByGoodId(project.ProjectId)
- if good.IsUser != 1 {
-
- //查询开关是否开启
- stockSetting, _ := service.FindStockSettingById(adminInfo.Org.Id)
-
- //开关已经开启
- if stockSetting.IsType == 1 {
- theTime, _ := time.ParseInLocation(timeLayout2, execution_time, loc)
- scheduleDateStart := theTime.Format("2006-01-02")
- timeLayout3 := "2006-01-02"
- loc, _ := time.LoadLocation("Local")
- execuTime, _ := time.ParseInLocation(timeLayout3, scheduleDateStart, loc)
- //查询该耗材是否已经出库
- auto, _ := service.GetAutoWarehouseOutList(project.ProjectId, execuTime.Unix(), adminInfo.Org.Id, project.PatientId)
- if auto.ID == 0 {
- c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeStockExced)
- return
- }
- }
- }
-
- if good.IsUser == 1 && good.IsWarehouse == 1 {
-
- //查询开关是否开启
- stockSetting, _ := service.FindStockSettingById(adminInfo.Org.Id)
-
- //开关已经开启
- if stockSetting.IsType == 1 {
- theTime, _ := time.ParseInLocation(timeLayout2, execution_time, loc)
- scheduleDateStart := theTime.Format("2006-01-02")
- timeLayout3 := "2006-01-02"
- loc, _ := time.LoadLocation("Local")
- execuTime, _ := time.ParseInLocation(timeLayout3, scheduleDateStart, loc)
- //查询该耗材是否已经出库
- auto, _ := service.GetAutoWarehouseOutList(project.ProjectId, execuTime.Unix(), adminInfo.Org.Id, project.PatientId)
- if auto.ID == 0 {
- c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeStockExced)
- return
- }
- }
- }
- }
-
- if project.ExecutionState == 1 {
- c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeAdviceExced)
- return
- }
- if project.Checker >= 0 && project.Checker == adminInfo.AdminUser.Id {
- c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeExceAndCheckNotOneUser)
- return
- }
- project.ExecutionState = 1
- project.ExecutionStaff = adminInfo.AdminUser.Id
- project.ExecutionTime = theTime.Unix()
- if team_id == 0 {
- // 查询信息规挡的设置天数
-
- infor, _ := service.GetDialysisInformationSetting(project.RecordDate)
- if infor.ID > 0 {
-
- var cha_time int64
-
- timeNowStr := time.Now().Format("2006-01-02")
- timeNewDate, _ := utils.ParseTimeStringToTime("2006-01-02", timeNowStr)
-
- //今日的日期减去设置的日期
- cha_time = timeNewDate.Unix() - infor.WeekDay*86400
-
- if cha_time >= project.RecordDate {
- //查询审核是否允许
- infor, _ := service.GetDialysisInformationByRecordDate(project.PatientId, project.PatientId, project.UserOrgId, 4)
- //申请状态不允许的情况 拒绝修改
- if infor.ApplicationStatus != 1 {
- c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeInformationExist)
- return
- }
-
- }
- }
- err := service.SaveHisProject(&project)
- if err == nil {
- c.ServeSuccessJSON(map[string]interface{}{
- "project": project,
- })
- } else {
- c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
- return
-
- }
- } else {
- if is_check_team == 2 { //虽然是组套数据,但不是检验项目
- // 查询信息规挡的设置天数
-
- infor, _ := service.GetDialysisInformationSetting(project.RecordDate)
- if infor.ID > 0 {
-
- var cha_time int64
-
- timeNowStr := time.Now().Format("2006-01-02")
- timeNewDate, _ := utils.ParseTimeStringToTime("2006-01-02", timeNowStr)
-
- //今日的日期减去设置的日期
- cha_time = timeNewDate.Unix() - infor.WeekDay*86400
-
- if cha_time >= project.RecordDate {
- //查询审核是否允许
- infor, _ := service.GetDialysisInformationByRecordDate(project.PatientId, project.PatientId, project.UserOrgId, 4)
- //申请状态不允许的情况 拒绝修改
- if infor.ApplicationStatus != 1 {
- c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeInformationExist)
- return
- }
-
- }
- }
- err := service.SaveHisProject(&project)
- if err == nil {
- c.ServeSuccessJSON(map[string]interface{}{
- "project": project,
- })
- } else {
- c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
- return
-
- }
- } else {
- // 查询信息规挡的设置天数
-
- infor, _ := service.GetDialysisInformationSetting(project.RecordDate)
- if infor.ID > 0 {
-
- var cha_time int64
-
- timeNowStr := time.Now().Format("2006-01-02")
- timeNewDate, _ := utils.ParseTimeStringToTime("2006-01-02", timeNowStr)
-
- //今日的日期减去设置的日期
- cha_time = timeNewDate.Unix() - infor.WeekDay*86400
-
- if cha_time >= project.RecordDate {
- //查询审核是否允许
- infor, _ := service.GetDialysisInformationByRecordDate(project.PatientId, project.PatientId, project.UserOrgId, 4)
- //申请状态不允许的情况 拒绝修改
- if infor.ApplicationStatus != 1 {
- c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeInformationExist)
- return
- }
-
- }
- }
- ps, _ := service.GetCheckTeamProject(team_id, project.PatientId, project.RecordDate, project.UserOrgId)
- var ids []int64
- for _, items := range ps {
- ids = append(ids, items.ID)
- }
- err := service.UpdateTeamProjectExceStatus(ids, adminInfo.AdminUser.Id, theTime.Unix())
- if err == nil {
- c.ServeSuccessJSON(map[string]interface{}{
- "project": project,
- })
- } else {
- c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
- return
-
- }
- }
-
- }
- }
-
- func (c *PatientApiController) CheckProject() {
-
- adminInfo := c.GetMobileAdminUserInfo()
- project_id, _ := c.GetInt64("project_id")
- team_id, _ := c.GetInt64("team_id")
- is_check_team, _ := c.GetInt64("is_check_team")
-
- project, _ := service.FindHisProjectById(adminInfo.Org.Id, project_id)
- if project.CheckState == 1 {
- c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeAdviceChecked)
- return
- }
- if project.ExecutionStaff >= 0 && project.ExecutionStaff == adminInfo.AdminUser.Id {
- c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeExceAndCheckNotOneUser)
- return
- }
-
- project.Checker = adminInfo.AdminUser.Id
- project.CheckTime = time.Now().Unix()
- project.CheckState = 1
- if team_id == 0 {
- // 查询信息规挡的设置天数
-
- infor, _ := service.GetDialysisInformationSetting(project.RecordDate)
- if infor.ID > 0 {
-
- var cha_time int64
-
- timeNowStr := time.Now().Format("2006-01-02")
- timeNewDate, _ := utils.ParseTimeStringToTime("2006-01-02", timeNowStr)
-
- //今日的日期减去设置的日期
- cha_time = timeNewDate.Unix() - infor.WeekDay*86400
-
- if cha_time >= project.RecordDate {
- //查询审核是否允许
- infor, _ := service.GetDialysisInformationByRecordDate(project.PatientId, project.PatientId, project.UserOrgId, 4)
- //申请状态不允许的情况 拒绝修改
- if infor.ApplicationStatus != 1 {
- c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeInformationExist)
- return
- }
-
- }
- }
- err := service.SaveHisProject(&project)
- if err == nil {
- c.ServeSuccessJSON(map[string]interface{}{
- "msg": "ok",
- "project": project,
- })
-
- } else {
- c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
- return
-
- }
-
- } else {
- if is_check_team == 2 { //虽然是组套数据,但不是检验项目
- // 查询信息规挡的设置天数
-
- infor, _ := service.GetDialysisInformationSetting(project.RecordDate)
- if infor.ID > 0 {
-
- var cha_time int64
-
- timeNowStr := time.Now().Format("2006-01-02")
- timeNewDate, _ := utils.ParseTimeStringToTime("2006-01-02", timeNowStr)
-
- //今日的日期减去设置的日期
- cha_time = timeNewDate.Unix() - infor.WeekDay*86400
-
- if cha_time >= project.RecordDate {
- //查询审核是否允许
- infor, _ := service.GetDialysisInformationByRecordDate(project.PatientId, project.PatientId, project.UserOrgId, 4)
- //申请状态不允许的情况 拒绝修改
- if infor.ApplicationStatus != 1 {
- c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeInformationExist)
- return
- }
-
- }
- }
- err := service.SaveHisProject(&project)
- if err == nil {
- c.ServeSuccessJSON(map[string]interface{}{
- "msg": "ok",
- "project": project,
- })
-
- } else {
- c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
- return
-
- }
-
- } else {
- // 查询信息规挡的设置天数
-
- infor, _ := service.GetDialysisInformationSetting(project.RecordDate)
- if infor.ID > 0 {
-
- var cha_time int64
-
- timeNowStr := time.Now().Format("2006-01-02")
- timeNewDate, _ := utils.ParseTimeStringToTime("2006-01-02", timeNowStr)
-
- //今日的日期减去设置的日期
- cha_time = timeNewDate.Unix() - infor.WeekDay*86400
-
- if cha_time >= project.RecordDate {
- //查询审核是否允许
- infor, _ := service.GetDialysisInformationByRecordDate(project.PatientId, project.PatientId, project.UserOrgId, 4)
- //申请状态不允许的情况 拒绝修改
- if infor.ApplicationStatus != 1 {
- c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeInformationExist)
- return
- }
-
- }
- }
- ps, _ := service.GetCheckTeamProject(team_id, project.PatientId, project.RecordDate, project.UserOrgId)
- var ids []int64
- for _, items := range ps {
- ids = append(ids, items.ID)
- }
- err := service.UpdateTeamProjectCheckStatus(ids, project.PatientId, project.RecordDate, project.UserOrgId, adminInfo.AdminUser.Id, time.Now().Unix())
- if err == nil {
- c.ServeSuccessJSON(map[string]interface{}{
- "project": project,
- })
- } else {
- c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
- return
-
- }
- }
-
- }
-
- }
|