def tested_positive_rpr_and_had_later_visit(self): found_rpr = False for enc in self.sorted_encounters(): if enc.get_xform().xpath("rpr") == "r": found_rpr = True continue # this healthy visit must have come after a positive test if found_rpr and is_healthy_pregnancy_encounter(enc): return True return False
def sorted_healthy_encounters(self): # TODO: should we sort by visit number or by date? return [enc for enc in self.sorted_encounters() if is_healthy_pregnancy_encounter(enc)]