Search in sources :

Example 51 with Account

use of org.hl7.fhir.dstu3.model.Account in project project_internship by phamthao8383.

the class UserServlet method updatePassword.

private void updatePassword(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
    response.setContentType("text/html;charset=UTF8");
    int idUser = Integer.parseInt(request.getParameter("idUser"));
    String account = request.getParameter("nameAccount");
    System.out.println(account);
    String password = request.getParameter("password");
    System.out.println(password);
    String ps1 = request.getParameter("newPassword");
    ps1 = passwordEncryption.encrypt(ps1);
    String ps2 = request.getParameter("confirmPassword");
    ps2 = passwordEncryption.encrypt(ps2);
    Account acc = accountService.CheckLogIn(account, password);
    System.out.println(acc.getUsername());
    if (acc.getUsername() != null) {
        accountService.editPassword(account, ps1);
        System.out.println("da doi mat khau");
        goGetInfo(request, response);
    } else {
        System.out.println("Chua doi mat khau");
        request.setAttribute("checkPassword", 0);
        goGetInfo(request, response);
    }
}
Also used : Account(model.Account) HandleString(util.HandleString)

Example 52 with Account

use of org.hl7.fhir.dstu3.model.Account in project project_internship by phamthao8383.

the class UserServlet method createNewAccount.

private void createNewAccount(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
    // response.setContentType("text/html;charset=UTF8");
    response.setContentType("text/html; charset=UTF-8");
    request.setCharacterEncoding("UTF-8");
    String nameAccount = request.getParameter("nameAccount");
    // List<Account> accountList = accountService.CheckAccount(nameAccount);
    // request.setAttribute("accountList", accountList);
    String name = request.getParameter("name");
    if (name != null && name != "") {
        name = handleString.handleFont(name);
        name = handleString.handleName(name);
    }
    String ps1 = request.getParameter("passw");
    String ps2 = request.getParameter("con_passw");
    ps1 = passwordEncryption.encrypt(ps1);
    String email = request.getParameter("email");
    String address = request.getParameter("address");
    address = handleString.handleFont(address);
    String phone = request.getParameter("phone");
    boolean isExist = isExistAccount(nameAccount);
    if (isExist) {
        request.setAttribute("isExist", true);
        System.out.println("Trùng tên account!!");
        goLogin(request, response);
        return;
    // 
    // accountList = null;
    } else {
        User user = new User(name, email, phone, address, "img", nameAccount);
        Account account1 = new Account(nameAccount, ps1, 2);
        accountService.AddAccount(account1);
        userService.addUserList(user);
        request.setAttribute("isExist", false);
        goLogin(request, response);
    }
}
Also used : Account(model.Account) User(model.User) HandleString(util.HandleString)

Example 53 with Account

use of org.hl7.fhir.dstu3.model.Account in project project_internship by phamthao8383.

the class AccountRepository method CheckLogIn.

public Account CheckLogIn(String userAccount, String password) {
    Account account = new Account();
    try {
        password = passwordEncryption.encrypt(password);
        String myQuery = "SELECT `account`.username, password, role_id  FROM `account` inner join user_role on `account`.username = user_role.username where `account`.username = ? and password = ?";
        PreparedStatement preparedStatement = this.baseRepository.getConnection().prepareStatement(myQuery);
        preparedStatement.setString(1, userAccount);
        preparedStatement.setString(2, password);
        ResultSet rs = preparedStatement.executeQuery();
        while (rs.next()) {
            account = new Account(rs.getString(1), rs.getString(2), rs.getInt(3));
        }
    } catch (SQLException e) {
        e.printStackTrace();
    }
    return account;
}
Also used : Account(model.Account) SQLException(java.sql.SQLException) ResultSet(java.sql.ResultSet) PreparedStatement(java.sql.PreparedStatement)

Example 54 with Account

use of org.hl7.fhir.dstu3.model.Account in project kindling by HL7.

the class ExampleAdorner method getState.

@Override
public XhtmlGeneratorAdornerState getState(XhtmlGenerator ref, XhtmlGeneratorAdornerState state, Element node) throws Exception {
    if (state == null) {
        if (node == null)
            return new ExampleAdornerState(State.Unknown, "", null, "", "");
        else if (definitions.hasResource(node.getLocalName()))
            return new ExampleAdornerState(State.Element, node.getLocalName(), definitions.getResourceByName(node.getLocalName()).getRoot(), "", "");
        else
            return new ExampleAdornerState(State.Unknown, "", null, "", "");
    } else {
        ExampleAdornerState s = (ExampleAdornerState) state;
        if (s.getState() == State.Element) {
            if (s.definition == null) {
                System.out.println("??");
            }
            if (// account for extra element
            s.definition != null && "Resource".equals(s.definition.typeCode()) && (s.getPath().endsWith(".entry.resource") || s.getPath().endsWith(".contained")) && definitions.isResource(node.getNodeName()))
                return new ExampleAdornerState(State.Element, s.getPath(), definitions.getResourceByName(node.getNodeName()).getRoot(), "", "");
            String p = s.getPath() + "." + node.getNodeName();
            ElementDefn e = s.getDefinition().getElementByName(node.getLocalName(), true, definitions, "adorn example", false);
            if (e == null && definitions.hasElementDefn(s.getDefinition().typeCodeNoParams())) {
                // well, we see if it's inherited...
                ElementDefn t = definitions.getElementDefn(s.getDefinition().typeCodeNoParams());
                while (t != null && e == null) {
                    e = t.getElementByName(node.getLocalName(), true, definitions, "adorn example", false);
                    if (e != null)
                        p = t.getName() + "." + e.getName();
                    else if (definitions.hasElementDefn(t.typeCodeNoParams()))
                        t = definitions.getElementDefn(t.typeCodeNoParams());
                    else
                        t = null;
                }
            } else if (e != null)
                p = s.getPath() + "." + e.getName();
            if (e == null)
                return new ExampleAdornerState(State.Unknown, s.getPath(), null, "", "");
            if (!e.isBaseResourceElement() && e.typeCode().contains("Reference") && !e.typeCode().contains("CodeableReference"))
                return new ExampleAdornerState(State.Reference, p, e, "", "");
            else if (!e.isBaseResourceElement() && e.typeCode().contains("canonical"))
                return new ExampleAdornerState(State.Reference, p, e, "", "");
            else if (!e.isBaseResourceElement() && e.typeCode().equals("uri"))
                return new ExampleAdornerState(State.Reference, p, e, "", "");
            else
                return new ExampleAdornerState(State.Element, p, e, "", "");
        } else if (s.getState() == State.Reference) {
            if (node.getLocalName().equals("reference")) {
                String type = extractType(node.getAttribute("value"));
                String id = extractId(node.getAttribute("value"), type);
                if (id == null)
                    return new ExampleAdornerState(State.Element, s.getPath() + ".reference", null, "", "");
                ResourceDefn r = definitions.getResourceByName(type);
                if (r == null)
                    throw new Exception("unable to find type " + type);
                for (Example e : r.getExamples()) {
                    if (id.equals(e.getId()))
                        if (Utilities.noString(e.getIg())) {
                            return new ExampleAdornerState(State.Reference, s.getPath() + ".reference", s.getDefinition(), "<a href=\"" + prefix + e.getTitle() + ".xml.html\">", "</a>");
                        } else {
                            ImplementationGuideDefn ig = definitions.getIgs().get(e.getIg());
                            return new ExampleAdornerState(State.Reference, s.getPath() + ".reference", s.getDefinition(), "<a href=\"" + prefix + ig.getPrefix() + e.getTitle() + ".xml.html\">", "</a>");
                        }
                    if (e.getXml() != null && e.getXml().getDocumentElement().getLocalName().equals("feed")) {
                        List<Element> entries = new ArrayList<Element>();
                        XMLUtil.getNamedChildren(e.getXml().getDocumentElement(), "entry", entries);
                        String url = "http://hl7.org/fhir/" + type + "/" + id;
                        for (Element c : entries) {
                            String t = XMLUtil.getNamedChild(c, "id").getAttribute("value");
                            if (url.equals(t))
                                return new ExampleAdornerState(State.Reference, s.getPath() + ".reference", s.getDefinition(), "<a href=\"" + prefix + e.getTitle() + ".xml.html#" + id + "\">", "</a>");
                        }
                    }
                }
                return new ExampleAdornerState(State.Reference, s.getPath() + ".reference", s.getDefinition(), "<font color=\"red\">", "</font>");
            } else
                return new ExampleAdornerState(State.Reference, s.getPath(), s.getDefinition(), "", "");
        } else
            // else
            return new ExampleAdornerState(State.Unknown, s.getPath(), null, "", "");
    }
}
Also used : Example(org.hl7.fhir.definitions.model.Example) Element(org.w3c.dom.Element) ElementDefn(org.hl7.fhir.definitions.model.ElementDefn) ArrayList(java.util.ArrayList) List(java.util.List) ImplementationGuideDefn(org.hl7.fhir.definitions.model.ImplementationGuideDefn) ResourceDefn(org.hl7.fhir.definitions.model.ResourceDefn)

Example 55 with Account

use of org.hl7.fhir.dstu3.model.Account in project redmatch by aehrc.

the class CompletionProcessor method handleAttribute.

/**
 * Handles searching for a FHIR resource attribute name.
 *
 * @param url The document url. Used to get the FHIR package for that document.
 * @param tokens The list of tokens.
 * @return A list of potential completions.
 */
private List<CompletionItem> handleAttribute(String url, List<? extends Token> tokens) {
    List<CompletionItem> completionItems = new ArrayList<>();
    // Look for ATTRIBUTE_START and return if we find a token that is not one of the following: NOT, PATH, OPEN_SQ,
    // INDEX, CLOSE_SQ or ATTRIBUTE_START
    List<Token> attributes = new ArrayList<>();
    int i = tokens.size() - 1;
    outer: for (; i >= 0; i--) {
        switch(tokens.get(i).getType()) {
            case RedmatchLexer.ATTRIBUTE_START:
                break outer;
            case RedmatchLexer.NOT:
            case RedmatchLexer.PATH:
            case RedmatchLexer.OPEN_SQ:
            case RedmatchLexer.INDEX:
            case RedmatchLexer.CLOSE_SQ:
            case RedmatchLexer.DOT:
                attributes.add(tokens.get(i));
                break;
            default:
                return completionItems;
        }
    }
    // We need to look for the resource token, because it is needed in the call to Ontoserver. This will be the second
    // ID token after the colon, going from right to left
    Token resourceToken = null;
    boolean hasSeenColon = false;
    boolean hasSeenResourceId = false;
    outer: for (; i >= 0; i--) {
        switch(tokens.get(i).getType()) {
            case RedmatchLexer.COLON:
                hasSeenColon = true;
                break;
            case RedmatchLexer.ID:
                if (hasSeenColon) {
                    if (hasSeenResourceId) {
                        resourceToken = tokens.get(i);
                        break outer;
                    } else {
                        hasSeenResourceId = true;
                    }
                }
                break;
            default:
                break;
        }
    }
    if (resourceToken == null) {
        return completionItems;
    }
    // The attributes array contains the tokens that make up the prefix
    StringBuilder sb = new StringBuilder();
    for (i = attributes.size() - 1; i >= 0; i--) {
        sb.append(attributes.get(i).getText());
    }
    String prefix = sb.toString();
    VersionedFhirPackage fhirPackage = documentService.getFhirPackage(url);
    if (fhirPackage == null) {
        return Collections.emptyList();
    }
    try {
        String parentResource = resourceToken.getText();
        ValueSet expansion = terminologyService.expand(fhirPackage, prefix, false, parentResource);
        for (ValueSet.ValueSetExpansionContainsComponent component : expansion.getExpansion().getContains()) {
            // +1 to account for the dot
            String code = component.getCode().substring(parentResource.length() + 1);
            completionItems.add(new CompletionItem(code));
        }
        return completionItems;
    } catch (IOException e) {
        log.error("There was a problem creating auto-completion results for document " + url + " and prefix " + prefix);
        return Collections.emptyList();
    }
}
Also used : ArrayList(java.util.ArrayList) Token(org.antlr.v4.runtime.Token) IOException(java.io.IOException) VersionedFhirPackage(au.csiro.redmatch.model.VersionedFhirPackage) CompletionItem(org.eclipse.lsp4j.CompletionItem) ValueSet(org.hl7.fhir.r4.model.ValueSet)

Aggregations

Test (org.testng.annotations.Test)17 Patient (org.hl7.fhir.dstu3.model.Patient)10 ArrayList (java.util.ArrayList)8 Appointment (org.hl7.fhir.dstu3.model.Appointment)8 Account (org.sagebionetworks.bridge.models.accounts.Account)8 Complex (org.hl7.fhir.r4.utils.formats.Turtle.Complex)7 StatusMessage (org.sagebionetworks.bridge.models.StatusMessage)7 IOException (java.io.IOException)6 DateRangeResourceList (org.sagebionetworks.bridge.models.DateRangeResourceList)6 Account (com.google.api.services.adsense.v2.model.Account)5 JsonElement (com.google.gson.JsonElement)5 ProcedureRequest (org.hl7.fhir.dstu3.model.ProcedureRequest)5 Complex (org.hl7.fhir.dstu3.utils.formats.Turtle.Complex)5 HealthDataSubmission (org.sagebionetworks.bridge.models.healthdata.HealthDataSubmission)5 Account (Model.Account)4 File (java.io.File)4 FileInputStream (java.io.FileInputStream)4 FileOutputStream (java.io.FileOutputStream)4 Account (model.Account)4 ContactPoint (org.hl7.fhir.dstu3.model.ContactPoint)4