o
    ki                     @  sR   d dl mZ d dlmZ d dlmZ ddlmZmZ ddl	m
Z
 G dd dZd	S )
    )annotations)Path)Any   )	read_json
write_json)now_isoc                   @  s   e Zd ZdZd	ddZdS )
OccupationServicez=Produces a preliminary occupation-alignment support analysis.applicant_baser   returndict[str, Any]c                 C  s`  t |d i dp	i }|dd}g }t|dD ]=}t |i dp"i }t|dp*d }|dv r3q|jd d	 d
 }| sAqt |i dpHi }	||	di dg  qtt	|}
t
 |g d|ped ddgddg|
dd}|d }t|d | ddddd|pd dddddddddd d!dd"|
rd#|
nd$ g}|d% jd&|d& d'd( |S ))Nzapplicant.json)defaultnominated_occupation zmeta/manifest.jsonstatus>   ignoredarchived	duplicate   	extractedzentities.jsonentitiesdetected_keywordszEMap responsibilities from verified employment records to occupation 'TBDz'.zVCross-check duties against official occupation criteria with a migration professional.z2Detailed duty statements tied to each role period.z0Employer references with role, dates, and hours.z@Support workflow only; not legal advice and not a visa decision.)generated_atr   verified_evidenceinferred_suggestionsmissing_evidencer   
disclaimer	generatedzoccupation_analysis.jsonz# Occupation Analysisz## Nominated Occupation
- zNot setz## Verified Evidencez- None auto-verified in V1.z## Inferred SuggestionszG- Map employment records to occupation duties and required skill level.z9- Validate with migration professional before submission.z## Missing Evidencez2- Employer references confirming role/dates/hours.z5- Duty statements that align to nominated occupation.z## Detected Keywords
- z, Nonezoccupation_analysis.md
zutf-8)encoding)r   getsortedrglobstrlowerparentsexistsextendsetr   r   join
write_text)selfr
   	applicant	nominatedevidence_keywordsmanifest_pathmanifestr   entities_pathpayloadunique_keywordsoutputgenerated_dirmd_lines r9   >apps/migration_evidence_builder/services/occupation_service.pyanalyze   sb   zOccupationService.analyzeN)r
   r   r   r   )__name__
__module____qualname____doc__r;   r9   r9   r9   r:   r	   
   s    r	   N)
__future__r   pathlibr   typingr   utils.json_utilsr   r   utils.time_utilsr   r	   r9   r9   r9   r:   <module>   s    