Skip to content

Commit

Permalink
#8 Add compatibility to Microsoft FHIR Server
Browse files Browse the repository at this point in the history
  • Loading branch information
Thopap committed May 8, 2024
1 parent a383e03 commit 5353245
Show file tree
Hide file tree
Showing 8 changed files with 26 additions and 23 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ public MhdSubmissionSet apply(SubmissionSet xdsSub, List<ListEntryComponent> 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) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,7 @@ public static String asSearchToken(ReferenceId id) {
*
* @return consumer setting proper defaults for lid and versionInfo
*/
public static Consumer<? super XDSMetaClass> assignDefaultVersioning() {
public static Consumer<XDSMetaClass> assignDefaultVersioning() {
return meta -> {
meta.setLogicalUuid(meta.getEntryUuid());
meta.setVersion(DEFAULT_VERSION);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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));
Expand Down Expand Up @@ -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));
}

Expand All @@ -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<MhdFolder> 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<MhdSubmissionSet> submissionSets = new ArrayList<>();
buildResultForSubmissionSet(submissionSetfhirQuery).iterator().forEachRemaining(submissionSets::add);

Expand Down Expand Up @@ -355,7 +358,7 @@ private List<Association> collectAssociationsOfFolders(IQuery<Bundle> folderFhir

private List<Association> collectAssociationsOfDocument(IQuery<Bundle> documentFhirQuery) {
var xdsAssocations = new ArrayList<Association>();
Bundle docResultBundle = documentFhirQuery.execute();
var docResultBundle = documentFhirQuery.execute();
var resultForDocuments = buildResultForDocuments(docResultBundle);

resultForDocuments.forEach(doc -> {
Expand All @@ -378,7 +381,7 @@ private List<Association> collectAssociationsOfDocument(IQuery<Bundle> documentF
}

private IQuery<Bundle> prepareQuery(FindDocumentsQuery query) {
IQuery<Bundle> documentFhirQuery = initDocumentQuery();
var documentFhirQuery = initDocumentQuery();
mapPatientIdToQuery(query, documentFhirQuery);

map(query.getClassCodes(), DocumentReference.CATEGORY, documentFhirQuery);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -300,7 +300,7 @@ private List<ListEntryComponent> createReferences(List<Association> 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);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand All @@ -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")
Expand All @@ -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));
Expand Down Expand Up @@ -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")
Expand Down Expand Up @@ -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));
Expand Down

0 comments on commit 5353245

Please sign in to comment.