use of org.openehealth.ipf.commons.ihe.xds.core.metadata.LocalizedString in project MobileAccessGateway by i4mi.
the class Iti65RequestConverter method processDocumentManifest.
/**
* ITI-65: process DocumentManifest resource from Bundle
* @param manifest
* @param submissionSet
*/
private void processDocumentManifest(DocumentManifest manifest, SubmissionSet submissionSet) {
// masterIdentifier SubmissionSet.uniqueId
Identifier masterIdentifier = manifest.getMasterIdentifier();
submissionSet.setUniqueId(noPrefix(masterIdentifier.getValue()));
submissionSet.assignEntryUuid();
manifest.setId(submissionSet.getEntryUuid());
CodeableConcept type = manifest.getType();
submissionSet.setContentTypeCode(transformCodeableConcept(type));
DateTimeType created = manifest.getCreatedElement();
submissionSet.setSubmissionTime(timestampFromDate(created));
// subject SubmissionSet.patientId
Reference ref = manifest.getSubject();
submissionSet.setPatientId(transformReferenceToIdentifiable(ref, manifest));
// Author
Extension authorRoleExt = manifest.getExtensionByUrl("http://fhir.ch/ig/ch-epr-mhealth/StructureDefinition/ch-ext-author-authorrole");
if (manifest.hasAuthor() || (authorRoleExt != null)) {
Identifiable identifiable = null;
Reference author = manifest.getAuthorFirstRep();
if (authorRoleExt != null) {
Coding coding = authorRoleExt.castToCoding(authorRoleExt.getValue());
if (coding != null) {
identifiable = new Identifiable(coding.getCode(), new AssigningAuthority(noPrefix(coding.getSystem())));
}
}
submissionSet.setAuthor(transformAuthor(author, manifest.getContained(), identifiable));
}
// recipient SubmissionSet.intendedRecipient
for (Reference recipientRef : manifest.getRecipient()) {
Resource res = findResource(recipientRef, manifest.getContained());
if (res instanceof Practitioner) {
Recipient recipient = new Recipient();
recipient.setPerson(transform((Practitioner) res));
recipient.setTelecom(transform(((Practitioner) res).getTelecomFirstRep()));
submissionSet.getIntendedRecipients().add(recipient);
} else if (res instanceof Organization) {
Recipient recipient = new Recipient();
recipient.setOrganization(transform((Organization) res));
recipient.setTelecom(transform(((Organization) res).getTelecomFirstRep()));
submissionSet.getIntendedRecipients().add(recipient);
} else if (res instanceof PractitionerRole) {
Recipient recipient = new Recipient();
PractitionerRole role = (PractitionerRole) res;
recipient.setOrganization(transform((Organization) findResource(role.getOrganization(), manifest.getContained())));
recipient.setPerson(transform((Practitioner) findResource(role.getPractitioner(), manifest.getContained())));
recipient.setTelecom(transform(role.getTelecomFirstRep()));
submissionSet.getIntendedRecipients().add(recipient);
} else if (res instanceof Patient) {
Recipient recipient = new Recipient();
recipient.setPerson(transform((Patient) res));
recipient.setTelecom(transform(((Patient) res).getTelecomFirstRep()));
} else if (res instanceof RelatedPerson) {
Recipient recipient = new Recipient();
recipient.setPerson(transform((RelatedPerson) res));
recipient.setTelecom(transform(((RelatedPerson) res).getTelecomFirstRep()));
}
}
// source SubmissionSet.sourceId
String source = noPrefix(manifest.getSource());
submissionSet.setSourceId(source);
String description = manifest.getDescription();
if (description != null)
submissionSet.setTitle(localizedString(description));
}
use of org.openehealth.ipf.commons.ihe.xds.core.metadata.LocalizedString in project MobileAccessGateway by i4mi.
the class Iti65RequestConverter method processDocumentManifest.
/**
* ITI-65: process ListResource resource from Bundle
* @param manifest
* @param submissionSet
*/
private void processDocumentManifest(ListResource manifest, SubmissionSet submissionSet) {
for (Identifier id : manifest.getIdentifier()) {
if (id.getUse() == null || id.getUse().equals(Identifier.IdentifierUse.OFFICIAL)) {
} else if (id.getUse().equals(Identifier.IdentifierUse.USUAL)) {
String uniqueId = noPrefix(id.getValue());
submissionSet.setUniqueId(uniqueId);
}
}
submissionSet.assignEntryUuid();
manifest.setId(submissionSet.getEntryUuid());
Extension designationType = manifest.getExtensionByUrl("http://profiles.ihe.net/ITI/MHD/StructureDefinition/ihe-designationType");
if (designationType != null && designationType.getValue() instanceof CodeableConcept) {
submissionSet.setContentTypeCode(transformCodeableConcept((CodeableConcept) designationType.getValue()));
}
DateTimeType created = manifest.getDateElement();
submissionSet.setSubmissionTime(timestampFromDate(created));
// subject SubmissionSet.patientId
Reference ref = manifest.getSubject();
submissionSet.setPatientId(transformReferenceToIdentifiable(ref, manifest));
// Author
Extension authorRoleExt = manifest.getExtensionByUrl("http://fhir.ch/ig/ch-epr-mhealth/StructureDefinition/ch-ext-author-authorrole");
if (manifest.hasSource() || (authorRoleExt != null)) {
Identifiable identifiable = null;
Reference author = manifest.getSource();
if (authorRoleExt != null) {
Coding coding = authorRoleExt.castToCoding(authorRoleExt.getValue());
if (coding != null) {
identifiable = new Identifiable(coding.getCode(), new AssigningAuthority(noPrefix(coding.getSystem())));
}
}
submissionSet.setAuthor(transformAuthor(author, manifest.getContained(), identifiable));
}
for (Extension recipientExt : manifest.getExtensionsByUrl("http://profiles.ihe.net/ITI/MHD/StructureDefinition/ihe-intendedRecipient")) {
Reference recipientRef = (Reference) recipientExt.getValue();
Resource res = findResource(recipientRef, manifest.getContained());
if (res instanceof Practitioner) {
Recipient recipient = new Recipient();
recipient.setPerson(transform((Practitioner) res));
recipient.setTelecom(transform(((Practitioner) res).getTelecomFirstRep()));
submissionSet.getIntendedRecipients().add(recipient);
} else if (res instanceof Organization) {
Recipient recipient = new Recipient();
recipient.setOrganization(transform((Organization) res));
recipient.setTelecom(transform(((Organization) res).getTelecomFirstRep()));
submissionSet.getIntendedRecipients().add(recipient);
} else if (res instanceof PractitionerRole) {
Recipient recipient = new Recipient();
PractitionerRole role = (PractitionerRole) res;
recipient.setOrganization(transform((Organization) findResource(role.getOrganization(), manifest.getContained())));
recipient.setPerson(transform((Practitioner) findResource(role.getPractitioner(), manifest.getContained())));
recipient.setTelecom(transform(role.getTelecomFirstRep()));
submissionSet.getIntendedRecipients().add(recipient);
} else if (res instanceof Patient) {
Recipient recipient = new Recipient();
recipient.setPerson(transform((Patient) res));
recipient.setTelecom(transform(((Patient) res).getTelecomFirstRep()));
} else if (res instanceof RelatedPerson) {
Recipient recipient = new Recipient();
recipient.setPerson(transform((RelatedPerson) res));
recipient.setTelecom(transform(((RelatedPerson) res).getTelecomFirstRep()));
}
}
Extension source = manifest.getExtensionByUrl("http://profiles.ihe.net/ITI/MHD/StructureDefinition/ihe-sourceId");
if (source != null && source.getValue() instanceof Identifier) {
submissionSet.setSourceId(noPrefix(((Identifier) source.getValue()).getValue()));
}
String title = manifest.getTitle();
if (title != null)
submissionSet.setTitle(localizedString(title));
Annotation note = manifest.getNoteFirstRep();
if (note != null && note.hasText()) {
submissionSet.setComments(localizedString(note.getText()));
}
}
use of org.openehealth.ipf.commons.ihe.xds.core.metadata.LocalizedString in project MobileAccessGateway by i4mi.
the class Iti66ResponseConverter method translateToFhir.
/**
* convert ITI-18 query response to ITI-66 response bundle
*/
@Override
public List<ListResource> translateToFhir(QueryResponse input, Map<String, Object> parameters) {
ArrayList<ListResource> list = new ArrayList<ListResource>();
if (input != null && Status.SUCCESS.equals(input.getStatus())) {
Map<String, ListResource> targetList = new HashMap<String, ListResource>();
if (input.getSubmissionSets() != null) {
for (SubmissionSet submissionSet : input.getSubmissionSets()) {
ListResource documentManifest = new ListResource();
documentManifest.setId(noUuidPrefix(submissionSet.getEntryUuid()));
documentManifest.setCode(new CodeableConcept(new Coding("http://profiles.ihe.net/ITI/MHD/CodeSystem/MHDlistTypes", "submissionset", "Submission Set")));
targetList.put(documentManifest.getId(), documentManifest);
list.add(documentManifest);
// limitedMetadata -> meta.profile canonical [0..*]
if (submissionSet.isLimitedMetadata()) {
documentManifest.getMeta().addProfile("http://profiles.ihe.net/ITI/MHD/StructureDefinition/IHE.MHD.Minimal.SubmissionSet");
} else {
documentManifest.getMeta().addProfile("http://profiles.ihe.net/ITI/MHD/StructureDefinition/IHE.MHD.Comprehensive.SubmissionSet");
}
// comment -> text Narrative [0..1]
LocalizedString comments = submissionSet.getComments();
if (comments != null) {
documentManifest.addNote().setText(comments.getValue());
}
// uniqueId -> masterIdentifier Identifier [0..1] [1..1]
if (submissionSet.getUniqueId() != null) {
documentManifest.addIdentifier((new Identifier().setUse(IdentifierUse.USUAL).setSystem("urn:ietf:rfc:3986").setValue("urn:oid:" + submissionSet.getUniqueId())));
}
// entryUUID -> identifier Identifier [0..*]
if (submissionSet.getEntryUuid() != null) {
documentManifest.addIdentifier((new Identifier().setUse(IdentifierUse.OFFICIAL).setSystem("urn:ietf:rfc:3986").setValue(asUuid(submissionSet.getEntryUuid()))));
}
// approved -> status=current Other status values are allowed but are not defined in this mapping to XDS.
if (AvailabilityStatus.APPROVED.equals(submissionSet.getAvailabilityStatus())) {
documentManifest.setStatus(ListResource.ListStatus.CURRENT);
}
documentManifest.setMode(ListMode.WORKING);
// contentTypeCode -> type CodeableConcept [0..1]
if (submissionSet.getContentTypeCode() != null) {
documentManifest.addExtension().setUrl("http://profiles.ihe.net/ITI/MHD/StructureDefinition/ihe-designationType").setValue(transform(submissionSet.getContentTypeCode()));
}
// patientId -> subject Reference(Patient| Practitioner| Group| Device) [0..1], Reference(Patient)
if (submissionSet.getPatientId() != null) {
Identifiable patient = submissionSet.getPatientId();
documentManifest.setSubject(transformPatient(patient));
}
// submissionTime -> created dateTime [0..1]
if (submissionSet.getSubmissionTime() != null) {
documentManifest.setDate(Date.from(submissionSet.getSubmissionTime().getDateTime().toInstant()));
}
// authorInstitution, authorPerson, authorRole, authorSpeciality, authorTelecommunication -> author Reference(Practitioner| PractitionerRole| Organization| Device| Patient| RelatedPerson) [0..*]
if (submissionSet.getAuthors() != null) {
for (Author author : submissionSet.getAuthors()) {
documentManifest.setSource(transformAuthor(author));
}
}
// intendedRecipient -> recipient Reference(Patient| Practitioner| PractitionerRole| RelatedPerson| Organization) [0..*]
List<Recipient> recipients = submissionSet.getIntendedRecipients();
for (Recipient recipient : recipients) {
Organization org = recipient.getOrganization();
Person person = recipient.getPerson();
ContactPoint contact = transform(recipient.getTelecom());
var organization = transform(org);
Practitioner practitioner = transformPractitioner(person);
if (organization != null && practitioner == null) {
if (contact != null)
organization.addTelecom(contact);
documentManifest.addExtension().setUrl("http://profiles.ihe.net/ITI/MHD/StructureDefinition/ihe-intendedRecipient").setValue(new Reference().setResource(organization));
} else if (organization != null && practitioner != null) {
PractitionerRole role = new PractitionerRole();
role.setPractitioner((Reference) new Reference().setResource(practitioner));
role.setOrganization((Reference) new Reference().setResource(organization));
if (contact != null)
role.addTelecom(contact);
documentManifest.addExtension().setUrl("http://profiles.ihe.net/ITI/MHD/StructureDefinition/ihe-intendedRecipient").setValue(new Reference().setResource(role));
} else if (organization == null && practitioner != null) {
// May be a patient, related person or practitioner
}
}
// sourceId -> source uri [0..1] [1..1]
if (submissionSet.getSourceId() != null) {
documentManifest.addExtension().setUrl("http://profiles.ihe.net/ITI/MHD/StructureDefinition/ihe-sourceId").setValue(new Identifier().setValue("urn:oid:" + submissionSet.getSourceId()));
}
// title -> description string [0..1]
LocalizedString title = submissionSet.getTitle();
if (title != null) {
documentManifest.setTitle(title.getValue());
}
}
}
if (input.getAssociations() != null) {
for (Association ass : input.getAssociations()) {
AssociationType tt = ass.getAssociationType();
String source = ass.getSourceUuid();
String target = ass.getTargetUuid();
if (tt == AssociationType.HAS_MEMBER) {
ListResource s = targetList.get(noUuidPrefix(source));
if (s != null) {
s.addEntry().setItem(new Reference().setReference("DocumentReference/" + noUuidPrefix(target)));
}
}
}
}
} else {
processError(input);
}
return list;
}
use of org.openehealth.ipf.commons.ihe.xds.core.metadata.LocalizedString in project ipf by oehf.
the class CodeTransformerTestBase method baseSetUp.
@BeforeEach
public final void baseSetUp() {
var factory = createFactory();
transformer = new CodeTransformer(factory);
objectLibrary = factory.createObjectLibrary();
var displayName = new LocalizedString();
displayName.setCharset("charset");
displayName.setLang("lang");
displayName.setValue("value");
code = new Code();
code.setCode("code");
code.setDisplayName(displayName);
code.setSchemeName("schemeName");
}
use of org.openehealth.ipf.commons.ihe.xds.core.metadata.LocalizedString in project MobileAccessGateway by i4mi.
the class Iti65RequestConverter method processDocumentReference.
/**
* ITI-65: process DocumentReference resource from Bundle
* @param reference
* @param entry
*/
private void processDocumentReference(DocumentReference reference, DocumentEntry entry) {
entry.assignEntryUuid();
reference.setId(entry.getEntryUuid());
Identifier masterIdentifier = reference.getMasterIdentifier();
entry.setUniqueId(noPrefix(masterIdentifier.getValue()));
// limitedMetadata -> meta.profile canonical [0..*]
// No action
// availabilityStatus -> status code {DocumentReferenceStatus} [1..1]
// approved -> status=current
// deprecated -> status=superseded
// Other status values are allowed but are not defined in this mapping to XDS.
DocumentReferenceStatus status = reference.getStatus();
switch(status) {
case CURRENT:
entry.setAvailabilityStatus(AvailabilityStatus.APPROVED);
break;
case SUPERSEDED:
entry.setAvailabilityStatus(AvailabilityStatus.DEPRECATED);
break;
default:
throw new InvalidRequestException("Unknown document status");
}
// contentTypeCode -> type CodeableConcept [0..1]
CodeableConcept type = reference.getType();
entry.setTypeCode(transform(type));
// classCode -> category CodeableConcept [0..*]
List<CodeableConcept> category = reference.getCategory();
entry.setClassCode(transform(category));
// patientId -> subject Reference(Patient| Practitioner| Group| Device) [0..1],
Reference subject = reference.getSubject();
entry.setPatientId(transformReferenceToIdentifiable(subject, reference));
// creationTime -> date instant [0..1]
entry.setCreationTime(timestampFromDate(reference.getDateElement()));
// PractitionerRole| Organization| Device| Patient| RelatedPerson) [0..*]
for (Reference authorRef : reference.getAuthor()) {
entry.getAuthors().add(transformAuthor(authorRef, reference.getContained(), null));
}
if (reference.hasAuthenticator()) {
Reference authenticatorRef = reference.getAuthenticator();
Resource authenticator = findResource(authenticatorRef, reference.getContained());
if (authenticator instanceof Practitioner) {
entry.setLegalAuthenticator(transform((Practitioner) authenticator));
} else if (authenticator instanceof PractitionerRole) {
Practitioner practitioner = (Practitioner) findResource(((PractitionerRole) authenticator).getPractitioner(), reference.getContained());
if (practitioner != null)
entry.setLegalAuthenticator(transform(practitioner));
} else
throw new InvalidRequestException("No authenticator of type Organization supported.");
}
// title -> description string [0..1]
String title = reference.getDescription();
if (title != null)
entry.setTitle(localizedString(title));
// confidentialityCode -> securityLabel CodeableConcept [0..*] Note: This
// is NOT the DocumentReference.meta, as that holds the meta tags for the
// DocumentReference itself.
List<CodeableConcept> securityLabels = reference.getSecurityLabel();
transformCodeableConcepts(securityLabels, entry.getConfidentialityCodes());
// mimeType -> content.attachment.contentType [1..1] code [0..1]
DocumentReferenceContentComponent content = reference.getContentFirstRep();
if (content == null)
throw new InvalidRequestException("Missing content field in DocumentReference");
Attachment attachment = content.getAttachment();
if (attachment == null)
throw new InvalidRequestException("Missing attachment field in DocumentReference");
entry.setMimeType(attachment.getContentType());
// languageCode -> content.attachment.language code [0..1]
entry.setLanguageCode(attachment.getLanguage());
// size -> content.attachment.size integer [0..1] The size is calculated
if (attachment.hasSize())
entry.setSize((long) attachment.getSize());
// on the data prior to base64 encoding, if the data is base64 encoded.
// hash -> content.attachment.hash string [0..1]
byte[] hash = attachment.getHash();
if (hash != null)
entry.setHash(Hex.encodeHexString(hash));
// comments -> content.attachment.title string [0..1]
String comments = attachment.getTitle();
if (comments != null)
entry.setComments(localizedString(comments));
// creationTime -> content.attachment.creation dateTime [0..1]
if (attachment.hasCreation()) {
if (entry.getCreationTime() == null)
entry.setCreationTime(timestampFromDate(attachment.getCreationElement()));
else if (!timestampFromDate(attachment.getCreationElement()).equals(entry.getCreationTime()))
throw new InvalidRequestException("DocumentReference.date does not match attachment.creation element");
}
// formatCode -> content.format Coding [0..1]
Coding coding = content.getFormat();
entry.setFormatCode(transform(coding));
DocumentReferenceContextComponent context = reference.getContext();
// Instead: referenceIdList -> related.identifier
for (Reference ref : context.getRelated()) {
Identifiable refId = transformReferenceToIdentifiable(ref, reference);
if (refId != null) {
ReferenceId referenceId = new ReferenceId();
referenceId.setAssigningAuthority(new CXiAssigningAuthority(null, refId.getAssigningAuthority().getUniversalId(), refId.getAssigningAuthority().getUniversalIdType()));
referenceId.setId(refId.getId());
entry.getReferenceIdList().add(referenceId);
}
}
// Currently not mapped
/*for (Reference encounterRef : context.getEncounter()) {
ReferenceId referenceId = new ReferenceId();
Identifiable id = transformReferenceToIdentifiable(encounterRef, reference);
if (id != null) {
referenceId.setIdTypeCode(ReferenceId.ID_TYPE_ENCOUNTER_ID);
referenceId.setId(id.getId());
//referenceId.setAssigningAuthority(new CXiAid.getAssigningAuthority().getUniversalId());
entry.getReferenceIdList().add(referenceId );
}*/
// eventCodeList -> context.event CodeableConcept [0..*]
List<CodeableConcept> events = context.getEvent();
transformCodeableConcepts(events, entry.getEventCodeList());
// serviceStartTime serviceStopTime -> context.period Period [0..1]
Period period = context.getPeriod();
if (period != null) {
entry.setServiceStartTime(timestampFromDate(period.getStartElement()));
entry.setServiceStopTime(timestampFromDate(period.getEndElement()));
}
// healthcareFacilityTypeCode -> context.facilityType CodeableConcept
// [0..1]
entry.setHealthcareFacilityTypeCode(transformCodeableConcept(context.getFacilityType()));
// practiceSettingCode -> context.practiceSetting CodeableConcept [0..1]
entry.setPracticeSettingCode(transformCodeableConcept(context.getPracticeSetting()));
Extension originalRole = reference.getExtensionByUrl("http://fhir.ch/ig/ch-epr-mhealth/StructureDefinition/ch-ext-author-authorrole");
if (originalRole != null) {
if (originalRole.getValue() instanceof Coding) {
Coding value = (Coding) originalRole.getValue();
String system = noPrefix(value.getSystem());
String code = value.getCode();
entry.setExtraMetadata(Collections.singletonMap("urn:e-health-suisse:2020:originalProviderRole", Collections.singletonList(code + "^^^&" + system + "&ISO")));
}
}
// Patient.identifier.use element set to ‘usual’.
if (context.hasSourcePatientInfo()) {
entry.setSourcePatientId(transformReferenceToIdentifiable(context.getSourcePatientInfo(), reference));
entry.setSourcePatientInfo(transformReferenceToPatientInfo(context.getSourcePatientInfo(), reference));
}
}
Aggregations