use of org.hl7.fhir.r5.model.CanonicalType in project cqf-ruler by DBCG.
the class ExpressionEvaluation method cleanReferences.
private List<CanonicalType> cleanReferences(List<CanonicalType> references) {
List<CanonicalType> cleanRefs = new ArrayList<>();
List<CanonicalType> noDupes = new ArrayList<>();
for (CanonicalType reference : references) {
boolean dup = false;
for (CanonicalType ref : noDupes) {
if (ref.equalsDeep(reference)) {
dup = true;
}
}
if (!dup) {
noDupes.add(reference);
}
}
for (CanonicalType reference : noDupes) {
cleanRefs.add(new CanonicalType(reference.getValue().replace("#", "")));
}
return cleanRefs;
}
use of org.hl7.fhir.r5.model.CanonicalType in project cqf-ruler by DBCG.
the class CanonicalsTest method partialCanonicalType.
@Test
public void partialCanonicalType() {
CanonicalType testUrl = new CanonicalType("http://fhir.acme.com/Questionnaire/example");
assertEquals("http://fhir.acme.com/Questionnaire/example", Canonicals.getUrl(testUrl));
assertEquals("Questionnaire", Canonicals.getResourceType(testUrl));
assertEquals("example", Canonicals.getIdPart(testUrl));
assertNull(Canonicals.getVersion(testUrl));
assertNull(Canonicals.getFragment(testUrl));
}
use of org.hl7.fhir.r5.model.CanonicalType in project cqf-ruler by DBCG.
the class CanonicalsTest method fullCanonicalType.
@Test
public void fullCanonicalType() {
CanonicalType testUrl = new CanonicalType("http://fhir.acme.com/Questionnaire/example|1.0#vs1");
assertEquals("http://fhir.acme.com/Questionnaire/example", Canonicals.getUrl(testUrl));
assertEquals("example", Canonicals.getIdPart(testUrl));
assertEquals("1.0", Canonicals.getVersion(testUrl));
assertEquals("vs1", Canonicals.getFragment(testUrl));
}
use of org.hl7.fhir.r5.model.CanonicalType in project Gravity-SDOH-Exchange-RI by FHIR.
the class PatientTaskService method addQuestionnairesToTaskBundle.
private void addQuestionnairesToTaskBundle(Bundle responseBundle) {
// Extract all 'addresses' references as ids and search for corresponding Conditions, since they cannot be included.
List<String> urls = FhirUtil.getFromBundle(responseBundle, Task.class, Bundle.SearchEntryMode.MATCH).stream().map(t -> t.getInput().stream().filter(i -> SDCTemporaryCode.QUESTIONNAIRE.getCode().equals(i.getType().getCodingFirstRep().getCode())).findAny().orElse(null)).filter(Objects::nonNull).filter(i -> i.getValue() instanceof CanonicalType).map(i -> ((CanonicalType) i.getValue()).getValue()).collect(Collectors.toList());
Bundle questionnaires = ehrClient.search().forResource(Questionnaire.class).where(Questionnaire.URL.matches().values(urls)).returnBundle(Bundle.class).execute();
FhirUtil.mergeBundles(ehrClient.getFhirContext(), responseBundle, questionnaires);
}
use of org.hl7.fhir.r5.model.CanonicalType in project Gravity-SDOH-Exchange-RI by FHIR.
the class ConvertService method convert.
public Map<String, Object> convert(JSONObject questionnaireResponse) throws IOException {
QuestionnaireResponse qs = (QuestionnaireResponse) fhirContext.newJsonParser().parseResource(questionnaireResponse.toString());
if (qs.getQuestionnaire() == null) {
throw new IllegalStateException(String.format("QuestionnaireResponse '%s' does not contain a link to a Questionnaire.", qs.getIdElement().getIdPart()));
}
Optional<Questionnaire> foundQuestionnaire = questionnaireRepository.findByCanonnicalUri(qs.getQuestionnaire());
if (!foundQuestionnaire.isPresent()) {
throw new ResourceNotFoundException(String.format("Questionnaire was not found by URL '%s'.", qs.getQuestionnaire()));
}
Questionnaire questionnaire = foundQuestionnaire.get();
String mapUri = ((CanonicalType) questionnaire.getExtensionByUrl(MAP_EXTENSION).getValue()).getValueAsString();
boolean mapExists = validationEngine.getContext().listTransforms().stream().anyMatch(map -> map.getUrl().equals(mapUri));
if (!mapExists) {
loadMapIg(mapUri);
}
return new ObjectMapper().readValue(convertToBundle(questionnaireResponse, mapUri), Map.class);
}
Aggregations