Skip to content

Commit

Permalink
#1 Add initial Folder support
Browse files Browse the repository at this point in the history
  • Loading branch information
Thopap committed Dec 3, 2023
1 parent c60e9a5 commit 467a501
Showing 1 changed file with 46 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
package org.openehealth.app.xdstofhir.registry.common.mapper;

import static org.openehealth.app.xdstofhir.registry.common.MappingSupport.urnDecodedScheme;

import java.util.function.Function;
import java.util.stream.Collectors;

import lombok.RequiredArgsConstructor;
import org.hl7.fhir.r4.model.CodeableConcept;
import org.hl7.fhir.r4.model.Identifier;
import org.openehealth.app.xdstofhir.registry.common.fhir.MhdFolder;
import org.openehealth.ipf.commons.ihe.xds.core.metadata.AvailabilityStatus;
import org.openehealth.ipf.commons.ihe.xds.core.metadata.Folder;
import org.openehealth.ipf.commons.ihe.xds.core.metadata.LocalizedString;
import org.springframework.stereotype.Component;

@Component
@RequiredArgsConstructor
public class FhirToXdsFolderMapper extends AbstractFhirToXdsMapper
implements Function<MhdFolder, Folder> {
@Override
public Folder apply(MhdFolder mhdFolder) {
if (mhdFolder.getIdentifier().isEmpty())
return null;
var patientId = obtainIndexPatientId(mhdFolder.getSubject());
if (patientId == null)
return null;
var folder = new Folder();
folder.setPatientId(patientId);
folder.setUniqueId(urnDecodedScheme(mhdFolder.getIdentifier().stream()
.filter(id -> Identifier.IdentifierUse.USUAL.equals(id.getUse())).findFirst().get().getValue()));
folder.setEntryUuid(bestQualifiedIdentified(mhdFolder.getIdentifier()).getId());
folder.setAvailabilityStatus(AvailabilityStatus.APPROVED);
folder.setLastUpdateTime(fromDateTime(mhdFolder.getDateElement()));
folder.getCodeList().addAll(mhdFolder.getDesignationType().stream()
.map(CodeableConcept::getCodingFirstRep)
.map(this::fromCode)
.collect(Collectors.toList()));
if (mhdFolder.getTitle() != null)
folder.setTitle(new LocalizedString(mhdFolder.getTitle()));
if (!mhdFolder.getNote().isEmpty())
folder.setComments(new LocalizedString(mhdFolder.getNoteFirstRep().getText()));
return folder;
}

}

0 comments on commit 467a501

Please sign in to comment.