def subj_pred_idx_to_uri(s: URIRef, p: URIRef, idx: Optional[int] = None) -> URIRef:
    """ Convert FHIR subject, predicate and entry index into a URI.  The resulting element can be substituted
    for the name of the target BNODE
    :param s: Subject URI (e.g. "fhir:Patient/f201", "fhir:Patient/f201.Patient.identifier_0", ...)
    :param p: Predicate URI (e.g. "fhir:Patient.identifier", "fhir.Identifier.use
    :param idx: Relative position of BNODE if in a list
    :return: URI that can replace the BNODE (e.g. "fhir:Patient/f201
    """
    return URIRef(str(s) + '.' + str(p).rsplit('/', 1)[1] + ("_{}".format(idx) if idx is not None else ''))