use of org.hl7.fhir.dstu3.model.Bundle in project gpconnect-demonstrator by nhsconnect.
the class SlotResourceProvider method getSlotByIds.
@Search
public Bundle getSlotByIds(@RequiredParam(name = "start") DateParam startDate, @RequiredParam(name = "end") DateParam endDate, @RequiredParam(name = "status") String status, @OptionalParam(name = "searchFilter") TokenAndListParam searchFilters, @IncludeParam(allow = { "Slot:schedule", "Schedule:actor:Practitioner", "Schedule:actor:Location", "Location:managingOrganization" }) Set<Include> theIncludes) {
boolean foundSchedule = false;
for (Include anInclude : theIncludes) {
// getParamName returns any text between the first and second colons
if (anInclude.getParamName().equals("schedule")) {
foundSchedule = true;
break;
}
}
if (!foundSchedule) {
// TODO check not invalid parameter?
throwInvalidRequest400_BadRequestException("No include Slot:schedule parameter has been provided");
}
Bundle bundle = new Bundle();
String bookingOdsCode = "";
String bookingOrgType = "";
if (!status.equals("free")) {
throwUnprocessableEntityInvalid422_ParameterException("Status incorrect: Must be equal to free");
}
try {
startDate.isEmpty();
endDate.isEmpty();
} catch (Exception e) {
throwUnprocessableEntityInvalid422_ParameterException("Start Date and End Date must be populated with a correct date format");
}
if (startDate.getPrefix() != ParamPrefixEnum.GREATERTHAN_OR_EQUALS || endDate.getPrefix() != ParamPrefixEnum.LESSTHAN_OR_EQUALS) {
throwUnprocessableEntityInvalid422_ParameterException("Invalid Prefix used");
}
validateStartDateParamAndEndDateParam(startDate, endDate);
if (searchFilters != null) {
List<TokenOrListParam> searchFilter = searchFilters.getValuesAsQueryTokens();
for (TokenOrListParam filter : searchFilter) {
TokenParam token = filter.getValuesAsQueryTokens().get(0);
if (token.getSystem().equals(SystemURL.VS_GPC_ORG_TYPE)) {
bookingOrgType = token.getValue();
}
if (token.getSystem().equals(SystemURL.ID_ODS_ORGANIZATION_CODE)) {
bookingOdsCode = token.getValue();
}
}
}
boolean actorPractitioner = false;
boolean actorLocation = false;
boolean managingOrganisation = false;
for (Include include : theIncludes) {
switch(include.getValue()) {
case "Schedule:actor:Practitioner":
actorPractitioner = true;
break;
case "Schedule:actor:Location":
actorLocation = true;
break;
case "Location:managingOrganization":
managingOrganisation = true;
break;
}
}
startDate.getValueAsInstantDt().getValue();
getScheduleOperation.populateBundle(bundle, new OperationOutcome(), startDate.getValueAsInstantDt().getValue(), endDate.getValueAsInstantDt().getValue(), actorPractitioner, actorLocation, managingOrganisation, bookingOdsCode, bookingOrgType);
return bundle;
}
use of org.hl7.fhir.dstu3.model.Bundle in project bunsen by cerner.
the class FunctionsTest method bundleToJson.
@Test
public void bundleToJson() {
String jsonBundle = Functions.toJsonBundle(conditions);
Bundle bundle = (Bundle) CONTEXT.newJsonParser().parseResource(jsonBundle);
Condition parsedCondition = (Condition) bundle.getEntryFirstRep().getResource();
Assert.assertEquals(condition.getId(), parsedCondition.getId());
}
use of org.hl7.fhir.dstu3.model.Bundle in project bunsen by cerner.
the class Functions method toBundle.
/**
* Returns a bundle containing all resources in the dataset. This should be used
* with caution for large datasets, since the returned bundle will include all data.
*
* @param dataset a dataset of FHIR resoruces
* @return a bundle containing those resources.
*/
public static Bundle toBundle(Dataset<? extends Resource> dataset) {
List<Resource> resources = (List<Resource>) dataset.collectAsList();
Bundle bundle = new Bundle();
for (Resource resource : resources) {
bundle.addEntry().setResource(resource);
}
return bundle;
}
use of org.hl7.fhir.dstu3.model.Bundle in project loinc2hpo by monarch-initiative.
the class ObservationDownloader method retrieveObservation.
static List<Observation> retrieveObservation(String loincCode) {
List<Observation> results = new ArrayList<>();
Bundle bundle = client.search().forResource(Observation.class).where(new TokenClientParam("code").exactly().systemAndCode(LOINC_SYSTEM, loincCode)).prettyPrint().returnBundle(Bundle.class).execute();
while (true) {
for (Bundle.BundleEntryComponent bundleEntryComponent : bundle.getEntry()) {
Observation observation = (Observation) bundleEntryComponent.getResource();
results.add(observation);
}
if (bundle.getLink(IBaseBundle.LINK_NEXT) != null) {
bundle = client.loadPage().next(bundle).execute();
} else {
break;
}
}
return results;
}
use of org.hl7.fhir.dstu3.model.Bundle in project loinc2hpo by monarch-initiative.
the class ObservationDownloader method retrievePatient.
static List<Patient> retrievePatient(String given, String family) {
List<Patient> patients = new ArrayList<>();
Bundle bundle = client.search().forResource(Patient.class).where(new StringClientParam("given").matches().value(given)).where(new StringClientParam("family").matches().value(family)).prettyPrint().returnBundle(Bundle.class).execute();
while (true) {
for (Bundle.BundleEntryComponent bundleEntryComponent : bundle.getEntry()) {
Patient patient = (Patient) bundleEntryComponent.getResource();
patients.add(patient);
}
if (bundle.getLink(IBaseBundle.LINK_NEXT) != null) {
bundle = client.loadPage().next(bundle).execute();
} else {
break;
}
}
return patients;
}
Aggregations