Search in sources :

Example 46 with Specimen

use of org.hl7.fhir.r4.model.Specimen in project org.hl7.fhir.core by hapifhir.

the class RdfParser method composeSpecimen.

protected void composeSpecimen(Complex parent, String parentType, String name, Specimen element, int index) {
    if (element == null)
        return;
    Complex t;
    if (Utilities.noString(parentType))
        t = parent;
    else {
        t = parent.predicate("fhir:" + parentType + '.' + name);
    }
    composeDomainResource(t, "Specimen", name, element, index);
    for (int i = 0; i < element.getIdentifier().size(); i++) composeIdentifier(t, "Specimen", "identifier", element.getIdentifier().get(i), i);
    if (element.hasAccessionIdentifier())
        composeIdentifier(t, "Specimen", "accessionIdentifier", element.getAccessionIdentifier(), -1);
    if (element.hasStatusElement())
        composeEnum(t, "Specimen", "status", element.getStatusElement(), -1);
    if (element.hasType())
        composeCodeableConcept(t, "Specimen", "type", element.getType(), -1);
    if (element.hasSubject())
        composeReference(t, "Specimen", "subject", element.getSubject(), -1);
    if (element.hasReceivedTimeElement())
        composeDateTime(t, "Specimen", "receivedTime", element.getReceivedTimeElement(), -1);
    for (int i = 0; i < element.getParent().size(); i++) composeReference(t, "Specimen", "parent", element.getParent().get(i), i);
    for (int i = 0; i < element.getRequest().size(); i++) composeReference(t, "Specimen", "request", element.getRequest().get(i), i);
    if (element.hasCollection())
        composeSpecimenSpecimenCollectionComponent(t, "Specimen", "collection", element.getCollection(), -1);
    for (int i = 0; i < element.getProcessing().size(); i++) composeSpecimenSpecimenProcessingComponent(t, "Specimen", "processing", element.getProcessing().get(i), i);
    for (int i = 0; i < element.getContainer().size(); i++) composeSpecimenSpecimenContainerComponent(t, "Specimen", "container", element.getContainer().get(i), i);
    for (int i = 0; i < element.getNote().size(); i++) composeAnnotation(t, "Specimen", "note", element.getNote().get(i), i);
}
Also used : Complex(org.hl7.fhir.dstu3.utils.formats.Turtle.Complex)

Example 47 with Specimen

use of org.hl7.fhir.r4.model.Specimen in project nia-patient-switching-standard-adaptor by NHSDigital.

the class SpecimenMapperTest method testInvalidSpecimenIsNotMapped.

@Test
public void testInvalidSpecimenIsNotMapped() {
    RCMRMT030101UK04EhrExtract ehrExtract = unmarshallEhrExtract("specimen_invalid.xml");
    List<Specimen> specimenList = specimenMapper.mapSpecimen(ehrExtract, List.of(DIAGNOSTIC_REPORT_WITHOUT_SPECIMEN), PATIENT, PRACTICE_CODE);
    assertThat(specimenList).isEmpty();
}
Also used : Specimen(org.hl7.fhir.dstu3.model.Specimen) RCMRMT030101UK04EhrExtract(org.hl7.v3.RCMRMT030101UK04EhrExtract) Test(org.junit.jupiter.api.Test)

Example 48 with Specimen

use of org.hl7.fhir.r4.model.Specimen in project nia-patient-switching-standard-adaptor by NHSDigital.

the class SpecimenMapperTest method generateDiagnosticReportWithSpecimenReference.

private static DiagnosticReport generateDiagnosticReportWithSpecimenReference() {
    DiagnosticReport diagnosticReport = (DiagnosticReport) new DiagnosticReport().setId(DR_ID);
    List<Reference> specimen = List.of(new Reference(SPECIMEN_PREFIX + TEST_SPECIMEN_ID));
    diagnosticReport.setSpecimen(specimen);
    return diagnosticReport;
}
Also used : Reference(org.hl7.fhir.dstu3.model.Reference) DiagnosticReport(org.hl7.fhir.dstu3.model.DiagnosticReport)

Example 49 with Specimen

use of org.hl7.fhir.r4.model.Specimen in project nia-patient-switching-standard-adaptor by NHSDigital.

the class SpecimenMapperTest method testSpecimenIsMapped.

@Test
public void testSpecimenIsMapped() {
    when(dateTimeMapper.mapDateTime(any())).thenCallRealMethod();
    RCMRMT030101UK04EhrExtract ehrExtract = unmarshallEhrExtract("specimen_valid.xml");
    List<Specimen> specimenList = specimenMapper.mapSpecimen(ehrExtract, List.of(DIAGNOSTIC_REPORT_WITH_SPECIMEN), PATIENT, PRACTICE_CODE);
    assertThat(specimenList).isNotEmpty();
    final Specimen specimen = specimenList.get(0);
    checkFixedValues(specimen);
    assertThat(specimen.getNote().get(0).getText()).isEqualTo(NOTE_TEXT);
    assertThat(specimen.getAccessionIdentifier().getValue()).isEqualTo(ACCESSION_IDENTIFIER_VALUE);
    assertThat(specimen.getType().getText()).isEqualTo(SPECIMEN_TYPE_TEXT);
    assertThat(specimen.getCollection().getCollected().toString()).isEqualTo(SPECIMEN_COLLECTED_DATETIME.toString());
}
Also used : Specimen(org.hl7.fhir.dstu3.model.Specimen) RCMRMT030101UK04EhrExtract(org.hl7.v3.RCMRMT030101UK04EhrExtract) Test(org.junit.jupiter.api.Test)

Aggregations

Test (org.junit.jupiter.api.Test)19 IBaseResource (org.hl7.fhir.instance.model.api.IBaseResource)11 BundleEntryComponent (org.hl7.fhir.r4.model.Bundle.BundleEntryComponent)11 Resource (org.hl7.fhir.r4.model.Resource)11 Complex (org.hl7.fhir.dstu2016may.formats.RdfGenerator.Complex)9 Complex (org.hl7.fhir.r4.utils.formats.Turtle.Complex)9 Complex (org.hl7.fhir.dstu3.utils.formats.Turtle.Complex)8 Coding (org.hl7.fhir.r4.model.Coding)8 DiagnosticReport (org.hl7.fhir.r4.model.DiagnosticReport)8 Reference (org.hl7.fhir.r4.model.Reference)8 Attachment (org.hl7.fhir.r4.model.Attachment)7 Bundle (org.hl7.fhir.r4.model.Bundle)6 Observation (org.hl7.fhir.r4.model.Observation)6 Specimen (org.hl7.fhir.dstu3.model.Specimen)4 Turtle (org.hl7.fhir.dstu3.utils.formats.Turtle)4 ResourceModel (io.github.linuxforhealth.api.ResourceModel)3 RCMRMT030101UK04EhrExtract (org.hl7.v3.RCMRMT030101UK04EhrExtract)3 FHIRContext (io.github.linuxforhealth.fhir.FHIRContext)2 File (java.io.File)2 FhirPath (au.csiro.pathling.fhirpath.FhirPath)1