use of org.hl7.fhir.r4.model.DocumentReference in project org.hl7.fhir.core by hapifhir.
the class RdfParser method composeDocumentReference.
protected void composeDocumentReference(Complex parent, String parentType, String name, DocumentReference element, int index) {
if (element == null)
return;
Complex t;
if (Utilities.noString(parentType))
t = parent;
else {
t = parent.predicate("fhir:" + parentType + '.' + name);
}
composeDomainResource(t, "DocumentReference", name, element, index);
if (element.hasMasterIdentifier())
composeIdentifier(t, "DocumentReference", "masterIdentifier", element.getMasterIdentifier(), -1);
for (int i = 0; i < element.getIdentifier().size(); i++) composeIdentifier(t, "DocumentReference", "identifier", element.getIdentifier().get(i), i);
if (element.hasSubject())
composeReference(t, "DocumentReference", "subject", element.getSubject(), -1);
if (element.hasType())
composeCodeableConcept(t, "DocumentReference", "type", element.getType(), -1);
if (element.hasClass_())
composeCodeableConcept(t, "DocumentReference", "class", element.getClass_(), -1);
for (int i = 0; i < element.getAuthor().size(); i++) composeReference(t, "DocumentReference", "author", element.getAuthor().get(i), i);
if (element.hasCustodian())
composeReference(t, "DocumentReference", "custodian", element.getCustodian(), -1);
if (element.hasAuthenticator())
composeReference(t, "DocumentReference", "authenticator", element.getAuthenticator(), -1);
if (element.hasCreatedElement())
composeDateTime(t, "DocumentReference", "created", element.getCreatedElement(), -1);
if (element.hasIndexedElement())
composeInstant(t, "DocumentReference", "indexed", element.getIndexedElement(), -1);
if (element.hasStatusElement())
composeEnum(t, "DocumentReference", "status", element.getStatusElement(), -1);
if (element.hasDocStatus())
composeCodeableConcept(t, "DocumentReference", "docStatus", element.getDocStatus(), -1);
for (int i = 0; i < element.getRelatesTo().size(); i++) composeDocumentReferenceDocumentReferenceRelatesToComponent(t, "DocumentReference", "relatesTo", element.getRelatesTo().get(i), i);
if (element.hasDescriptionElement())
composeString(t, "DocumentReference", "description", element.getDescriptionElement(), -1);
for (int i = 0; i < element.getSecurityLabel().size(); i++) composeCodeableConcept(t, "DocumentReference", "securityLabel", element.getSecurityLabel().get(i), i);
for (int i = 0; i < element.getContent().size(); i++) composeDocumentReferenceDocumentReferenceContentComponent(t, "DocumentReference", "content", element.getContent().get(i), i);
if (element.hasContext())
composeDocumentReferenceDocumentReferenceContextComponent(t, "DocumentReference", "context", element.getContext(), -1);
}
use of org.hl7.fhir.r4.model.DocumentReference in project org.hl7.fhir.core by hapifhir.
the class TurtleTests method test_documentreference_example.
@Test
public void test_documentreference_example() throws FileNotFoundException, IOException, Exception {
System.out.println("documentreference-example.ttl");
new Turtle().parse(TextFile.fileToString("C:\\work\\org.hl7.fhir\\build\\publish\\documentreference-example.ttl"));
}
use of org.hl7.fhir.r4.model.DocumentReference in project fhir-bridge by ehrbase.
the class DocumentReferenceIT method executeMappingException.
@Override
public Exception executeMappingException(String resource) throws IOException {
DocumentReference documentReference = (DocumentReference) testFileLoader.loadResource(resource);
DocumentReferenceToHipDocumentConverter converter = new DocumentReferenceToHipDocumentConverter();
return assertThrows(ConversionException.class, () -> converter.convert(documentReference));
}
use of org.hl7.fhir.r4.model.DocumentReference in project eCRNow by drajer-health.
the class EicrServiceImpl method handleReportabilityResponse.
public void handleReportabilityResponse(ReportabilityResponse data, String xRequestId, boolean saveToEhr) {
logger.debug(" Start processing RR");
if (data.getRrXml() != null && !data.getRrXml().isEmpty()) {
logger.debug("Reportability Response: {}, saveToEhr: {}", data.getRrXml(), saveToEhr);
final CdaRrModel rrModel = rrParser.parse(data.getRrXml());
final CdaIi rrDocId = rrModel.getRrDocId();
final CdaIi eicrDocId = rrModel.getEicrDocId();
if (rrDocId == null || StringUtils.isBlank(rrDocId.getRootValue())) {
throw new IllegalArgumentException("Reportability response is missing RR_Doc_Id");
}
if (eicrDocId == null || StringUtils.isBlank(eicrDocId.getRootValue())) {
throw new IllegalArgumentException("Reportability response is missing EICR_Doc_Id");
}
logger.info("Processing RR_DOC_ID {} of type {} for EICR_DOC_ID {}", rrDocId.getRootValue(), rrModel.getReportableType(), eicrDocId.getRootValue());
final Eicr ecr = eicrDao.getEicrByDocId(eicrDocId.getRootValue());
if (ecr != null) {
logger.info(" Found the ecr for doc Id = {}", eicrDocId.getRootValue());
ecr.setResponseType(EicrTypes.RrType.REPORTABLE.toString());
ecr.setResponseDocId(rrDocId.getRootValue());
ecr.setResponseXRequestId(xRequestId);
ecr.setResponseData(data.getRrXml());
if (rrModel.getReportableType() != null)
ecr.setResponseType(rrModel.getReportableType());
else
ecr.setResponseType(CdaRrModel.UNKONWN_RESPONSE_TYPE);
if (rrModel.getReportableType() != null && rrModel.getReportableStatus() != null)
ecr.setResponseTypeDisplay(rrModel.getReportableType() + "-" + rrModel.getReportableStatus().getDisplayName());
else if (rrModel.getReportableType() != null)
ecr.setResponseTypeDisplay(rrModel.getReportableType());
else if (rrModel.getReportableStatus() != null)
ecr.setResponseTypeDisplay(rrModel.getReportableStatus().getDisplayName());
else
ecr.setResponseTypeDisplay(CdaRrModel.UNKONWN_RESPONSE_TYPE);
if (saveToEhr) {
try {
logger.info(" RR Xml and eCR is present hence create a document reference ");
DocumentReference docRef = constructDocumentReference(data, ecr);
if (docRef != null) {
logger.info(" Document Reference created successfully, submitting to Ehr ");
submitDocRefToEhr(docRef, ecr);
}
} catch (Exception e) {
logger.error(" Error submitting Document Reference to EHR due to exception: {}", e.getMessage());
// Save the fact that we could not submit the message to the EHR.
ecr.setRrProcStatus(EventTypes.RrProcStatusEnum.FAILED_EHR_SUBMISSION.toString());
saveOrUpdate(ecr);
throw e;
}
}
saveOrUpdate(ecr);
} else {
String errorMsg = "Unable to find Eicr for EICR_DOC_ID: " + eicrDocId.getRootValue();
logger.error(errorMsg);
throw new IllegalArgumentException(errorMsg);
}
} else {
String errorMsg = "Received empty RR in request: " + xRequestId;
logger.error(errorMsg);
throw new IllegalArgumentException(errorMsg);
}
}
use of org.hl7.fhir.r4.model.DocumentReference in project nia-patient-switching-standard-adaptor by NHSDigital.
the class DocumentReferenceMapper method mapDocumentReference.
private DocumentReference mapDocumentReference(RCMRMT030101UK04NarrativeStatement narrativeStatement, RCMRMT030101UK04EhrComposition ehrComposition, Patient patient, RCMRMT030101UK04EhrExtract ehrExtract, List<Encounter> encounterList, Organization organization) {
DocumentReference documentReference = new DocumentReference();
var id = narrativeStatement.getReference().get(0).getReferredToExternalDocument().getId().getRoot();
documentReference.addIdentifier(buildIdentifier(id, organization.getIdentifierFirstRep().getValue()));
documentReference.setId(id);
documentReference.getMeta().addProfile(META_PROFILE);
documentReference.setStatus(DocumentReferenceStatus.CURRENT);
documentReference.setType(getType(narrativeStatement));
documentReference.setSubject(new Reference(patient));
documentReference.setIndexedElement(getIndexed(ehrExtract));
documentReference.setDescription(buildDescription(narrativeStatement));
documentReference.setCustodian(new Reference(organization));
getAuthor(narrativeStatement, ehrComposition).ifPresent(documentReference::addAuthor);
if (narrativeStatement.hasAvailabilityTime() && narrativeStatement.getAvailabilityTime().hasValue()) {
documentReference.setCreatedElement(DateFormatUtil.parseToDateTimeType(narrativeStatement.getAvailabilityTime().getValue()));
}
var encounterReference = encounterList.stream().filter(encounter -> encounter.getId().equals(ehrComposition.getId().getRoot())).findFirst().map(Reference::new);
if (encounterReference.isPresent()) {
DocumentReference.DocumentReferenceContextComponent documentReferenceContextComponent = new DocumentReference.DocumentReferenceContextComponent().setEncounter(encounterReference.get());
documentReference.setContext(documentReferenceContextComponent);
}
setContentAttachments(documentReference, narrativeStatement);
return documentReference;
}
Aggregations