@@ -44,9 +44,11 @@ public Set<String> extractAllInputPaths(List<Benefit> benefits) {
4444 /**
4545 * Transforms a CheckConfig's inputDefinition JSON Schema by applying all schema transformations.
4646 * Currently applies:
47- * 1. People transformation: converts people array to object keyed by personId
47+ * 1. People transformation: converts people array to object keyed by personId(s)
4848 * 2. Enrollments transformation: moves enrollments under people.{personId}.enrollments
4949 *
50+ * Supports both single personId (String) and multiple peopleIds (List<String>) parameters.
51+ *
5052 * @param checkConfig The CheckConfig containing inputDefinition and parameters
5153 * @return A new JsonNode with all transformations applied
5254 */
@@ -57,30 +59,68 @@ public JsonNode transformInputDefinitionSchema(CheckConfig checkConfig) {
5759 return inputDefinition != null ? inputDefinition .deepCopy () : objectMapper .createObjectNode ();
5860 }
5961
60- // Extract personId from parameters
62+ // Extract personId(s) from parameters - supports both single personId and multiple peopleIds
6163 Map <String , Object > parameters = checkConfig .getParameters ();
62- String personId = parameters != null ? ( String ) parameters . get ( "personId" ) : null ;
64+ List < String > personIds = extractPersonIds ( parameters ) ;
6365
6466 // Apply each transformation in sequence
6567 JsonNode schema = inputDefinition .deepCopy ();
66- schema = transformPeopleSchema (schema , personId );
67- schema = transformEnrollmentsSchema (schema , personId );
68+ schema = transformPeopleSchema (schema , personIds );
69+ schema = transformEnrollmentsSchema (schema , personIds );
6870
6971 return schema ;
7072 }
7173
74+ /**
75+ * Extracts person IDs from parameters, supporting both:
76+ * - personId: a single String ID
77+ * - peopleIds: a List of String IDs
78+ *
79+ * @param parameters The parameters map from CheckConfig
80+ * @return List of person IDs (may be empty if neither parameter is set)
81+ */
82+ private List <String > extractPersonIds (Map <String , Object > parameters ) {
83+ if (parameters == null ) {
84+ return Collections .emptyList ();
85+ }
86+
87+ List <String > personIds = new ArrayList <>();
88+
89+ // Check for single personId
90+ Object personId = parameters .get ("personId" );
91+ if (personId instanceof String && !((String ) personId ).isEmpty ()) {
92+ personIds .add ((String ) personId );
93+ }
94+
95+ // Check for multiple peopleIds
96+ Object peopleIds = parameters .get ("peopleIds" );
97+ if (peopleIds instanceof List ) {
98+ for (Object id : (List <?>) peopleIds ) {
99+ if (id instanceof String && !((String ) id ).isEmpty ()) {
100+ personIds .add ((String ) id );
101+ }
102+ }
103+ }
104+
105+ return personIds ;
106+ }
107+
72108 /**
73109 * Transforms the `people` array property into an object with personId-keyed properties.
74110 *
75- * Example:
111+ * Example (single ID) :
76112 * Input: { people: { type: "array", items: { properties: { dateOfBirth: ... } } } }
77113 * Output: { people: { type: "object", properties: { [personId]: { properties: { dateOfBirth: ... } } } } }
78114 *
115+ * Example (multiple IDs):
116+ * Input: { people: { type: "array", items: { properties: { dateOfBirth: ... } } } }
117+ * Output: { people: { type: "object", properties: { [id1]: {...}, [id2]: {...} } } }
118+ *
79119 * @param schema The JSON Schema to transform
80- * @param personId The personId to use as the key under people
120+ * @param personIds List of personIds to use as keys under people
81121 * @return A new JsonNode with `people` transformed, or the original if no transformation needed
82122 */
83- public JsonNode transformPeopleSchema (JsonNode schema , String personId ) {
123+ public JsonNode transformPeopleSchema (JsonNode schema , List < String > personIds ) {
84124 if (schema == null || !schema .has ("properties" )) {
85125 return schema != null ? schema .deepCopy () : objectMapper .createObjectNode ();
86126 }
@@ -93,8 +133,8 @@ public JsonNode transformPeopleSchema(JsonNode schema, String personId) {
93133 return schema .deepCopy ();
94134 }
95135
96- // If people property exists but no personId , return original (can't transform)
97- if (personId == null || personId .isEmpty ()) {
136+ // If people property exists but no personIds , return original (can't transform)
137+ if (personIds == null || personIds .isEmpty ()) {
98138 return schema .deepCopy ();
99139 }
100140
@@ -105,12 +145,14 @@ public JsonNode transformPeopleSchema(JsonNode schema, String personId) {
105145 // Get the items schema from the people array
106146 JsonNode itemsSchema = peopleProperty .get ("items" );
107147
108- // Transform people from array to object with personId as a nested property
148+ // Transform people from array to object with personIds as nested properties
109149 ObjectNode newPeopleSchema = objectMapper .createObjectNode ();
110150 newPeopleSchema .put ("type" , "object" );
111151 ObjectNode newPeopleProperties = objectMapper .createObjectNode ();
112152 if (itemsSchema != null ) {
113- newPeopleProperties .set (personId , itemsSchema .deepCopy ());
153+ for (String personId : personIds ) {
154+ newPeopleProperties .set (personId , itemsSchema .deepCopy ());
155+ }
114156 }
115157
116158 newPeopleSchema .set ("properties" , newPeopleProperties );
@@ -122,15 +164,19 @@ public JsonNode transformPeopleSchema(JsonNode schema, String personId) {
122164 * Transforms the `enrollments` array property by moving it under people.{personId}.enrollments
123165 * as an array of strings (benefit names).
124166 *
125- * Example:
167+ * Example (single ID) :
126168 * Input: { enrollments: { type: "array", items: { properties: { personId: ..., benefit: ... } } } }
127169 * Output: { people: { type: "object", properties: { [personId]: { properties: { enrollments: { type: "array", items: { type: "string" } } } } } } }
128170 *
171+ * Example (multiple IDs):
172+ * Input: { enrollments: { type: "array", ... } }
173+ * Output: { people: { type: "object", properties: { [id1]: { properties: { enrollments: ... } }, [id2]: { properties: { enrollments: ... } } } } }
174+ *
129175 * @param schema The JSON Schema to transform
130- * @param personId The personId to use as the key under people
176+ * @param personIds List of personIds to use as keys under people
131177 * @return A new JsonNode with `enrollments` transformed, or the original if no transformation needed
132178 */
133- public JsonNode transformEnrollmentsSchema (JsonNode schema , String personId ) {
179+ public JsonNode transformEnrollmentsSchema (JsonNode schema , List < String > personIds ) {
134180 if (schema == null || !schema .has ("properties" )) {
135181 return schema != null ? schema .deepCopy () : objectMapper .createObjectNode ();
136182 }
@@ -143,8 +189,8 @@ public JsonNode transformEnrollmentsSchema(JsonNode schema, String personId) {
143189 return schema .deepCopy ();
144190 }
145191
146- // If enrollments property exists but no personId , return original (can't transform)
147- if (personId == null || personId .isEmpty ()) {
192+ // If enrollments property exists but no personIds , return original (can't transform)
193+ if (personIds == null || personIds .isEmpty ()) {
148194 return schema .deepCopy ();
149195 }
150196
@@ -180,27 +226,30 @@ public JsonNode transformEnrollmentsSchema(JsonNode schema, String personId) {
180226 transformedProperties .set ("people" , peopleSchema );
181227 }
182228
183- // Get or create the personId property under people
184- JsonNode existingPersonId = peopleProps .get (personId );
185- ObjectNode personIdSchema ;
186- ObjectNode personIdProps ;
229+ // Add enrollments under each personId
230+ for (String personId : personIds ) {
231+ // Get or create the personId property under people
232+ JsonNode existingPersonId = peopleProps .get (personId );
233+ ObjectNode personIdSchema ;
234+ ObjectNode personIdProps ;
235+
236+ if (existingPersonId != null && existingPersonId .has ("properties" )) {
237+ // PersonId already exists
238+ personIdSchema = (ObjectNode ) existingPersonId ;
239+ personIdProps = (ObjectNode ) personIdSchema .get ("properties" );
240+ } else {
241+ // Create new personId structure
242+ personIdSchema = objectMapper .createObjectNode ();
243+ personIdSchema .put ("type" , "object" );
244+ personIdProps = objectMapper .createObjectNode ();
245+ personIdSchema .set ("properties" , personIdProps );
246+ peopleProps .set (personId , personIdSchema );
247+ }
187248
188- if (existingPersonId != null && existingPersonId .has ("properties" )) {
189- // PersonId already exists
190- personIdSchema = (ObjectNode ) existingPersonId ;
191- personIdProps = (ObjectNode ) personIdSchema .get ("properties" );
192- } else {
193- // Create new personId structure
194- personIdSchema = objectMapper .createObjectNode ();
195- personIdSchema .put ("type" , "object" );
196- personIdProps = objectMapper .createObjectNode ();
197- personIdSchema .set ("properties" , personIdProps );
198- peopleProps .set (personId , personIdSchema );
249+ // Add enrollments under the personId
250+ personIdProps .set ("enrollments" , enrollmentsSchema .deepCopy ());
199251 }
200252
201- // Add enrollments under the personId
202- personIdProps .set ("enrollments" , enrollmentsSchema );
203-
204253 return transformedSchema ;
205254 }
206255
0 commit comments