Search in sources :

Example 6 with DocumentReference

use of org.hl7.fhir.r4.model.DocumentReference in project hl7v2-fhir-converter by LinuxForHealth.

the class Hl7DocumentReferenceFHIRConversionTest method doc_ref_has_all_fields_in_yaml.

// Note: All tests for MDM_T02 and MDM_T06 are the same. Use parameters.
@ParameterizedTest
@ValueSource(strings = { "MDM^T02", "MDM^T06" })
void doc_ref_has_all_fields_in_yaml(String segment) {
    // every field covered in the yaml should be listed here
    String documentReference = "MSH|^~\\&|HL7Soup|Instance1|MCM|Instance2|200911021022|Security|" + segment + "^MDM_T02|64322|P|2.6|123|456|ER|AL|USA|ASCII|en|2.6|56789^NID^UID|MCM||||\n" + "PID|1||000054321^^^MRN|||||||||||||M|CAT|||||N\n" + "PV1|1|I||||||||||||||||||||||||||||||||||||||||||\n" + "ORC|NW|||PGN001|SC|D|1|||MS|MS|||||\n" + "OBR|1||||||20170825010500|||||||||||||002|||||F||||||||\n" + "TXA|1|OP|TEXT|20180117144200|5566^PAPLast^PAPFirst^J^^MD|20180117144200|201801180346||<PHYSID>|<PHYSID>|MODL|<MESSAGEID>|4466^TRANSCLast^TRANSCFirst^J||<MESSAGEID>|This segment is for description|PA|R|AV|||||\n" + "OBX|1|SN|||||||||X";
    DocumentReference report = ResourceUtils.getDocumentReference(ftv, documentReference);
    assertThat(report.hasAuthenticator()).isTrue();
    assertThat(report.hasAuthor()).isTrue();
    assertThat(report.hasContent()).isTrue();
    assertThat(report.hasContext()).isTrue();
    assertThat(report.hasDate()).isTrue();
    assertThat(report.hasDescription()).isTrue();
    assertThat(report.hasDocStatus()).isTrue();
    assertThat(report.hasId()).isTrue();
    assertThat(report.hasIdentifier()).isTrue();
    assertThat(report.hasMasterIdentifier()).isTrue();
    assertThat(report.hasSecurityLabel()).isTrue();
    assertThat(report.hasStatus()).isTrue();
    assertThat(report.hasSubject()).isTrue();
    assertThat(report.hasType()).isTrue();
}
Also used : DocumentReference(org.hl7.fhir.r4.model.DocumentReference) ValueSource(org.junit.jupiter.params.provider.ValueSource) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest)

Example 7 with DocumentReference

use of org.hl7.fhir.r4.model.DocumentReference in project hl7v2-fhir-converter by LinuxForHealth.

the class Hl7IdentifierFHIRConversionTest method documentReferenceIdentifierTest3.

@Test
void documentReferenceIdentifierTest3() {
    // Placer from OBR, Filler from TXA-15
    String documentReferenceMessage = "MSH|^~\\&|HL7Soup|Instance1|MCM|Instance2|200911021022|Security|MDM^T02|64322|P|2.6|123|456|ER|AL|USA|ASCII|en|2.6|56789^NID^UID|MCM||||\n" + "PID|1||000054321^^^MRN|||||||||||||M|CAT|||||N\n" + "PV1|1|I|||||||||||||||||||||||||||||||||||||||||||\n" + "ORC|NW|||PGN001|SC|D|1||20170825010500|MS|MS||||20170825010500|\n" + "OBR|1|CD_000000^OE||2244^General Order|||20170825010500||||||Relevant Clinical Information|||||||002|||||F|||550600^Tsadok550600^Janetary~660600^Merrit660600^Darren^F~770600^Das770600^Surjya^P~880600^Winter880600^Oscar^||||770600&Das770600&Surjya&P^^^6N^1234^A|\n" + "TXA|1||B45678||||||||||||FON001^IE\n";
    DocumentReference report = ResourceUtils.getDocumentReference(ftv, documentReferenceMessage);
    // Expect 3 identifiers
    assertThat(report.hasIdentifier()).isTrue();
    assertThat(report.getIdentifier()).hasSize(3);
    List<Identifier> identifiers = report.getIdentifier();
    // Match the three id's to position; we can't depend on an order.
    int posExtId = getIdentifierPositionByValue("200911021022", identifiers);
    assertThat(posExtId).isNotSameAs(-1);
    int posFILLER = getIdentifierPositionByValue("FON001", identifiers);
    assertThat(posFILLER).isNotSameAs(-1);
    int posPLACER = getIdentifierPositionByValue("CD_000000", identifiers);
    assertThat(posPLACER).isNotSameAs(-1);
    // Identifier 1: extID from MSH-7
    Identifier identifier = report.getIdentifier().get(posExtId);
    String value = identifier.getValue();
    String system = identifier.getSystem();
    // MSH-7
    assertThat(value).isEqualTo("200911021022");
    assertThat(system).isEqualTo("urn:id:extID");
    // Identifier 2: Filler
    Identifier identifier3 = report.getIdentifier().get(posFILLER);
    value = identifier3.getValue();
    system = identifier3.getSystem();
    // TXA-15.1
    assertThat(value).isEqualTo("FON001");
    // TXA.15.2
    assertThat(system).isEqualTo("urn:id:IE");
    CodeableConcept type = identifier3.getType();
    Coding coding = type.getCoding().get(0);
    assertThat(type.getText()).isNull();
    assertThat(coding.getSystem()).isEqualTo("http://terminology.hl7.org/CodeSystem/v2-0203");
    assertThat(coding.getCode()).isEqualTo("FILL");
    assertThat(coding.getDisplay()).isEqualTo("Filler Identifier");
    // Identifier 3: Placer
    identifier = report.getIdentifier().get(posPLACER);
    value = identifier.getValue();
    system = identifier.getSystem();
    // OBR.2.1
    assertThat(value).isEqualTo("CD_000000");
    // OBR.2.2
    assertThat(system).isEqualTo("urn:id:OE");
    type = identifier.getType();
    coding = type.getCoding().get(0);
    assertThat(type.getText()).isNull();
    assertThat(coding.getSystem()).isEqualTo("http://terminology.hl7.org/CodeSystem/v2-0203");
    assertThat(coding.getCode()).isEqualTo("PLAC");
    assertThat(coding.getDisplay()).isEqualTo("Placer Identifier");
}
Also used : Identifier(org.hl7.fhir.r4.model.Identifier) Coding(org.hl7.fhir.r4.model.Coding) DocumentReference(org.hl7.fhir.r4.model.DocumentReference) CodeableConcept(org.hl7.fhir.r4.model.CodeableConcept) Test(org.junit.jupiter.api.Test)

Example 8 with DocumentReference

use of org.hl7.fhir.r4.model.DocumentReference in project summary-care-record-api by NHSDigital.

the class GetScrController method getScrId.

@GetMapping(path = "/DocumentReference", produces = { APPLICATION_FHIR_JSON_VALUE })
@SuppressWarnings("checkstyle:parameternumber")
@LogExecutionTime
public String getScrId(@RequestHeader(NHSD_ASID) @NotNull String nhsdAsid, @RequestHeader(CLIENT_IP) @NotNull String clientIp, @RequestParam("patient") @NotNull @PatientId String patient, @RequestParam(required = false) @TypeCode String type, @RequestParam(name = "_sort", required = false) @SortMethod String sort, @RequestParam(name = "_count", required = false) @RecordCount Integer count) {
    LOGGER.info("Received GET SCR ID request");
    String nhsNumber = extractNhsNumber(patient);
    Bundle bundle = getScrService.getScrId(nhsNumber, nhsdAsid, clientIp);
    return fhirParser.encodeToJson(bundle);
}
Also used : Bundle(org.hl7.fhir.r4.model.Bundle) LogExecutionTime(uk.nhs.adaptors.scr.logging.LogExecutionTime) GetMapping(org.springframework.web.bind.annotation.GetMapping)

Example 9 with DocumentReference

use of org.hl7.fhir.r4.model.DocumentReference in project summary-care-record-api by NHSDigital.

the class GetScrService method getScrId.

@LogExecutionTime
public Bundle getScrId(String nhsNumber, String nhsdAsid, String clientIp) {
    Document scrIdXml = getScrIdRawXml(nhsNumber, nhsdAsid, clientIp);
    checkDetectedIssues(scrIdXml);
    EventListQueryResponse response = eventListQueryResponseParser.parseXml(scrIdXml);
    Bundle bundle = buildBundle();
    if (StringUtils.isNotEmpty(response.getLatestScrId())) {
        bundle.setTotal(1);
        Patient patient = buildPatientResource(nhsNumber);
        DocumentReference documentReference = buildDocumentReference(nhsNumber, response, patient);
        bundle.addEntry(new BundleEntryComponent().setFullUrl(getScrUrl() + "/DocumentReference/" + documentReference.getId()).setResource(documentReference).setSearch(new Bundle.BundleEntrySearchComponent().setMode(MATCH)));
        bundle.addEntry(new BundleEntryComponent().setFullUrl(patient.getId()).setResource(patient));
    } else {
        bundle.setTotal(0);
    }
    return bundle;
}
Also used : BundleEntryComponent(org.hl7.fhir.r4.model.Bundle.BundleEntryComponent) Bundle(org.hl7.fhir.r4.model.Bundle) EventListQueryResponse(uk.nhs.adaptors.scr.models.EventListQueryResponse) Patient(org.hl7.fhir.r4.model.Patient) Document(org.w3c.dom.Document) DocumentReference(org.hl7.fhir.r4.model.DocumentReference) LogExecutionTime(uk.nhs.adaptors.scr.logging.LogExecutionTime)

Example 10 with DocumentReference

use of org.hl7.fhir.r4.model.DocumentReference 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();
}
Also used : Observation(org.hl7.fhir.r4.model.Observation) Attachment(org.hl7.fhir.r4.model.Attachment) ResourceNotFoundException(ca.uhn.fhir.rest.server.exceptions.ResourceNotFoundException) IBaseResource(org.hl7.fhir.instance.model.api.IBaseResource) DocumentReference(org.hl7.fhir.r4.model.DocumentReference) IdType(org.hl7.fhir.r4.model.IdType)

Aggregations

DocumentReference (org.hl7.fhir.r4.model.DocumentReference)32 ParameterizedTest (org.junit.jupiter.params.ParameterizedTest)15 ValueSource (org.junit.jupiter.params.provider.ValueSource)15 Identifier (org.hl7.fhir.r4.model.Identifier)12 CodeableConcept (org.hl7.fhir.r4.model.CodeableConcept)10 Coding (org.hl7.fhir.r4.model.Coding)8 Attachment (org.hl7.fhir.r4.model.Attachment)7 Reference (org.hl7.fhir.r4.model.Reference)7 BundleEntryComponent (org.hl7.fhir.r4.model.Bundle.BundleEntryComponent)6 Practitioner (org.hl7.fhir.r4.model.Practitioner)6 Resource (org.hl7.fhir.r4.model.Resource)6 Complex (org.hl7.fhir.dstu2016may.formats.RdfGenerator.Complex)5 IBaseResource (org.hl7.fhir.instance.model.api.IBaseResource)5 Bundle (org.hl7.fhir.r4.model.Bundle)5 HashMap (java.util.HashMap)4 Complex (org.hl7.fhir.dstu3.utils.formats.Turtle.Complex)4 DocumentReferenceContextComponent (org.hl7.fhir.r4.model.DocumentReference.DocumentReferenceContextComponent)4 Complex (org.hl7.fhir.r4.utils.formats.Turtle.Complex)4 Test (org.junit.jupiter.api.Test)4 Identifiable (org.openehealth.ipf.commons.ihe.xds.core.metadata.Identifiable)4