use of org.hl7.v3.RCMRMT030101UK04EhrComposition in project nia-patient-switching-standard-adaptor by NHSDigital.
the class DocumentReferenceMapper method mapDocumentReference.
private DocumentReference mapDocumentReference(RCMRMT030101UK04NarrativeStatement narrativeStatement, RCMRMT030101UK04EhrComposition ehrComposition, Patient patient, RCMRMT030101UK04EhrExtract ehrExtract, List<Encounter> encounterList, Organization organization) {
DocumentReference documentReference = new DocumentReference();
var id = narrativeStatement.getReference().get(0).getReferredToExternalDocument().getId().getRoot();
documentReference.addIdentifier(buildIdentifier(id, organization.getIdentifierFirstRep().getValue()));
documentReference.setId(id);
documentReference.getMeta().addProfile(META_PROFILE);
documentReference.setStatus(DocumentReferenceStatus.CURRENT);
documentReference.setType(getType(narrativeStatement));
documentReference.setSubject(new Reference(patient));
documentReference.setIndexedElement(getIndexed(ehrExtract));
documentReference.setDescription(buildDescription(narrativeStatement));
documentReference.setCustodian(new Reference(organization));
getAuthor(narrativeStatement, ehrComposition).ifPresent(documentReference::addAuthor);
if (narrativeStatement.hasAvailabilityTime() && narrativeStatement.getAvailabilityTime().hasValue()) {
documentReference.setCreatedElement(DateFormatUtil.parseToDateTimeType(narrativeStatement.getAvailabilityTime().getValue()));
}
var encounterReference = encounterList.stream().filter(encounter -> encounter.getId().equals(ehrComposition.getId().getRoot())).findFirst().map(Reference::new);
if (encounterReference.isPresent()) {
DocumentReference.DocumentReferenceContextComponent documentReferenceContextComponent = new DocumentReference.DocumentReferenceContextComponent().setEncounter(encounterReference.get());
documentReference.setContext(documentReferenceContextComponent);
}
setContentAttachments(documentReference, narrativeStatement);
return documentReference;
}
use of org.hl7.v3.RCMRMT030101UK04EhrComposition in project nia-patient-switching-standard-adaptor by NHSDigital.
the class EncounterMapper method generateLinkSetTopicLists.
private void generateLinkSetTopicLists(RCMRMT030101UK04EhrComposition ehrComposition, ListResource consultation, List<ListResource> topics) {
var linkSetList = getLinkSets(ehrComposition);
if (!CollectionUtils.isEmpty(linkSetList)) {
var linkSetTopic = consultationListMapper.mapToTopic(consultation, null);
addLinkSetsAsTopicEntries(linkSetList, linkSetTopic);
consultation.addEntry(new ListEntryComponent(new Reference(linkSetTopic)));
topics.add(linkSetTopic);
}
}
use of org.hl7.v3.RCMRMT030101UK04EhrComposition in project nia-patient-switching-standard-adaptor by NHSDigital.
the class ConditionMapper method getCondition.
private Condition getCondition(RCMRMT030101UK04EhrExtract ehrExtract, Patient patient, List<Encounter> encounters, RCMRMT030101UK04EhrComposition composition, RCMRMT030101UK04LinkSet linkSet, String practiseCode) {
String id = linkSet.getId().getRoot();
Condition condition = (Condition) new Condition().addIdentifier(buildIdentifier(id, practiseCode)).addCategory(generateCategory()).setId(id).setMeta(generateMeta(META_PROFILE));
buildClinicalStatus(linkSet.getCode()).ifPresentOrElse(condition::setClinicalStatus, () -> {
condition.setClinicalStatus(ACTIVE);
condition.addNote(new Annotation(new StringType(DEFAULT_CLINICAL_STATUS)));
});
condition.setSubject(new Reference(patient));
condition.addExtension(buildProblemSignificance(linkSet.getCode()));
generateAnnotationToMinor(linkSet.getCode()).ifPresent(condition::addNote);
buildContext(composition, encounters).ifPresent(condition::setContext);
buildOnsetDateTimeType(linkSet).ifPresent(condition::setOnset);
buildAbatementDateTimeType(linkSet.getEffectiveTime()).ifPresent(condition::setAbatement);
buildAssertedDateTimeType(composition).ifPresentOrElse(condition::setAssertedDateElement, () -> condition.setAssertedDateElement(parseToDateTimeType(ehrExtract.getAvailabilityTime().getValue())));
composition.getParticipant2().stream().findFirst().ifPresent(participant2 -> condition.setAsserter(new Reference(new IdType(ResourceType.Practitioner.name(), participant2.getAgentRef().getId().getRoot()))));
return condition;
}
use of org.hl7.v3.RCMRMT030101UK04EhrComposition in project nia-patient-switching-standard-adaptor by NHSDigital.
the class EncounterMapper method getPeriod.
private Period getPeriod(RCMRMT030101UK04EhrComposition ehrComposition) {
Period period = new Period();
var effectiveTime = ehrComposition.getEffectiveTime();
var availabilityTime = ehrComposition.getAvailabilityTime();
if (effectiveTime.hasCenter()) {
return period.setStartElement(DateFormatUtil.parseToDateTimeType(effectiveTime.getCenter().getValue()));
} else if (effectiveTime.hasLow() && effectiveTime.hasHigh()) {
return period.setStartElement(DateFormatUtil.parseToDateTimeType(effectiveTime.getLow().getValue())).setEndElement(DateFormatUtil.parseToDateTimeType(effectiveTime.getHigh().getValue()));
} else if (effectiveTime.hasLow() && !effectiveTime.hasHigh()) {
return period.setStartElement(DateFormatUtil.parseToDateTimeType(effectiveTime.getLow().getValue()));
} else if (!effectiveTime.hasLow() && effectiveTime.hasHigh()) {
return period.setEndElement(DateFormatUtil.parseToDateTimeType(effectiveTime.getHigh().getValue()));
} else if (effectiveTime.getCenter() != null && effectiveTime.getCenter().hasNullFlavor() && CsNullFlavor.UNK.value().equals(effectiveTime.getCenter().getNullFlavor().value())) {
return null;
} else if (availabilityTime.hasValue()) {
return period.setStartElement(DateFormatUtil.parseToDateTimeType(availabilityTime.getValue()));
}
return null;
}
use of org.hl7.v3.RCMRMT030101UK04EhrComposition in project nia-patient-switching-standard-adaptor by NHSDigital.
the class EncounterMapper method generateStructuredConsultation.
private void generateStructuredConsultation(List<RCMRMT030101UK04CompoundStatement> topicCompoundStatementList, RCMRMT030101UK04EhrComposition ehrComposition, ListResource consultation, List<ListResource> topics, List<ListResource> categories) {
topicCompoundStatementList.forEach(topicCompoundStatement -> {
var topic = consultationListMapper.mapToTopic(consultation, topicCompoundStatement);
consultation.addEntry(new ListEntryComponent(new Reference(topic)));
generateCategoryLists(topicCompoundStatement, topic, categories);
generateLinkSetTopicLists(ehrComposition, consultation, topics);
topics.add(topic);
});
}
Aggregations