Skip to content

Commit

Permalink
EPA-20: Decide which metadata to use when producing an ePA export (#9)
Browse files Browse the repository at this point in the history
  • Loading branch information
annadurrer-oviva authored Jun 5, 2024
1 parent 3b1bebc commit 2911b58
Showing 1 changed file with 19 additions and 16 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,7 @@ void writeDocument() {
konnektorService.getAuthorInstitutions().stream()
.findFirst()
.orElseThrow(() -> new IllegalStateException("no SMC-B found"));
var document = buildDocumentPayload(documentId, authorInstitution, EXPORT_XML.getBytes());
var document = buildDocumentPayload(documentId, authorInstitution, hcid, EXPORT_XML.getBytes());

// 3) write the FHIR/MIO document
assertDoesNotThrow(() -> konnektorService.writeDocument(recordIdentifier, document));
Expand All @@ -161,14 +161,15 @@ void replaceDocument() {
.findFirst()
.orElseThrow(() -> new IllegalStateException("no SMC-B found"));

var document = buildDocumentPayload(documentId, authorInstitution, EXPORT_XML.getBytes());
var document = buildDocumentPayload(documentId, authorInstitution, hcid, EXPORT_XML.getBytes());

// 3) write the FHIR/MIO document
assertDoesNotThrow(() -> konnektorService.writeDocument(recordIdentifier, document));

// 4) replace the document
var newDocumentId = UUID.randomUUID();
var newDocument = buildDocumentPayload(newDocumentId, authorInstitution, EXPORT_XML.getBytes());
var newDocument =
buildDocumentPayload(newDocumentId, authorInstitution, hcid, EXPORT_XML.getBytes());
assertDoesNotThrow(
() -> konnektorService.replaceDocument(recordIdentifier, newDocument, documentId));
}
Expand Down Expand Up @@ -201,8 +202,9 @@ private KonnektorService buildService() throws Exception {
}

private Document buildDocumentPayload(
UUID id, AuthorInstitution authorInstitution, byte[] contents) {
var repositoryUniqueId = UUID.randomUUID().toString();
UUID id, AuthorInstitution authorInstitution, String homeCommunityId, byte[] contents) {
var repositoryUniqueId = homeCommunityId;
var currentDate = LocalDateTime.now().toString();

// IMPORTANT: Without the urn prefix we can't replace it later
var documentUuid = "urn:uuid:" + id;
Expand All @@ -213,24 +215,25 @@ private Document buildDocumentPayload(
List.of(
new Author(
null,
"Tester",
"DIGA-Test",
"Oviva Direkt für Adipositas",
"Oviva AG",
"",
"",
"",
"Dr",
// Der identifier in AuthorInstitution muss eine gültige TelematikId sein, so
// wie sie z. B. auf der SMC-B-Karte enthalten ist
List.of(authorInstitution),
List.of("11^^^&1.3.6.1.4.1.19376.3.276.1.5.13&ISO"),
List.of(),
List.of())),
List.of("12^^^&1.3.6.1.4.1.19376.3.276.1.5.13&ISO"),
List.of("25^^^&1.3.6.1.4.1.19376.3.276.1.5.11&ISO"),
List.of("^^Internet^[email protected]"))),
"AVAILABLE",
List.of(ConfidentialityCode.NORMAL.getValue()),
ClassCode.DURCHFUEHRUNGSPROTOKOLL.getValue(),
"DiGA MIO-Beispiel eines Dokument von Referenzimplementierung geschickt (Simple Roundtrip)",
LocalDateTime.now().minusHours(3),
documentUuid,
List.of(EventCode.PATIENTEN_MITGEBRACHT.getValue()),
List.of(
EventCode.VIRTUAL_ENCOUNTER.getValue(), EventCode.PATIENTEN_MITGEBRACHT.getValue()),
FormatCode.DIGA.getValue(),
"",
HealthcareFacilityCode.PATIENT_AUSSERHALB_BETREUUNG.getValue(),
Expand All @@ -239,13 +242,13 @@ private Document buildDocumentPayload(
"application/fhir+xml",
PracticeSettingCode.PATIENT_AUSSERHALB_BETREUUNG.getValue(),
List.of(),
LocalDateTime.now().minusWeeks(2),
LocalDateTime.now().minusWeeks(1),
null,
null,
contents.length,
"Gesundheitsmonitoring",
"ePA Export Oviva Direkt for Obesity " + currentDate,
TypeCode.PATIENTENEIGENE_DOKUMENTE.getValue(),
documentUuid,
"monitoring.xml",
"Oviva_DiGA_Export_" + currentDate,
repositoryUniqueId,
"",
KVNR),
Expand Down

0 comments on commit 2911b58

Please sign in to comment.