Skip to content

Commit e4d8225

Browse files
authored
Fixed Bunsen's dissimilarity for managingOrganization identifier. (#634)
* Fixed Bunsen's dissimilarity for managingOrganization identifier. * Removed wildcard import. * Addressed review comments. * Modified java docs for DefinitionVisitor visitReference method. * Modified java docs for DefinitionVisitor visitReference method.
1 parent 32d16b4 commit e4d8225

File tree

10 files changed

+63
-5
lines changed

10 files changed

+63
-5
lines changed

bunsen/bunsen-avro/src/main/java/com/cerner/bunsen/avro/converters/DefinitionToAvroVisitor.java

+4-2
Original file line numberDiff line numberDiff line change
@@ -555,8 +555,10 @@ public HapiConverter<Schema> visitReference(String elementName,
555555
List<String> referenceTypes,
556556
List<StructureField<HapiConverter<Schema>>> children) {
557557

558-
// Generate a record name based on the type of references it can contain.
559-
String recordName = referenceTypes.stream().collect(Collectors.joining()) + "Reference";
558+
// Generate a record name based on the element name.
559+
String recordName = elementName + "Reference";
560+
// Remove extension type [x] as this creates issue while identifying schema.
561+
recordName = recordName.replaceAll("\\[x\\]", "");
560562

561563
String fullName = basePackage + "." + recordName;
562564

bunsen/bunsen-avro/src/test/java/com/cerner/bunsen/avro/R4AvroConverterTest.java

+10
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
import org.hl7.fhir.r4.model.Coding;
2020
import org.hl7.fhir.r4.model.Condition;
2121
import org.hl7.fhir.r4.model.Extension;
22+
import org.hl7.fhir.r4.model.Identifier;
2223
import org.hl7.fhir.r4.model.IntegerType;
2324
import org.hl7.fhir.r4.model.Medication;
2425
import org.hl7.fhir.r4.model.MedicationRequest;
@@ -285,6 +286,15 @@ public void testSingleReference() {
285286
testConditionDecoded.getSubject().getReference());
286287
}
287288

289+
@Test
290+
public void testManagingOrganizationIdentifier() {
291+
292+
Identifier identifier = testPatientDecoded.getManagingOrganization().getIdentifier();
293+
294+
Assert.assertNotNull(identifier);
295+
Assert.assertEquals(identifier.getAssigner().getReference(), "Organization/234");
296+
}
297+
288298
@Test
289299
public void testMultiReferenceTypes() {
290300

bunsen/bunsen-avro/src/test/java/com/cerner/bunsen/avro/Stu3AvroConverterTest.java

+10
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
import org.hl7.fhir.dstu3.model.Coding;
2222
import org.hl7.fhir.dstu3.model.Condition;
2323
import org.hl7.fhir.dstu3.model.Extension;
24+
import org.hl7.fhir.dstu3.model.Identifier;
2425
import org.hl7.fhir.dstu3.model.IntegerType;
2526
import org.hl7.fhir.dstu3.model.Medication;
2627
import org.hl7.fhir.dstu3.model.MedicationRequest;
@@ -282,6 +283,15 @@ public void testSingleReference() {
282283
testConditionDecoded.getSubject().getReference());
283284
}
284285

286+
@Test
287+
public void testManagingOrganizationIdentifier() {
288+
289+
Identifier identifier = testPatientDecoded.getManagingOrganization().getIdentifier();
290+
291+
Assert.assertNotNull(identifier);
292+
Assert.assertEquals(identifier.getAssigner().getReference(), "Organization/234");
293+
}
294+
285295
@Test
286296
public void testMultiReferenceTypes() {
287297

bunsen/bunsen-core-r4/src/main/java/com/cerner/bunsen/definitions/r4/R4StructureDefinitions.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -620,7 +620,7 @@ private <T> T transform(DefinitionVisitor<T> visitor,
620620
.sorted()
621621
.collect(Collectors.toList());
622622

623-
return visitor.visitReference(rootName, referenceTypes, childElements);
623+
return visitor.visitReference(parentElement.toString(), referenceTypes, childElements);
624624

625625
} else {
626626

bunsen/bunsen-core-r4/src/test/java/com/cerner/bunsen/r4/TestData.java

+12
Original file line numberDiff line numberDiff line change
@@ -203,6 +203,13 @@ public static Patient newPatient() {
203203
patient.setActive(true);
204204
patient.setMultipleBirth(new IntegerType(1));
205205

206+
// This is to introduce conflict with managingOrganization identifier
207+
// and make sure conflict is resolved.
208+
Identifier patientIdentifier = new Identifier();
209+
patientIdentifier.setId("patient123");
210+
patientIdentifier.getAssigner().setReference("Organization/123");
211+
patient.setIdentifier(List.of(patientIdentifier));
212+
206213
patient.setBirthDateElement(new DateType("1945-01-02"));
207214

208215
patient.addGeneralPractitioner().setReference("Practitioner/12345");
@@ -212,6 +219,11 @@ public static Patient newPatient() {
212219
practitionerIdentifier.getAssigner().setReference("Organization/123456");
213220
patient.getGeneralPractitionerFirstRep().setIdentifier(practitionerIdentifier);
214221

222+
Identifier managingOrganisationIdentifier = new Identifier();
223+
managingOrganisationIdentifier.setId("O123456");
224+
managingOrganisationIdentifier.getAssigner().setReference("Organization/234");
225+
patient.getManagingOrganization().setIdentifier(managingOrganisationIdentifier);
226+
215227
Address address = patient.addAddress();
216228
address.addLine("123 Fake Street");
217229
address.setCity("Chicago");

bunsen/bunsen-core-stu3/src/main/java/com/cerner/bunsen/definitions/stu3/Stu3StructureDefinitions.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -586,7 +586,7 @@ private <T> T transform(DefinitionVisitor<T> visitor,
586586
.sorted()
587587
.collect(Collectors.toList());
588588

589-
return visitor.visitReference(rootName, referenceTypes, childElements);
589+
return visitor.visitReference(parentElement.toString(), referenceTypes, childElements);
590590

591591
} else {
592592

bunsen/bunsen-core-stu3/src/test/java/com/cerner/bunsen/stu3/TestData.java

+12
Original file line numberDiff line numberDiff line change
@@ -198,6 +198,13 @@ public static Patient newPatient() {
198198
patient.setActive(true);
199199
patient.setMultipleBirth(new IntegerType(1));
200200

201+
// This is to introduce conflict with managingOrganization identifier
202+
// and make sure conflict is resolved.
203+
Identifier patientIdentifier = new Identifier();
204+
patientIdentifier.setId("patient123");
205+
patientIdentifier.getAssigner().setReference("Organization/123");
206+
patient.setIdentifier(List.of(patientIdentifier));
207+
201208
patient.setBirthDateElement(new DateType("1945-01-02"));
202209

203210
patient.addGeneralPractitioner().setReference("Practitioner/12345");
@@ -207,6 +214,11 @@ public static Patient newPatient() {
207214
practitionerIdentifier.getAssigner().setReference("Organization/123456");
208215
patient.getGeneralPractitionerFirstRep().setIdentifier(practitionerIdentifier);
209216

217+
Identifier managingOrganisationIdentifier = new Identifier();
218+
managingOrganisationIdentifier.setId("O123456");
219+
managingOrganisationIdentifier.getAssigner().setReference("Organization/234");
220+
patient.getManagingOrganization().setIdentifier(managingOrganisationIdentifier);
221+
210222
Address address = patient.addAddress();
211223
address.addLine("123 Fake Street");
212224
address.setId("address123");

bunsen/bunsen-core/src/main/java/com/cerner/bunsen/definitions/DefinitionVisitor.java

+4-1
Original file line numberDiff line numberDiff line change
@@ -50,8 +50,11 @@ T visitContained(String elementPath,
5050

5151
/**
5252
* Visits a reference type.
53+
* The element name in itself is not sufficient as similar element names at
54+
* different places cause conflict and hence we would need full schema path
55+
* to differentiate between such conflicting reference names.
5356
*
54-
* @param elementName the element to visit.
57+
* @param elementName the full schema path of element which needs to be visited.
5558
* @param referenceTypes the types of resource that can be referenced
5659
* @param children the child fields of the reference
5760
* @return the visitor result.

bunsen/bunsen-core/src/main/java/com/cerner/bunsen/definitions/HapiCompositeConverter.java

+3
Original file line numberDiff line numberDiff line change
@@ -167,6 +167,9 @@ public Object fromHapi(Object input) {
167167
StructureField<HapiConverter<T>> schemaEntry = schemaIterator.next();
168168
// We do not want id in nested elements or sub-elements.
169169
// https://github.com/FHIR/sql-on-fhir/blob/master/sql-on-fhir.md#id-fields-omitted
170+
// So, there can be schema elements where id is not present in which case we should
171+
// check whether field name is id; if yes, proceed accordingly and set the iterator
172+
// for meta element and if not then the field is going to be meta element.
170173
if (schemaEntry.fieldName().equals("id")) {
171174
// Id element.
172175
values[0] = schemaEntry.result().fromHapi(((IAnyResource) composite).getIdElement());

pipelines/controller/pom.xml

+6
Original file line numberDiff line numberDiff line change
@@ -124,6 +124,12 @@
124124
<groupId>org.apache.parquet</groupId>
125125
<artifactId>parquet-hadoop-bundle</artifactId>
126126
</exclusion>
127+
<!-- This exclusion is required as it fails to read artifact descriptor for
128+
org.glassfish:javax.el:jar:3.0.1-b06-SNAPSHOT when built project at root level. -->
129+
<exclusion>
130+
<groupId>org.glassfish</groupId>
131+
<artifactId>javax.el</artifactId>
132+
</exclusion>
127133
</exclusions>
128134
</dependency>
129135
</dependencies>

0 commit comments

Comments
 (0)