Entry 3131
reporting stuff
Submitted by anonymous
on Feb. 4, 2010 at 12:21 a.m.
Language: Python. Code size: 4.8 KB.
def QualifyingOperations((facts,entailed),start,stop): """ Take fact graph and entailed graph, start/stop as datetime and return a generator over the qualifying operations """ from Modules import * # print start, stop for hosp in GenerateHospitalizations(facts,entailed): sortedEpisodeEvents = sorted(hosp, key=lambda x:x.startDt) relaxedLogic foundFirst = False for qualOp in ( OperationObj(facts,entailed,event.evt) for event in sortedEpisodeEvents ): passedGeneral,passedSpecific = IsQualifyingOperations(event.evt,(facts,entailed)) if passedGeneral: #Passed general criteria (one of our physicians) inTimeWindow = qualOp and str(qualOp.startDt) > str(Literal(start)) and \ str(qualOp.startDt) < str(Literal(stop)) if passedSpecific and inTimeWindow and not foundFirst: #This is the first (in temporal order), that satisfied the full criteria #We identify it as such and it will have the normal tag in addition to #the tag for the more restricted class of qualifying operation #Indicate we have found the first of its kind qualOp.specific = True foundFirst = True yield qualOp, hosp elif inTimeWindow: #This operation passed the more general criteria and is in #the time window, so we indicate it as a member of the less #specific class of qualifying operations qualOp.specific = False yield qualOp, hosp def IsQualifyingOperations(evt,(facts,entailed)): """ The core qualifying case criteria (excluding the requirement of the first one in an episode) is: - An operation performed (primarily) by one of our staff physicians - An operation not involving an aborted procedure - IT is *NOT* the case that the only procedure performed was an ECMO or balloon pump Returns whether or not operations passes *both* criteria as a tuple of booleans """ from Modules import * query=OPS_IN_WINDOW%(' || \n\t'.join( ['?ID = ptrec:%s'%_id for _id in CARDIAC_SURGEONS]))#, if facts.query(query, initBindings={Variable('EVT'):evt}, initNs={u'ptrec' : PTREC_NS, u'fztime': FZ_TIME, u'time' : TIME }).askAnswer[0]: #Operation within window involving our cardiac surgeons as primary staff surgeon op = OperationObj(facts,entailed,evt) #Exclude operations involving aborted procedures if op.involvesProcedure( PTREC_NS['SurgicalProcedure_other_cardiac_aborted_procedure']): return (True,False) #exclude operations with a single component that is any of #EXCLUDING_ISOLATED_PROCS if len(op)==1 and first(op)[-1] in EXCLUDING_ISOLATED_PROCS: return (True,False) return (True,True) else: return (False,False) qualifyingEvtStatements = [] for evtObj,hosp in identifyQualifyingOperations( (self.aBoxGraph, self.network.inferredFacts)): qualifyingEvtStatements.append((evtObj.evt,RDF.type,REPORTING.LoosleyQualifyingOperation)) if evtObj.specific: qualifyingEvtStatements.append((evtObj.evt,RDF.type,REPORTING.QualifyingOperation)) qualQuads = [] for evtObj,hosp in identifyQualifyingOperations( (aBoxGraph,network.inferredFacts), qualDate, options.outcomeQualification): qualQuads.append((evtObj.evt,RDF.type,REPORTING.LoosleyQualifyingOperation,network.inferredFacts)) if evtObj.specific: qualQuads.append((evtObj.evt,RDF.type,REPORTING.QualifyingOperation,network.inferredFacts)) qualifyingEvtStatements = [] for evtObj,hosp in identifyQualifyingOperations( (network.builder.aBoxGraph,network.inferredFacts), qualDate, options.outcomeQualification): qualifyingEvtStatements.append((evtObj.evt,RDF.type,REPORTING.LoosleyQualifyingOperation,network.inferredFacts)) if evtObj.specific: qualifyingEvtStatements.append((evtObj.evt,RDF.type,REPORTING.QualifyingOperation,network.inferredFacts))
This snippet took 0.01 seconds to highlight.
Back to the Entry List or Home.