use of org.hl7.fhir.dstu2.model.Attachment in project fhir-bridge by ehrbase.
the class DocumentReferenceToHipDocumentConverter method getMultimedia.
private MediendateiCluster getMultimedia(DocumentReference documentReference) {
Attachment attachment = documentReference.getContentFirstRep().getAttachment();
DvMultimedia multimedia = new DvMultimedia();
multimedia.setUri(new DvURI(attachment.getUrl()));
multimedia.setMediaType(new CodePhrase(new TerminologyId("IANA_media-types"), attachment.getContentType()));
multimedia.setSize(attachment.getSize());
MediendateiCluster result = new MediendateiCluster();
result.setMediendateiInhalt(multimedia);
result.setMediendateiInhaltValue(attachment.getTitle());
result.setBeschreibungValue(documentReference.getDescription());
getCreation(attachment).ifPresent(result::setErstelltValue);
return result;
}
use of org.hl7.fhir.dstu2.model.Attachment in project Gravity-SDOH-Exchange-RI by FHIR.
the class PersonalCharacteristicsInfoHolderToDtoConverter method convert.
@Override
public PersonalCharacteristicDto convert(T infoHolder) {
Observation obs = infoHolder.getObservation();
PersonalCharacteristicDto dto = new PersonalCharacteristicDto(obs.getIdElement().getIdPart());
List<String> errors = new ArrayList<>();
// Type
Validated.withError(dto, () -> dto.setType(CharacteristicCode.fromCode(obs.getCode().getCodingFirstRep().getCode())));
try {
// Method + detail
CodeableConcept method = obs.getMethod();
Validated.withError(dto, () -> dto.setMethod(CharacteristicMethod.fromCode(method.getCodingFirstRep().getCode())));
dto.setMethodDetail(method.getText());
// Value + detail
if (obs.getValue() instanceof CodeableConcept) {
CodeableConcept value = (CodeableConcept) obs.getValue();
dto.setValue(new CodingDto(value.getCodingFirstRep().getCode(), value.getCodingFirstRep().getDisplay()));
dto.setValueDetail(value.getText());
} else if (obs.hasComponent() && CharacteristicCode.ETHNICITY.equals(dto.getType())) {
convertEthnicity(obs, dto);
} else if (obs.hasComponent() && CharacteristicCode.RACE.equals(dto.getType())) {
convertRace(obs, dto);
}
} catch (FHIRException exc) {
dto.getErrors().add(exc.getMessage());
}
// Description. Will make sense only for the race and ethnicity
dto.setDescription(obs.getComponent().stream().filter(c -> CharacteristicCode.SYSTEM.equals(c.getCode().getCodingFirstRep().getSystem()) && c.hasValueStringType()).map(cc -> cc.getValueStringType().getValue()).findFirst().orElse(null));
// Performer
Practitioner performer = infoHolder.getPerformer();
dto.setPerformer(new ReferenceDto(performer.getIdElement().getIdPart(), performer.getNameFirstRep().getNameAsSingleString()));
// Has Attachment
if (CharacteristicCode.SEX_GENDER.equals(dto.getType()) && obs.hasDerivedFrom()) {
dto.setHasAttachment(true);
}
return dto;
}
use of org.hl7.fhir.dstu2.model.Attachment in project Gravity-SDOH-Exchange-RI by FHIR.
the class ConsentService method createConsent.
public ConsentDto createConsent(String name, MultipartFile attachment, UserDto userDto) {
Reference patient = FhirUtil.toReference(Patient.class, SmartOnFhirContext.get().getPatient());
Reference organization = retrieveOrganization(userDto);
Consent consent = new CreateConsentFactory(name, patient, attachment, organization).createConsent();
MethodOutcome methodOutcome = ehrClient.create().resource(consent).execute();
Consent savedConsent = (Consent) methodOutcome.getResource();
return new ConsentToDtoConverter().convert(savedConsent);
}
use of org.hl7.fhir.dstu2.model.Attachment in project Gravity-SDOH-Exchange-RI by FHIR.
the class CreateConsentFactory method createConsent.
public Consent createConsent() {
Consent consent = new Consent();
consent.getSourceAttachment().setTitle(name);
try {
consent.getSourceAttachment().setData(attachment.getBytes());
} catch (IOException e) {
throw new ConsentCreateException("Consent attachment cannot be read.");
}
consent.getSourceAttachment().setContentType(MediaType.APPLICATION_PDF_VALUE);
consent.setId(IdType.newRandomUuid());
consent.setStatus(Consent.ConsentState.ACTIVE);
consent.setDateTimeElement(DateTimeType.now());
consent.getMeta().addProfile(SDOHProfiles.CONSENT);
ConsentScope consentScope = ConsentScope.PATIENTPRIVACY;
consent.getScope().addCoding(new Coding(consentScope.getSystem(), consentScope.toCode(), consentScope.getDisplay()));
V3ActCode actCode = V3ActCode.IDSCL;
consent.addCategory(new CodeableConcept().addCoding(new Coding(actCode.getSystem(), actCode.toCode(), actCode.getDisplay())));
consent.setPatient(patient);
ConsentPolicy consentPolicy = ConsentPolicy.HIPAAAUTH;
consent.getPolicyRule().addCoding(new Coding(consentPolicy.getSystem(), consentPolicy.toCode(), consentPolicy.getDisplay()));
V3RoleClass roleClass = V3RoleClass.PAT;
consent.getProvision().addActor().setReference(patient).getRole().addCoding(new Coding(roleClass.getSystem(), roleClass.toCode(), roleClass.getDisplay()));
ConsentAction consentAction = ConsentAction.DISCLOSE;
consent.getProvision().addAction().getCoding().add(new Coding(consentAction.getSystem(), consentAction.toCode(), consentAction.getDisplay()));
consent.getOrganization().add(organization);
return consent;
}
use of org.hl7.fhir.dstu2.model.Attachment in project geoprism-registry by terraframe.
the class AbstractFhirResourceProcessor method getGeometry.
protected Geometry getGeometry(Location location, ServerGeoObjectType type) {
Extension extension = location.getExtensionByUrl("http://hl7.org/fhir/StructureDefinition/location-boundary-geojson");
if (extension != null) {
Attachment value = (Attachment) extension.getValue();
if (value.hasData()) {
Decoder decoder = Base64.getDecoder();
byte[] binary = decoder.decode(value.getDataElement().getValueAsString());
String geojson = new String(binary);
GeoJsonReader reader = new GeoJsonReader();
try {
return reader.read(geojson);
} catch (ParseException e) {
e.printStackTrace();
}
}
}
return null;
}
Aggregations