use of org.hl7.fhir.dstu3.model.QuestionnaireResponse in project Gravity-SDOH-Exchange-RI by FHIR.
the class ConvertService method convertToBundle.
private String convertToBundle(JSONObject questionnaireResponse, String mapUri) {
try (ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream()) {
Element element = validationEngine.transform(questionnaireResponse.toString().getBytes(), Manager.FhirFormat.JSON, mapUri);
new JsonParser(validationEngine.getContext()).compose(element, byteArrayOutputStream, org.hl7.fhir.r5.formats.IParser.OutputStyle.PRETTY, null);
return byteArrayOutputStream.toString();
} catch (IOException e) {
throw new IllegalStateException("QuestionnaireResponse with id cannot be parsed.", e.getCause());
}
}
use of org.hl7.fhir.dstu3.model.QuestionnaireResponse in project Gravity-SDOH-Exchange-RI by FHIR.
the class PatientTaskService method addQuestionnaireResponsesToTaskBundle.
private void addQuestionnaireResponsesToTaskBundle(Bundle responseBundle) {
FhirUtil.getFromBundle(responseBundle, Task.class, Bundle.SearchEntryMode.MATCH).stream().filter(Task::hasOutput).flatMap(t -> t.getOutput().stream()).forEach(c -> {
Coding coding = FhirUtil.findCoding(Lists.newArrayList(c.getType()), SDCTemporaryCode.SYSTEM, SDCTemporaryCode.QUESTIONNAIRE_RESPONSE.getCode());
if (coding != null) {
String questionnaireResponseId = ((Reference) c.getValue()).getReferenceElement().getIdPart();
Bundle questionnaireResponse = ehrClient.search().forResource(QuestionnaireResponse.class).where(BaseResource.RES_ID.exactly().codes(questionnaireResponseId)).returnBundle(Bundle.class).execute();
FhirUtil.mergeBundles(ehrClient.getFhirContext(), responseBundle, questionnaireResponse);
}
});
}
use of org.hl7.fhir.dstu3.model.QuestionnaireResponse in project Gravity-SDOH-Exchange-RI by FHIR.
the class AssessmentService method search.
public AssessmentDto search(String questionnaireUrl) {
Assert.notNull(SmartOnFhirContext.get().getPatient(), "Patient id cannot be null.");
Bundle responseBundle = searchAssessmentQuery().where(QuestionnaireResponse.QUESTIONNAIRE.hasId(questionnaireUrl)).returnBundle(Bundle.class).execute();
responseBundle = addQuestionnairesToAssessmentBundle(responseBundle);
return new AssessmentBundleToDtoConverter().convert(responseBundle).stream().findFirst().orElseThrow(() -> new ResourceNotFoundException(String.format("Resource of type QuestionnaireResponse with " + "questionnaire url '%s' is not known", questionnaireUrl)));
}
use of org.hl7.fhir.dstu3.model.QuestionnaireResponse in project integration-adaptor-111 by nhsconnect.
the class CompositionMapper method mapComposition.
public Composition mapComposition(POCDMT000002UK01ClinicalDocument1 clinicalDocument, Encounter encounter, List<CarePlan> carePlans, List<QuestionnaireResponse> questionnaireResponseList, ReferralRequest referralRequest, List<PractitionerRole> practitionerRoles) {
Composition composition = new Composition();
composition.setIdElement(resourceUtil.newRandomUuid());
Identifier docIdentifier = new Identifier();
docIdentifier.setUse(USUAL);
docIdentifier.setValue(clinicalDocument.getSetId().getRoot());
composition.setTitle(COMPOSITION_TITLE).setType(createCodeableConcept()).setStatus(FINAL).setEncounter(resourceUtil.createReference(encounter)).setSubject(encounter.getSubject()).setDateElement(DateUtil.parse(clinicalDocument.getEffectiveTime().getValue())).setIdentifier(docIdentifier);
if (clinicalDocument.getConfidentialityCode().isSetCode()) {
composition.setConfidentiality(Composition.DocumentConfidentiality.valueOf(clinicalDocument.getConfidentialityCode().getCode()));
}
if (isNotEmpty(clinicalDocument.getRelatedDocumentArray()) && clinicalDocument.getRelatedDocumentArray(0).getParentDocument().getIdArray(0).isSetRoot()) {
Identifier relatedDocIdentifier = new Identifier();
relatedDocIdentifier.setUse(USUAL);
relatedDocIdentifier.setValue(clinicalDocument.getRelatedDocumentArray(0).getParentDocument().getIdArray(0).getRoot());
composition.addRelatesTo().setCode(Composition.DocumentRelationshipType.REPLACES).setTarget(relatedDocIdentifier);
}
practitionerRoles.stream().forEach(it -> composition.addAuthor(it.getPractitioner()));
if (clinicalDocument.getComponent().isSetStructuredBody()) {
for (POCDMT000002UK01Component3 component3 : clinicalDocument.getComponent().getStructuredBody().getComponentArray()) {
SectionComponent sectionComponent = new SectionComponent();
addSectionChildren(sectionComponent, component3.getSection());
composition.addSection(sectionComponent);
}
}
for (CarePlan carePlan : carePlans) {
composition.addSection(buildSectionComponentFromResource(carePlan));
}
if (!referralRequest.isEmpty()) {
composition.addSection(buildSectionComponentFromResource(referralRequest));
}
if (questionnaireResponseList != null) {
addPathwaysToSection(composition, questionnaireResponseList);
}
return composition;
}
use of org.hl7.fhir.dstu3.model.QuestionnaireResponse in project integration-adaptor-111 by nhsconnect.
the class CompositionMapperTest method setUp.
@BeforeEach
public void setUp() {
effectiveTime.setValue(EFFECTIVE_DATE);
questionnaireResponseList = new ArrayList<>();
questionnaireResponseList.add(questionnaireResponse);
POCDMT000002UK01RelatedDocument1[] relatedDocsArray = { mock(POCDMT000002UK01RelatedDocument1.class) };
when(clinicalDocument.getRelatedDocumentArray()).thenReturn(relatedDocsArray);
when(clinicalDocument.getRelatedDocumentArray(0)).thenReturn(relatedDocument1);
when(relatedDocument1.getParentDocument()).thenReturn(parentDocument1);
when(parentDocument1.getIdArray(0)).thenReturn(ii);
when(clinicalDocument.getSetId()).thenReturn(ii);
when(clinicalDocument.getEffectiveTime()).thenReturn(effectiveTime);
when(ii.getRoot()).thenReturn("411910CF-1A76-4330-98FE-C345DDEE5553");
when(clinicalDocument.getConfidentialityCode()).thenReturn(ce);
when(ce.getCode()).thenReturn("V");
when(ce.isSetCode()).thenReturn(true);
when(ii.isSetRoot()).thenReturn(true);
when(referralRequest.fhirType()).thenReturn("ReferralRequest");
when(resourceUtil.newRandomUuid()).thenReturn(new IdType(RANDOM_UUID));
when(resourceUtil.createReference(encounter)).thenReturn(new Reference(encounter));
when(resourceUtil.createReference(questionnaireResponse)).thenReturn(new Reference(questionnaireResponse));
when(resourceUtil.createReference(carePlan)).thenReturn(new Reference(carePlan));
when(resourceUtil.createReference(referralRequest)).thenReturn(new Reference(referralRequest));
mockStructuredBody();
}
Aggregations