| 365 | | if (!Context.hasPrivilege(OpenmrsConstants.PRIV_MANAGE_CONCEPT_CLASSES)) |
|---|
| 366 | | throw new APIAuthenticationException("Privilege required: " |
|---|
| 367 | | + OpenmrsConstants.PRIV_MANAGE_CONCEPT_CLASSES); |
|---|
| 368 | | |
|---|
| 369 | | Context.getConceptService().checkIfLocked(); |
|---|
| 370 | | |
|---|
| 371 | | dao.createConceptClass(cc); |
|---|
| 372 | | } |
|---|
| 373 | | |
|---|
| 374 | | /** |
|---|
| 375 | | * Update ConceptClass |
|---|
| 376 | | * |
|---|
| 377 | | * @param ConceptClass to update |
|---|
| 378 | | * @throws APIException |
|---|
| 379 | | * @deprecated moved to ConceptServiceImpl |
|---|
| | 357 | Context.getConceptService().saveConceptClass(cc); |
|---|
| | 358 | } |
|---|
| | 359 | |
|---|
| | 360 | /** |
|---|
| | 361 | * @deprecated moved to ConceptService |
|---|
| 382 | | if (!Context.hasPrivilege(OpenmrsConstants.PRIV_MANAGE_CONCEPT_CLASSES)) |
|---|
| 383 | | throw new APIAuthenticationException("Privilege required: " |
|---|
| 384 | | + OpenmrsConstants.PRIV_MANAGE_CONCEPT_CLASSES); |
|---|
| 385 | | |
|---|
| 386 | | Context.getConceptService().checkIfLocked(); |
|---|
| 387 | | |
|---|
| 388 | | dao.updateConceptClass(cc); |
|---|
| 389 | | } |
|---|
| 390 | | |
|---|
| 391 | | /** |
|---|
| 392 | | * Delete ConceptClass |
|---|
| 393 | | * |
|---|
| 394 | | * @param ConceptClass to delete |
|---|
| 395 | | * @throws APIException |
|---|
| 396 | | * @deprecated moved to ConceptServiceImpl |
|---|
| | 364 | Context.getConceptService().saveConceptClass(cc); |
|---|
| | 365 | } |
|---|
| | 366 | |
|---|
| | 367 | /** |
|---|
| | 368 | * @deprecated moved to ConceptService |
|---|
| 399 | | if (!Context.hasPrivilege(OpenmrsConstants.PRIV_MANAGE_CONCEPT_CLASSES)) |
|---|
| 400 | | throw new APIAuthenticationException("Privilege required: " |
|---|
| 401 | | + OpenmrsConstants.PRIV_MANAGE_CONCEPT_CLASSES); |
|---|
| 402 | | |
|---|
| 403 | | Context.getConceptService().checkIfLocked(); |
|---|
| 404 | | |
|---|
| 405 | | dao.deleteConceptClass(cc); |
|---|
| 406 | | } |
|---|
| 407 | | |
|---|
| 408 | | /** |
|---|
| 409 | | * Create a new ConceptDatatype |
|---|
| 410 | | * |
|---|
| 411 | | * @param ConceptDatatype to create |
|---|
| 412 | | * @throws APIException |
|---|
| 413 | | * @deprecated moved to ConceptServiceImpl |
|---|
| | 371 | Context.getConceptService().purgeConceptClass(cc); |
|---|
| | 372 | } |
|---|
| | 373 | |
|---|
| | 374 | /** |
|---|
| | 375 | * @deprecated moved to ConceptService |
|---|
| 416 | | if (!Context.hasPrivilege(OpenmrsConstants.PRIV_MANAGE_CONCEPT_DATATYPES)) |
|---|
| 417 | | throw new APIAuthenticationException("Privilege required: " |
|---|
| 418 | | + OpenmrsConstants.PRIV_MANAGE_CONCEPT_DATATYPES); |
|---|
| 419 | | |
|---|
| 420 | | Context.getConceptService().checkIfLocked(); |
|---|
| 421 | | |
|---|
| 422 | | dao.createConceptDatatype(cd); |
|---|
| 423 | | } |
|---|
| 424 | | |
|---|
| 425 | | /** |
|---|
| 426 | | * Update ConceptDatatype |
|---|
| 427 | | * |
|---|
| 428 | | * @param ConceptDatatype to update |
|---|
| 429 | | * @throws APIException |
|---|
| 430 | | * @deprecated moved to ConceptServiceImpl |
|---|
| | 378 | Context.getConceptService().saveConceptDatatype(cd); |
|---|
| | 379 | } |
|---|
| | 380 | |
|---|
| | 381 | /** |
|---|
| | 382 | * @deprecated moved to ConceptService |
|---|
| 433 | | if (!Context.hasPrivilege(OpenmrsConstants.PRIV_MANAGE_CONCEPT_DATATYPES)) |
|---|
| 434 | | throw new APIAuthenticationException("Privilege required: " |
|---|
| 435 | | + OpenmrsConstants.PRIV_MANAGE_CONCEPT_DATATYPES); |
|---|
| 436 | | |
|---|
| 437 | | Context.getConceptService().checkIfLocked(); |
|---|
| 438 | | |
|---|
| 439 | | dao.updateConceptDatatype(cd); |
|---|
| 440 | | } |
|---|
| 441 | | |
|---|
| 442 | | /** |
|---|
| 443 | | * Delete ConceptDatatype |
|---|
| 444 | | * |
|---|
| 445 | | * @param ConceptDatatype to delete |
|---|
| 446 | | * @throws APIException |
|---|
| 447 | | * @deprecated moved to ConceptServiceImpl |
|---|
| | 385 | Context.getConceptService().saveConceptDatatype(cd); |
|---|
| | 386 | } |
|---|
| | 387 | |
|---|
| | 388 | /** |
|---|
| | 389 | * @deprecated moved to ConceptService |
|---|
| 570 | | if (!Context.hasPrivilege(OpenmrsConstants.PRIV_EDIT_CONCEPTS)) |
|---|
| 571 | | throw new APIAuthenticationException("Privilege required: " |
|---|
| 572 | | + OpenmrsConstants.PRIV_EDIT_CONCEPTS); |
|---|
| 573 | | |
|---|
| 574 | | Context.getConceptService().checkIfLocked(); |
|---|
| 575 | | |
|---|
| 576 | | // Run the operation in batches |
|---|
| 577 | | ConceptService cs = Context.getConceptService(); |
|---|
| 578 | | int batchStartId = 0; |
|---|
| 579 | | int endId = cs.getNextAvailableId(); |
|---|
| 580 | | int batchSize = 1000; |
|---|
| 581 | | |
|---|
| 582 | | while (batchStartId < endId) |
|---|
| 583 | | { |
|---|
| 584 | | updateConceptWords(batchStartId, batchStartId + batchSize); |
|---|
| 585 | | Context.clearSession(); |
|---|
| 586 | | batchStartId += batchSize; |
|---|
| 587 | | } |
|---|
| 588 | | |
|---|
| 589 | | } |
|---|
| 590 | | |
|---|
| 591 | | /** |
|---|
| 592 | | * Iterates over all concepts with conceptIds between |
|---|
| 593 | | * <code>conceptIdStart</code> and <code>conceptIdEnd</code> (inclusive) |
|---|
| 594 | | * calling updateConceptWord(concept) |
|---|
| 595 | | * |
|---|
| 596 | | * @throws APIException |
|---|
| 597 | | * @deprecated moved to ConceptServiceImpl |
|---|
| | 492 | Context.getConceptService().updateConceptWords(); |
|---|
| | 493 | } |
|---|
| | 494 | |
|---|
| | 495 | /** |
|---|
| | 496 | * @deprecated moved to ConceptService |
|---|
| 601 | | if (!Context.hasPrivilege(OpenmrsConstants.PRIV_EDIT_CONCEPTS)) |
|---|
| 602 | | throw new APIAuthenticationException("Privilege required: " |
|---|
| 603 | | + OpenmrsConstants.PRIV_EDIT_CONCEPTS); |
|---|
| 604 | | |
|---|
| 605 | | Context.getConceptService().checkIfLocked(); |
|---|
| 606 | | |
|---|
| 607 | | Integer i = conceptIdStart; |
|---|
| 608 | | ConceptService cs = Context.getConceptService(); |
|---|
| 609 | | while (i++ <= conceptIdEnd) { |
|---|
| 610 | | updateConceptWord(cs.getConcept(i)); |
|---|
| 611 | | } |
|---|
| 612 | | } |
|---|
| 613 | | |
|---|
| 614 | | /** |
|---|
| 615 | | * Updates the concept set derived business table for this concept (bursting |
|---|
| 616 | | * the concept sets) |
|---|
| 617 | | * |
|---|
| 618 | | * @param concept |
|---|
| 619 | | * @throws APIException |
|---|
| 620 | | * @deprecated moved to ConceptServiceImpl |
|---|
| | 500 | Context.getConceptService().updateConceptWords(conceptIdStart, conceptIdEnd); |
|---|
| | 501 | } |
|---|
| | 502 | |
|---|
| | 503 | /** |
|---|
| | 504 | * @deprecated moved to ConceptService |
|---|
| 623 | | if (!Context.hasPrivilege(OpenmrsConstants.PRIV_EDIT_CONCEPTS)) |
|---|
| 624 | | throw new APIAuthenticationException("Privilege required: " |
|---|
| 625 | | + OpenmrsConstants.PRIV_EDIT_CONCEPTS); |
|---|
| 626 | | |
|---|
| 627 | | Context.getConceptService().checkIfLocked(); |
|---|
| 628 | | |
|---|
| 629 | | dao.updateConceptSetDerived(concept); |
|---|
| 630 | | } |
|---|
| 631 | | |
|---|
| 632 | | /** |
|---|
| 633 | | * Iterates over all concepts calling updateConceptSetDerived(concept) |
|---|
| 634 | | * |
|---|
| 635 | | * @throws APIException |
|---|
| 636 | | * @deprecated moved to ConceptServiceImpl |
|---|
| | 507 | Context.getConceptService().updateConceptSetDerived(concept); |
|---|
| | 508 | } |
|---|
| | 509 | |
|---|
| | 510 | /** |
|---|
| | 511 | * @deprecated moved to ConceptService |
|---|
| 639 | | if (!Context.hasPrivilege(OpenmrsConstants.PRIV_EDIT_CONCEPTS)) |
|---|
| 640 | | throw new APIAuthenticationException("Privilege required: " |
|---|
| 641 | | + OpenmrsConstants.PRIV_EDIT_CONCEPTS); |
|---|
| 642 | | |
|---|
| 643 | | Context.getConceptService().checkIfLocked(); |
|---|
| 644 | | |
|---|
| 645 | | dao.updateConceptSetDerived(); |
|---|
| 646 | | } |
|---|
| 647 | | |
|---|
| 648 | | /** |
|---|
| 649 | | * @see org.openmrs.api.AdministrationService#createConceptProposal(org.openmrs.ConceptProposal) |
|---|
| 650 | | * @deprecated moved to ConceptServiceImpl |
|---|
| | 514 | Context.getConceptService().updateConceptSetDerived(); |
|---|
| | 515 | } |
|---|
| | 516 | |
|---|
| | 517 | /** |
|---|
| | 518 | * @deprecated moved to ConceptService |
|---|
| 653 | | if (!Context.hasPrivilege(OpenmrsConstants.PRIV_ADD_CONCEPT_PROPOSAL)) |
|---|
| 654 | | throw new APIAuthenticationException("Privilege required: " |
|---|
| 655 | | + OpenmrsConstants.PRIV_ADD_CONCEPT_PROPOSAL); |
|---|
| 656 | | |
|---|
| 657 | | dao.createConceptProposal(cp); |
|---|
| 658 | | } |
|---|
| 659 | | |
|---|
| 660 | | /** |
|---|
| 661 | | * @deprecated moved to ConceptServiceImpl |
|---|
| 662 | | * @see org.openmrs.api.AdministrationService#updateConceptProposal(org.openmrs.ConceptProposal) |
|---|
| | 521 | Context.getConceptService().saveConceptProposal(cp); |
|---|
| | 522 | } |
|---|
| | 523 | |
|---|
| | 524 | /** |
|---|
| | 525 | * @deprecated moved to ConceptService |
|---|
| 665 | | if (!Context.hasPrivilege(OpenmrsConstants.PRIV_EDIT_CONCEPT_PROPOSAL)) |
|---|
| 666 | | throw new APIAuthenticationException("Privilege required: " |
|---|
| 667 | | + OpenmrsConstants.PRIV_EDIT_CONCEPT_PROPOSAL); |
|---|
| 668 | | |
|---|
| 669 | | cp.setChangedBy(Context.getAuthenticatedUser()); |
|---|
| 670 | | cp.setDateChanged(new Date()); |
|---|
| 671 | | dao.updateConceptProposal(cp); |
|---|
| 672 | | } |
|---|
| 673 | | |
|---|
| 674 | | /** |
|---|
| 675 | | * @deprecated moved to ConceptServiceImpl |
|---|
| 676 | | * @see org.openmrs.api.AdministrationService#mapConceptProposalToConcept(org.openmrs.ConceptProposal, org.openmrs.Concept) |
|---|
| | 528 | Context.getConceptService().saveConceptProposal(cp); |
|---|
| | 529 | } |
|---|
| | 530 | |
|---|
| | 531 | /** |
|---|
| | 532 | * @deprecated moved to ConceptService |
|---|
| 680 | | |
|---|
| 681 | | if (!Context.hasPrivilege(OpenmrsConstants.PRIV_ADD_CONCEPTS)) |
|---|
| 682 | | throw new APIAuthenticationException("Privilege required: " |
|---|
| 683 | | + OpenmrsConstants.PRIV_ADD_CONCEPTS); |
|---|
| 684 | | |
|---|
| 685 | | if (cp.getState().equals(OpenmrsConstants.CONCEPT_PROPOSAL_REJECT)) { |
|---|
| 686 | | rejectConceptProposal(cp); |
|---|
| 687 | | return; |
|---|
| 688 | | } |
|---|
| 689 | | |
|---|
| 690 | | if (mappedConcept == null) |
|---|
| 691 | | throw new APIException("Illegal Mapped Concept"); |
|---|
| 692 | | |
|---|
| 693 | | if (cp.getState().equals(OpenmrsConstants.CONCEPT_PROPOSAL_CONCEPT) |
|---|
| 694 | | || !StringUtils.hasText(cp.getFinalText())) { |
|---|
| 695 | | cp.setState(OpenmrsConstants.CONCEPT_PROPOSAL_CONCEPT); |
|---|
| 696 | | cp.setFinalText(""); |
|---|
| 697 | | } else if (cp.getState() |
|---|
| 698 | | .equals(OpenmrsConstants.CONCEPT_PROPOSAL_SYNONYM)) { |
|---|
| 699 | | |
|---|
| 700 | | Context.getConceptService().checkIfLocked(); |
|---|
| 701 | | |
|---|
| 702 | | String finalText = cp.getFinalText(); |
|---|
| 703 | | ConceptSynonym syn = new ConceptSynonym(mappedConcept, |
|---|
| 704 | | finalText, |
|---|
| 705 | | Context.getLocale()); |
|---|
| 706 | | syn.setDateCreated(new Date()); |
|---|
| 707 | | syn.setCreator(Context.getAuthenticatedUser()); |
|---|
| 708 | | |
|---|
| 709 | | mappedConcept.addSynonym(syn); |
|---|
| 710 | | mappedConcept.setChangedBy(Context.getAuthenticatedUser()); |
|---|
| 711 | | mappedConcept.setDateChanged(new Date()); |
|---|
| 712 | | updateConceptWord(mappedConcept); |
|---|
| 713 | | } |
|---|
| 714 | | |
|---|
| 715 | | cp.setMappedConcept(mappedConcept); |
|---|
| 716 | | |
|---|
| 717 | | if (cp.getObsConcept() != null) { |
|---|
| 718 | | Obs ob = new Obs(); |
|---|
| 719 | | ob.setEncounter(cp.getEncounter()); |
|---|
| 720 | | ob.setConcept(cp.getObsConcept()); |
|---|
| 721 | | ob.setValueCoded(cp.getMappedConcept()); |
|---|
| 722 | | ob.setCreator(Context.getAuthenticatedUser()); |
|---|
| 723 | | ob.setDateCreated(new Date()); |
|---|
| 724 | | ob.setObsDatetime(cp.getEncounter().getEncounterDatetime()); |
|---|
| 725 | | ob.setLocation(cp.getEncounter().getLocation()); |
|---|
| 726 | | ob.setPerson(cp.getEncounter().getPatient()); |
|---|
| 727 | | cp.setObs(ob); |
|---|
| 728 | | } |
|---|
| 729 | | |
|---|
| 730 | | updateConceptProposal(cp); |
|---|
| 731 | | } |
|---|
| 732 | | |
|---|
| 733 | | /** |
|---|
| 734 | | * @deprecated moved to ConceptServiceImpl |
|---|
| | 536 | Context.getConceptService().mapConceptProposalToConcept(cp, mappedConcept); |
|---|
| | 537 | } |
|---|
| | 538 | |
|---|
| | 539 | /** |
|---|
| | 540 | * @deprecated moved to ConceptService |
|---|