Skip to content

Commit 09cd17b

Browse files
authored
Chore/data updates (LIF-Initiative#824)
<!-- Thank you for your pull request. Please review the requirements below. Bug fixes and new features should be reported on the issue tracker: https://github.com/lif-initiative/lif-core/issues Contributing guide: https://github.com/lif-initiative/lif-core/blob/main/docs/CONTRIBUTING.md Code of Conduct: https://github.com/lif-initiative/lif-core/blob/main/CODE_OF_CONDUCT.md --> ##### Checklist <!-- Remove items that do not apply. For completed items, change [ ] to [x]. --> - [x] commit message follows commit guidelines (see commitlint.config.mjs) - [x] tests are included (unit and/or integration tests) - [ ] all tests are successful - [ ] documentation is changed or added (in /docs directory) - [ ] code passes linting checks (`uv run ruff check`) - [ ] code passes formatting checks (`uv run ruff format`) - [ ] code passes type checking (`uv run ty check`) - [ ] pre-commit hooks have been run successfully - [ ] database schema changes: migration files created and CHANGELOG.md updated - [ ] API changes: base (Python code) documentation in `docs/` and project README updated - [ ] configuration changes: relevant folder README updated - [ ] breaking changes: added to MIGRATION.md with upgrade instructions and CHANGELOG.md entry ##### Type of Change <!-- Check all that apply --> These are questionable data updates I did not add to the big data update PR. Please review if we need to add this or ignore it. - [ ] Bug fix (non-breaking change which fixes an issue) - [ ] New feature (non-breaking change which adds functionality) - [ ] Breaking change (fix or feature that would cause existing functionality to not work as expected) - [ ] Documentation update - [ ] Infrastructure/deployment change - [ ] Performance improvement - [ ] Code refactoring ##### Description of Change <!-- Provide a clear and detailed description of the change below this comment. Include: - What problem does this solve? - What is the solution? - Are there any side effects or limitations? - How should reviewers test this? --> ##### Related Issues <!-- Link to related issues using #issue_number --> Closes # [[add Github issue number]] ##### Testing <!-- Describe the testing you've done --> - [x] Manual testing performed - [ ] Automated tests added/updated - [x] Integration testing completed ##### Project Area(s) Affected <!-- Check all project areas affected by this change --> - [x] bases/ - [ ] components/ - [ ] orchestrators/ - [ ] frontends/ - [ ] deployments/ - [ ] CloudFormation/SAM templates - [x] Database schema - [ ] API endpoints - [ ] Documentation - [ ] Testing ##### Additional Notes <!-- Any additional information that reviewers should know -->
2 parents e86843d + 36edcc1 commit 09cd17b

File tree

3 files changed

+114
-19
lines changed

3 files changed

+114
-19
lines changed

bases/lif/example_data_source_rest_api/core.py

Lines changed: 57 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -39,22 +39,73 @@ async def health_check():
3939
"100001": {
4040
"person": {
4141
"id": "100001",
42-
"employment": {"preferences": {"preferred_org_types": ["Public Sector", "Private Sector"]}},
42+
"employment": {
43+
"preferences": {
44+
"id": "employment-preferences-100001-001",
45+
"preferred_org_types": ["Public Sector", "Private Sector"],
46+
"preferred_org_names": ["Government Agencies", "Technology Companies"],
47+
}
48+
},
49+
}
50+
},
51+
"100002": {
52+
"person": {
53+
"id": "100002",
54+
"employment": {
55+
"preferences": {
56+
"id": "employment-preferences-100002-001",
57+
"preferred_org_types": ["Non-Profit"],
58+
"preferred_org_names": ["Healthcare Organizations", "Community Services"],
59+
}
60+
},
61+
}
62+
},
63+
"100003": {
64+
"person": {
65+
"id": "100003",
66+
"employment": {
67+
"preferences": {
68+
"id": "employment-preferences-100003-001",
69+
"preferred_org_types": ["Private Sector"],
70+
"preferred_org_names": ["Corporate Partners", "Technology Companies"],
71+
}
72+
},
73+
}
74+
},
75+
"100004": {
76+
"person": {
77+
"id": "100004",
78+
"employment": {
79+
"preferences": {
80+
"id": "employment-preferences-100004-001",
81+
"preferred_org_types": ["Public Sector"],
82+
"preferred_org_names": ["Government Agencies", "Educational Institutions"],
83+
}
84+
},
4385
}
4486
},
45-
"100002": {"person": {"id": "100002", "employment": {"preferences": {"preferred_org_types": ["Non-Profit"]}}}},
46-
"100003": {"person": {"id": "100003", "employment": {"preferences": {"preferred_org_types": ["Private Sector"]}}}},
47-
"100004": {"person": {"id": "100004", "employment": {"preferences": {"preferred_org_types": ["Public Sector"]}}}},
4887
"100005": {
4988
"person": {
5089
"id": "100005",
51-
"employment": {"preferences": {"preferred_org_types": ["Non-Profit", "Private Sector"]}},
90+
"employment": {
91+
"preferences": {
92+
"id": "employment-preferences-100005-001",
93+
"preferred_org_types": ["Non-Profit", "Private Sector"],
94+
"preferred_org_names": ["Healthcare Organizations", "Research Institutions"],
95+
}
96+
},
5297
}
5398
},
5499
"100006": {
55100
"person": {
56101
"id": "100006",
57-
"employment": {"preferences": {"preferred_org_types": ["Non-Profit", "Public Sector"]}},
102+
"employment": {
103+
"preferences": {
104+
"id": "employment-preferences-100006-001",
105+
"preferred_org_types": ["Non-Profit", "Public Sector"],
106+
"preferred_org_names": ["Community Services", "Government Agencies"],
107+
}
108+
},
58109
}
59110
},
60111
}

components/lif/data_source_adapters/lif_to_lif_adapter/graphql_query_all_fields_org3.graphql

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,8 @@ query GetPersonByIdentifier($identifier: String!, $identifierType: String!) {
2626
name
2727
}
2828
identifier
29-
#awardIssueDate
30-
#credentialAwardee
29+
awardIssueDate
30+
credentialAwardee
3131
}
3232
CourseLearningExperience {
3333
informationSourceId
@@ -42,8 +42,6 @@ query GetPersonByIdentifier($identifier: String!, $identifierType: String!) {
4242
informationSourceOrganization
4343
identifier
4444
name
45-
#awardIssueDate
46-
#credentialAwardee
4745
}
4846
}
4947
Proficiency {
@@ -52,8 +50,6 @@ query GetPersonByIdentifier($identifier: String!, $identifierType: String!) {
5250
description
5351
RefCredentialAward {
5452
identifier
55-
#awardIssueDate
56-
#credentialAwardee
5753
informationSourceId
5854
informationSourceOrganization
5955
}

test/components/lif/translator/test_core.py

Lines changed: 55 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -109,18 +109,40 @@ def test_base_translator_final_validation_failure():
109109
# New test for Translator.run with employment preferences mapping
110110
@pytest.mark.asyncio
111111
async def test_translator_run_with_employment_preferences(monkeypatch):
112-
# Input data from the prompt
112+
# Input data matching the r1_demo_data structure in example_data_source_rest_api/core.py
113113
input_data = {
114114
"person": {
115115
"id": "100001",
116-
"employment": {"preferences": {"preferred_org_types": ["Public Sector", "Private Sector"]}},
116+
"employment": {
117+
"preferences": {
118+
"id": "employment-preferences-100001-001",
119+
"preferred_org_types": ["Public Sector", "Private Sector"],
120+
"preferred_org_names": ["Government Agencies", "Technology Companies"],
121+
}
122+
},
117123
}
118124
}
119125

120-
# Expected result from the prompt
121-
expected = {"Person": [{"EmploymentPreferences": [{"organizationTypes": ["Public Sector", "Private Sector"]}]}]}
126+
# Expected LIF output matching new-lif-schema.json EmploymentPreferences requirements
127+
expected = {
128+
"Person": [
129+
{
130+
"EmploymentPreferences": [
131+
{
132+
"identifier": "employment-preferences-100001-001",
133+
"organizationTypes": ["Public Sector", "Private Sector"],
134+
"organizationNames": ["Government Agencies", "Technology Companies"],
135+
}
136+
]
137+
}
138+
]
139+
}
122140

123-
# Transformation payload mimicking the MDR response in transformations_for_26_to_17.json
141+
# Transformation payload mimicking the MDR response
142+
# Maps source fields to LIF EmploymentPreferences fields:
143+
# person.employment.preferences.id -> EmploymentPreferences.identifier
144+
# person.employment.preferences.preferred_org_types -> EmploymentPreferences.organizationTypes
145+
# person.employment.preferences.preferred_org_names -> EmploymentPreferences.organizationNames
124146
transformation_payload = {
125147
"total": 2,
126148
"page": 1,
@@ -138,7 +160,7 @@ async def test_translator_run_with_employment_preferences(monkeypatch):
138160
"TransformationGroupDescription": None,
139161
"TransformationGroupNotes": None,
140162
"TransformationId": 1375,
141-
"TransformationExpression": '{ "Person": [{ "EmploymentPreferences": [{ "organizationTypes": person.employment.preferences.preferred_org_types }] }] }',
163+
"TransformationExpression": '{ "Person": [{ "EmploymentPreferences": [{ "identifier": person.employment.preferences.id, "organizationTypes": person.employment.preferences.preferred_org_types, "organizationNames": person.employment.preferences.preferred_org_names }] }] }',
142164
"TransformationExpressionLanguage": "JSONata",
143165
"TransformationNotes": None,
144166
"TransformationAlignment": None,
@@ -148,6 +170,19 @@ async def test_translator_run_with_employment_preferences(monkeypatch):
148170
"TransformationContributor": None,
149171
"TransformationContributorOrganization": None,
150172
"TransformationSourceAttributes": [
173+
{
174+
"AttributeId": 1896,
175+
"EntityId": 377,
176+
"AttributeName": "id",
177+
"AttributeType": "Source",
178+
"Notes": None,
179+
"CreationDate": None,
180+
"ActivationDate": None,
181+
"DeprecationDate": None,
182+
"Contributor": None,
183+
"ContributorOrganization": None,
184+
"EntityIdPath": "person.employment.preferences",
185+
},
151186
{
152187
"AttributeId": 1895,
153188
"EntityId": 377,
@@ -160,7 +195,20 @@ async def test_translator_run_with_employment_preferences(monkeypatch):
160195
"Contributor": None,
161196
"ContributorOrganization": None,
162197
"EntityIdPath": "person.employment.preferences",
163-
}
198+
},
199+
{
200+
"AttributeId": 1897,
201+
"EntityId": 377,
202+
"AttributeName": "preferred_org_names",
203+
"AttributeType": "Source",
204+
"Notes": None,
205+
"CreationDate": None,
206+
"ActivationDate": None,
207+
"DeprecationDate": None,
208+
"Contributor": None,
209+
"ContributorOrganization": None,
210+
"EntityIdPath": "person.employment.preferences",
211+
},
164212
],
165213
"TransformationTargetAttribute": {
166214
"AttributeId": 1876,

0 commit comments

Comments
 (0)