Search in sources :

Example 1 with Organization

use of org.openehealth.ipf.commons.ihe.xds.core.metadata.Organization 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;
}
Also used : Organization(org.openehealth.ipf.commons.ihe.xds.core.metadata.Organization) HashMap(java.util.HashMap) Reference(org.hl7.fhir.r4.model.Reference) ArrayList(java.util.ArrayList) SubmissionSet(org.openehealth.ipf.commons.ihe.xds.core.metadata.SubmissionSet) Recipient(org.openehealth.ipf.commons.ihe.xds.core.metadata.Recipient) LocalizedString(org.openehealth.ipf.commons.ihe.xds.core.metadata.LocalizedString) PractitionerRole(org.hl7.fhir.r4.model.PractitionerRole) LocalizedString(org.openehealth.ipf.commons.ihe.xds.core.metadata.LocalizedString) Identifiable(org.openehealth.ipf.commons.ihe.xds.core.metadata.Identifiable) Practitioner(org.hl7.fhir.r4.model.Practitioner) ContactPoint(org.hl7.fhir.r4.model.ContactPoint) Identifier(org.hl7.fhir.r4.model.Identifier) Association(org.openehealth.ipf.commons.ihe.xds.core.metadata.Association) AssociationType(org.openehealth.ipf.commons.ihe.xds.core.metadata.AssociationType) Coding(org.hl7.fhir.r4.model.Coding) Author(org.openehealth.ipf.commons.ihe.xds.core.metadata.Author) ListResource(org.hl7.fhir.r4.model.ListResource) Person(org.openehealth.ipf.commons.ihe.xds.core.metadata.Person) CodeableConcept(org.hl7.fhir.r4.model.CodeableConcept)

Example 2 with Organization

use of org.openehealth.ipf.commons.ihe.xds.core.metadata.Organization in project ipf by oehf.

the class ProvideAndRegisterDocumentSetRequestValidatorTest method testValidateDelegatesToSubmitObjectsRequestValidator.

@Test
public void testValidateDelegatesToSubmitObjectsRequestValidator() {
    // Try a failure that is produced by the SubmitObjectsRequestValidator
    docEntry.getAuthors().get(0).getAuthorInstitution().add(new Organization(null, "LOL", null));
    expectFailure(ORGANIZATION_NAME_MISSING);
}
Also used : Organization(org.openehealth.ipf.commons.ihe.xds.core.metadata.Organization) Test(org.junit.jupiter.api.Test)

Aggregations

Organization (org.openehealth.ipf.commons.ihe.xds.core.metadata.Organization)2 ArrayList (java.util.ArrayList)1 HashMap (java.util.HashMap)1 CodeableConcept (org.hl7.fhir.r4.model.CodeableConcept)1 Coding (org.hl7.fhir.r4.model.Coding)1 ContactPoint (org.hl7.fhir.r4.model.ContactPoint)1 Identifier (org.hl7.fhir.r4.model.Identifier)1 ListResource (org.hl7.fhir.r4.model.ListResource)1 Practitioner (org.hl7.fhir.r4.model.Practitioner)1 PractitionerRole (org.hl7.fhir.r4.model.PractitionerRole)1 Reference (org.hl7.fhir.r4.model.Reference)1 Test (org.junit.jupiter.api.Test)1 Association (org.openehealth.ipf.commons.ihe.xds.core.metadata.Association)1 AssociationType (org.openehealth.ipf.commons.ihe.xds.core.metadata.AssociationType)1 Author (org.openehealth.ipf.commons.ihe.xds.core.metadata.Author)1 Identifiable (org.openehealth.ipf.commons.ihe.xds.core.metadata.Identifiable)1 LocalizedString (org.openehealth.ipf.commons.ihe.xds.core.metadata.LocalizedString)1 Person (org.openehealth.ipf.commons.ihe.xds.core.metadata.Person)1 Recipient (org.openehealth.ipf.commons.ihe.xds.core.metadata.Recipient)1 SubmissionSet (org.openehealth.ipf.commons.ihe.xds.core.metadata.SubmissionSet)1