Skip to content

Commit

Permalink
implement the #437 SimplifiedPublish iti-105 transaction
Browse files Browse the repository at this point in the history
  • Loading branch information
Boris Stanojevic committed Dec 12, 2023
1 parent 4c46d46 commit e76eb78
Show file tree
Hide file tree
Showing 18 changed files with 3,406 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ public enum FhirEventTypeCode implements EventType, EnumeratedCodedValue<EventTy
MobilePatientDemographicsQuery("ITI-78", IHE_SYSTEM_NAME, "Mobile Patient Demographics Query"),
RetrieveATNAAuditEvent("ITI-81", IHE_SYSTEM_NAME, "Retrieve ATNA AuditEvent"),
MobilePatientIdentifierCrossReferenceQuery("ITI-83", IHE_SYSTEM_NAME, "Mobile Patient Identifier Cross-reference Query"),
SimplifiedPublish("ITI-105", IHE_SYSTEM_NAME, "Simplified Publish"),
MobileQueryExistingData("PCC-44", IHE_SYSTEM_NAME, "Mobile Query Existing Data"),
QueryPharmacyDocumentsOverMhd("PHARM-5", IHE_SYSTEM_NAME, "Query Pharmacy Documents over MHD"),
MobilePrivacyPolicyFeed("PPQ-3", EHS_SYSTEM_NAME, "Mobile Privacy Policy Feed"),
Expand Down
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();
}
}
}
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);
}

}
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();
}
}
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;
}
}
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);
}

}
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();
}
}
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);
}

}
Loading

0 comments on commit e76eb78

Please sign in to comment.