use of org.hl7.fhir.r4.model.DocumentReference in project MobileAccessGateway by i4mi.
the class Iti66ResponseConverter method translateToFhir.
/**
* convert ITI-18 query response to ITI-66 response bundle
*/
@Override
public List<ListResource> translateToFhir(QueryResponse input, Map<String, Object> parameters) {
ArrayList<ListResource> list = new ArrayList<ListResource>();
if (input != null && Status.SUCCESS.equals(input.getStatus())) {
Map<String, ListResource> targetList = new HashMap<String, ListResource>();
if (input.getSubmissionSets() != null) {
for (SubmissionSet submissionSet : input.getSubmissionSets()) {
ListResource documentManifest = new ListResource();
documentManifest.setId(noUuidPrefix(submissionSet.getEntryUuid()));
documentManifest.setCode(new CodeableConcept(new Coding("http://profiles.ihe.net/ITI/MHD/CodeSystem/MHDlistTypes", "submissionset", "Submission Set")));
targetList.put(documentManifest.getId(), documentManifest);
list.add(documentManifest);
// limitedMetadata -> meta.profile canonical [0..*]
if (submissionSet.isLimitedMetadata()) {
documentManifest.getMeta().addProfile("http://profiles.ihe.net/ITI/MHD/StructureDefinition/IHE.MHD.Minimal.SubmissionSet");
} else {
documentManifest.getMeta().addProfile("http://profiles.ihe.net/ITI/MHD/StructureDefinition/IHE.MHD.Comprehensive.SubmissionSet");
}
// comment -> text Narrative [0..1]
LocalizedString comments = submissionSet.getComments();
if (comments != null) {
documentManifest.addNote().setText(comments.getValue());
}
// uniqueId -> masterIdentifier Identifier [0..1] [1..1]
if (submissionSet.getUniqueId() != null) {
documentManifest.addIdentifier((new Identifier().setUse(IdentifierUse.USUAL).setSystem("urn:ietf:rfc:3986").setValue("urn:oid:" + submissionSet.getUniqueId())));
}
// entryUUID -> identifier Identifier [0..*]
if (submissionSet.getEntryUuid() != null) {
documentManifest.addIdentifier((new Identifier().setUse(IdentifierUse.OFFICIAL).setSystem("urn:ietf:rfc:3986").setValue(asUuid(submissionSet.getEntryUuid()))));
}
// approved -> status=current Other status values are allowed but are not defined in this mapping to XDS.
if (AvailabilityStatus.APPROVED.equals(submissionSet.getAvailabilityStatus())) {
documentManifest.setStatus(ListResource.ListStatus.CURRENT);
}
documentManifest.setMode(ListMode.WORKING);
// contentTypeCode -> type CodeableConcept [0..1]
if (submissionSet.getContentTypeCode() != null) {
documentManifest.addExtension().setUrl("http://profiles.ihe.net/ITI/MHD/StructureDefinition/ihe-designationType").setValue(transform(submissionSet.getContentTypeCode()));
}
// patientId -> subject Reference(Patient| Practitioner| Group| Device) [0..1], Reference(Patient)
if (submissionSet.getPatientId() != null) {
Identifiable patient = submissionSet.getPatientId();
documentManifest.setSubject(transformPatient(patient));
}
// submissionTime -> created dateTime [0..1]
if (submissionSet.getSubmissionTime() != null) {
documentManifest.setDate(Date.from(submissionSet.getSubmissionTime().getDateTime().toInstant()));
}
// authorInstitution, authorPerson, authorRole, authorSpeciality, authorTelecommunication -> author Reference(Practitioner| PractitionerRole| Organization| Device| Patient| RelatedPerson) [0..*]
if (submissionSet.getAuthors() != null) {
for (Author author : submissionSet.getAuthors()) {
documentManifest.setSource(transformAuthor(author));
}
}
// intendedRecipient -> recipient Reference(Patient| Practitioner| PractitionerRole| RelatedPerson| Organization) [0..*]
List<Recipient> recipients = submissionSet.getIntendedRecipients();
for (Recipient recipient : recipients) {
Organization org = recipient.getOrganization();
Person person = recipient.getPerson();
ContactPoint contact = transform(recipient.getTelecom());
var organization = transform(org);
Practitioner practitioner = transformPractitioner(person);
if (organization != null && practitioner == null) {
if (contact != null)
organization.addTelecom(contact);
documentManifest.addExtension().setUrl("http://profiles.ihe.net/ITI/MHD/StructureDefinition/ihe-intendedRecipient").setValue(new Reference().setResource(organization));
} else if (organization != null && practitioner != null) {
PractitionerRole role = new PractitionerRole();
role.setPractitioner((Reference) new Reference().setResource(practitioner));
role.setOrganization((Reference) new Reference().setResource(organization));
if (contact != null)
role.addTelecom(contact);
documentManifest.addExtension().setUrl("http://profiles.ihe.net/ITI/MHD/StructureDefinition/ihe-intendedRecipient").setValue(new Reference().setResource(role));
} else if (organization == null && practitioner != null) {
// May be a patient, related person or practitioner
}
}
// sourceId -> source uri [0..1] [1..1]
if (submissionSet.getSourceId() != null) {
documentManifest.addExtension().setUrl("http://profiles.ihe.net/ITI/MHD/StructureDefinition/ihe-sourceId").setValue(new Identifier().setValue("urn:oid:" + submissionSet.getSourceId()));
}
// title -> description string [0..1]
LocalizedString title = submissionSet.getTitle();
if (title != null) {
documentManifest.setTitle(title.getValue());
}
}
}
if (input.getAssociations() != null) {
for (Association ass : input.getAssociations()) {
AssociationType tt = ass.getAssociationType();
String source = ass.getSourceUuid();
String target = ass.getTargetUuid();
if (tt == AssociationType.HAS_MEMBER) {
ListResource s = targetList.get(noUuidPrefix(source));
if (s != null) {
s.addEntry().setItem(new Reference().setReference("DocumentReference/" + noUuidPrefix(target)));
}
}
}
}
} else {
processError(input);
}
return list;
}
use of org.hl7.fhir.r4.model.DocumentReference in project MobileAccessGateway by i4mi.
the class Iti67ResponseConverter method translateToFhir.
@Override
public List<DocumentReference> translateToFhir(QueryResponse input, Map<String, Object> parameters) {
ArrayList<DocumentReference> list = new ArrayList<DocumentReference>();
if (input != null && Status.SUCCESS.equals(input.getStatus())) {
// process relationship association
Map<String, List<DocumentReferenceRelatesToComponent>> relatesToMapping = new HashMap<String, List<DocumentReferenceRelatesToComponent>>();
for (Association association : input.getAssociations()) {
// Relationship type -> relatesTo.code code [1..1]
// relationship reference -> relatesTo.target Reference(DocumentReference)
String source = association.getSourceUuid();
String target = association.getTargetUuid();
AssociationType type = association.getAssociationType();
DocumentReferenceRelatesToComponent relatesTo = new DocumentReferenceRelatesToComponent();
if (type != null)
switch(type) {
case APPEND:
relatesTo.setCode(DocumentRelationshipType.APPENDS);
break;
case REPLACE:
relatesTo.setCode(DocumentRelationshipType.REPLACES);
break;
case TRANSFORM:
relatesTo.setCode(DocumentRelationshipType.TRANSFORMS);
break;
case SIGNS:
relatesTo.setCode(DocumentRelationshipType.SIGNS);
break;
}
relatesTo.setTarget(new Reference().setReference("urn:oid:" + target));
if (!relatesToMapping.containsKey(source))
relatesToMapping.put(source, new ArrayList<DocumentReferenceRelatesToComponent>());
relatesToMapping.get(source).add(relatesTo);
}
if (input.getDocumentEntries() != null) {
for (DocumentEntry documentEntry : input.getDocumentEntries()) {
DocumentReference documentReference = new DocumentReference();
// FIXME do we need to cache this id in
documentReference.setId(noUuidPrefix(documentEntry.getEntryUuid()));
// relation to the DocumentManifest itself
// for
list.add(documentReference);
// limitedMetadata -> meta.profile canonical [0..*]
if (documentEntry.isLimitedMetadata()) {
documentReference.getMeta().addProfile("http://ihe.net/fhir/StructureDefinition/IHE_MHD_Query_Comprehensive_DocumentReference");
} else {
documentReference.getMeta().addProfile("http://ihe.net/fhir/StructureDefinition/IHE_MHD_Comprehensive_DocumentManifest");
}
// uniqueId -> masterIdentifier Identifier [0..1] [1..1]
if (documentEntry.getUniqueId() != null) {
documentReference.setMasterIdentifier((new Identifier().setValue("urn:oid:" + documentEntry.getUniqueId())));
}
// DocumentReference.identifier. use shall be ‘official’
if (documentEntry.getEntryUuid() != null) {
documentReference.addIdentifier((new Identifier().setSystem("urn:ietf:rfc:3986").setValue(asUuid(documentEntry.getEntryUuid()))).setUse(IdentifierUse.OFFICIAL));
}
// Other status values are allowed but are not defined in this mapping to XDS.
if (AvailabilityStatus.APPROVED.equals(documentEntry.getAvailabilityStatus())) {
documentReference.setStatus(DocumentReferenceStatus.CURRENT);
}
if (AvailabilityStatus.DEPRECATED.equals(documentEntry.getAvailabilityStatus())) {
documentReference.setStatus(DocumentReferenceStatus.SUPERSEDED);
}
// contentTypeCode -> type CodeableConcept [0..1]
if (documentEntry.getTypeCode() != null) {
documentReference.setType(transform(documentEntry.getTypeCode()));
}
// classCode -> category CodeableConcept [0..*]
if (documentEntry.getClassCode() != null) {
documentReference.addCategory((transform(documentEntry.getClassCode())));
}
// representing the XDS Affinity Domain Patient.
if (documentEntry.getPatientId() != null) {
Identifiable patient = documentEntry.getPatientId();
documentReference.setSubject(transformPatient(patient));
}
// creationTime -> date instant [0..1]
if (documentEntry.getCreationTime() != null) {
documentReference.setDate(Date.from(documentEntry.getCreationTime().getDateTime().toInstant()));
}
// PractitionerRole| Organization| Device| Patient| RelatedPerson) [0..*]
if (documentEntry.getAuthors() != null) {
for (Author author : documentEntry.getAuthors()) {
documentReference.addAuthor(transformAuthor(author));
}
}
// legalAuthenticator -> authenticator Note 1
// Reference(Practitioner|Practition erRole|Organization [0..1]
Person person = documentEntry.getLegalAuthenticator();
if (person != null) {
Practitioner practitioner = transformPractitioner(person);
documentReference.setAuthenticator((Reference) new Reference().setResource(practitioner));
}
// Relationship Association -> relatesTo [0..*]
// [1..1]
documentReference.setRelatesTo(relatesToMapping.get(documentEntry.getEntryUuid()));
// title -> description string [0..1]
if (documentEntry.getTitle() != null) {
documentReference.setDescription(documentEntry.getTitle().getValue());
}
// DocumentReference itself.
if (documentEntry.getConfidentialityCodes() != null) {
documentReference.addSecurityLabel(transform(documentEntry.getConfidentialityCodes()));
}
DocumentReferenceContentComponent content = documentReference.addContent();
Attachment attachment = new Attachment();
content.setAttachment(attachment);
// mimeType -> content.attachment.contentType [1..1] code [0..1]
if (documentEntry.getMimeType() != null) {
attachment.setContentType(documentEntry.getMimeType());
}
// languageCode -> content.attachment.language code [0..1]
if (documentEntry.getLanguageCode() != null) {
attachment.setLanguage(documentEntry.getLanguageCode());
}
// retrievable location of the document -> content.attachment.url uri
// [0..1] [1..1
// has to defined, for the PoC we define
// $host:port/camel/$repositoryid/$uniqueid
attachment.setUrl(config.getUriMagXdsRetrieve() + "?uniqueId=" + documentEntry.getUniqueId() + "&repositoryUniqueId=" + documentEntry.getRepositoryUniqueId());
// size -> content.attachment.size integer [0..1] The size is calculated
if (documentEntry.getSize() != null) {
attachment.setSize(documentEntry.getSize().intValue());
}
// on the data prior to base64 encoding, if the data is base64 encoded.
if (documentEntry.getHash() != null) {
attachment.setHash(Hex.fromHex(documentEntry.getHash()));
}
// comments -> content.attachment.title string [0..1]
if (documentEntry.getComments() != null) {
attachment.setTitle(documentEntry.getComments().getValue());
}
// TcreationTime -> content.attachment.creation dateTime [0..1]
if (documentEntry.getCreationTime() != null) {
attachment.setCreation(Date.from(documentEntry.getCreationTime().getDateTime().toInstant()));
}
// formatCode -> content.format Coding [0..1]
if (documentEntry.getFormatCode() != null) {
content.setFormat(transform(documentEntry.getFormatCode()).getCodingFirstRep());
}
DocumentReferenceContextComponent context = new DocumentReferenceContextComponent();
documentReference.setContext(context);
// referenceIdList -> context.encounter Reference(Encounter) [0..*] When
// referenceIdList contains an encounter, and a FHIR Encounter is available, it
// may be referenced.
// Map to context.related
List<ReferenceId> refIds = documentEntry.getReferenceIdList();
if (refIds != null) {
for (ReferenceId refId : refIds) {
context.getRelated().add(transform(refId));
}
}
// eventCodeList -> context.event CodeableConcept [0..*]
if (documentEntry.getEventCodeList() != null) {
documentReference.getContext().setEvent(transformMultiple(documentEntry.getEventCodeList()));
}
// serviceStartTime serviceStopTime -> context.period Period [0..1]
if (documentEntry.getServiceStartTime() != null || documentEntry.getServiceStopTime() != null) {
Period period = new Period();
period.setStartElement(transform(documentEntry.getServiceStartTime()));
period.setEndElement(transform(documentEntry.getServiceStopTime()));
documentReference.getContext().setPeriod(period);
}
// [0..1]
if (documentEntry.getHealthcareFacilityTypeCode() != null) {
context.setFacilityType(transform(documentEntry.getHealthcareFacilityTypeCode()));
}
// practiceSettingCode -> context.practiceSetting CodeableConcept [0..1]
if (documentEntry.getPracticeSettingCode() != null) {
context.setPracticeSetting(transform(documentEntry.getPracticeSettingCode()));
}
// sourcePatientId and sourcePatientInfo -> context.sourcePatientInfo
// Reference(Patient) [0..1] Contained Patient Resource with
// Patient.identifier.use element set to ‘usual’.
Identifiable sourcePatientId = documentEntry.getSourcePatientId();
PatientInfo sourcePatientInfo = documentEntry.getSourcePatientInfo();
Patient sourcePatient = new Patient();
if (sourcePatientId != null) {
sourcePatient.addIdentifier((new Identifier().setSystem("urn:oid:" + sourcePatientId.getAssigningAuthority().getUniversalId()).setValue(sourcePatientId.getId())).setUse(IdentifierUse.OFFICIAL));
}
if (sourcePatientInfo != null) {
sourcePatient.setBirthDateElement(transformToDate(sourcePatientInfo.getDateOfBirth()));
String gender = sourcePatientInfo.getGender();
if (gender != null) {
switch(gender) {
case "F":
sourcePatient.setGender(Enumerations.AdministrativeGender.FEMALE);
break;
case "M":
sourcePatient.setGender(Enumerations.AdministrativeGender.MALE);
break;
case "U":
sourcePatient.setGender(Enumerations.AdministrativeGender.UNKNOWN);
break;
case "A":
sourcePatient.setGender(Enumerations.AdministrativeGender.OTHER);
break;
}
}
ListIterator<Name> names = sourcePatientInfo.getNames();
while (names.hasNext()) {
Name name = names.next();
sourcePatient.addName(transform(name));
}
ListIterator<Address> addresses = sourcePatientInfo.getAddresses();
while (addresses.hasNext()) {
Address address = addresses.next();
if (address != null)
sourcePatient.addAddress(transform(address));
}
}
if (sourcePatientId != null || sourcePatientInfo != null) {
context.getSourcePatientInfo().setResource(sourcePatient);
}
}
}
} else {
processError(input);
}
return list;
}
use of org.hl7.fhir.r4.model.DocumentReference in project synthea by synthetichealth.
the class FhirR4 method clinicalNote.
/**
* Add a clinical note to the Bundle, which adds both a DocumentReference and a
* DiagnosticReport.
*
* @param rand Source of randomness to use when generating ids etc
* @param personEntry The Entry for the Person
* @param bundle Bundle to add the Report to
* @param encounterEntry Current Encounter entry
* @param clinicalNoteText The plain text contents of the note.
* @param currentNote If this is the most current note.
* @return The entry for the DocumentReference.
*/
private static BundleEntryComponent clinicalNote(RandomNumberGenerator rand, BundleEntryComponent personEntry, Bundle bundle, BundleEntryComponent encounterEntry, String clinicalNoteText, boolean currentNote) {
// We'll need the encounter...
org.hl7.fhir.r4.model.Encounter encounter = (org.hl7.fhir.r4.model.Encounter) encounterEntry.getResource();
// Add a DiagnosticReport
DiagnosticReport reportResource = new DiagnosticReport();
if (USE_US_CORE_IG) {
Meta meta = new Meta();
meta.addProfile("http://hl7.org/fhir/us/core/StructureDefinition/us-core-diagnosticreport-note");
reportResource.setMeta(meta);
}
reportResource.setStatus(DiagnosticReportStatus.FINAL);
reportResource.addCategory(new CodeableConcept(new Coding(LOINC_URI, "34117-2", "History and physical note")));
reportResource.getCategoryFirstRep().addCoding(new Coding(LOINC_URI, "51847-2", "Evaluation+Plan note"));
reportResource.setCode(reportResource.getCategoryFirstRep());
reportResource.setSubject(new Reference(personEntry.getFullUrl()));
reportResource.setEncounter(new Reference(encounterEntry.getFullUrl()));
reportResource.setEffective(encounter.getPeriod().getStartElement());
reportResource.setIssued(encounter.getPeriod().getStart());
if (encounter.hasParticipant()) {
reportResource.addPerformer(encounter.getParticipantFirstRep().getIndividual());
} else {
reportResource.addPerformer(encounter.getServiceProvider());
}
reportResource.addPresentedForm().setContentType("text/plain; charset=utf-8").setData(clinicalNoteText.getBytes(java.nio.charset.StandardCharsets.UTF_8));
newEntry(rand, bundle, reportResource);
// Add a DocumentReference
DocumentReference documentReference = new DocumentReference();
if (USE_US_CORE_IG) {
Meta meta = new Meta();
meta.addProfile("http://hl7.org/fhir/us/core/StructureDefinition/us-core-documentreference");
documentReference.setMeta(meta);
}
if (currentNote) {
documentReference.setStatus(DocumentReferenceStatus.CURRENT);
} else {
documentReference.setStatus(DocumentReferenceStatus.SUPERSEDED);
}
documentReference.addIdentifier().setSystem("urn:ietf:rfc:3986").setValue("urn:uuid:" + reportResource.getId());
documentReference.setType(reportResource.getCategoryFirstRep());
documentReference.addCategory(new CodeableConcept(new Coding("http://hl7.org/fhir/us/core/CodeSystem/us-core-documentreference-category", "clinical-note", "Clinical Note")));
documentReference.setSubject(new Reference(personEntry.getFullUrl()));
documentReference.setDate(encounter.getPeriod().getStart());
documentReference.addAuthor(reportResource.getPerformerFirstRep());
documentReference.setCustodian(encounter.getServiceProvider());
documentReference.addContent().setAttachment(reportResource.getPresentedFormFirstRep()).setFormat(new Coding("http://ihe.net/fhir/ValueSet/IHE.FormatCode.codesystem", "urn:ihe:iti:xds:2017:mimeTypeSufficient", "mimeType Sufficient"));
documentReference.setContext(new DocumentReferenceContextComponent().addEncounter(reportResource.getEncounter()).setPeriod(encounter.getPeriod()));
return newEntry(rand, bundle, documentReference);
}
use of org.hl7.fhir.r4.model.DocumentReference in project hl7v2-fhir-converter by LinuxForHealth.
the class Hl7DocumentReferenceFHIRConversionTest method doc_ref_authenticator_and_author_test.
@ParameterizedTest
@ValueSource(strings = { "MDM^T02", "MDM^T06" })
void doc_ref_authenticator_and_author_test(String segment) {
String documentReferenceMessage = "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||TEXT||||201801180346||<PHYSID1>^DOE^JANE^J^^MD||||||||||AV|||<PHYSID2>^DOE^JOHN^K^^MD||\n" + "OBX|1|ST|100||This is content|||||||X\n";
List<BundleEntryComponent> e = ResourceUtils.createFHIRBundleFromHL7MessageReturnEntryList(ftv, documentReferenceMessage);
List<Resource> documentReferenceList = ResourceUtils.getResourceList(e, ResourceType.DocumentReference);
String s = context.getParser().encodeResourceToString(documentReferenceList.get(0));
Class<? extends IBaseResource> klass = DocumentReference.class;
DocumentReference documentReference = (DocumentReference) context.getParser().parseResource(klass, s);
String requesterRefAuthor = documentReference.getAuthor().get(0).getReference();
String requesterRefAuthenticator = documentReference.getAuthenticator().getReference();
Practitioner practAuthor = ResourceUtils.getSpecificPractitionerFromBundleEntriesList(e, requesterRefAuthor);
Practitioner practAuthenticator = ResourceUtils.getSpecificPractitionerFromBundleEntriesList(e, requesterRefAuthenticator);
assertThat(documentReference.hasAuthor()).isTrue();
assertThat(documentReference.hasAuthenticator()).isTrue();
assertThat(documentReference.getAuthor()).hasSize(1);
assertThat(documentReference.getAuthorFirstRep().getDisplay()).isEqualTo("MD JANE J DOE");
assertThat(documentReference.getAuthenticator().getDisplay()).isEqualTo("MD JOHN K DOE");
// Value passed to Author is used as Identifier value in practitioner
assertThat(practAuthor.getIdentifierFirstRep().getValue()).isEqualTo("<PHYSID1>");
// Value passed to Authenticator is used as Identifier value in practitioner
assertThat(practAuthenticator.getIdentifierFirstRep().getValue()).isEqualTo("<PHYSID2>");
}
use of org.hl7.fhir.r4.model.DocumentReference in project hl7v2-fhir-converter by LinuxForHealth.
the class Hl7DocumentReferenceFHIRConversionTest method docRefContextAndServiceRequestPresenceTest.
@ParameterizedTest
@ValueSource(strings = { "MDM^T02", "MDM^T06" })
void docRefContextAndServiceRequestPresenceTest(String segment) {
String documentReferenceMessage = "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" + // All three practitioner id's are provided (ORC.2, ORC.3, ORC.456)
"ORC|NW|P1005|F1005|PGN001|SC|D|1|||MS|MS|||||\n" + "OBR|1||||||20170825010500|||||||||||||002||||CUS|F||||||||\n" + // TXA.4 used for context start
"TXA|1||TEXT|20180117144200|5566^PAPLast^PAPFirst^J^^MD||201801180346||<PHYSID1>||||||||||AV|||<PHYSID2>||\n" + // OBX is type ST so an observation will be created
"OBX|1|ST|100||This is content|||||||X\n";
List<BundleEntryComponent> e = ResourceUtils.createFHIRBundleFromHL7MessageReturnEntryList(ftv, documentReferenceMessage);
List<Resource> documentReferenceList = ResourceUtils.getResourceList(e, ResourceType.DocumentReference);
String s = context.getParser().encodeResourceToString(documentReferenceList.get(0));
Class<? extends IBaseResource> klass = DocumentReference.class;
DocumentReference documentReference = (DocumentReference) context.getParser().parseResource(klass, s);
String requesterRef = documentReference.getContext().getRelatedFirstRep().getReference();
Practitioner practBundle = ResourceUtils.getSpecificPractitionerFromBundleEntriesList(e, requesterRef);
DocumentReference.DocumentReferenceContextComponent refContext = documentReference.getContext();
// TXA.4
assertThat(refContext.getPeriod().getStartElement().toString()).containsPattern("2018-01-17T14:42:00");
assertThat(refContext.hasRelated()).isTrue();
assertThat(refContext.hasPracticeSetting()).isFalse();
assertThat(practBundle.getIdentifierFirstRep().getValue()).isEqualTo("5566");
// Value passed to Context(TXA.5) is used as Identifier value in practitioner
assertThat(practBundle.hasName()).isTrue();
assertThat(practBundle.getNameFirstRep().getTextElement().getValue()).isEqualTo("MD PAPFirst J PAPLast");
// This part of the test serves as a sanity check for all MDM_T0x's that associated resources are created
// Verify we have the other resources we expect and there are no extra resources created
// Expected are DocumentReference, ServiceRequest, Observation, 3 Practitioners, Patient, and Encounter
assertThat(e.size()).isEqualTo(8);
List<Resource> patientResource = ResourceUtils.getResourceList(e, ResourceType.Patient);
assertThat(patientResource).hasSize(1);
List<Resource> encounterResource = ResourceUtils.getResourceList(e, ResourceType.Encounter);
assertThat(encounterResource).hasSize(1);
List<Resource> practitionerResource = ResourceUtils.getResourceList(e, ResourceType.Practitioner);
assertThat(practitionerResource).hasSize(3);
// Verify one Observation is created (from the ST)
List<Resource> obsResource = ResourceUtils.getResourceList(e, ResourceType.Observation);
// TODO: When NTE is implemented, then update this.
assertThat(obsResource).hasSize(1);
// Confirm that associated ServiceRequest is created.
List<Resource> serviceRequestList = ResourceUtils.getResourceList(e, ResourceType.ServiceRequest);
assertThat(serviceRequestList).hasSize(1);
}
Aggregations