Skip to content

Commit

Permalink
consider ballot changes in the CH:PPQm implementation guide
Browse files Browse the repository at this point in the history
  • Loading branch information
unixoid committed Oct 29, 2023
1 parent 49edc96 commit 46be8ee
Show file tree
Hide file tree
Showing 7 changed files with 15 additions and 16 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -129,8 +129,8 @@ class FhirToXacmlTranslator {
/**
* Translates a CH:PPQ-5 request into a CH:PPQ-2 request.
*
* @param httpQuery
* @return
* @param httpQuery HTTP query string
* @return PPQ-2 request POJO
*/
XACMLPolicyQueryType translatePpq5To2Request(String httpQuery) {
List<NameValuePair> params = URLEncodedUtils.parse(httpQuery, StandardCharsets.UTF_8);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,8 +57,8 @@ public static FhirContext getFhirContext() {

public static class Profiles {
public static final String CONSENT = "http://fhir.ch/ig/ch-epr-ppqm/StructureDefinition/PpqmConsent";
public static final String REQUEST_BUNDLE = "http://fhir.ch/ig/ch-epr-ppqm/StructureDefinition/PpqmRequestBundle";
public static final String RESPONSE_BUNDLE = "http://fhir.ch/ig/ch-epr-ppqm/StructureDefinition/PpqmResponseBundle";
public static final String FEED_REQUEST_BUNDLE = "http://fhir.ch/ig/ch-epr-ppqm/StructureDefinition/PpqmFeedRequestBundle";
public static final String RETRIEVE_RESPONSE_BUNDLE = "http://fhir.ch/ig/ch-epr-ppqm/StructureDefinition/PpqmRetrieveResponseBundle";
}

public static class CodingSystems {
Expand Down Expand Up @@ -122,7 +122,7 @@ public static Bundle createPpq4SubmitRequestBundle(Collection<Consent> consents,
Bundle bundle = new Bundle();
bundle.setId(UUID.randomUUID().toString());
bundle.setType(Bundle.BundleType.TRANSACTION);
bundle.getMeta().addProfile(Profiles.REQUEST_BUNDLE);
bundle.getMeta().addProfile(Profiles.FEED_REQUEST_BUNDLE);
for (Consent consent : consents) {
Bundle.BundleEntryComponent entry = new Bundle.BundleEntryComponent();
entry.getRequest().setMethod(httpMethod);
Expand All @@ -147,7 +147,7 @@ public static Bundle createPpq4DeleteRequestBundle(Collection<String> consentIds
Bundle bundle = new Bundle();
bundle.setId(UUID.randomUUID().toString());
bundle.setType(Bundle.BundleType.TRANSACTION);
bundle.getMeta().addProfile(Profiles.REQUEST_BUNDLE);
bundle.getMeta().addProfile(Profiles.FEED_REQUEST_BUNDLE);
for (String consentId : consentIds) {
Bundle.BundleEntryComponent entry = new Bundle.BundleEntryComponent();
entry.getRequest().setMethod(Bundle.HTTPVerb.DELETE);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ public ChPpq4Validator(FhirContext fhirContext) {

@Override
public void validateRequest(Object payload, Map<String, Object> parameters) {
handleOperationOutcome(validateProfileConformance((Resource) payload, ChPpqmUtils.Profiles.REQUEST_BUNDLE));
handleOperationOutcome(validateProfileConformance((Resource) payload, ChPpqmUtils.Profiles.FEED_REQUEST_BUNDLE));
}

@Override
Expand Down
Binary file not shown.
Original file line number Diff line number Diff line change
Expand Up @@ -185,17 +185,17 @@ public void testPpq4To1RequestTranslation() {
{
Bundle ppq4Request = ChPpqmUtils.createPpq4SubmitRequestBundle(consents, Bundle.HTTPVerb.POST);
assert ppq4Request.getMeta().getProfile().stream()
.anyMatch(canonicalType -> ChPpqmUtils.Profiles.REQUEST_BUNDLE.equals(canonicalType.getValue()));
.anyMatch(canonicalType -> ChPpqmUtils.Profiles.FEED_REQUEST_BUNDLE.equals(canonicalType.getValue()));
new ChPpq4Validator(ChPpqmUtils.FHIR_CONTEXT).validateRequest(ppq4Request, null);
AddPolicyRequest addRequest = (AddPolicyRequest) FHIR_TO_XACML_TRANSLATOR.translatePpq4To1Request(ppq4Request);
AddPolicyRequest addRequest = FHIR_TO_XACML_TRANSLATOR.translatePpq4To1Request(ppq4Request);
Xacml20MessageValidator.validateChPpq1Request(addRequest);
}
{
Bundle ppq4Request = ChPpqmUtils.createPpq4SubmitRequestBundle(consents, Bundle.HTTPVerb.PUT);
assert ppq4Request.getMeta().getProfile().stream()
.anyMatch(canonicalType -> ChPpqmUtils.Profiles.REQUEST_BUNDLE.equals(canonicalType.getValue()));
.anyMatch(canonicalType -> ChPpqmUtils.Profiles.FEED_REQUEST_BUNDLE.equals(canonicalType.getValue()));
new ChPpq4Validator(ChPpqmUtils.FHIR_CONTEXT).validateRequest(ppq4Request, null);
UpdatePolicyRequest updateRequest = (UpdatePolicyRequest) FHIR_TO_XACML_TRANSLATOR.translatePpq4To1Request(ppq4Request);
UpdatePolicyRequest updateRequest = FHIR_TO_XACML_TRANSLATOR.translatePpq4To1Request(ppq4Request);
Xacml20MessageValidator.validateChPpq1Request(updateRequest);
}
{
Expand All @@ -204,9 +204,9 @@ public void testPpq4To1RequestTranslation() {
.collect(Collectors.toSet());
Bundle ppq4Request = ChPpqmUtils.createPpq4DeleteRequestBundle(consentIds);
assert ppq4Request.getMeta().getProfile().stream()
.anyMatch(canonicalType -> ChPpqmUtils.Profiles.REQUEST_BUNDLE.equals(canonicalType.getValue()));
.anyMatch(canonicalType -> ChPpqmUtils.Profiles.FEED_REQUEST_BUNDLE.equals(canonicalType.getValue()));
new ChPpq4Validator(ChPpqmUtils.FHIR_CONTEXT).validateRequest(ppq4Request, null);
DeletePolicyRequest deleteRequest = (DeletePolicyRequest) FHIR_TO_XACML_TRANSLATOR.translatePpq4To1Request(ppq4Request);
DeletePolicyRequest deleteRequest = FHIR_TO_XACML_TRANSLATOR.translatePpq4To1Request(ppq4Request);
Xacml20MessageValidator.validateChPpq1Request(deleteRequest);
}

Expand All @@ -221,7 +221,7 @@ public void testPpq1To4ResponseTranslation() {
create203Consent(createUuid(), "123456789012345678", "urn:e-health-suisse:2015:policies:provide-level:restricted"));

Bundle ppq4Request = ChPpqmUtils.createPpq4SubmitRequestBundle(consents, Bundle.HTTPVerb.POST);
AddPolicyRequest ppq1Request = (AddPolicyRequest) FHIR_TO_XACML_TRANSLATOR.translatePpq4To1Request(ppq4Request);
AddPolicyRequest ppq1Request = FHIR_TO_XACML_TRANSLATOR.translatePpq4To1Request(ppq4Request);
EprPolicyRepositoryResponse ppq1Response = new EprPolicyRepositoryResponse();
ppq1Response.setStatus(PpqConstants.StatusCode.SUCCESS);
Bundle ppq4Response = XacmlToFhirTranslator.translatePpq1To4Response(ppq4Request, ppq1Request, ppq1Response);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ package org.openehealth.ipf.commons.ihe.xacml20

import org.apache.velocity.Template
import org.apache.velocity.VelocityContext
import org.apache.velocity.app.Velocity
import org.apache.velocity.app.VelocityEngine
import org.apache.velocity.runtime.resource.loader.ClasspathResourceLoader
import org.herasaf.xacml.core.policy.impl.PolicySetType
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ public void test1() throws Exception {
create202Consent(createUuid(), "123456789012345678", "urn:e-health-suisse:2015:policies:access-level:normal"),
create203Consent(createUuid(), "123456789012345678", "urn:e-health-suisse:2015:policies:provide-level:restricted"));
Bundle requestBundle = new Bundle();
requestBundle.getMeta().addProfile(ChPpqmUtils.Profiles.REQUEST_BUNDLE);
requestBundle.getMeta().addProfile(ChPpqmUtils.Profiles.FEED_REQUEST_BUNDLE);
requestBundle.setId(createUuid());
requestBundle.setType(Bundle.BundleType.TRANSACTION);
for (Consent consent : consents) {
Expand Down

0 comments on commit 46be8ee

Please sign in to comment.