Search in sources :

Example 71 with Attachment

use of org.hl7.fhir.r4.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;
}
Also used : TerminologyId(com.nedap.archie.rm.support.identification.TerminologyId) CodePhrase(com.nedap.archie.rm.datatypes.CodePhrase) Attachment(org.hl7.fhir.r4.model.Attachment) DvMultimedia(com.nedap.archie.rm.datavalues.encapsulated.DvMultimedia) MediendateiCluster(org.ehrbase.fhirbridge.ehr.opt.hipdocumentcomposition.definition.MediendateiCluster) DvURI(com.nedap.archie.rm.datavalues.DvURI)

Example 72 with Attachment

use of org.hl7.fhir.r4.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;
}
Also used : CodingDto(org.hl7.gravity.refimpl.sdohexchange.dto.response.CodingDto) Converter(org.springframework.core.convert.converter.Converter) EthnicityCode(org.hl7.gravity.refimpl.sdohexchange.codes.EthnicityCode) ReferenceDto(org.hl7.gravity.refimpl.sdohexchange.dto.response.ReferenceDto) CodeableConcept(org.hl7.fhir.r4.model.CodeableConcept) CharacteristicCode(org.hl7.gravity.refimpl.sdohexchange.codes.CharacteristicCode) PersonalCharacteristicsInfoHolder(org.hl7.gravity.refimpl.sdohexchange.fhir.extract.characteristic.PersonalCharacteristicsInfoBundleExtractor.PersonalCharacteristicsInfoHolder) RaceCode(org.hl7.gravity.refimpl.sdohexchange.codes.RaceCode) Collectors(java.util.stream.Collectors) Validated(org.hl7.gravity.refimpl.sdohexchange.dto.Validated) ArrayList(java.util.ArrayList) CodingDto(org.hl7.gravity.refimpl.sdohexchange.dto.response.CodingDto) List(java.util.List) PersonalCharacteristicDto(org.hl7.gravity.refimpl.sdohexchange.dto.response.characteristic.PersonalCharacteristicDto) DetailedRaceCode(org.hl7.gravity.refimpl.sdohexchange.codes.DetailedRaceCode) Coding(org.hl7.fhir.r4.model.Coding) CharacteristicMethod(org.hl7.gravity.refimpl.sdohexchange.codes.CharacteristicMethod) FHIRException(org.hl7.fhir.exceptions.FHIRException) Observation(org.hl7.fhir.r4.model.Observation) DetailedEthnicityCode(org.hl7.gravity.refimpl.sdohexchange.codes.DetailedEthnicityCode) Practitioner(org.hl7.fhir.r4.model.Practitioner) Practitioner(org.hl7.fhir.r4.model.Practitioner) ReferenceDto(org.hl7.gravity.refimpl.sdohexchange.dto.response.ReferenceDto) PersonalCharacteristicDto(org.hl7.gravity.refimpl.sdohexchange.dto.response.characteristic.PersonalCharacteristicDto) Observation(org.hl7.fhir.r4.model.Observation) ArrayList(java.util.ArrayList) FHIRException(org.hl7.fhir.exceptions.FHIRException) CodeableConcept(org.hl7.fhir.r4.model.CodeableConcept)

Example 73 with Attachment

use of org.hl7.fhir.r4.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);
}
Also used : Consent(org.hl7.fhir.r4.model.Consent) CreateConsentFactory(org.hl7.gravity.refimpl.sdohexchange.fhir.factory.resource.CreateConsentFactory) Reference(org.hl7.fhir.r4.model.Reference) MethodOutcome(ca.uhn.fhir.rest.api.MethodOutcome) ConsentToDtoConverter(org.hl7.gravity.refimpl.sdohexchange.dto.converter.ConsentToDtoConverter)

Example 74 with Attachment

use of org.hl7.fhir.r4.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;
}
Also used : ConsentScope(org.hl7.fhir.r4.model.codesystems.ConsentScope) ConsentCreateException(org.hl7.gravity.refimpl.sdohexchange.exception.ConsentCreateException) V3ActCode(org.hl7.fhir.r4.model.codesystems.V3ActCode) Consent(org.hl7.fhir.r4.model.Consent) Coding(org.hl7.fhir.r4.model.Coding) V3RoleClass(org.hl7.fhir.r4.model.codesystems.V3RoleClass) ConsentPolicy(org.hl7.fhir.r4.model.codesystems.ConsentPolicy) IOException(java.io.IOException) ConsentAction(org.hl7.fhir.r4.model.codesystems.ConsentAction) CodeableConcept(org.hl7.fhir.r4.model.CodeableConcept)

Example 75 with Attachment

use of org.hl7.fhir.r4.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;
}
Also used : Extension(org.hl7.fhir.r4.model.Extension) GeoJsonReader(com.vividsolutions.jts.io.geojson.GeoJsonReader) Attachment(org.hl7.fhir.r4.model.Attachment) ParseException(com.vividsolutions.jts.io.ParseException) Decoder(java.util.Base64.Decoder)

Aggregations

Attachment (org.hl7.fhir.r4.model.Attachment)33 ArrayList (java.util.ArrayList)32 Attachment (com.ibm.cloud.cloudant.v1.model.Attachment)17 Reference (org.hl7.fhir.r4.model.Reference)17 Test (org.testng.annotations.Test)17 DocumentRevisionStatus (com.ibm.cloud.cloudant.v1.model.DocumentRevisionStatus)16 Revisions (com.ibm.cloud.cloudant.v1.model.Revisions)16 XhtmlNode (org.hl7.fhir.utilities.xhtml.XhtmlNode)16 NotImplementedException (org.apache.commons.lang3.NotImplementedException)14 HashMap (java.util.HashMap)12 Coding (org.hl7.fhir.r4.model.Coding)11 Document (com.ibm.cloud.cloudant.v1.model.Document)10 List (java.util.List)10 DiagnosticReport (org.hl7.fhir.r4.model.DiagnosticReport)10 BundleEntryComponent (org.hl7.fhir.r4.model.Bundle.BundleEntryComponent)9 DocumentReference (org.hl7.fhir.r4.model.DocumentReference)9 Observation (org.hl7.fhir.r4.model.Observation)9 IBaseResource (org.hl7.fhir.instance.model.api.IBaseResource)8 Resource (org.hl7.fhir.r4.model.Resource)8 DesignDocument (com.ibm.cloud.cloudant.v1.model.DesignDocument)7