use of se.inera.intyg.common.support.model.common.internal.Patient in project webcert by sklintyg.
the class IntygResource method createDraft.
@POST
@Consumes(MediaType.APPLICATION_JSON)
@Produces(MediaType.APPLICATION_JSON)
public Response createDraft(CreateNewDraftRequest request) {
Utkast utkast = new Utkast();
Patient patient = request.getPatient();
utkast.setPatientPersonnummer(patient.getPersonId());
utkast.setPatientFornamn(patient.getFornamn());
utkast.setPatientMellannamn(patient.getMellannamn());
utkast.setPatientEfternamn(patient.getEfternamn());
utkast.setIntygsId(request.getIntygId());
utkast.setIntygsTyp(request.getIntygType());
utkast.setStatus(UtkastStatus.DRAFT_INCOMPLETE);
Vardenhet vardenhet = request.getHosPerson().getVardenhet();
utkast.setEnhetsId(vardenhet.getEnhetsid());
utkast.setEnhetsNamn(vardenhet.getEnhetsnamn());
Vardgivare vardgivare = vardenhet.getVardgivare();
utkast.setVardgivarId(vardgivare.getVardgivarid());
utkast.setVardgivarNamn(vardgivare.getVardgivarnamn());
VardpersonReferens vardPerson = new VardpersonReferens();
vardPerson.setNamn(request.getHosPerson().getFullstandigtNamn());
vardPerson.setHsaId(request.getHosPerson().getPersonId());
utkast.setSenastSparadAv(vardPerson);
utkast.setSkapadAv(vardPerson);
utkastRepository.save(utkast);
return Response.ok().build();
}
use of se.inera.intyg.common.support.model.common.internal.Patient in project webcert by sklintyg.
the class IntygModuleApiController method createRenewalCopyRequest.
private CreateRenewalCopyRequest createRenewalCopyRequest(String orgIntygsId, String intygsTyp, CopyIntygRequest request) {
HoSPersonal hosPerson = createHoSPersonFromUser();
Patient patient = createPatientFromCopyIntygRequest(request);
CreateRenewalCopyRequest req = new CreateRenewalCopyRequest(orgIntygsId, intygsTyp, patient, hosPerson);
// Add new personnummer to request
addPersonnummerToRequest(req, userService.getUser().getParameters());
// Set djupintegrerad flag on request to true if origin is DJUPINTEGRATION
setDeepIntegrationFlagOnRequest(req);
return req;
}
use of se.inera.intyg.common.support.model.common.internal.Patient in project webcert by sklintyg.
the class IntygModuleApiController method createReplacementCopyRequest.
private CreateReplacementCopyRequest createReplacementCopyRequest(String orgIntygsId, String intygsTyp, CopyIntygRequest request) {
HoSPersonal hosPerson = createHoSPersonFromUser();
Patient patient = createPatientFromCopyIntygRequest(request);
final WebCertUser user = userService.getUser();
IntegrationParameters parameters = user.getParameters();
boolean coherentJournaling = parameters != null && parameters.isSjf();
CreateReplacementCopyRequest req = new CreateReplacementCopyRequest(orgIntygsId, intygsTyp, patient, hosPerson, coherentJournaling);
// Add new personnummer to request
addPersonnummerToRequest(req, parameters);
// Set djupintegrerad flag on request to true if origin is DJUPINTEGRATION
setDeepIntegrationFlagOnRequest(req);
return req;
}
use of se.inera.intyg.common.support.model.common.internal.Patient in project webcert by sklintyg.
the class UtkastApiController method createServiceRequest.
private CreateNewDraftRequest createServiceRequest(CreateUtkastRequest req) {
Patient pat = patientDetailsResolver.resolvePatient(req.getPatientPersonnummer(), req.getIntygType());
// CreateUtkastRequest is the manual entry.
if (pat == null) {
pat = new Patient();
pat.setPersonId(req.getPatientPersonnummer());
pat.setFornamn(req.getPatientFornamn());
pat.setMellannamn(req.getPatientMellannamn());
pat.setEfternamn(req.getPatientEfternamn());
pat.setFullstandigtNamn(IntygConverterUtil.concatPatientName(pat.getFornamn(), pat.getMellannamn(), pat.getEfternamn()));
pat.setPostadress(req.getPatientPostadress());
pat.setPostnummer(req.getPatientPostnummer());
pat.setPostort(req.getPatientPostort());
}
return new CreateNewDraftRequest(null, req.getIntygType(), null, createHoSPersonFromUser(), pat);
}
use of se.inera.intyg.common.support.model.common.internal.Patient in project webcert by sklintyg.
the class AbstractUtkastBuilder method populateCopyUtkastFromSignedIntyg.
/*
* (non-Javadoc)
*
* @see
* se.inera.intyg.webcert.web.service.utkast.CopyUtkastBuilder#populateCopyUtkastFromSignedIntyg(se.inera.intyg.
* webcert.web.service.utkast.dto.CreateNewDraftCopyRequest, se.inera.intyg.webcert.integration.pu.model.Person)
*/
@Override
public CopyUtkastBuilderResponse populateCopyUtkastFromSignedIntyg(T copyRequest, Person patientDetails, boolean addRelation, boolean coherentJournaling, boolean enforceEnhet) throws ModuleNotFoundException, ModuleException {
String orignalIntygsId = copyRequest.getOriginalIntygId();
String originalIntygsTyp = copyRequest.getOriginalIntygTyp();
String intygsTyp = copyRequest.getTyp();
IntygContentHolder signedIntygHolder = intygService.fetchIntygData(orignalIntygsId, originalIntygsTyp, coherentJournaling);
ModuleApi orgModuleApi = moduleRegistry.getModuleApi(originalIntygsTyp);
Utlatande orgUtlatande;
try {
orgUtlatande = orgModuleApi.getUtlatandeFromJson(signedIntygHolder.getContents());
} catch (IOException e) {
throw new ModuleException("Could not convert orignal certificate to Utlatande", e);
}
GrundData grundData = signedIntygHolder.getUtlatande().getGrundData();
se.inera.intyg.common.support.model.common.internal.Vardenhet vardenhet = grundData.getSkapadAv().getVardenhet();
if (coherentJournaling && enforceEnhet) {
verifyEnhetsAuth(vardenhet.getVardgivare().getVardgivarid(), vardenhet.getEnhetsid(), true);
}
LOG.debug("Populating copy with details from signed Intyg '{}'", orignalIntygsId);
CopyUtkastBuilderResponse builderResponse = new CopyUtkastBuilderResponse();
builderResponse.setOrginalEnhetsId(vardenhet.getEnhetsid());
builderResponse.setOrginalEnhetsNamn(vardenhet.getEnhetsnamn());
builderResponse.setOrginalVardgivarId(vardenhet.getVardgivare().getVardgivarid());
builderResponse.setOrginalVardgivarNamn(vardenhet.getVardgivare().getVardgivarnamn());
ModuleApi moduleApi = moduleRegistry.getModuleApi(intygsTyp);
// Set relation to null if not applicable
Relation relation = createRelation(copyRequest);
String newDraftCopyId = intygsIdStrategy.createId();
String draftCopyJson = getInternalModel(orgUtlatande, moduleApi, copyRequest, patientDetails, relation, newDraftCopyId);
UtkastStatus utkastStatus = validateDraft(moduleApi, draftCopyJson);
Utkast utkast = buildUtkastCopy(copyRequest, newDraftCopyId, intygsTyp, addRelation, relation, draftCopyJson, utkastStatus);
if (patientDetails != null) {
populatePatientDetailsFromPerson(utkast, patientDetails);
} else {
se.inera.intyg.common.support.model.common.internal.Patient patient = signedIntygHolder.getUtlatande().getGrundData().getPatient();
populatePatientDetailsFromPatient(utkast, patient);
}
replacePatientPersonnummerWithNew(utkast, copyRequest);
builderResponse.setUtkastCopy(utkast);
return builderResponse;
}
Aggregations