use of uk.gov.hscic.model.organization.OrganizationDetails in project gpconnect-demonstrator by nhsconnect.
the class OrganizationEntityToObjectTransformer method transform.
@Override
public OrganizationDetails transform(final OrganizationEntity organizationEntity) {
OrganizationDetails organization = new OrganizationDetails();
organization.setId(organizationEntity.getId());
organization.setOrgCode(organizationEntity.getOrgCode());
organization.setOrgName(organizationEntity.getOrgName());
organization.setLastUpdated(organizationEntity.getLastUpdated());
return organization;
}
use of uk.gov.hscic.model.organization.OrganizationDetails in project gpconnect-demonstrator by nhsconnect.
the class OrganizationResourceProvider method convertOrganizaitonDetailsListToOrganizationList.
private List<Organization> convertOrganizaitonDetailsListToOrganizationList(List<OrganizationDetails> organizationDetails) {
Map<String, Organization> map = new HashMap<>();
for (OrganizationDetails organizationDetail : organizationDetails) {
String mapKey = String.format("%s", organizationDetail.getOrgCode());
if (map.containsKey(mapKey)) {
continue;
}
Identifier identifier = new Identifier().setSystem(SystemURL.ID_ODS_ORGANIZATION_CODE).setValue(organizationDetail.getOrgCode());
Organization organization = new Organization().setName(organizationDetail.getOrgName()).addIdentifier(identifier);
String resourceId = String.valueOf(organizationDetail.getId());
String versionId = String.valueOf(organizationDetail.getLastUpdated().getTime());
String resourceType = organization.getResourceType().toString();
IdType id = new IdType(resourceType, resourceId, versionId);
organization.setId(id);
organization.getMeta().setVersionId(versionId);
organization.getMeta().setLastUpdated(organizationDetail.getLastUpdated());
organization.getMeta().addProfile(SystemURL.SD_GPC_ORGANIZATION);
organization = addAdditionalProperties(organization);
map.put(mapKey, organization);
}
return new ArrayList<>(map.values());
}
use of uk.gov.hscic.model.organization.OrganizationDetails in project gpconnect-demonstrator by nhsconnect.
the class OrganizationResourceProvider method getOrganizationById.
@Read(version = true)
public Organization getOrganizationById(@IdParam IdType organizationId) {
OrganizationDetails organizationDetails = null;
String idPart = organizationId.getIdPart();
try {
Long id = Long.parseLong(idPart);
organizationDetails = organizationSearch.findOrganizationDetails(id);
if (organizationDetails == null) {
throw OperationOutcomeFactory.buildOperationOutcomeException(new ResourceNotFoundException("No organization details found for organization ID: " + idPart), SystemCode.ORGANISATION_NOT_FOUND, IssueType.INVALID);
}
} catch (NumberFormatException nfe) {
throw OperationOutcomeFactory.buildOperationOutcomeException(new ResourceNotFoundException("No organization details found for organization ID: " + idPart), SystemCode.ORGANISATION_NOT_FOUND, IssueType.INVALID);
}
return IdentifierValidator.versionComparison(organizationId, convertOrganizaitonDetailsListToOrganizationList(Collections.singletonList(organizationDetails)).get(0));
}
use of uk.gov.hscic.model.organization.OrganizationDetails in project gpconnect-demonstrator by nhsconnect.
the class PopulateSlotBundle method populateBundle.
public void populateBundle(Bundle bundle, OperationOutcome operationOutcome, Date planningHorizonStart, Date planningHorizonEnd, boolean actorPractitioner, boolean actorLocation, String bookingOdsCode, String bookingOrgType) {
bundle.getMeta().addProfile(SystemURL.SD_GPC_SRCHSET_BUNDLE);
List<Location> locations = locationResourceProvider.getAllLocationDetails();
BundleEntryComponent locationEntry = new BundleEntryComponent();
locationEntry.setResource(locations.get(0));
locationEntry.setFullUrl("Location/" + locations.get(0).getIdElement().getIdPart());
// find the organization from the ods code
List<OrganizationDetails> organizations = organizationSearch.findOrganizationDetailsByOrgODSCode(bookingOdsCode);
// schedules
List<Schedule> schedules = scheduleResourceProvider.getSchedulesForLocationId(locations.get(0).getIdElement().getIdPart(), planningHorizonStart, planningHorizonEnd);
if (!schedules.isEmpty()) {
for (Schedule schedule : schedules) {
schedule.getMeta().addProfile(SystemURL.SD_GPC_SCHEDULE);
BundleEntryComponent scheduleEntry = new BundleEntryComponent();
scheduleEntry.setResource(schedule);
scheduleEntry.setFullUrl("Schedule/" + schedule.getIdElement().getIdPart());
// practitioners
List<Reference> practitionerActors = scheduleResourceProvider.getPractitionerReferences(schedule);
if (!practitionerActors.isEmpty()) {
for (Reference practitionerActor : practitionerActors) {
Practitioner practitioner = practitionerResourceProvider.getPractitionerById((IdType) practitionerActor.getReferenceElement());
if (practitioner == null) {
Coding errorCoding = new Coding().setSystem(SystemURL.VS_GPC_ERROR_WARNING_CODE).setCode(SystemCode.REFERENCE_NOT_FOUND);
CodeableConcept errorCodableConcept = new CodeableConcept().addCoding(errorCoding);
errorCodableConcept.setText("Invalid Reference");
operationOutcome.addIssue().setSeverity(IssueSeverity.ERROR).setCode(IssueType.NOTFOUND).setDetails(errorCodableConcept);
throw new ResourceNotFoundException("Practitioner Reference returning null");
}
if (actorPractitioner == true) {
BundleEntryComponent practionerEntry = new BundleEntryComponent();
practionerEntry.setResource(practitioner);
practionerEntry.setFullUrl("Practitioner/" + practitioner.getIdElement().getIdPart());
bundle.addEntry(practionerEntry);
}
}
}
Set<Slot> slots = new HashSet<Slot>();
if (!organizations.isEmpty()) {
slots.addAll(slotResourceProvider.getSlotsForScheduleIdAndOrganizationId(schedule.getIdElement().getIdPart(), planningHorizonStart, planningHorizonEnd, organizations.get(0).getId()));
}
slots.addAll(slotResourceProvider.getSlotsForScheduleIdAndOrganizationType(schedule.getIdElement().getIdPart(), planningHorizonStart, planningHorizonEnd, bookingOrgType));
String freeBusyType = "FREE";
if (!slots.isEmpty()) {
for (Slot slot : slots) {
if (freeBusyType.equalsIgnoreCase(slot.getStatus().toString())) {
BundleEntryComponent slotEntry = new BundleEntryComponent();
slotEntry.setResource(slot);
slotEntry.setFullUrl("Slot/" + slot.getIdElement().getIdPart());
bundle.addEntry(slotEntry);
bundle.addEntry(scheduleEntry);
if (actorLocation == true) {
bundle.addEntry(locationEntry);
}
}
}
}
}
}
}
Aggregations