use of org.hl7.fhir.dstu3.model.IdType in project gpconnect-demonstrator by nhsconnect.
the class SlotResourceProvider method getSlotById.
@Read()
public Slot getSlotById(@IdParam IdType slotId) {
SlotDetail slotDetail = slotSearch.findSlotByID(slotId.getIdPartAsLong());
if (slotDetail == null) {
OperationOutcome operationalOutcome = new OperationOutcome();
operationalOutcome.addIssue().setSeverity(IssueSeverity.ERROR).setDiagnostics("No slot details found for ID: " + slotId.getIdPart());
throw new InternalErrorException("No slot details found for ID: " + slotId.getIdPart(), operationalOutcome);
}
return slotDetailToSlotResourceConverter(slotDetail);
}
use of org.hl7.fhir.dstu3.model.IdType in project gpconnect-demonstrator by nhsconnect.
the class SlotResourceProvider method slotDetailToSlotResourceConverter.
private Slot slotDetailToSlotResourceConverter(SlotDetail slotDetail) {
Slot slot = new Slot();
Date lastUpdated = slotDetail.getLastUpdated() == null ? new Date() : slotDetail.getLastUpdated();
String resourceId = String.valueOf(slotDetail.getId());
String versionId = String.valueOf(lastUpdated.getTime());
String resourceType = slot.getResourceType().toString();
IdType id = new IdType(resourceType, resourceId, versionId);
slot.setId(id);
slot.getMeta().setVersionId(versionId);
slot.getMeta().setLastUpdated(lastUpdated);
slot.getMeta().addProfile(SystemURL.SD_GPC_SLOT);
slot.setIdentifier(Collections.singletonList(new Identifier().setSystem(SystemURL.ID_SDS_USER_ID).setValue(slotDetail.getId().toString())));
Coding coding = new Coding().setSystem(SystemURL.HL7_VS_C80_PRACTICE_CODES).setCode(String.valueOf(slotDetail.getTypeCode())).setDisplay(slotDetail.getTypeDisply());
CodeableConcept codableConcept = new CodeableConcept().addCoding(coding);
codableConcept.setText(slotDetail.getTypeDisply());
List<CodeableConcept> serviceType = new ArrayList<CodeableConcept>();
serviceType.add(codableConcept);
slot.setServiceType(serviceType);
slot.setSchedule(new Reference("Schedule/" + slotDetail.getScheduleReference()));
slot.setStart(slotDetail.getStartDateTime());
slot.setEnd(slotDetail.getEndDateTime());
switch(slotDetail.getFreeBusyType().toLowerCase(Locale.UK)) {
case "free":
slot.setStatus(SlotStatus.FREE);
break;
default:
slot.setStatus(SlotStatus.BUSY);
break;
}
return slot;
}
use of org.hl7.fhir.dstu3.model.IdType in project gpconnect-demonstrator by nhsconnect.
the class LocationResourceProvider method getLocationById.
@Read(version = true)
public Location getLocationById(@IdParam IdType locationId) {
LocationDetails locationDetails = locationSearch.findLocationById(locationId.getIdPart());
if (locationDetails == null) {
throw OperationOutcomeFactory.buildOperationOutcomeException(new ResourceNotFoundException("No location details found for location ID: " + locationId.getIdPart()), SystemCode.REFERENCE_NOT_FOUND, IssueType.INCOMPLETE);
}
Location location = locationDetailsToLocation(locationDetails);
return location;
}
use of org.hl7.fhir.dstu3.model.IdType in project gpconnect-demonstrator by nhsconnect.
the class LocationResourceProvider method locationDetailsToLocation.
private Location locationDetailsToLocation(LocationDetails locationDetails) {
Location location = new Location();
String resourceId = String.valueOf(locationDetails.getId());
String versionId = String.valueOf(locationDetails.getLastUpdated().getTime());
String resourceType = location.getResourceType().toString();
IdType id = new IdType(resourceType, resourceId, versionId);
location.setId(id);
location.getMeta().setVersionId(versionId);
location.getMeta().setLastUpdated(locationDetails.getLastUpdated());
location.getMeta().addProfile(SystemURL.SD_GPC_LOCATION);
location.setName(locationDetails.getName());
location.setIdentifier(Collections.singletonList(new Identifier().setSystem(SystemURL.ID_ODS_SITE_CODE).setValue(locationDetails.getSiteOdsCode())));
Coding locationCommTypeCode = new Coding();
locationCommTypeCode.setCode("COMM");
locationCommTypeCode.setSystem(SystemURL.VS_CC_SER_DEL_LOCROLETYPE);
locationCommTypeCode.setDisplay("Community Location");
Coding locationGachTypeCode = new Coding();
locationGachTypeCode.setCode("GACH");
locationGachTypeCode.setSystem(SystemURL.VS_CC_SER_DEL_LOCROLETYPE);
locationGachTypeCode.setDisplay("Hospitals; General Acute Care Hospital");
@SuppressWarnings("deprecation") CodeableConcept locationType = new CodeableConcept();
locationType.addCoding(locationCommTypeCode);
locationType.addCoding(locationGachTypeCode);
location.setType(locationType);
Organization orgz = FindOrganization(locationDetails.getOrgOdsCode());
if (orgz != null) {
Reference mngOrg = new Reference();
mngOrg.setReference("Organization/" + orgz.getId());
mngOrg.setDisplay(orgz.getName());
location.setManagingOrganization(mngOrg);
}
EnumSet<LocationStatus> statusList = EnumSet.allOf(LocationStatus.class);
LocationStatus locationStatus = null;
String status = locationDetails.getStatus();
if (status != null) {
for (LocationStatus statusItem : statusList) {
if (statusItem.toCode().equalsIgnoreCase(status)) {
locationStatus = statusItem;
break;
}
}
}
location.setAddress(createAddress(locationDetails));
location.setStatus(locationStatus);
return location;
}
use of org.hl7.fhir.dstu3.model.IdType 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());
}
Aggregations