Search in sources :

Example 1 with RegisterDocumentSetBuilder

use of org.openehealth.ipf.commons.ihe.xds.core.requests.builder.RegisterDocumentSetBuilder in project MobileAccessGateway by i4mi.

the class Iti67RequestUpdateConverter method convertDocumentReferenceToDocumentEntry.

/**
 * ITI-67 Response to ITI-57 request converter
 *
 * @param searchParameter
 * @return
 */
public SubmitObjectsRequest convertDocumentReferenceToDocumentEntry(@Body DocumentReference documentReference) {
    SubmissionSet submissionSet = new SubmissionSet();
    submissionSet.setSubmissionTime(new Timestamp(ZonedDateTime.now(), Timestamp.Precision.SECOND));
    Extension source = documentReference.getExtensionByUrl("http://profiles.ihe.net/ITI/MHD/StructureDefinition/ihe-sourceId");
    if (source != null && source.getValue() instanceof Identifier) {
        submissionSet.setSourceId(noPrefix(((Identifier) source.getValue()).getValue()));
    }
    Extension designationType = documentReference.getExtensionByUrl("http://profiles.ihe.net/ITI/MHD/StructureDefinition/ihe-designationType");
    if (designationType != null && designationType.getValue() instanceof CodeableConcept) {
        submissionSet.setContentTypeCode(transformCodeableConcept((CodeableConcept) designationType.getValue()));
    }
    Extension authorRoleExt = documentReference.getExtensionByUrl("http://fhir.ch/ig/ch-epr-mhealth/StructureDefinition/ch-ext-author-authorrole");
    if (authorRoleExt != null) {
        Identifiable identifiable = null;
        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(null, null, identifiable));
    }
    // TODO should be
    RegisterDocumentSetBuilder builder = new RegisterDocumentSetBuilder(true, submissionSet);
    // true?
    DocumentEntry entry = new DocumentEntry();
    processDocumentReference(documentReference, entry);
    entry.setLogicalUuid(new URN(UUID.randomUUID()).toString());
    submissionSet.setPatientId(entry.getPatientId());
    submissionSet.assignEntryUuid();
    builder.withDocument(entry);
    builder.withAssociation(createHasMemberAssocationWithOriginalPreviousLabel(submissionSet, entry));
    return EbXML30Converters.convert(builder.build());
}
Also used : Extension(org.hl7.fhir.r4.model.Extension) URN(org.openehealth.ipf.commons.core.URN) Identifier(org.hl7.fhir.r4.model.Identifier) Coding(org.hl7.fhir.r4.model.Coding) RegisterDocumentSetBuilder(org.openehealth.ipf.commons.ihe.xds.core.requests.builder.RegisterDocumentSetBuilder) SubmissionSet(org.openehealth.ipf.commons.ihe.xds.core.metadata.SubmissionSet) DocumentEntry(org.openehealth.ipf.commons.ihe.xds.core.metadata.DocumentEntry) AssigningAuthority(org.openehealth.ipf.commons.ihe.xds.core.metadata.AssigningAuthority) Timestamp(org.openehealth.ipf.commons.ihe.xds.core.metadata.Timestamp) CodeableConcept(org.hl7.fhir.r4.model.CodeableConcept) Identifiable(org.openehealth.ipf.commons.ihe.xds.core.metadata.Identifiable)

Aggregations

CodeableConcept (org.hl7.fhir.r4.model.CodeableConcept)1 Coding (org.hl7.fhir.r4.model.Coding)1 Extension (org.hl7.fhir.r4.model.Extension)1 Identifier (org.hl7.fhir.r4.model.Identifier)1 URN (org.openehealth.ipf.commons.core.URN)1 AssigningAuthority (org.openehealth.ipf.commons.ihe.xds.core.metadata.AssigningAuthority)1 DocumentEntry (org.openehealth.ipf.commons.ihe.xds.core.metadata.DocumentEntry)1 Identifiable (org.openehealth.ipf.commons.ihe.xds.core.metadata.Identifiable)1 SubmissionSet (org.openehealth.ipf.commons.ihe.xds.core.metadata.SubmissionSet)1 Timestamp (org.openehealth.ipf.commons.ihe.xds.core.metadata.Timestamp)1 RegisterDocumentSetBuilder (org.openehealth.ipf.commons.ihe.xds.core.requests.builder.RegisterDocumentSetBuilder)1