use of org.hl7.fhir.r4.model.Bundle.BundleType.DOCUMENT 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.Bundle.BundleType.DOCUMENT 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();
}
use of org.hl7.fhir.r4.model.Bundle.BundleType.DOCUMENT in project integration-adaptor-111 by nhsconnect.
the class EncounterReportBundleServiceTest method shouldMapIncomingReferralWithPractitioners.
@Test
@SuppressWarnings("MagicNumber")
public void shouldMapIncomingReferralWithPractitioners() throws XmlException {
ItkReportHeader itkReportHeader = new ItkReportHeader();
List<Reference> recipients = new ArrayList<>();
when(reference.getResource()).thenReturn(PRACTITIONER);
recipients.add(reference);
REFERRAL_REQUEST.setRecipient(recipients);
Bundle encounterBundle = encounterReportBundleService.createEncounterBundle(document, itkReportHeader, MESSAGEID);
List<BundleEntryComponent> entries = encounterBundle.getEntry();
verifyEntry(entries.get(7), REFERRAL_REQUEST_ID.getValue(), ResourceType.ReferralRequest);
verifyEntry(entries.get(8), PRACTITIONER_ID.getValue(), ResourceType.Practitioner);
}
use of org.hl7.fhir.r4.model.Bundle.BundleType.DOCUMENT in project org.hl7.fhir.core by hapifhir.
the class CountryCodesConverter method execute.
private void execute() throws ParserConfigurationException, SAXException, IOException {
Document src = load();
CodeSystem cs1 = new CodeSystem();
CodeSystem cs2 = new CodeSystem();
CodeSystem cs3 = new CodeSystem();
setMetadata(src, cs1, "iso3166", "urn:iso:std:iso:3166", "", "");
setMetadata(src, cs2, "iso3166-2", "urn:iso:std:iso:3166:-2", "Part2", " Part 2");
cs1.addProperty().setCode("canonical").setDescription("The 2 letter code that identifies the same country (so 2/3/numeric codes can be aligned)").setType(PropertyType.CODE);
cs2.addProperty().setCode("country").setDescription("The 2 letter code that identifies the country for the subdivision").setType(PropertyType.CODE);
for (Element e : XMLUtil.getNamedChildren(src.getDocumentElement(), "country")) {
System.out.println(e.getAttribute("id"));
String c2 = XMLUtil.getNamedChildText(e, "alpha-2-code");
String c3 = XMLUtil.getNamedChildText(e, "alpha-3-code");
String cN = XMLUtil.getNamedChildText(e, "numeric-code");
Element n = XMLUtil.getNamedChildByAttribute(e, "short-name", "lang3code", "eng");
if (n == null)
n = XMLUtil.getNamedChildByAttribute(e, "short-name-upper-case", "lang3code", "eng");
if (n == null)
continue;
String name = n.getTextContent();
n = XMLUtil.getNamedChildByAttribute(e, "full-name", "lang3code", "eng");
if (n == null)
n = XMLUtil.getNamedChildByAttribute(e, "full-name-upper-case", "lang3code", "eng");
if (n == null)
n = XMLUtil.getNamedChildByAttribute(e, "short-name", "lang3code", "eng");
if (n == null)
n = XMLUtil.getNamedChildByAttribute(e, "short-name-upper-case", "lang3code", "eng");
String desc = n.getTextContent();
ConceptDefinitionComponent cc = cs1.addConcept();
cc.setCode(c2);
cc.setDisplay(name);
cc.setDefinition(desc);
poplang(e, cc);
if (c3 != null) {
cc = cs1.addConcept();
cc.setCode(c3);
cc.setDisplay(name);
cc.setDefinition(desc);
cc.addProperty().setCode("canonical").setValue(new CodeType(c2));
poplang(e, cc);
}
if (cN != null) {
cc = cs1.addConcept();
cc.setCode(cN);
cc.setDisplay(name);
cc.setDefinition(desc);
cc.addProperty().setCode("canonical").setValue(new CodeType(c2));
poplang(e, cc);
}
for (Element sd : XMLUtil.getNamedChildren(e, "subdivision")) {
cc = cs2.addConcept();
cc.setCode(XMLUtil.getNamedChildText(sd, "subdivision-code"));
Element l = XMLUtil.getNamedChild(sd, "subdivision-locale");
cc.setDisplay(XMLUtil.getNamedChildText(l, "subdivision-locale-name"));
cc.addProperty().setCode("country").setValue(new CodeType(c2));
}
}
cs1.setCount(cs1.getConcept().size());
cs2.setCount(cs2.getConcept().size());
throw new Error("Needs revisiting");
// new JsonParser().setOutputStyle(OutputStyle.PRETTY).compose(new FileOutputStream(Utilities.path(dest, "4.0.1", "package", "CodeSstem-iso3166.json")), cs1);
// new JsonParser().setOutputStyle(OutputStyle.PRETTY).compose(new FileOutputStream(Utilities.path(dest, "3.0.2", "package", "CodeSstem-iso3166.json")), cs1); // format hasn't changed
// new JsonParser().setOutputStyle(OutputStyle.PRETTY).compose(new FileOutputStream(Utilities.path(dest, "4.0.1", "package", "CodeSstem-iso3166-2.json")), cs2);
// new JsonParser().setOutputStyle(OutputStyle.PRETTY).compose(new FileOutputStream(Utilities.path(dest, "3.0.2", "package", "CodeSstem-iso3166-2.json")), cs2); // format hasn't changed
}
use of org.hl7.fhir.r4.model.Bundle.BundleType.DOCUMENT in project org.hl7.fhir.core by hapifhir.
the class NarrativeGenerator method generateDocumentNarrative.
public XhtmlNode generateDocumentNarrative(Bundle feed) {
/*
When the document is presented for human consumption, applications must present the collated narrative portions of the following resources in order:
* The Composition resource
* The Subject resource
* Resources referenced in the section.content
*/
XhtmlNode root = new XhtmlNode(NodeType.Element, "div");
Composition comp = (Composition) feed.getEntry().get(0).getResource();
root.getChildNodes().add(comp.getText().getDiv());
Resource subject = ResourceUtilities.getById(feed, null, comp.getSubject().getReference());
if (subject != null && subject instanceof DomainResource) {
root.addTag("hr");
root.getChildNodes().add(((DomainResource) subject).getText().getDiv());
}
List<SectionComponent> sections = comp.getSection();
renderSections(feed, root, sections, 1);
return root;
}
Aggregations