Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
45 changes: 45 additions & 0 deletions cin_validator/ingress.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,8 @@ class XMLtoCSV:
to be populated with children's data from XML input.
:param DataFrame Reviews: DataFrame of fields for the Reviews table for validation.
to be populated with children's data from XML input.
:param DataFrame PreProceedings: DataFrame of fields for the Pre Proceedings and FGDM table for validation.
to be populated with children's data from XML input.
:param list id_cols: List of columns containing IDs that can be used to merge tables.
"""

Expand Down Expand Up @@ -130,6 +132,21 @@ class XMLtoCSV:
columns=["LAchildID", "CINdetailsID", "CPPID", "CPPreviewDate"]
)

PreProceedings = pd.DataFrame(
[
"PPStartDate",
"LBPSentDate",
"FGDMMeetingOffer",
"FGDMMeetingFac",
"InitialPPMeetingDate",
"ReviewMeetingsCount",
"StepDecisionDate",
"PPOutcome",
"CourtAppDate",
"LetterInitCPDate",
]
)

id_cols = ["LAchildID", "CINdetailsID", "AssessmentID", "CPPID"]

def __init__(self, root):
Expand Down Expand Up @@ -309,6 +326,7 @@ def create_CINdetails(self, child):
self.create_CINplanDates(cin_detail)
self.create_Section47(cin_detail)
self.create_ChildProtectionPlans(cin_detail)
self.create_PreProceedings(cin_detail)

cin_details_df = pd.DataFrame(cin_details_list)
self.CINdetails = pd.concat(
Expand Down Expand Up @@ -466,6 +484,33 @@ def create_ChildProtectionPlans(self, cin_detail):
[self.ChildProtectionPlans, plans_df], ignore_index=True
)

def create_PreProceedings(self, cin_detail):
"""
Populates the PreProceedings table. Multiple PreProceedings blocks can exist in one CINdetails block.

:param xml child: 'child' element from the XML input
:returns: DataFrame of data for an individual child for the PreProceedings Table.
:rtype: DataFrame
"""

sections_list = []
columns = self.PreProceedings.columns
elements = list(set(columns).difference(set(self.id_cols)))

sections = cin_detail.findall("PreProceedingsandFGDM")
for section in sections:
section_dict = {
"LAchildID": self.LAchildID,
"CINdetailsID": self.CINdetailsID,
}
section_dict = get_values(elements, section_dict, section)
sections_list.append(section_dict)

sections_df = pd.DataFrame(sections_list)
self.PreProceedings = pd.concat(
[self.PreProceedings, sections_df], ignore_index=True
)

def create_Reviews(self, plan):
"""
Populates the ChildIdentifiers table. Multiple Reviews blocks can exist in one Reviews block.
Expand Down
113 changes: 113 additions & 0 deletions fake_data/CIN_Census_2026.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,113 @@
<Message>
<Header>
<CollectionDetails>
<Collection>CIN</Collection>
<Year>2023</Year>
<ReferenceDate>2024-03-31</ReferenceDate>
</CollectionDetails>
<Source>
<SourceLevel>L</SourceLevel>
<LEA>201</LEA>
<SoftwareCode>Local Authority</SoftwareCode>
<Release>ver 3.1.21</Release>
<SerialNo>001</SerialNo>
<DateTime>2023-05-23T11:14:05</DateTime>
</Source>
</Header>
<Children>
<Child>
<ChildIdentifiers>
<LAchildID>DfEX0000001</LAchildID>
<UPN>A123456789123</UPN>
<FormerUPN>X98765432123B</FormerUPN>
<UPNunknown>UN3</UPNunknown>PersonBirthDate
<PersonBirthDate>2015-03-27</PersonBirthDate>
<Sex>1</Sex>
</ChildIdentifiers>
<ChildCharacteristics>
<Ethnicity>WBRI</Ethnicity>
<Disabilities>
<Disability>HAND</Disability>
<Disability>HEAR</Disability>
</Disabilities>
</ChildCharacteristics>
<CINdetails>
<CINreferralDate>2022-10-06</CINreferralDate>
<ReferralSource>1A</ReferralSource>
<PrimaryNeedCode>N4</PrimaryNeedCode>
<CINclosureDate>2023-02-27</CINclosureDate>
<ReasonForClosure>RC1</ReasonForClosure>
<DateOfInitialCPC>2022-12-06</DateOfInitialCPC>
<Assessments>
<AssessmentActualStartDate>2028-04-28</AssessmentActualStartDate>
<AssessmentAuthorisationDate>2020-09-19</AssessmentAuthorisationDate>
<FactorsIdentifiedAtAssessment>
<AssessmentFactors>1C</AssessmentFactors>
<AssessmentFactors>RB</AssessmentFactors>
<AssessmentFactors>6B</AssessmentFactors>
</FactorsIdentifiedAtAssessment>
</Assessments>
<CINPlanDates>
<CINPlanStartDate>2023-01-24</CINPlanStartDate>
<CINPlanEndDate>2023-01-26</CINPlanEndDate>
</CINPlanDates>
<Section47>
<S47ActualStartDate>2022-06-02</S47ActualStartDate>
<InitialCPCtarget>2022-06-23</InitialCPCtarget>
<DateOfInitialCPC>2022-06-17</DateOfInitialCPC>
<ICPCnotRequired>false</ICPCnotRequired>
</Section47>
<ReferralNFA>0</ReferralNFA>
<ChildProtectionPlans>
<CPPstartDate>2022-02-17</CPPstartDate>
<CPPendDate>2023-03-14</CPPendDate>
<InitialCategoryOfAbuse>PHY</InitialCategoryOfAbuse>
<LatestCategoryOfAbuse>PHY</LatestCategoryOfAbuse>
<NumberOfPreviousCPP>10</NumberOfPreviousCPP>
<Reviews>
<CPPreviewDate>2023-02-15</CPPreviewDate>
</Reviews>
</ChildProtectionPlans>
<PreProceedingsandFGDM>
<PPStartDate>2026-09-09</PPStartDate>
<LBPSentDate>2026-09-20</LBPSentDate>
<FGDMMeetingOffer>1</FGDMMeetingOffer>
<FGDMMeetingFac>1</FGDMMeetingFac>
<InitialPPMeetingDate>2026-09-28</InitialPPMeetingDate>
<ReviewMeetingsCount>3</ReviewMeetingsCount>
<StepDecisionDate>2026-12-01</StepDecisionDate>
<PPOutcome>A</PPOutcome>
<CourtAppDate>2026-12-18</CourtAppDate>
<LetterInitCPDate>2027-02-05</LetterInitCPDate>
</PreProceedingsandFGDM>
</CINdetails>
</Child>
<Child>
<ChildIdentifiers>
<LAchildID>child_fails_assessments</LAchildID>
<UPNunknown>UN1</UPNunknown>
<PersonBirthDate>2023-09-25</PersonBirthDate>
<Sex>M</Sex>
</ChildIdentifiers>
<ChildCharacteristics>
<Ethnicity>WBRI</Ethnicity>
<Disabilities>
<Disability>NONE</Disability>
</Disabilities>
</ChildCharacteristics>
<CINdetails>
<CINreferralDate>2024-10-24</CINreferralDate>
<ReferralSource>1A</ReferralSource>
<PrimaryNeedCode>N1</PrimaryNeedCode>
<CINclosureDate>2024-10-29</CINclosureDate>
<ReasonForClosure>RC9</ReasonForClosure>
<Assessments>
<AssessmentActualStartDate>2023-12-25</AssessmentActualStartDate>
<AssessmentAuthorisationDate>2024-01-27</AssessmentAuthorisationDate>
<FactorsIdentifiedAtAssessment/>
</Assessments>
<ReferralNFA>false</ReferralNFA>
</CINdetails>
</Child>
</Children>
</Message>
Loading