Search in sources :

Example 31 with Type

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;
}
Also used : AlertType(javafx.scene.control.Alert.AlertType) ButtonType(javafx.scene.control.ButtonType) Type(model.Type) Category(model.Category)

Example 32 with Type

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());
}
Also used : KeyEvent(javafx.scene.input.KeyEvent) Type(model.Type) AlertType(javafx.scene.control.Alert.AlertType) ObservableValue(javafx.beans.value.ObservableValue) RenameClassSchemeCommand(controller.command.RenameClassSchemeCommand) ChangeListener(javafx.beans.value.ChangeListener) Alert(javafx.scene.control.Alert)

Example 33 with Type

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));
}
Also used : Broadcast(org.apache.spark.broadcast.Broadcast) Dataset(org.apache.spark.sql.Dataset) ConceptMaps(com.cerner.bunsen.codes.ConceptMaps) JavaSparkContext(org.apache.spark.api.java.JavaSparkContext) Set(java.util.Set) HashMap(java.util.HashMap) Deque(java.util.Deque) Function(java.util.function.Function) Collectors(java.util.stream.Collectors) Serializable(java.io.Serializable) ArrayList(java.util.ArrayList) HashSet(java.util.HashSet) List(java.util.List) Map(java.util.Map) ConceptMapGroupUnmappedMode(org.hl7.fhir.dstu3.model.ConceptMap.ConceptMapGroupUnmappedMode) ArrayDeque(java.util.ArrayDeque) Collections(java.util.Collections) ConceptMap(org.hl7.fhir.dstu3.model.ConceptMap) Mapping(com.cerner.bunsen.codes.Mapping) SparkSession(org.apache.spark.sql.SparkSession) HashMap(java.util.HashMap) Mapping(com.cerner.bunsen.codes.Mapping) ArrayList(java.util.ArrayList) List(java.util.List) JavaSparkContext(org.apache.spark.api.java.JavaSparkContext) ConceptMap(org.hl7.fhir.dstu3.model.ConceptMap)

Example 34 with Type

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;
}
Also used : Organization(org.hl7.fhir.dstu3.model.Organization) Reference(org.hl7.fhir.dstu3.model.Reference) LocationStatus(org.hl7.fhir.dstu3.model.Location.LocationStatus) Location(org.hl7.fhir.dstu3.model.Location) IdType(org.hl7.fhir.dstu3.model.IdType)

Example 35 with Type

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
}
Also used : ContactPointUse(org.hl7.fhir.dstu3.model.ContactPoint.ContactPointUse) AddressUse(org.hl7.fhir.dstu3.model.Address.AddressUse)

Aggregations

Type (model.Type)14 Type (ca.uhn.hl7v2.model.Type)10 AlertType (javafx.scene.control.Alert.AlertType)8 ArrayList (java.util.ArrayList)5 ButtonType (javafx.scene.control.ButtonType)5 SlotDetail (uk.gov.hscic.model.appointment.SlotDetail)5 HL7Exception (ca.uhn.hl7v2.HL7Exception)4 TypeController (controller.controller.TypeController)4 Property (model.Property)4 IdType (org.hl7.fhir.dstu3.model.IdType)4 Reference (org.hl7.fhir.dstu3.model.Reference)4 Composite (ca.uhn.hl7v2.model.Composite)3 HashMap (java.util.HashMap)3 ChangeListener (javafx.beans.value.ChangeListener)3 ObservableValue (javafx.beans.value.ObservableValue)3 Alert (javafx.scene.control.Alert)3 TreeItem (javafx.scene.control.TreeItem)3 KeyEvent (javafx.scene.input.KeyEvent)3 Category (model.Category)3 IdDt (ca.uhn.fhir.model.primitive.IdDt)2