use of org.hl7.fhir.r4b.model.Attachment in project hl7v2-fhir-converter by LinuxForHealth.
the class Hl7ORUMessageTest method test_oru_patient_diagReport.
// DiagnosticReports are only created from ORU messages so the test of DiagnosticReport content is included in this test module.
// Suppress warnings about too many assertions in a test. Justification: creating a FHIR message is very costly; we need to check many asserts per creation for efficiency.
@java.lang.SuppressWarnings("squid:S5961")
@Test
// Test the minimum scenario where the least possible segments and resource info are provided in the message
void test_oru_patient_diagReport() throws IOException {
String hl7message = "MSH|^~\\\\&|SendTest1|Sendfac1|Receiveapp1|Receivefac1|200603081747|security|ORU^R01|MSGID000005|T|2.6\r" + "PID||45483|45483||SMITH^SUZIE^||20160813|M|||123 MAIN STREET^^SCHENECTADY^NY^12345||(123)456-7890|||||^^^T||||||||||||\r" + "OBR|1||986^IA PHIMS Stage^2.16.840.1.114222.4.3.3.5.1.2^ISO|1051-2^New Born Screening^LN|||20151009173644|||||||||||||002|||||F|||2740^Tsadok^Janetary~2913^Merrit^Darren^F~3065^Mahoney^Paul^J~4723^Loh^Robert^L~9052^Winter^Oscar^|||||\r";
List<BundleEntryComponent> e = ResourceUtils.createFHIRBundleFromHL7MessageReturnEntryList(ftv, hl7message);
// Verify correct resources created
List<Resource> patientResource = ResourceUtils.getResourceList(e, ResourceType.Patient);
assertThat(patientResource).hasSize(1);
List<Resource> diagnosticReport = ResourceUtils.getResourceList(e, ResourceType.DiagnosticReport);
assertThat(diagnosticReport).hasSize(1);
List<Resource> servReqResource = ResourceUtils.getResourceList(e, ResourceType.ServiceRequest);
assertThat(servReqResource).hasSize(1);
// Expecting only the above resources, no extras!
assertThat(e).hasSize(3);
// /////////////////////////////////////////
// Now confirm content of the diagnosticReport because we don't have separate tests for DiagnosticReport
// /////////////////////////////////////////
DiagnosticReport diag = ResourceUtils.getResourceDiagnosticReport(diagnosticReport.get(0), context);
// Verify status from OBR.25
assertThat(diag.getStatus().toCode()).isEqualTo("final");
// Verify category from OBR.24
assertThat(diag.getCategory()).isEmpty();
// Verify code from OBR.4
assertThat(diag.hasCode()).isTrue();
List<Coding> codings = diag.getCode().getCoding();
assertThat(codings).hasSize(1);
Coding coding = codings.get(0);
assertThat(coding.hasDisplay()).isTrue();
assertThat(coding.getDisplay()).hasToString("New Born Screening");
assertThat(coding.hasCode()).isTrue();
assertThat(coding.getCode()).hasToString("1051-2");
assertThat(coding.hasSystem()).isTrue();
assertThat(coding.getSystem()).hasToString("http://loinc.org");
// Verify encounter reference
assertThat(diag.getEncounter().isEmpty()).isTrue();
// Verify subject reference
assertThat(diag.getSubject().isEmpty()).isFalse();
// Verify effectiveDateTime from OBR.7 and OBR.8
// This also verifies the type, confirming effectiveDateTime was set rather than effectivePeriod
assertThat(diag.getEffectiveDateTimeType().asStringValue()).isEqualTo("2015-10-09T17:36:44+08:00");
// Verify issued from OBR.22
assertThat(diag.getIssued()).isNull();
// Verify resultsInterpreter from OBR.32
assertThat(diag.getResultsInterpreter()).isEmpty();
// Verify basedOn is ref to the ServiceRequest created for ORC or OBR
assertThat(diag.getBasedOn()).hasSize(1);
assertThat(diag.getBasedOn().get(0).getReference().substring(0, 15)).isEqualTo("ServiceRequest/");
// Verify specimen reference
assertThat(diag.getSpecimen()).isEmpty();
// Verify result reference
assertThat(diag.getResult()).isEmpty();
// Verify presentedForm from OBX of type TX - In this case no attachments created since there are no OBX with type TX
List<Attachment> attachments = diag.getPresentedForm();
Assertions.assertEquals(0, attachments.size(), "Unexpected number of attachments");
}
use of org.hl7.fhir.r4b.model.Attachment in project fhir-bridge by ehrbase.
the class DocumentReferenceProcessor method process.
@Override
public void process(Exchange exchange) throws Exception {
DocumentReference documentReference = exchange.getIn().getMandatoryBody(DocumentReference.class);
Attachment attachment = documentReference.getContentFirstRep().getAttachment();
ObjectWriteResponse response = minioService.uploadObject(new ByteArrayInputStream(attachment.getData()), attachment.getContentType());
if (!attachment.hasSize()) {
attachment.setSize(attachment.getData().length);
}
attachment.setUrl(minioService.getObjectUrl(response.object()));
attachment.setData(null);
exchange.getMessage().setHeader(CamelConstants.MINIO_OBJECT, response.object());
MethodOutcome outcome = new MethodOutcome().setResource(documentReference);
exchange.setProperty(CamelConstants.OUTCOME, outcome);
}
use of org.hl7.fhir.r4b.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.r4b.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.r4b.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);
}
Aggregations