92 lines
3.3 KiB
Python
92 lines
3.3 KiB
Python
import json, re
|
|
|
|
def norm(s):
|
|
return re.sub(r'[^a-z]', '', (s or '').lower())
|
|
|
|
alis = json.load(open('.alis_staff.json'))
|
|
# ALIS staff: list of dicts
|
|
arecs = []
|
|
for s in alis:
|
|
arecs.append({
|
|
'first': s.get('firstName','') or '',
|
|
'last': s.get('lastName','') or '',
|
|
'nick': s.get('nickName','') or '',
|
|
'job': s.get('jobRole') or '(none)',
|
|
'status': s.get('status',''),
|
|
'email': s.get('primaryEmail') or '',
|
|
})
|
|
|
|
def is_cg(job):
|
|
return 'caregiver' in (job or '').lower()
|
|
|
|
# Load AD caregivers
|
|
ad = []
|
|
for line in open('.ad_cg.tsv'):
|
|
line=line.rstrip('\n')
|
|
if not line.strip(): continue
|
|
parts=line.split('\t')
|
|
if len(parts)<4: continue
|
|
gn,sn,upn,en=parts[0],parts[1],parts[2],parts[3]
|
|
ad.append({'gn':gn,'sn':sn,'upn':upn,'enabled':en})
|
|
|
|
def find_alis(gn, sn):
|
|
# match by last-name token overlap, then by first name / nickname
|
|
ad_last_tokens = set(t for t in norm(sn) and norm(sn).split() or []) # not used
|
|
ad_sn = norm(sn); ad_gn = norm(gn)
|
|
# try surname tokens
|
|
sn_tokens = [norm(t) for t in sn.split() if norm(t)]
|
|
cands=[]
|
|
for r in arecs:
|
|
a_sn = norm(r['last'])
|
|
a_sn_tokens=[norm(t) for t in r['last'].split() if norm(t)]
|
|
# surname match: any shared token or containment
|
|
shared = any(t in a_sn_tokens for t in sn_tokens) or ad_sn==a_sn or ad_sn in a_sn or a_sn in ad_sn
|
|
if shared:
|
|
cands.append(r)
|
|
# disambiguate by first name / nick if multiple
|
|
if len(cands)>1:
|
|
fn_match=[r for r in cands if norm(r['first'])==ad_gn or norm(r['nick'])==ad_gn or ad_gn in (norm(r['first'])+norm(r['nick'])) ]
|
|
if fn_match: return fn_match
|
|
return cands
|
|
|
|
print("=== AD caregiver -> ALIS match ===")
|
|
print(f"{'AD NAME':28} {'UPN':40} {'ALIS jobRole':34} {'ALIS status'}")
|
|
matched_alis_ids=set()
|
|
ad_only=[]; ad_other=[]; ad_cg=[]
|
|
for u in ad:
|
|
name=f"{u['gn']} {u['sn']}"
|
|
if u['upn'].startswith('pilot.test'):
|
|
continue
|
|
if u['enabled']=='False':
|
|
continue
|
|
cands=find_alis(u['gn'],u['sn'])
|
|
if not cands:
|
|
print(f"{name:28} {u['upn']:40} {'-- NOT FOUND IN ALIS (Hired) --':34}")
|
|
ad_only.append(name); continue
|
|
# pick a caregiver candidate if present else first
|
|
cg=[c for c in cands if is_cg(c['job'])]
|
|
pick = cg[0] if cg else cands[0]
|
|
tag = pick['job']
|
|
print(f"{name:28} {u['upn']:40} {tag:34} {pick['status']}")
|
|
if is_cg(pick['job']): ad_cg.append(name)
|
|
else: ad_other.append((name, pick['job']))
|
|
|
|
print()
|
|
print(f"AD caregivers that ARE ALIS caregivers: {len(ad_cg)}")
|
|
print(f"AD caregivers with OTHER ALIS title (ignore per Howard): {len(ad_other)}")
|
|
for n,j in ad_other: print(f" {n:28} -> {j}")
|
|
print(f"AD caregivers NOT FOUND in ALIS Hired: {len(ad_only)}")
|
|
for n in ad_only: print(f" {n}")
|
|
|
|
# ALIS caregivers with no AD caregiver account
|
|
print()
|
|
print("=== ALIS caregivers (jobRole~caregiver) with NO AD caregiver account ===")
|
|
ad_norm=set(norm(u['sn']).split()[-1] if u['sn'] else '' for u in ad)
|
|
ad_last=[norm(t) for u in ad for t in u['sn'].split()]
|
|
for r in arecs:
|
|
if not is_cg(r['job']): continue
|
|
a_tokens=[norm(t) for t in r['last'].split()]
|
|
if any(t in ad_last for t in a_tokens):
|
|
continue
|
|
print(f" {r['first']} {r['last']:22} job={r['job']:34} status={r['status']} email={r['email']}")
|