"""Healthcare -> tech roles. Applied to the base app text by build.py."""
import re
ROLES = [  # longest first
 ("Bank Theatre Support Worker","Junior Graphic Designer"),("Theatre Stores Coordinator","Scrum Master"),
 ("Senior Scrub Nurse","Senior React Developer"),("Patient Transport Porter","Technical Support Engineer"),
 ("Operating Department Practitioner","Product Designer"),("Sterile Services Technician","QA Engineer"),
 ("Anaesthetic Assistant","Node.js Developer"),("Healthcare Assistant","Data Analyst"),
 ("Endoscopy Assistant","Mobile App Developer"),("Theatre Coordinator","Design Lead"),
 ("Theatre Attendant","UI/UX Designer"),("Recovery Nurse","Frontend Developer"),
 ("Scrub Nurse","React Developer"),("Night Porter","DevOps Engineer"),
]
SKILLS = {
 "UI/UX Designer":["Figma","User research","Wireframing"],"React Developer":["React","TypeScript","Redux"],
 "Product Designer":["Product strategy","Prototyping","Design systems"],"Frontend Developer":["JavaScript","CSS","Accessibility"],
 "QA Engineer":["Test automation","Cypress","Regression testing"],"Node.js Developer":["Node.js","REST APIs","PostgreSQL"],
 "Data Analyst":["SQL","Power BI","Python"],"DevOps Engineer":["AWS","Docker","CI/CD"],
}
PLAIN = [
 ('<span>Current hospital</span>','<span>Current company</span>'),('placeholder="e.g. Aster Medcity"','placeholder="e.g. Infosys"'),
 ('<span>Years in theatres</span>','<span>Years of experience</span>'),
 ('Add the hospital they work at now','Add the company they work at now'),
 ('placeholder="e.g. Perioperative services"','placeholder="e.g. Engineering"'),('placeholder="e.g. Main theatres, Level 3"','placeholder="e.g. London office, Floor 3"'),
 ('hint:"Panel with the theatre manager"','hint:"Panel with the design lead"'),('hint:"References and DBS check"','hint:"References and background check"'),
 ('const OB_ITEMS=["Offer letter signed","Background and DBS check","Occupational health clearance","Scrubs and theatre shoes fitted","Theatre safety induction"]',
  'const OB_ITEMS=["Offer letter signed","Background check","Right-to-work check","Laptop and accounts set up","Security & onboarding induction"]'),
 ('4 yrs · Apollo Hospitals','4 yrs · Infosys'),('6 yrs · NHS Leeds','6 yrs · Sky UK'),('3 yrs · Max Healthcare','3 yrs · Zomato'),
 ('5 yrs · Cleveland Clinic','5 yrs · Spotify'),('6 yrs · Manipal Hospitals','6 yrs · Razorpay'),('1 yr · Charité Berlin','1 yr · Zalando'),
 ('Strong on instrument counts and swab checks. Second reference still pending.','Strong on design systems and user research. Second reference still pending.'),
 ('No theatre experience yet. Keep for the trainee intake.','No production experience yet. Keep for the graduate intake.'),
 ('const GHOSP=["St Mary\'s Hospital","Royal Free Hospital","Aster Medcity","Kokilaben Hospital","Mayo Clinic","Royal Infirmary","Narayana Health","King\'s College Hospital","Charité Berlin","Mount Sinai","AIIMS Delhi","Guy\'s & St Thomas\'"]',
  'const GHOSP=["Google","Microsoft","Infosys","TCS","Wipro","Accenture","Atlassian","Spotify","Zalando","Shopify","Freshworks","Swiggy"]'),
 ('Panel interview with the theatre manager · Theatre 4 seminar room','Panel interview with the design lead · Meeting room 4'),
 ('cut theatre waste','cut office waste'),
 ('HR round · references and DBS paperwork · video call','HR round · references and background check · video call'),
 ('const SKILL_SUG=["Communication","Critical Thinking","Problem Solving","Teamwork","Infection control","Patient transfer","Sterile field","Instrument counts","Manual handling","Time management","Attention to detail"]',
  'const SKILL_SUG=["Communication","Problem Solving","Teamwork","Figma","React","TypeScript","User research","Design systems","Accessibility","Time management","Attention to detail"]'),
 ('["Theatre roles · 5 stages"','["Design roles · 5 stages"'),('["Bank staff · 3 stages"','["Contractors · 3 stages"'),('["Trainee intake · 6 stages"','["Graduate intake · 6 stages"'),
 ('manager at Cleveland Clinic','manager at Spotify'),
 ('title:"Theatre team huddle"','title:"Design team stand-up"'),('title:"Perioperative hiring review"','title:"Engineering hiring review"'),
 ('title:"Infection control training"','title:"Accessibility training"'),('title:"Manual handling refresher"','title:"Security awareness refresher"'),
 ('title:"Bank staff induction"','title:"New starter induction"'),
 ('industry:"Healthcare"','industry:"Technology"'),
]
DEPTS={"ta":"Design","j2":"Engineering","j3":"Design","j4":"Engineering","j5":"Quality","j6":"Engineering","j7":"Data","j8":"Platform"}

def apply(app):
    for a,b in PLAIN:
        assert a in app, "retheme: missing "+a[:60]
        app = app.replace(a,b)
    # job departments
    for jid,dept in DEPTS.items():
        app, n = re.subn(r'(\{id:"%s",title:"[^"]+",status:"active"[^}]*?dept:")[^"]+(")' % jid, r'\g<1>%s\g<2>' % dept, app, count=1)
        assert n==1, jid
    # talent pool: map role + give role-specific skills
    def tp(m):
        role = dict(ROLES).get(m.group(2), m.group(2))
        return '%s"%s",%s,[%s]]' % (m.group(1), role, m.group(3), ",".join('"%s"' % s for s in SKILLS[role]))
    app, n = re.subn(r'(\["[^"]+","[^"]+",)"([^"]+)",("[^"]+",\d+,\d+,\d+),\[[^\]]*\]\]', tp, app)
    assert n >= 27, n
    for a,b in ROLES: app = app.replace(a,b)
    return app
