Changeset 4543
- Timestamp:
- 06/03/08 22:22:16 (7 months ago)
- Files:
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
openmrs-modules/tbla/web/src/org/openmrs/module/tbla/web/controller/NewPatientFormController.java
r4519 r4543 35 35 import org.openmrs.Tribe; 36 36 import org.openmrs.api.DuplicateIdentifierException; 37 import org.openmrs.api.EncounterService;38 37 import org.openmrs.api.IdentifierNotUniqueException; 39 38 import org.openmrs.api.InsufficientIdentifiersException; … … 43 42 import org.openmrs.api.PatientService; 44 43 import org.openmrs.api.PersonService; 44 import org.openmrs.api.PersonService.ATTR_VIEW_TYPE; 45 45 import org.openmrs.api.context.Context; 46 46 import org.openmrs.module.ModuleFactory; … … 51 51 import org.openmrs.util.OpenmrsConstants; 52 52 import org.openmrs.util.OpenmrsUtil; 53 import org.openmrs.util.OpenmrsConstants.PERSON_TYPE; 53 54 import org.openmrs.web.WebConstants; 54 55 import org.openmrs.web.controller.patient.ShortPatientModel; … … 111 112 if (Context.isAuthenticated()) { 112 113 PatientService ps = Context.getPatientService(); 113 EncounterService es = Context.getEncounterService();114 114 MessageSourceAccessor msa = getMessageSourceAccessor(); 115 115 … … 163 163 } 164 164 else 165 loc = es.getLocation(Integer.valueOf(locs[i]));165 loc = Context.getLocationService().getLocation(Integer.valueOf(locs[i])); 166 166 167 167 PatientIdentifier pi = new PatientIdentifier(id, pit, loc); … … 354 354 355 355 // 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)) { 357 357 String value = request.getParameter(type.getPersonAttributeTypeId().toString()); 358 358 … … 398 398 Patient newPatient = null; 399 399 try { 400 newPatient = ps. updatePatient(patient);400 newPatient = ps.savePatient(patient); 401 401 } catch ( InvalidIdentifierFormatException iife ) { 402 402 log.error(iife); … … 441 441 String[] personAs = request.getParameterValues("personA"); 442 442 String[] types = request.getParameterValues("relationshipType"); 443 Person person = personService.getPerson(patient );443 Person person = personService.getPerson(patient.getPatientId()); 444 444 List<Relationship> relationships; 445 445 List<Person> newPersonAs = new Vector<Person>(); //list of all persons specifically selected in the form 446 446 447 447 if (person != null) 448 relationships = personService.getRelationships (person);448 relationships = personService.getRelationshipsByPerson(person); 449 449 else 450 450 relationships = new Vector<Relationship>(); … … 486 486 if (newPersonAs.contains(rel.getPersonA()) || 487 487 person.equals(rel.getPersonA())) 488 personService. updateRelationship(rel);488 personService.saveRelationship(rel); 489 489 else 490 personService. deleteRelationship(rel);490 personService.purgeRelationship(rel); 491 491 } 492 492 … … 498 498 499 499 String codProp = Context.getAdministrationService().getGlobalProperty("concept.causeOfDeath"); 500 Concept causeOfDeath = Context.getConceptService().getConcept ByIdOrName(codProp);500 Concept causeOfDeath = Context.getConceptService().getConcept(codProp); 501 501 502 502 if ( causeOfDeath != null ) { 503 Set<Obs> obssDeath = Context.getObsService().getObservations(patient, causeOfDeath, false);503 List<Obs> obssDeath = Context.getObsService().getObservationsByPersonAndConcept(patient, causeOfDeath); 504 504 if ( obssDeath != null ) { 505 505 if ( obssDeath.size() > 1 ) { … … 520 520 obsDeath.setPerson(patient); 521 521 obsDeath.setConcept(causeOfDeath); 522 Location loc = Context.get EncounterService().getLocationByName("Unknown Location");523 if ( loc == null ) loc = Context.get EncounterService().getLocation(new Integer(1));522 Location loc = Context.getLocationService().getLocation("Unknown Location"); 523 if ( loc == null ) loc = Context.getLocationService().getLocation(new Integer(1)); 524 524 // TODO person healthcenter if ( loc == null ) loc = patient.getHealthCenter(); 525 525 if ( loc != null ) obsDeath.setLocation(loc); … … 533 533 log.debug("Current cause is null, attempting to set to NONE"); 534 534 String noneConcept = Context.getAdministrationService().getGlobalProperty("concept.none"); 535 currCause = Context.getConceptService().getConcept ByIdOrName(noneConcept);535 currCause = Context.getConceptService().getConcept(noneConcept); 536 536 } 537 537 … … 546 546 // check if this is an "other" concept - if so, then we need to add value_text 547 547 String otherConcept = Context.getAdministrationService().getGlobalProperty("concept.otherNonCoded"); 548 Concept conceptOther = Context.getConceptService().getConcept ByIdOrName(otherConcept);548 Concept conceptOther = Context.getConceptService().getConcept(otherConcept); 549 549 if ( conceptOther != null ) { 550 550 if ( conceptOther.equals(currCause) ) { … … 562 562 } 563 563 564 Context.getObsService(). updateObs(obsDeath);564 Context.getObsService().saveObs(obsDeath, null); 565 565 } else { 566 566 log.debug("Current cause is still null - aborting mission"); … … 703 703 // get 'other' cause of death 704 704 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); 708 708 if ( obssDeath.size() == 1 ) { 709 709 Obs obsDeath = obssDeath.iterator().next();