Downloads Documentation Community Contribute Demo






Show Sidebar
Login | Register

Changeset 4543

Show
Ignore:
Timestamp:
06/03/08 22:22:16 (7 months ago)
Author:
jacobb
Message:

tbla module: Updated NewPatientFormController.java to match the OpenMRS updates in revision 4532.

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • openmrs-modules/tbla/web/src/org/openmrs/module/tbla/web/controller/NewPatientFormController.java

    r4519 r4543  
    3535import org.openmrs.Tribe; 
    3636import org.openmrs.api.DuplicateIdentifierException; 
    37 import org.openmrs.api.EncounterService; 
    3837import org.openmrs.api.IdentifierNotUniqueException; 
    3938import org.openmrs.api.InsufficientIdentifiersException; 
     
    4342import org.openmrs.api.PatientService; 
    4443import org.openmrs.api.PersonService; 
     44import org.openmrs.api.PersonService.ATTR_VIEW_TYPE; 
    4545import org.openmrs.api.context.Context; 
    4646import org.openmrs.module.ModuleFactory; 
     
    5151import org.openmrs.util.OpenmrsConstants; 
    5252import org.openmrs.util.OpenmrsUtil; 
     53import org.openmrs.util.OpenmrsConstants.PERSON_TYPE; 
    5354import org.openmrs.web.WebConstants; 
    5455import org.openmrs.web.controller.patient.ShortPatientModel; 
     
    111112                if (Context.isAuthenticated()) { 
    112113                        PatientService ps = Context.getPatientService(); 
    113                         EncounterService es = Context.getEncounterService(); 
    114114                        MessageSourceAccessor msa = getMessageSourceAccessor(); 
    115115                         
     
    163163                                                        } 
    164164                                                        else 
    165                                                                 loc = es.getLocation(Integer.valueOf(locs[i])); 
     165                                                                loc = Context.getLocationService().getLocation(Integer.valueOf(locs[i])); 
    166166                                                         
    167167                                                        PatientIdentifier pi = new PatientIdentifier(id, pit, loc); 
     
    354354                         
    355355                        // look for person attributes in the request and save to person 
    356                         for (PersonAttributeType type : personService.getPersonAttributeTypes("patient", "viewing")) { 
     356                        for (PersonAttributeType type : personService.getPersonAttributeTypes(PERSON_TYPE.PATIENT, ATTR_VIEW_TYPE.VIEWING)) { 
    357357                                String value = request.getParameter(type.getPersonAttributeTypeId().toString()); 
    358358                                 
     
    398398                        Patient newPatient = null; 
    399399                        try { 
    400                                 newPatient = ps.updatePatient(patient); 
     400                                newPatient = ps.savePatient(patient); 
    401401                        } catch ( InvalidIdentifierFormatException iife ) { 
    402402                                log.error(iife); 
     
    441441                                String[] personAs = request.getParameterValues("personA"); 
    442442                                String[] types = request.getParameterValues("relationshipType"); 
    443                                 Person person = personService.getPerson(patient); 
     443                                Person person = personService.getPerson(patient.getPatientId()); 
    444444                                List<Relationship> relationships; 
    445445                                List<Person> newPersonAs = new Vector<Person>(); //list of all persons specifically selected in the form 
    446446                                 
    447447                                if (person != null)  
    448                                         relationships = personService.getRelationships(person); 
     448                                        relationships = personService.getRelationshipsByPerson(person); 
    449449                                else 
    450450                                        relationships = new Vector<Relationship>(); 
     
    486486                                        if (newPersonAs.contains(rel.getPersonA()) ||  
    487487                                                        person.equals(rel.getPersonA())) 
    488                                                 personService.updateRelationship(rel); 
     488                                                personService.saveRelationship(rel); 
    489489                                        else 
    490                                                 personService.deleteRelationship(rel); 
     490                                                personService.purgeRelationship(rel); 
    491491                                } 
    492492                                 
     
    498498         
    499499                                        String codProp = Context.getAdministrationService().getGlobalProperty("concept.causeOfDeath"); 
    500                                         Concept causeOfDeath = Context.getConceptService().getConceptByIdOrName(codProp); 
     500                                        Concept causeOfDeath = Context.getConceptService().getConcept(codProp); 
    501501         
    502502                                        if ( causeOfDeath != null ) { 
    503                                                 Set<Obs> obssDeath = Context.getObsService().getObservations(patient, causeOfDeath, false); 
     503                                                List<Obs> obssDeath = Context.getObsService().getObservationsByPersonAndConcept(patient, causeOfDeath); 
    504504                                                if ( obssDeath != null ) { 
    505505                                                        if ( obssDeath.size() > 1 ) { 
     
    520520                                                                        obsDeath.setPerson(patient); 
    521521                                                                        obsDeath.setConcept(causeOfDeath); 
    522                                                                         Location loc = Context.getEncounterService().getLocationByName("Unknown Location"); 
    523                                                                         if ( loc == null ) loc = Context.getEncounterService().getLocation(new Integer(1)); 
     522                                                                        Location loc = Context.getLocationService().getLocation("Unknown Location"); 
     523                                                                        if ( loc == null ) loc = Context.getLocationService().getLocation(new Integer(1)); 
    524524                                                                        // TODO person healthcenter if ( loc == null ) loc = patient.getHealthCenter(); 
    525525                                                                        if ( loc != null ) obsDeath.setLocation(loc); 
     
    533533                                                                        log.debug("Current cause is null, attempting to set to NONE"); 
    534534                                                                        String noneConcept = Context.getAdministrationService().getGlobalProperty("concept.none"); 
    535                                                                         currCause = Context.getConceptService().getConceptByIdOrName(noneConcept); 
     535                                                                        currCause = Context.getConceptService().getConcept(noneConcept); 
    536536                                                                } 
    537537                                                                 
     
    546546                                                                        // check if this is an "other" concept - if so, then we need to add value_text 
    547547                                                                        String otherConcept = Context.getAdministrationService().getGlobalProperty("concept.otherNonCoded"); 
    548                                                                         Concept conceptOther = Context.getConceptService().getConceptByIdOrName(otherConcept); 
     548                                                                        Concept conceptOther = Context.getConceptService().getConcept(otherConcept); 
    549549                                                                        if ( conceptOther != null ) { 
    550550                                                                                if ( conceptOther.equals(currCause) ) { 
     
    562562                                                                        } 
    563563                                                                         
    564                                                                         Context.getObsService().updateObs(obsDeath); 
     564                                                                        Context.getObsService().saveObs(obsDeath, null); 
    565565                                                                } else { 
    566566                                                                        log.debug("Current cause is still null - aborting mission"); 
     
    703703                                // get 'other' cause of death 
    704704                                String propCause = Context.getAdministrationService().getGlobalProperty("concept.causeOfDeath"); 
    705                                        Concept conceptCause = Context.getConceptService().getConceptByIdOrName(propCause); 
    706                                         if ( conceptCause != null ) { 
    707                                                 Set<Obs> obssDeath = Context.getObsService().getObservations(patient, conceptCause, false); 
     705                               Concept conceptCause = Context.getConceptService().getConcept(propCause); 
     706                                        if ( conceptCause != null && patient.getPatientId() != null) { 
     707                                                List<Obs> obssDeath = Context.getObsService().getObservationsByPersonAndConcept(patient, conceptCause); 
    708708                                                if ( obssDeath.size() == 1 ) { 
    709709                                                        Obs obsDeath = obssDeath.iterator().next();