use of org.hl7.fhir.dstu2.model.Attachment in project summary-care-record-api by NHSDigital.
the class GetScrService method buildDocumentReferenceContent.
private DocumentReferenceContentComponent buildDocumentReferenceContent(String nhsNumber, String scrId) {
DocumentReferenceContentComponent content = new DocumentReferenceContentComponent();
String attachmentUrl = String.format(ATTACHMENT_URL, getScrUrl(), scrId, nhsNumber);
content.setAttachment(new Attachment().setUrl(attachmentUrl));
return content;
}
use of org.hl7.fhir.dstu2.model.Attachment in project Gravity-SDOH-Exchange-RI by FHIR.
the class PersonalCharacteristicsService method retrieveDerivedFrom.
public AttachmentDto retrieveDerivedFrom(String id) {
Observation obs = observationRepository.getWithDocumentReference(id);
if (obs == null) {
throw new ResourceNotFoundException(new IdType(Observation.class.getSimpleName(), id));
}
IBaseResource ref = obs.getDerivedFromFirstRep().getResource();
if (ref == null || !(ref instanceof DocumentReference)) {
throw new IllegalStateException("Observation with id " + id + " does not have a derived-from field set to a Document Reference resource.");
}
DocumentReference docRef = (DocumentReference) ref;
Attachment attachment = docRef.getContentFirstRep().getAttachment();
if (attachment == null) {
throw new IllegalStateException("DocumentReference with id " + docRef.getIdElement().getIdPart() + " does not have an attachment.");
}
return AttachmentDto.builder().content(attachment.getData()).contentType(attachment.getContentType()).title(attachment.getTitle()).build();
}
use of org.hl7.fhir.dstu2.model.Attachment in project Gravity-SDOH-Exchange-RI by FHIR.
the class ConsentService method retrieveAttachmentInfo.
public AttachmentDto retrieveAttachmentInfo(String id) {
Optional<Consent> foundConsent = consentRepository.find(id);
if (!foundConsent.isPresent()) {
throw new ResourceNotFoundException(String.format("Consent with id '%s' was not found.", id));
}
Consent consent = foundConsent.get();
Attachment attachment = consent.getSourceAttachment();
return AttachmentDto.builder().content(attachment.getData()).contentType(attachment.getContentType()).title(attachment.getTitle()).build();
}
use of org.hl7.fhir.dstu2.model.Attachment in project Gravity-SDOH-Exchange-RI by FHIR.
the class RecordedSexGenderBundleFactory method onBundleCreated.
@Override
protected void onBundleCreated(Bundle bundle) {
Observation obs = (Observation) bundle.getEntry().get(0).getResource();
DocumentReference docRef = new DocumentReference().setStatus(Enumerations.DocumentReferenceStatus.CURRENT).setDate(new Date());
docRef.addAuthor(new Reference(new IdType(SmartOnFhirContext.get().getFhirUser()).toUnqualifiedVersionless()));
docRef.addContent().setAttachment(new Attachment().setTitle(derivedFromFileName).setContentType(MediaType.APPLICATION_PDF_VALUE).setData(derivedFromFile));
docRef.setId(IdType.newRandomUuid());
Bundle.BundleEntryComponent postEntry = FhirUtil.createPostEntry(docRef);
obs.addDerivedFrom(FhirUtil.toReference(DocumentReference.class, docRef.getIdElement().getIdPart()));
bundle.addEntry(postEntry);
}
use of org.hl7.fhir.dstu2.model.Attachment in project org.hl7.fhir.core by hapifhir.
the class Questionnaire10_50 method convertQuestionnaireQuestionType.
public static org.hl7.fhir.r5.model.Enumeration<org.hl7.fhir.r5.model.Questionnaire.QuestionnaireItemType> convertQuestionnaireQuestionType(org.hl7.fhir.dstu2.model.Enumeration<org.hl7.fhir.dstu2.model.Questionnaire.AnswerFormat> src) throws FHIRException {
if (src == null || src.isEmpty())
return null;
org.hl7.fhir.r5.model.Enumeration<org.hl7.fhir.r5.model.Questionnaire.QuestionnaireItemType> tgt = new org.hl7.fhir.r5.model.Enumeration<>(new org.hl7.fhir.r5.model.Questionnaire.QuestionnaireItemTypeEnumFactory());
ConversionContext10_50.INSTANCE.getVersionConvertor_10_50().copyElement(src, tgt);
tgt.addExtension(VersionConvertorConstants.EXT_QUESTIONNAIRE_ITEM_TYPE_ORIGINAL, new CodeType(src.getValueAsString()));
switch(src.getValue()) {
case BOOLEAN:
tgt.setValue(org.hl7.fhir.r5.model.Questionnaire.QuestionnaireItemType.BOOLEAN);
break;
case DECIMAL:
tgt.setValue(org.hl7.fhir.r5.model.Questionnaire.QuestionnaireItemType.DECIMAL);
break;
case INTEGER:
tgt.setValue(org.hl7.fhir.r5.model.Questionnaire.QuestionnaireItemType.INTEGER);
break;
case DATE:
tgt.setValue(org.hl7.fhir.r5.model.Questionnaire.QuestionnaireItemType.DATE);
break;
case DATETIME:
tgt.setValue(org.hl7.fhir.r5.model.Questionnaire.QuestionnaireItemType.DATETIME);
break;
case INSTANT:
tgt.setValue(org.hl7.fhir.r5.model.Questionnaire.QuestionnaireItemType.DATETIME);
break;
case TIME:
tgt.setValue(org.hl7.fhir.r5.model.Questionnaire.QuestionnaireItemType.TIME);
break;
case STRING:
tgt.setValue(org.hl7.fhir.r5.model.Questionnaire.QuestionnaireItemType.STRING);
break;
case TEXT:
tgt.setValue(org.hl7.fhir.r5.model.Questionnaire.QuestionnaireItemType.TEXT);
break;
case URL:
tgt.setValue(org.hl7.fhir.r5.model.Questionnaire.QuestionnaireItemType.URL);
break;
case CHOICE:
tgt.setValue(org.hl7.fhir.r5.model.Questionnaire.QuestionnaireItemType.CODING);
break;
case OPENCHOICE:
tgt.setValue(org.hl7.fhir.r5.model.Questionnaire.QuestionnaireItemType.CODING);
break;
case ATTACHMENT:
tgt.setValue(org.hl7.fhir.r5.model.Questionnaire.QuestionnaireItemType.ATTACHMENT);
break;
case REFERENCE:
tgt.setValue(org.hl7.fhir.r5.model.Questionnaire.QuestionnaireItemType.REFERENCE);
break;
case QUANTITY:
tgt.setValue(org.hl7.fhir.r5.model.Questionnaire.QuestionnaireItemType.QUANTITY);
break;
default:
tgt.setValue(org.hl7.fhir.r5.model.Questionnaire.QuestionnaireItemType.NULL);
break;
}
return tgt;
}
Aggregations