-
Notifications
You must be signed in to change notification settings - Fork 65
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
implement the #437 SimplifiedPublish iti-105 transaction
- Loading branch information
Boris Stanojevic
committed
Dec 12, 2023
1 parent
4c46d46
commit e76eb78
Showing
18 changed files
with
3,406 additions
and
0 deletions.
There are no files selected for viewing
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
.../r4/mhd/src/main/java/org/openehealth/ipf/commons/ihe/fhir/iti105/Iti105AuditDataset.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 2023 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.fhir.iti105; | ||
|
||
import lombok.Getter; | ||
import lombok.Setter; | ||
import org.hl7.fhir.r4.model.DocumentReference; | ||
import org.openehealth.ipf.commons.ihe.fhir.audit.FhirAuditDataset; | ||
|
||
/** | ||
* @author Boris Stanojevic | ||
* @since 4.8 | ||
*/ | ||
public class Iti105AuditDataset extends FhirAuditDataset { | ||
|
||
// Document reference unique ID | ||
@Getter @Setter | ||
private String documentReferenceId; | ||
|
||
public Iti105AuditDataset(boolean serverSide) { | ||
super(serverSide); | ||
} | ||
|
||
|
||
public void enrichDatasetFromDocumentReference(DocumentReference documentReference) { | ||
var reference = documentReference.getSubject(); | ||
getPatientIds().add(reference.getResource() != null ? | ||
reference.getResource().getIdElement().getValue() : | ||
reference.getReference()); | ||
// If available, use the documentReference masterIdentifier as documentReferenceId | ||
if (documentReference.hasMasterIdentifier() && documentReference.getMasterIdentifier().hasValue()) { | ||
this.documentReferenceId = documentReference.getMasterIdentifier().getValue(); | ||
} | ||
} | ||
} |
59 changes: 59 additions & 0 deletions
59
...r4/mhd/src/main/java/org/openehealth/ipf/commons/ihe/fhir/iti105/Iti105AuditStrategy.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,59 @@ | ||
/* | ||
* Copyright 2023 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.fhir.iti105; | ||
|
||
import ca.uhn.fhir.rest.api.MethodOutcome; | ||
import org.hl7.fhir.r4.model.DocumentReference; | ||
import org.openehealth.ipf.commons.audit.AuditContext; | ||
import org.openehealth.ipf.commons.ihe.fhir.audit.FhirAuditStrategy; | ||
|
||
import java.util.Map; | ||
|
||
/** | ||
* @author Boris Stanojevic | ||
* @since 4.8 | ||
*/ | ||
public abstract class Iti105AuditStrategy extends FhirAuditStrategy<Iti105AuditDataset> { | ||
|
||
public Iti105AuditStrategy(boolean serverSide) { | ||
super(serverSide); | ||
} | ||
|
||
@Override | ||
public Iti105AuditDataset createAuditDataset() { | ||
return new Iti105AuditDataset(isServerSide()); | ||
} | ||
|
||
@Override | ||
public Iti105AuditDataset enrichAuditDatasetFromRequest(Iti105AuditDataset auditDataset, Object request, | ||
Map<String, Object> parameters) { | ||
var dataset = super.enrichAuditDatasetFromRequest(auditDataset, request, parameters); | ||
if (request instanceof DocumentReference) { | ||
dataset.enrichDatasetFromDocumentReference((DocumentReference) request); | ||
} | ||
return dataset; | ||
} | ||
|
||
@Override | ||
public boolean enrichAuditDatasetFromResponse(Iti105AuditDataset auditDataset, Object response, AuditContext auditContext) { | ||
var methodOutcome = (MethodOutcome) response; | ||
if (methodOutcome.getResource() != null && methodOutcome.getResource().getIdElement() != null) { | ||
auditDataset.setDocumentReferenceId(methodOutcome.getResource().getIdElement().getValue()); | ||
} | ||
return super.enrichAuditDatasetFromResponse(auditDataset, response, auditContext); | ||
} | ||
|
||
} |
51 changes: 51 additions & 0 deletions
51
.../src/main/java/org/openehealth/ipf/commons/ihe/fhir/iti105/Iti105ClientAuditStrategy.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,51 @@ | ||
/* | ||
* Copyright 2023 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.fhir.iti105; | ||
|
||
import org.openehealth.ipf.commons.audit.AuditContext; | ||
import org.openehealth.ipf.commons.audit.codes.ParticipantObjectIdTypeCode; | ||
import org.openehealth.ipf.commons.audit.codes.ParticipantObjectTypeCodeRole; | ||
import org.openehealth.ipf.commons.audit.model.AuditMessage; | ||
import org.openehealth.ipf.commons.ihe.core.atna.event.PHIExportBuilder; | ||
import org.openehealth.ipf.commons.ihe.fhir.audit.codes.FhirEventTypeCode; | ||
|
||
import java.util.Collections; | ||
|
||
/** | ||
* @author Boris Stanojevic | ||
* @since 4.8 | ||
*/ | ||
public class Iti105ClientAuditStrategy extends Iti105AuditStrategy { | ||
|
||
public Iti105ClientAuditStrategy() { | ||
super(false); | ||
} | ||
|
||
@Override | ||
public AuditMessage[] makeAuditMessage(AuditContext auditContext, Iti105AuditDataset auditDataset) { | ||
return new PHIExportBuilder<>(auditContext, auditDataset, FhirEventTypeCode.SimplifiedPublish) | ||
.setPatient(auditDataset.getPatientId()) | ||
.addExportedEntity( | ||
auditDataset.getDocumentReferenceId() != null ? | ||
auditDataset.getDocumentReferenceId() : | ||
auditContext.getAuditValueIfMissing(), | ||
ParticipantObjectIdTypeCode.XdsMetadata, | ||
ParticipantObjectTypeCodeRole.Job, | ||
Collections.emptyList()) | ||
.getMessages(); | ||
} | ||
} |
53 changes: 53 additions & 0 deletions
53
.../org/openehealth/ipf/commons/ihe/fhir/iti105/Iti105DocumentReferenceResourceProvider.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,53 @@ | ||
/* | ||
* Copyright 2023 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.fhir.iti105; | ||
|
||
import ca.uhn.fhir.rest.annotation.Create; | ||
import ca.uhn.fhir.rest.annotation.ResourceParam; | ||
import ca.uhn.fhir.rest.api.MethodOutcome; | ||
import ca.uhn.fhir.rest.api.server.RequestDetails; | ||
import org.hl7.fhir.instance.model.api.IBaseResource; | ||
import org.hl7.fhir.r4.model.DocumentReference; | ||
import org.openehealth.ipf.commons.ihe.fhir.AbstractResourceProvider; | ||
|
||
import javax.servlet.http.HttpServletRequest; | ||
import javax.servlet.http.HttpServletResponse; | ||
|
||
/** | ||
* Resource Provider for MHD (ITI-105) based on creating a DocumentReference resource | ||
* | ||
* @author Boris Stanojevic | ||
* @since 4.8 | ||
*/ | ||
public class Iti105DocumentReferenceResourceProvider extends AbstractResourceProvider { | ||
|
||
@SuppressWarnings("unused") | ||
@Create | ||
public MethodOutcome createDocumentReference( | ||
@ResourceParam DocumentReference documentReference, | ||
RequestDetails requestDetails, | ||
HttpServletRequest httpServletRequest, | ||
HttpServletResponse httpServletResponse) { | ||
|
||
return requestAction(documentReference, null, httpServletRequest, httpServletResponse, requestDetails); | ||
} | ||
|
||
@Override | ||
public Class<? extends IBaseResource> getResourceType() { | ||
return DocumentReference.class; | ||
} | ||
} |
43 changes: 43 additions & 0 deletions
43
...4/mhd/src/main/java/org/openehealth/ipf/commons/ihe/fhir/iti105/Iti105RequestFactory.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,43 @@ | ||
/* | ||
* Copyright 2023 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.fhir.iti105; | ||
|
||
import ca.uhn.fhir.rest.api.MethodOutcome; | ||
import ca.uhn.fhir.rest.client.api.IGenericClient; | ||
import ca.uhn.fhir.rest.gclient.IClientExecutable; | ||
import org.hl7.fhir.r4.model.DocumentReference; | ||
import org.openehealth.ipf.commons.ihe.fhir.ClientRequestFactory; | ||
|
||
import java.util.Map; | ||
|
||
/** | ||
* A {@link ClientRequestFactory} for ITI-105 requests | ||
* | ||
* @author Boris Stanojevic | ||
* @since 4.8 | ||
*/ | ||
public class Iti105RequestFactory implements ClientRequestFactory<IClientExecutable<?, ?>> { | ||
|
||
@Override | ||
public IClientExecutable getClientExecutable( | ||
IGenericClient client, | ||
Object requestData, | ||
Map<String, Object> parameters) { | ||
return client.create().resource((DocumentReference) requestData); | ||
} | ||
|
||
} |
49 changes: 49 additions & 0 deletions
49
.../src/main/java/org/openehealth/ipf/commons/ihe/fhir/iti105/Iti105ServerAuditStrategy.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 2023 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.fhir.iti105; | ||
|
||
import org.openehealth.ipf.commons.audit.AuditContext; | ||
import org.openehealth.ipf.commons.audit.codes.ParticipantObjectIdTypeCode; | ||
import org.openehealth.ipf.commons.audit.codes.ParticipantObjectTypeCodeRole; | ||
import org.openehealth.ipf.commons.audit.model.AuditMessage; | ||
import org.openehealth.ipf.commons.ihe.core.atna.event.PHIImportBuilder; | ||
import org.openehealth.ipf.commons.ihe.fhir.audit.codes.FhirEventTypeCode; | ||
|
||
import java.util.Collections; | ||
|
||
/** | ||
* @author Boris Stanojevic | ||
* @since 4.8 | ||
*/ | ||
public class Iti105ServerAuditStrategy extends Iti105AuditStrategy { | ||
|
||
public Iti105ServerAuditStrategy() { | ||
super(true); | ||
} | ||
|
||
@Override | ||
public AuditMessage[] makeAuditMessage(AuditContext auditContext, Iti105AuditDataset auditDataset) { | ||
return new PHIImportBuilder<>(auditContext, auditDataset, FhirEventTypeCode.SimplifiedPublish) | ||
.setPatient(auditDataset.getPatientId()) | ||
.addImportedEntity( | ||
auditDataset.getDocumentReferenceId(), | ||
ParticipantObjectIdTypeCode.XdsMetadata, | ||
ParticipantObjectTypeCodeRole.Job, | ||
Collections.emptyList()) | ||
.getMessages(); | ||
} | ||
} |
41 changes: 41 additions & 0 deletions
41
...main/java/org/openehealth/ipf/commons/ihe/fhir/iti105/Iti105TransactionConfiguration.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,41 @@ | ||
/* | ||
* Copyright 2023 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.fhir.iti105; | ||
|
||
import ca.uhn.fhir.context.FhirVersionEnum; | ||
import org.openehealth.ipf.commons.ihe.fhir.FhirTransactionConfiguration; | ||
|
||
/** | ||
* Standard Configuration for Iti105Component. | ||
* | ||
* @author Boris Stanojevic | ||
* @since 4.8 | ||
*/ | ||
public class Iti105TransactionConfiguration extends FhirTransactionConfiguration<Iti105AuditDataset> { | ||
|
||
public Iti105TransactionConfiguration() { | ||
super("mhd-iti105", | ||
"Simplified Publish", | ||
false, | ||
new Iti105ClientAuditStrategy(), | ||
new Iti105ServerAuditStrategy(), | ||
FhirVersionEnum.R4, | ||
new Iti105DocumentReferenceResourceProvider(), | ||
new Iti105RequestFactory(), | ||
Iti105Validator::new); | ||
} | ||
|
||
} |
Oops, something went wrong.