-
Notifications
You must be signed in to change notification settings - Fork 66
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
ITI-51 query "FindDocumentsByReferenceIdListForMultiplePatients"; closes
- Loading branch information
Showing
10 changed files
with
255 additions
and
2 deletions.
There are no files selected for viewing
85 changes: 85 additions & 0 deletions
85
...mmons/ihe/xds/core/requests/query/FindDocumentsByReferenceIdForMultiplePatientsQuery.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,85 @@ | ||
/* | ||
* Copyright 2024 the original author or authors. | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
package org.openehealth.ipf.commons.ihe.xds.core.requests.query; | ||
|
||
import jakarta.xml.bind.annotation.*; | ||
import lombok.EqualsAndHashCode; | ||
import lombok.Getter; | ||
import lombok.Setter; | ||
import lombok.ToString; | ||
import org.openehealth.ipf.commons.ihe.xds.core.metadata.AvailabilityStatus; | ||
import org.openehealth.ipf.commons.ihe.xds.core.metadata.DocumentEntryType; | ||
import org.openehealth.ipf.commons.ihe.xds.core.metadata.Identifiable; | ||
import org.openehealth.ipf.commons.ihe.xds.core.metadata.ReferenceId; | ||
import org.openehealth.ipf.commons.ihe.xds.core.transform.requests.query.QuerySlotHelper; | ||
|
||
import java.io.Serial; | ||
import java.util.List; | ||
|
||
/** | ||
* Represents a Multi-Patient stored query for FindDocuments by Reference ID. | ||
*/ | ||
@XmlAccessorType(XmlAccessType.FIELD) | ||
@XmlType(name = "FindDocumentsByReferenceIdForMultiplePatientsQuery", | ||
propOrder = {"patientIds","status", "documentEntryTypes", "referenceIds"}) | ||
@XmlRootElement(name = "findDocumentsByReferenceIdForMultiplePatientsQuery") | ||
@EqualsAndHashCode(callSuper = true, doNotUseGetters = true) | ||
@ToString(callSuper = true, doNotUseGetters = true) | ||
public class FindDocumentsByReferenceIdForMultiplePatientsQuery extends DocumentsQuery implements DocumentEntryTypeAwareStoredQuery { | ||
@Serial | ||
private static final long serialVersionUID = -8981126710746958226L; | ||
|
||
@Getter @Setter private List<Identifiable> patientIds; | ||
@Getter @Setter private List<AvailabilityStatus> status; | ||
@XmlElement(name = "documentEntryType") | ||
@Getter @Setter private List<DocumentEntryType> documentEntryTypes; | ||
@XmlElement(name = "referenceId") | ||
@Getter @Setter private QueryList<String> referenceIds; | ||
|
||
/** | ||
* Constructs the query. | ||
*/ | ||
public FindDocumentsByReferenceIdForMultiplePatientsQuery() { | ||
super(QueryType.FIND_DOCUMENTS_BY_REFERENCE_ID_MPQ); | ||
} | ||
|
||
@Override | ||
public void accept(Visitor visitor) { | ||
visitor.visit(this); | ||
} | ||
|
||
/** | ||
* Allows to use a collection of {@link ReferenceId} instead of a collection of {@link String} | ||
* for specifying the query parameter "$XDSDocumentEntryReferenceIdList". | ||
* | ||
* @param referenceIds a collection of {@link ReferenceId} objects with AND/OR semantics. | ||
*/ | ||
public void setTypedReferenceIds(QueryList<ReferenceId> referenceIds) { | ||
this.referenceIds = QuerySlotHelper.render(referenceIds); | ||
} | ||
|
||
/** | ||
* Tries to return the query parameter "$XDSDocumentEntryReferenceIdList" | ||
* as a collection of {@link ReferenceId} instead of a collection of {@link String}. | ||
* This may fail if SQL LIKE wildcards ("%", "_", etc.) are used in one or more elements. | ||
* | ||
* @return a collection of {@link ReferenceId} objects with AND/OR semantics. | ||
*/ | ||
public QueryList<ReferenceId> getTypedReferenceIds() { | ||
return QuerySlotHelper.parse(this.referenceIds, ReferenceId.class); | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
49 changes: 49 additions & 0 deletions
49
...ansform/requests/query/FindDocumentsByReferenceIdForMultiplePatientsQueryTransformer.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
/* | ||
* Copyright 2024 the original author or authors. | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
package org.openehealth.ipf.commons.ihe.xds.core.transform.requests.query; | ||
|
||
import lombok.Getter; | ||
import org.openehealth.ipf.commons.ihe.xds.core.ebxml.EbXMLAdhocQueryRequest; | ||
import org.openehealth.ipf.commons.ihe.xds.core.requests.query.FindDocumentsByReferenceIdForMultiplePatientsQuery; | ||
|
||
import static org.openehealth.ipf.commons.ihe.xds.core.transform.requests.QueryParameter.*; | ||
|
||
/** | ||
* Transforms between a {@link FindDocumentsByReferenceIdForMultiplePatientsQuery} and {@link EbXMLAdhocQueryRequest}. | ||
*/ | ||
public class FindDocumentsByReferenceIdForMultiplePatientsQueryTransformer extends DocumentsQueryTransformer<FindDocumentsByReferenceIdForMultiplePatientsQuery> { | ||
|
||
@Getter | ||
private static final FindDocumentsByReferenceIdForMultiplePatientsQueryTransformer instance = new FindDocumentsByReferenceIdForMultiplePatientsQueryTransformer(); | ||
|
||
@Override | ||
protected void toEbXML(FindDocumentsByReferenceIdForMultiplePatientsQuery query, QuerySlotHelper slots) { | ||
super.toEbXML(query, slots); | ||
slots.fromPatientIdList(DOC_ENTRY_PATIENT_ID, query.getPatientIds()); | ||
slots.fromDocumentEntryType(DOC_ENTRY_TYPE, query.getDocumentEntryTypes()); | ||
slots.fromStatus(DOC_ENTRY_STATUS, query.getStatus()); | ||
slots.fromStringList(DOC_ENTRY_REFERENCE_IDS, query.getReferenceIds()); | ||
} | ||
|
||
@Override | ||
protected void fromEbXML(FindDocumentsByReferenceIdForMultiplePatientsQuery query, QuerySlotHelper slots) { | ||
super.fromEbXML(query, slots); | ||
query.setPatientIds(slots.toPatientIdList(DOC_ENTRY_PATIENT_ID)); | ||
query.setDocumentEntryTypes(slots.toDocumentEntryType(DOC_ENTRY_TYPE)); | ||
query.setStatus(slots.toStatus(DOC_ENTRY_STATUS)); | ||
query.setReferenceIds(slots.toStringQueryList(DOC_ENTRY_REFERENCE_IDS)); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
71 changes: 71 additions & 0 deletions
71
...quests/ebxml30/FindDocumentsByReferenceIdListForMultiplePatientsQueryTransformerTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,71 @@ | ||
/* | ||
* Copyright 2024 the original author or authors. | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
package org.openehealth.ipf.commons.ihe.xds.core.transform.requests.ebxml30; | ||
|
||
import org.junit.jupiter.api.BeforeEach; | ||
import org.junit.jupiter.api.Test; | ||
import org.openehealth.ipf.commons.ihe.xds.core.SampleData; | ||
import org.openehealth.ipf.commons.ihe.xds.core.ebxml.ebxml30.EbXMLFactory30; | ||
import org.openehealth.ipf.commons.ihe.xds.core.requests.query.FindDocumentsByReferenceIdForMultiplePatientsQuery; | ||
import org.openehealth.ipf.commons.ihe.xds.core.requests.query.QueryType; | ||
import org.openehealth.ipf.commons.ihe.xds.core.transform.requests.QueryParameter; | ||
import org.openehealth.ipf.commons.ihe.xds.core.transform.requests.query.AbstractQueryTransformerTest; | ||
import org.openehealth.ipf.commons.ihe.xds.core.transform.requests.query.FindDocumentsByReferenceIdForMultiplePatientsQueryTransformer; | ||
|
||
import java.util.Arrays; | ||
|
||
import static org.junit.jupiter.api.Assertions.assertEquals; | ||
|
||
/** | ||
* Tests for {@link FindDocumentsByReferenceIdForMultiplePatientsQueryTransformer}. | ||
* @author Dmytro Rud | ||
*/ | ||
public class FindDocumentsByReferenceIdListForMultiplePatientsQueryTransformerTest extends AbstractQueryTransformerTest<FindDocumentsByReferenceIdForMultiplePatientsQuery, FindDocumentsByReferenceIdForMultiplePatientsQueryTransformer> { | ||
|
||
@BeforeEach | ||
public void setUp() { | ||
transformer = FindDocumentsByReferenceIdForMultiplePatientsQueryTransformer.getInstance(); | ||
query = (FindDocumentsByReferenceIdForMultiplePatientsQuery) SampleData.createFindDocumentsByReferenceIdForMultiplePatientsQuery().getQuery(); | ||
ebXML = new EbXMLFactory30().createAdhocQueryRequest(); | ||
} | ||
|
||
@Test | ||
public void testToEbXML() { | ||
transformer.toEbXML(query, ebXML); | ||
|
||
assertEquals(QueryType.FIND_DOCUMENTS_BY_REFERENCE_ID_MPQ.getId(), ebXML.getId()); | ||
assertEquals("12.21.41", ebXML.getHome()); | ||
assertEquals(Arrays.asList("('id3^^^&1.3&ISO')", "('id4^^^&1.4&ISO')"), | ||
ebXML.getSlotValues(QueryParameter.DOC_ENTRY_PATIENT_ID.getSlotName())); | ||
|
||
var referenceIdSlots = ebXML.getSlots(QueryParameter.DOC_ENTRY_REFERENCE_IDS.getSlotName()); | ||
assertEquals(2, referenceIdSlots.size()); | ||
assertEquals(Arrays.asList( | ||
"('ref-id-11^^^&1.1.1.1&ISO^urn:ihe:iti:xds:2013:uniqueId')", | ||
"('ref-id-12^^^^urn:ihe:iti:xdw:2013:workflowInstanceId')", | ||
"('ref-id-13^^^^urn:ihe:iti:xds:2013:referral')"), | ||
referenceIdSlots.get(0).getValueList()); | ||
assertEquals(Arrays.asList( | ||
"('ref-id-21^^^&1.1.1.2&ISO^urn:ihe:iti:xds:2013:accession')", | ||
"('ref-id-22^^^^urn:ihe:iti:xds:2013:order')"), | ||
referenceIdSlots.get(1).getValueList()); | ||
} | ||
|
||
@Override | ||
protected FindDocumentsByReferenceIdForMultiplePatientsQuery emptyQuery() { | ||
return new FindDocumentsByReferenceIdForMultiplePatientsQuery(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters