use of org.hl7.fhir.dstu3.model.Type in project uPMT by coco35700.
the class MainViewController method duplicate.
private Category duplicate(Category c) {
Category newc = new Category(c.getName());
newc.setColor(c.getColor());
for (Type t : c.getTypes()) {
newc.addType(t);
}
return newc;
}
use of org.hl7.fhir.dstu3.model.Type in project uPMT by coco35700.
the class TypeTreeViewControllerClass method rename.
@Override
public void rename() {
super.rename();
ChangeListener<Boolean> listener = new ChangeListener<Boolean>() {
@Override
public void changed(ObservableValue<? extends Boolean> arg0, Boolean oldPropertyValue, Boolean newPropertyValue) {
if (!newPropertyValue) {
if (type.getType().isCategory()) {
String oldName = new String(type.getType().getName());
if (!oldName.equals(textField.getText())) {
boolean hasName = false;
// System.out.println("Parent: "+type.getParent().getName());
for (Type classe : type.getParent().getTypes()) {
// System.out.println("Classes: "+classe.getName());
if (classe.getName().equals(textField.getText())) {
hasName = true;
break;
}
}
if (!hasName) {
RenameClassSchemeCommand cmd = new RenameClassSchemeCommand(type.getClassNameController(), oldName, textField.getText(), main);
cmd.execute();
UndoCollector.INSTANCE.add(cmd);
} else {
Alert alert = new Alert(AlertType.INFORMATION);
alert.setTitle(main._langBundle.getString("invalid_name"));
alert.setHeaderText(null);
alert.setContentText(main._langBundle.getString("class_name_invalid"));
alert.show();
}
}
}
typePane.setLeft(nomType);
rename.setDisable(false);
textField.focusedProperty().removeListener(this);
}
}
};
textField.setOnKeyPressed(new EventHandler<KeyEvent>() {
@Override
public void handle(KeyEvent event) {
if (event.getCode() == KeyCode.ENTER) {
if (type.getType().isProperty()) {
textField.setText(textField.getText());
}
typePane.setLeft(nomType);
rename.setDisable(false);
}
if (event.getCode() == KeyCode.ESCAPE) {
typePane.setLeft(nomType);
rename.setDisable(true);
}
}
});
textField.focusedProperty().addListener(listener);
typePane.setLeft(textField);
Platform.runLater(() -> textField.requestFocus());
Platform.runLater(() -> textField.selectAll());
}
use of org.hl7.fhir.dstu3.model.Type in project bunsen by cerner.
the class BroadcastableMappings method broadcast.
/**
* Broadcast mappings stored in the given conceptMaps instance that match the given
* conceptMapUris.
*
* @param conceptMaps the {@link ConceptMaps} instance with the content to broadcast
* @param conceptMapUriToVersion map of the concept map URIs to broadcast to their versions.
* @return a broadcast variable containing a mappings object usable in UDFs.
*/
public static Broadcast<BroadcastableMappings> broadcast(ConceptMaps conceptMaps, Map<String, String> conceptMapUriToVersion) {
Map<String, ConceptMap> mapsToLoad = conceptMaps.getMaps().collectAsList().stream().filter(conceptMap -> conceptMap.getVersion().equals(conceptMapUriToVersion.get(conceptMap.getUrl()))).collect(Collectors.toMap(ConceptMap::getUrl, Function.identity()));
// Expand the concept maps to load and sort them so dependencies are before
// their dependents in the list.
List<String> sortedMapsToLoad = sortMapsToLoad(conceptMapUriToVersion.keySet(), mapsToLoad);
// Since this is used to map from one system to another, we use only targets
// that don't introduce inaccurate meanings. (For instance, we can't map
// general condition code to a more specific type, since that is not
// representative of the source data.)
Dataset<Mapping> mappings = conceptMaps.getMappings(conceptMapUriToVersion).filter("equivalence in ('equivalent', 'equals', 'wider', 'subsumes')");
// Group mappings by their concept map URI
Map<String, List<Mapping>> groupedMappings = mappings.collectAsList().stream().collect(Collectors.groupingBy(Mapping::getConceptMapUri));
Map<String, BroadcastableConceptMap> broadcastableMaps = new HashMap<>();
for (String conceptMapUri : sortedMapsToLoad) {
ConceptMap map = mapsToLoad.get(conceptMapUri);
Set<String> children = getMapChildren(map);
List<BroadcastableConceptMap> childMaps = children.stream().map(child -> broadcastableMaps.get(child)).collect(Collectors.toList());
BroadcastableConceptMap broadcastableConceptMap = new BroadcastableConceptMap(conceptMapUri, groupedMappings.getOrDefault(conceptMapUri, Collections.emptyList()), childMaps);
broadcastableMaps.put(conceptMapUri, broadcastableConceptMap);
}
JavaSparkContext ctx = new JavaSparkContext(conceptMaps.getMaps().sparkSession().sparkContext());
return ctx.broadcast(new BroadcastableMappings(broadcastableMaps));
}
use of org.hl7.fhir.dstu3.model.Type in project gpconnect-demonstrator by nhsconnect.
the class LocationResourceProvider method locationDetailsToLocation.
/**
* convert locationDetails to fhir resource
* @param locationDetails
* @return Location resource
*/
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());
// #207 no site code
// location.setIdentifier(Collections.singletonList(new Identifier().setSystem(SystemURL.ID_ODS_SITE_CODE).setValue(locationDetails.getSiteOdsCode())));
// #246 remove type element
// 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(orgz.getId());
// #246 remove display element
// 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.Type in project gpconnect-demonstrator by nhsconnect.
the class PatientResourceProvider method validateTelecomAndAddress.
private void validateTelecomAndAddress(Patient patient) {
// 0..1 of phone - (not nec. temp), 0..1 of email
HashSet<ContactPointUse> phoneUse = new HashSet<>();
int emailCount = 0;
for (ContactPoint telecom : patient.getTelecom()) {
if (telecom.hasSystem()) {
if (telecom.getSystem() != null) {
switch(telecom.getSystem()) {
case PHONE:
if (telecom.hasUse()) {
switch(telecom.getUse()) {
case HOME:
case WORK:
case MOBILE:
case TEMP:
if (!phoneUse.contains(telecom.getUse())) {
phoneUse.add(telecom.getUse());
} else {
throwInvalidRequest400_BadRequestException("Only one Telecom of type phone with use type " + telecom.getUse().toString().toLowerCase() + " is allowed in a register patient request.");
}
break;
default:
throwInvalidRequest400_BadRequestException("Invalid Telecom of type phone use type " + telecom.getUse().toString().toLowerCase() + " in a register patient request.");
}
} else {
throwInvalidRequest400_BadRequestException("Invalid Telecom - no Use type provided in a register patient request.");
}
break;
case EMAIL:
if (++emailCount > 1) {
throwInvalidRequest400_BadRequestException("Only one Telecom of type " + "email" + " is allowed in a register patient request.");
}
break;
default:
throwInvalidRequest400_BadRequestException("Telecom system is missing in a register patient request.");
}
}
} else {
throwInvalidRequest400_BadRequestException("Telecom system is missing in a register patient request.");
}
}
// iterate telcom
// count by useType - Only the first address is persisted at present
HashSet<AddressUse> useTypeCount = new HashSet<>();
for (Address address : patient.getAddress()) {
AddressUse useType = address.getUse();
// #189 address use types work and old are not allowed
if (useType == WORK || useType == OLD) {
throwUnprocessableEntity422_InvalidResourceException("Address use type " + useType + " cannot be sent in a register patient request.");
}
if (!useTypeCount.contains(useType)) {
useTypeCount.add(useType);
} else {
// #174 Only a single address of each usetype may be sent
throwUnprocessableEntity422_InvalidResourceException("Only a single address of each use type can be sent in a register patient request.");
}
}
// for address
}
Aggregations