diff --git a/src/main/java/org/openehealth/app/xdstofhir/registry/common/mapper/AbstractXdsToFhirMapper.java b/src/main/java/org/openehealth/app/xdstofhir/registry/common/mapper/AbstractXdsToFhirMapper.java index 479da17..a4b9b90 100644 --- a/src/main/java/org/openehealth/app/xdstofhir/registry/common/mapper/AbstractXdsToFhirMapper.java +++ b/src/main/java/org/openehealth/app/xdstofhir/registry/common/mapper/AbstractXdsToFhirMapper.java @@ -90,7 +90,7 @@ protected Reference fromAuthor(final Author author) { role.setSpecialty(author.getAuthorSpecialty().stream().map(this::convertToCode).toList()); if (!author.getAuthorInstitution().isEmpty()) { // TODO: currently only the first element is mapped, because FHIR only support cardinality 1 - var xdsAuthorOrg = author.getAuthorInstitution().get(0); + var xdsAuthorOrg = author.getAuthorInstitution().getFirst(); var org = new Organization(); org.setName(xdsAuthorOrg.getOrganizationName()); if (xdsAuthorOrg.getIdNumber() != null) { diff --git a/src/main/java/org/openehealth/app/xdstofhir/registry/common/mapper/FhirToXdsDocumentMapper.java b/src/main/java/org/openehealth/app/xdstofhir/registry/common/mapper/FhirToXdsDocumentMapper.java index 70e872b..37cda7f 100644 --- a/src/main/java/org/openehealth/app/xdstofhir/registry/common/mapper/FhirToXdsDocumentMapper.java +++ b/src/main/java/org/openehealth/app/xdstofhir/registry/common/mapper/FhirToXdsDocumentMapper.java @@ -112,7 +112,7 @@ private Address fromAddress(org.hl7.fhir.r4.model.Address fhirAddress) { var address = new Address(); address.setCity(fhirAddress.getCity()); if (!fhirAddress.getLine().isEmpty()) { - address.setStreetAddress(fhirAddress.getLine().get(0).asStringValue()); + address.setStreetAddress(fhirAddress.getLine().getFirst().asStringValue()); } address.setZipOrPostalCode(fhirAddress.getPostalCode()); address.setCountry(fhirAddress.getCountry()); diff --git a/src/main/java/org/openehealth/app/xdstofhir/registry/common/mapper/XdsToFhirSubmissionsetMapper.java b/src/main/java/org/openehealth/app/xdstofhir/registry/common/mapper/XdsToFhirSubmissionsetMapper.java index 0c72f85..b1c763a 100644 --- a/src/main/java/org/openehealth/app/xdstofhir/registry/common/mapper/XdsToFhirSubmissionsetMapper.java +++ b/src/main/java/org/openehealth/app/xdstofhir/registry/common/mapper/XdsToFhirSubmissionsetMapper.java @@ -31,7 +31,7 @@ public MhdSubmissionSet apply(SubmissionSet xdsSub, List ref mhdList.setDateElement(fromTimestamp(xdsSub.getSubmissionTime())); mhdList.setDesignationType(fromCode(xdsSub.getContentTypeCode())); if (!xdsSub.getAuthors().isEmpty()) - mhdList.setSource(fromAuthor(xdsSub.getAuthors().get(0))); + mhdList.setSource(fromAuthor(xdsSub.getAuthors().getFirst())); if (xdsSub.getTitle() != null) mhdList.setTitle(xdsSub.getTitle().getValue()); if (xdsSub.getComments() != null) { diff --git a/src/main/java/org/openehealth/app/xdstofhir/registry/query/StoredQueryMapper.java b/src/main/java/org/openehealth/app/xdstofhir/registry/query/StoredQueryMapper.java index 6feaf15..1a492f7 100644 --- a/src/main/java/org/openehealth/app/xdstofhir/registry/query/StoredQueryMapper.java +++ b/src/main/java/org/openehealth/app/xdstofhir/registry/query/StoredQueryMapper.java @@ -135,7 +135,7 @@ public static String asSearchToken(ReferenceId id) { * * @return consumer setting proper defaults for lid and versionInfo */ - public static Consumer assignDefaultVersioning() { + public static Consumer assignDefaultVersioning() { return meta -> { meta.setLogicalUuid(meta.getEntryUuid()); meta.setVersion(DEFAULT_VERSION); diff --git a/src/main/java/org/openehealth/app/xdstofhir/registry/query/StoredQueryVistorImpl.java b/src/main/java/org/openehealth/app/xdstofhir/registry/query/StoredQueryVistorImpl.java index 97af88a..9d2fa04 100644 --- a/src/main/java/org/openehealth/app/xdstofhir/registry/query/StoredQueryVistorImpl.java +++ b/src/main/java/org/openehealth/app/xdstofhir/registry/query/StoredQueryVistorImpl.java @@ -107,10 +107,13 @@ public void visit(FindFoldersQuery query) { public void visit(GetSubmissionSetsQuery query) { var submissionSetfhirQuery = initSubmissionSetQuery(); var searchIdentifiers = query.getUuids().stream().map(MappingSupport::toUrnCoded).toList(); - submissionSetfhirQuery.where(ListResource.ITEM.hasChainedProperty( + submissionSetfhirQuery.where(ListResource.ITEM. hasChainedProperty("DocumentReference", new TokenClientParam("identifier").exactly().systemAndValues(URI_URN, searchIdentifiers))); - buildResultForSubmissionSet(submissionSetfhirQuery); var mapSubmissionSets = mapSubmissionSets(buildResultForSubmissionSet(submissionSetfhirQuery)); + submissionSetfhirQuery = initSubmissionSetQuery(); + submissionSetfhirQuery.where(ListResource.ITEM. hasChainedProperty("List", + new TokenClientParam("identifier").exactly().systemAndValues(URI_URN, searchIdentifiers))); + mapSubmissionSets.addAll(mapSubmissionSets(buildResultForSubmissionSet(submissionSetfhirQuery))); var documentFhirQuery = initDocumentQuery(); documentFhirQuery.where(DocumentReference.IDENTIFIER.exactly().systemAndValues(URI_URN, searchIdentifiers)); @@ -181,7 +184,7 @@ public void visit(GetFoldersQuery query) { public void visit(GetFoldersForDocumentQuery query) { var folderFhirQuery = initFolderQuery(); var identifier = MappingSupport.toUrnCoded(Objects.requireNonNullElse(query.getUniqueId(), query.getUuid())); - folderFhirQuery.where(ListResource.ITEM.hasChainedProperty(DocumentReference.IDENTIFIER.exactly().systemAndValues(URI_URN, identifier))); + folderFhirQuery.where(ListResource.ITEM.hasChainedProperty("DocumentReference", DocumentReference.IDENTIFIER.exactly().systemAndValues(URI_URN, identifier))); mapFolders(buildResultForFolder(folderFhirQuery)); } @@ -208,12 +211,12 @@ public void visit(GetDocumentsAndAssociationsQuery query) { var fhirDocuments = mapDocuments(buildResultForDocuments(documentFhirQuery)); var folderFhirQuery = initFolderQuery(); - folderFhirQuery.where(ListResource.ITEM.hasChainedProperty(identifier)); + folderFhirQuery.where(ListResource.ITEM.hasChainedProperty("DocumentReference", identifier)); List folders = new ArrayList<>(); buildResultForFolder(folderFhirQuery).iterator().forEachRemaining(folders::add); var submissionSetfhirQuery = initSubmissionSetQuery(); - submissionSetfhirQuery.where(ListResource.ITEM.hasChainedProperty(identifier)); + submissionSetfhirQuery.where(ListResource.ITEM.hasChainedProperty("DocumentReference", identifier)); List submissionSets = new ArrayList<>(); buildResultForSubmissionSet(submissionSetfhirQuery).iterator().forEachRemaining(submissionSets::add); @@ -355,7 +358,7 @@ private List collectAssociationsOfFolders(IQuery folderFhir private List collectAssociationsOfDocument(IQuery documentFhirQuery) { var xdsAssocations = new ArrayList(); - Bundle docResultBundle = documentFhirQuery.execute(); + var docResultBundle = documentFhirQuery.execute(); var resultForDocuments = buildResultForDocuments(docResultBundle); resultForDocuments.forEach(doc -> { @@ -378,7 +381,7 @@ private List collectAssociationsOfDocument(IQuery documentF } private IQuery prepareQuery(FindDocumentsQuery query) { - IQuery documentFhirQuery = initDocumentQuery(); + var documentFhirQuery = initDocumentQuery(); mapPatientIdToQuery(query, documentFhirQuery); map(query.getClassCodes(), DocumentReference.CATEGORY, documentFhirQuery); diff --git a/src/main/java/org/openehealth/app/xdstofhir/registry/register/RegisterDocumentsProcessor.java b/src/main/java/org/openehealth/app/xdstofhir/registry/register/RegisterDocumentsProcessor.java index e6455cf..3db2645 100644 --- a/src/main/java/org/openehealth/app/xdstofhir/registry/register/RegisterDocumentsProcessor.java +++ b/src/main/java/org/openehealth/app/xdstofhir/registry/register/RegisterDocumentsProcessor.java @@ -300,7 +300,7 @@ private List createReferences(List associations } private ListEntryComponent createReference(Association assoc, String refType) { - Reference item = new Reference( + var item = new Reference( new IdType(refType, assoc.getTargetUuid())); var id = new Identifier(); id.setSystem(MappingSupport.URI_URN); diff --git a/src/main/java/org/openehealth/app/xdstofhir/registry/remove/RemoveDocumentsProcessor.java b/src/main/java/org/openehealth/app/xdstofhir/registry/remove/RemoveDocumentsProcessor.java index be85ec3..16bc994 100644 --- a/src/main/java/org/openehealth/app/xdstofhir/registry/remove/RemoveDocumentsProcessor.java +++ b/src/main/java/org/openehealth/app/xdstofhir/registry/remove/RemoveDocumentsProcessor.java @@ -70,9 +70,9 @@ public Response remove(RemoveMetadata metadataToRemove) { uniqueResults.addAll(fetchFolderAndSubmissionSets(uuidsToDelete)); - uniqueResults.forEach(ref -> { - processAssociations(ref, ref.getEntry(), uuidsToDelete, builder); - }); + uniqueResults.forEach(ref -> + processAssociations(ref, ref.getEntry(), uuidsToDelete, builder) + ); uniqueResults.forEach(ref -> { boolean toDeleteTransaction = addToDeleteTransaction(ref, uuidsToDelete, builder); diff --git a/src/test/java/org/openehealth/app/xdstofhir/registry/query/StoredQueryVistorImplTest.java b/src/test/java/org/openehealth/app/xdstofhir/registry/query/StoredQueryVistorImplTest.java index 1d66814..ec85cb2 100644 --- a/src/test/java/org/openehealth/app/xdstofhir/registry/query/StoredQueryVistorImplTest.java +++ b/src/test/java/org/openehealth/app/xdstofhir/registry/query/StoredQueryVistorImplTest.java @@ -38,7 +38,7 @@ void testFindDocumentsQuery (){ mockServer.verify(request() .withQueryStringParameter("date", "ge19.*", "lt19.*")//skip verify the whole datetime to avoid timezone issues .withQueryStringParameter("period", "ge19.*", "lt19.*", "ge19.*", "lt19.*") - .withQueryStringParameter("patient.identifier", "urn:oid:1.3|id3") + .withQueryStringParameter("patient:Patient.identifier", "urn:oid:1.3|id3") .withQueryStringParameter("format", "urn:ihe:xds:scheme13|code13,urn:ihe:xds:scheme14|code14") .withQueryStringParameter("type", "urn:ihe:xds:schemet1|codet1,urn:ihe:xds:schemet2|codet2") .withQueryStringParameter("setting", "urn:ihe:xds:scheme3|code3,urn:ihe:xds:scheme4|code4") @@ -61,7 +61,7 @@ void testFindSubmissionSetQuery (){ classUnderTest.visit(query); mockServer.verify(request() - .withQueryStringParameter("patient.identifier", "urn:oid:1.2|id1") + .withQueryStringParameter("patient:Patient.identifier", "urn:oid:1.2|id1") .withQueryStringParameter("_include", "List:subject") .withQueryStringParameter("_profile", MappingSupport.MHD_COMPREHENSIVE_SUBMISSIONSET_PROFILE) .withQueryStringParameter("code", "https://profiles.ihe.net/ITI/MHD/CodeSystem/MHDlistTypes|submissionset") @@ -82,17 +82,17 @@ void testGetAllQuery (){ classUnderTest.visit(query); mockServer.verify(request("/DocumentReference") - .withQueryStringParameter("patient.identifier", "urn:oid:1.2|id1") + .withQueryStringParameter("patient:Patient.identifier", "urn:oid:1.2|id1") .withQueryStringParameter("_include", "DocumentReference:subject") .withQueryStringParameter("_profile", MappingSupport.MHD_COMPREHENSIVE_PROFILE)); mockServer.verify(request("/List") - .withQueryStringParameter("patient.identifier", "urn:oid:1.2|id1") + .withQueryStringParameter("patient:Patient.identifier", "urn:oid:1.2|id1") .withQueryStringParameter("_include", "List:subject") .withQueryStringParameter("_profile", MappingSupport.MHD_COMPREHENSIVE_SUBMISSIONSET_PROFILE)); mockServer.verify(request("/List") - .withQueryStringParameter("patient.identifier", "urn:oid:1.2|id1") + .withQueryStringParameter("patient:Patient.identifier", "urn:oid:1.2|id1") .withQueryStringParameter("_include", "List:subject") .withQueryStringParameter("_profile", MappingSupport.MHD_COMPREHENSIVE_FOLDER_PROFILE)); @@ -159,7 +159,7 @@ void testGetFolderForDocuments (){ classUnderTest.visit(query); mockServer.verify(request() - .withQueryStringParameter("item.identifier", "urn:ietf:rfc:3986|urn:ihe:xds:12.21.34") + .withQueryStringParameter("item:DocumentReference.identifier", "urn:ietf:rfc:3986|urn:ihe:xds:12.21.34") .withQueryStringParameter("_include", "List:subject") .withQueryStringParameter("_profile", MappingSupport.MHD_COMPREHENSIVE_FOLDER_PROFILE) .withQueryStringParameter("code", "https://profiles.ihe.net/ITI/MHD/CodeSystem/MHDlistTypes|folder") @@ -208,13 +208,13 @@ void testGetDocumentsAndAssociations (){ .withQueryStringParameter("_profile", MappingSupport.MHD_COMPREHENSIVE_PROFILE) ); mockServer.verify(request("/List") - .withQueryStringParameter("item.identifier", "urn:ietf:rfc:3986|urn:ihe:xds:12.21.34,urn:ietf:rfc:3986|urn:ihe:xds:43.56.89,urn:ietf:rfc:3986|urn:uuid:1.2.3.4,urn:ietf:rfc:3986|urn:uuid:2.3.4.5") + .withQueryStringParameter("item:DocumentReference.identifier", "urn:ietf:rfc:3986|urn:ihe:xds:12.21.34,urn:ietf:rfc:3986|urn:ihe:xds:43.56.89,urn:ietf:rfc:3986|urn:uuid:1.2.3.4,urn:ietf:rfc:3986|urn:uuid:2.3.4.5") .withQueryStringParameter("_include", "List:subject") .withQueryStringParameter("_profile", MappingSupport.MHD_COMPREHENSIVE_SUBMISSIONSET_PROFILE)); mockServer.verify(request("/List") - .withQueryStringParameter("item.identifier", "urn:ietf:rfc:3986|urn:ihe:xds:12.21.34,urn:ietf:rfc:3986|urn:ihe:xds:43.56.89,urn:ietf:rfc:3986|urn:uuid:1.2.3.4,urn:ietf:rfc:3986|urn:uuid:2.3.4.5") + .withQueryStringParameter("item:DocumentReference.identifier", "urn:ietf:rfc:3986|urn:ihe:xds:12.21.34,urn:ietf:rfc:3986|urn:ihe:xds:43.56.89,urn:ietf:rfc:3986|urn:uuid:1.2.3.4,urn:ietf:rfc:3986|urn:uuid:2.3.4.5") .withQueryStringParameter("_include", "List:subject") .withQueryStringParameter("_profile", MappingSupport.MHD_COMPREHENSIVE_FOLDER_PROFILE));