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());
}
Aggregations