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();
}
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");
}
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);
}
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;
}
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();
}
Aggregations