protected AuditEvent.AuditEventAgentNetworkType auditEventNetworkType(NetworkAccessPointTypeCode naptc) { try { return AuditEvent.AuditEventAgentNetworkType.fromCode(String.valueOf(naptc.getValue())); } catch (FHIRException e) { // should never happen throw new AuditException(e); } }
protected AuditEvent.AuditEventAction getAuditEventAction(EventActionCode eventActionCode) { try { return AuditEvent.AuditEventAction.fromCode(eventActionCode.getValue()); } catch (FHIRException e) { // should never happen throw new AuditException(e); } }
protected AuditEvent.AuditEventOutcome getAuditEventOutcome(EventOutcomeIndicator eventOutcomeIndicator) { try { return AuditEvent.AuditEventOutcome.fromCode(String.valueOf(eventOutcomeIndicator.getValue())); } catch (FHIRException e) { // should never happen throw new AuditException(e); } }
protected AuditEvent.AuditEventEntityComponent participantObjectIdentificationToEntity(ParticipantObjectIdentificationType poit) { AuditEvent.AuditEventEntityComponent entity = new AuditEvent.AuditEventEntityComponent() .setIdentifier(new Identifier() .setValue(poit.getParticipantObjectID())) // poit.getParticipantObjectIDTypeCode())) not used here .setType(new Coding() .setCode(String.valueOf(poit.getParticipantObjectTypeCode().getValue())) .setSystem("http://hl7.org/fhir/audit-entity-type")) .setRole(new Coding() .setCode(String.valueOf(poit.getParticipantObjectTypeCodeRole().getValue())) .setSystem("http://hl7.org/fhir/object-role")) .setLifecycle(new Coding() .setCode(String.valueOf(poit.getParticipantObjectDataLifeCycle().getValue())) .setSystem("http://hl7.org/fhir/dicom-audit-lifecycle")) .addSecurityLabel(new Coding() .setCode(poit.getParticipantObjectSensitivity())) .setName(poit.getParticipantObjectName()) // poit.getParticipantObjectDescription) not mappable here .setQuery(poit.getParticipantObjectQuery()); poit.getParticipantObjectDetails().forEach(tvp -> entity.addDetail(new AuditEvent.AuditEventEntityDetailComponent() .setType(tvp.getType()) .setValue(tvp.getValue()))); return entity; }
protected Element eventIdentification(EventIdentificationType eventIdentification) { Element element = new Element("EventIdentification"); if (eventIdentification != null) { element.setAttribute("EventActionCode", eventIdentification.getEventActionCode().getValue()); element.setAttribute("EventDateTime", eventIdentification.getEventDateTime().toString()); element.setAttribute("EventOutcomeIndicator", eventIdentification.getEventOutcomeIndicator().getValue().toString()); if (eventIdentification.getEventID() != null) { element.addContent(codedValueType("EventID", eventIdentification.getEventID())); } eventIdentification.getEventTypeCode().stream() .map(eventTypeCode -> codedValueType("EventTypeCode", eventTypeCode)) .forEach(element::addContent); if (eventIdentification.getEventOutcomeDescription() != null) { element.addContent( new Element("EventOutcomeDescription") .addContent(eventIdentification.getEventOutcomeDescription())); } eventIdentification.getPurposesOfUse().stream() .map(purposeOfUse -> codedValueType("PurposeOfUse", purposeOfUse)) .forEach(element::addContent); } return element; }
protected Element participantObjectIdentification(ParticipantObjectIdentificationType poi) { Element element = new Element("ParticipantObjectIdentification"); if (poi != null) { conditionallyAddAttribute(element, "ParticipantObjectID", poi.getParticipantObjectID()); if (poi.getParticipantObjectTypeCode() != null) { conditionallyAddAttribute(element, "ParticipantObjectTypeCode", poi.getParticipantObjectTypeCode().getValue().toString()); } conditionallyAddAttribute(element, "ParticipantObjectTypeCodeRole", poi.getParticipantObjectTypeCodeRole()); conditionallyAddAttribute(element, "ParticipantObjectDataLifeCycle", poi.getParticipantObjectDataLifeCycle()); conditionallyAddAttribute(element, "ParticipantObjectSensitivity", poi.getParticipantObjectSensitivity()); element.addContent(codedValueType("ParticipantObjectIDTypeCode", poi.getParticipantObjectIDTypeCode())); if (poi.getParticipantObjectName() != null) { element.addContent(new Element("ParticipantObjectName") .addContent(poi.getParticipantObjectName())); } if (poi.getParticipantObjectQuery() != null) { element.addContent(new Element("ParticipantObjectQuery") .addContent(new String( Base64.getEncoder().encode(poi.getParticipantObjectQuery()), StandardCharsets.UTF_8))); } poi.getParticipantObjectDetails().stream() .map(participantObjectDetail -> typeValuePairType("ParticipantObjectDetail", participantObjectDetail)) .forEach(element::addContent); poi.getParticipantObjectDescriptions().stream() .map(this::dicomObjectDescription) .forEach(element::addContent); } return element; }
@Override public void validate() { super.validate(); ParticipantObjectIdentificationType patient = getMessage().findParticipantObjectIdentifications(poi -> ParticipantObjectIdTypeCode.PatientNumber.equals(poi.getParticipantObjectIDTypeCode())).get(0); if (!PATIENT_ID_PATTERN.matcher(patient.getParticipantObjectID()).matches()) { throw new AuditException("Patient ID should be in CX format " + PATIENT_ID_PATTERN.pattern()); } } }
protected AuditMessage makeAuditMessage(AuditContext auditContext, Iti59AuditDataset auditDataset, Iti59AuditDataset.RequestItem requestItem) { PHIImportBuilder builder = new PHIImportBuilder<>( auditContext, auditDataset, requestItem.getOutcomeCode(), requestItem.getOutcomeDescription(), requestItem.getActionCode(), HpdEventTypeCode.ProviderInformationFeed, auditDataset.getPurposesOfUse()); builder.addImportedEntity( requestItem.getUid(), HpdParticipantObjectIdTypeCode.RelativeDistinguishedName, requestItem.getParticipantObjectTypeCode(), ParticipantObjectTypeCodeRole.Provider, requestItem.getParticipantObjectDataLifeCycle(), Translation.equals(requestItem.getParticipantObjectDataLifeCycle()) ? Collections.emptyList() : Collections.singletonList(builder.getTypeValuePair("old uid", requestItem.getUid()))); return builder.getMessage(); } }
@Override public void validate() { super.validate(); if (getMessage().findActiveParticipants(ap -> ActiveParticipantRoleIdCode.Application.equals(ap)).size() != 1) { throw new AuditException("Must have exactly one Application Active Participant"); } }
protected AuditEvent.AuditEventEntityComponent participantObjectIdentificationToEntity(ParticipantObjectIdentificationType poit) { AuditEvent.AuditEventEntityComponent entity = new AuditEvent.AuditEventEntityComponent() .setWhat(new Reference().setIdentifier(new Identifier() .setValue(poit.getParticipantObjectID()))) // poit.getParticipantObjectIDTypeCode())) not used here .setType(new Coding() .setCode(String.valueOf(poit.getParticipantObjectTypeCode().getValue())) .setSystem("http://hl7.org/fhir/audit-entity-type")) .setRole(new Coding() .setCode(String.valueOf(poit.getParticipantObjectTypeCodeRole().getValue())) .setSystem("http://hl7.org/fhir/object-role")) .setLifecycle(new Coding() .setCode(String.valueOf(poit.getParticipantObjectDataLifeCycle().getValue())) .setSystem("http://hl7.org/fhir/dicom-audit-lifecycle")) .addSecurityLabel(new Coding() .setCode(poit.getParticipantObjectSensitivity())) .setName(poit.getParticipantObjectName()) // poit.getParticipantObjectDescription) not mappable here .setQuery(poit.getParticipantObjectQuery()); poit.getParticipantObjectDetails().forEach(tvp -> entity.addDetail(new AuditEvent.AuditEventEntityDetailComponent() .setType(tvp.getType()) .setValue(new Base64BinaryType(tvp.getValue())))); return entity; }
protected AuditEvent.AuditEventAction getAuditEventAction(EventActionCode eventActionCode) { try { return AuditEvent.AuditEventAction.fromCode(eventActionCode.getValue()); } catch (FHIRException e) { // should never happen throw new AuditException(e); } }
protected AuditEvent.AuditEventOutcome getAuditEventOutcome(EventOutcomeIndicator eventOutcomeIndicator) { try { return AuditEvent.AuditEventOutcome.fromCode(String.valueOf(eventOutcomeIndicator.getValue())); } catch (FHIRException e) { // should never happen throw new AuditException(e); } }
protected AuditEvent.AuditEventAgentNetworkType auditEventNetworkType(NetworkAccessPointTypeCode naptc) { try { return AuditEvent.AuditEventAgentNetworkType.fromCode(String.valueOf(naptc.getValue())); } catch (FHIRException e) { // should never happen throw new AuditException(e); } }
@Override public void validate() { super.validate(); if (getMessage().getActiveParticipants().isEmpty() || getMessage().getActiveParticipants().size() > 2) { throw new AuditException("Must have one or two participants that started the Application"); } if (getMessage().findParticipantObjectIdentifications(poi -> ParticipantObjectIdTypeCode.URI.equals(poi.getParticipantObjectTypeCode())).size() != 1) { throw new AuditException("Must have exactly Audit Log Identity Participating Object "); } } }
protected AuditMessage makeAuditMessage(AuditContext auditContext, Iti59AuditDataset auditDataset, Iti59AuditDataset.RequestItem requestItem) { PHIExportBuilder builder = new PHIExportBuilder<>( auditContext, auditDataset, requestItem.getOutcomeCode(), null, requestItem.getActionCode(), HpdEventTypeCode.ProviderInformationFeed, auditDataset.getPurposesOfUse() ); builder.addExportedEntity( requestItem.getUid(), HpdParticipantObjectIdTypeCode.RelativeDistinguishedName, requestItem.getParticipantObjectTypeCode(), ParticipantObjectTypeCodeRole.Provider, requestItem.getParticipantObjectDataLifeCycle(), Translation.equals(requestItem.getParticipantObjectDataLifeCycle()) ? Collections.emptyList() : Collections.singletonList(builder.getTypeValuePair("old uid", requestItem.getUid())) ); return builder.getMessage(); }