use of org.openehealth.ipf.commons.ihe.xds.core.metadata.Recipient 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.Recipient 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.Recipient 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;
}
Aggregations