use of se.inera.intyg.common.support.model.common.internal.Vardenhet in project webcert by sklintyg.
the class HoSPersonHelper method createVardenhetFromIntygUser.
public static Vardenhet createVardenhetFromIntygUser(String enhetId, IntygUser user) {
AbstractVardenhet enhet = HoSPersonHelper.findVardenhetEllerMottagning(user, enhetId).orElseThrow(() -> new IllegalStateException("User '" + user.getHsaId() + "' has no MIU for care unit '" + enhetId + "'"));
if (enhet instanceof se.inera.intyg.infra.integration.hsa.model.Vardenhet) {
se.inera.intyg.infra.integration.hsa.model.Vardenhet hsaVardenhet = (se.inera.intyg.infra.integration.hsa.model.Vardenhet) enhet;
se.inera.intyg.infra.integration.hsa.model.Vardgivare hsaVardgivare = HoSPersonHelper.findVardgivare(user, hsaVardenhet.getVardgivareHsaId()).orElseThrow(() -> new IllegalStateException("Unable to find parent vÄrdgivare for vardenhet '" + enhetId + "'"));
Vardenhet vardenhet = new Vardenhet();
vardenhet.setEnhetsnamn(hsaVardenhet.getNamn());
vardenhet.setEnhetsid(hsaVardenhet.getId());
vardenhet.setArbetsplatsKod(hsaVardenhet.getArbetsplatskod());
vardenhet.setPostadress(hsaVardenhet.getPostadress());
vardenhet.setPostnummer(hsaVardenhet.getPostnummer());
vardenhet.setPostort(hsaVardenhet.getPostort());
vardenhet.setTelefonnummer(hsaVardenhet.getTelefonnummer());
se.inera.intyg.common.support.model.common.internal.Vardgivare vardgivare = new se.inera.intyg.common.support.model.common.internal.Vardgivare();
vardgivare.setVardgivarid(hsaVardgivare.getId());
vardgivare.setVardgivarnamn(hsaVardgivare.getNamn());
vardenhet.setVardgivare(vardgivare);
return vardenhet;
}
if (enhet instanceof Mottagning) {
Mottagning m = (Mottagning) enhet;
se.inera.intyg.infra.integration.hsa.model.Vardgivare hsaVardgivare = HoSPersonHelper.findVardgivareForMottagning(user, m.getId()).orElseThrow(() -> new IllegalStateException("Unable to find parent vÄrdgivare for mottagning '" + enhetId + "'"));
Vardenhet vardenhet = new Vardenhet();
vardenhet.setEnhetsnamn(m.getNamn());
vardenhet.setEnhetsid(m.getId());
vardenhet.setArbetsplatsKod(m.getArbetsplatskod());
vardenhet.setPostadress(m.getPostadress());
vardenhet.setPostnummer(m.getPostnummer());
vardenhet.setPostort(m.getPostort());
vardenhet.setTelefonnummer(m.getTelefonnummer());
se.inera.intyg.common.support.model.common.internal.Vardgivare vardgivare = new se.inera.intyg.common.support.model.common.internal.Vardgivare();
vardgivare.setVardgivarid(hsaVardgivare.getId());
vardgivare.setVardgivarnamn(hsaVardgivare.getNamn());
vardenhet.setVardgivare(vardgivare);
return vardenhet;
}
throw new IllegalArgumentException("AbstractVardenhet instance passed to createVardenhetFromIntygUser was of unsupported type: " + enhet.getClass().getName());
}
use of se.inera.intyg.common.support.model.common.internal.Vardenhet in project webcert by sklintyg.
the class CopyUtkastServiceImplTest method setup.
@Before
public void setup() {
hoSPerson = new HoSPersonal();
hoSPerson.setPersonId(HOSPERSON_ID);
hoSPerson.setFullstandigtNamn(HOSPERSON_NAME);
Vardgivare vardgivare = new Vardgivare();
vardgivare.setVardgivarid(VARDGIVARE_ID);
vardgivare.setVardgivarnamn(VARDGIVARE_NAME);
Vardenhet vardenhet = new Vardenhet();
vardenhet.setEnhetsid(VARDENHET_ID);
vardenhet.setEnhetsnamn(VARDENHET_NAME);
vardenhet.setVardgivare(vardgivare);
hoSPerson.setVardenhet(vardenhet);
patient = new Patient();
patient.setPersonId(PATIENT_SSN);
}
use of se.inera.intyg.common.support.model.common.internal.Vardenhet in project webcert by sklintyg.
the class SignaturServiceImpl method createDraftHash.
/**
* Called from the Controller when initiating a client (e.g. NetID) signature. Rewritten in INTYG-5048 so
* <i>starting</i> a signature process does NOT mutate the Utkast in any way. Instead, a temporary intyg JSON model
* including the signatureDate and signing identity is stored in a {@link PagaendeSignering} entity.
* <p>
* Once the signing has been completed
* (see {@link SignaturServiceImpl#createAndPersistSignature(Utkast, SignaturTicket, String, WebCertUser)}) the
* hash, intygsId and version from the JSON model in the PagaendeSignatur is validated and if everything works out,
* the final state is written to the Utkast table.
* <p>
* If the user for some reason failed to finish the signing (cancelled in NetID etc.), the Utkast table won't be
* affected or contain a signingDate even though it wasn't signed. A stale entry may remain in PAGAENDE_SIGNERING
* but since those cannot be reused such entries can remain there indefinitely or until cleaned up by a janitor
* task.
*
* @param intygId The id of the draft to generate signing ticket for
* @param version version
* @return
*/
@Override
@Transactional("jpaTransactionManager")
public SignaturTicket createDraftHash(String intygId, long version) {
LOG.debug("Hash for clientsignature of draft '{}'", intygId);
// Fetch Webcert user
WebCertUser user = getWebcertUserForSignering();
// Fetch the certificate draft
Utkast utkast = getUtkastForSignering(intygId, version, user);
LocalDateTime signeringstid = LocalDateTime.now();
try {
VardpersonReferens vardpersonReferens = UpdateUserUtil.createVardpersonFromWebCertUser(user);
ModuleApi moduleApi = moduleRegistry.getModuleApi(utkast.getIntygsTyp());
Vardenhet vardenhetFromJson = moduleApi.getUtlatandeFromJson(utkast.getModel()).getGrundData().getSkapadAv().getVardenhet();
String updatedInternal = moduleApi.updateBeforeSigning(utkast.getModel(), IntygConverterUtil.buildHosPersonalFromWebCertUser(user, vardenhetFromJson), signeringstid);
// Skapa ny PagaendeSignering
PagaendeSignering pagaendeSignering = new PagaendeSignering();
pagaendeSignering.setIntygData(updatedInternal);
pagaendeSignering.setIntygsId(utkast.getIntygsId());
pagaendeSignering.setSigneradAvHsaId(vardpersonReferens.getHsaId());
pagaendeSignering.setSigneradAvNamn(vardpersonReferens.getNamn());
pagaendeSignering.setSigneringsDatum(signeringstid);
pagaendeSignering = pagaendeSigneringRepository.save(pagaendeSignering);
return createSignaturTicket(utkast.getIntygsId(), pagaendeSignering.getInternReferens(), utkast.getVersion(), updatedInternal, signeringstid);
} catch (ModuleNotFoundException | IOException | ModuleException e) {
throw new WebCertServiceException(WebCertServiceErrorCodeEnum.INTERNAL_PROBLEM, "Unable to sign certificate: " + e.getMessage());
}
}
use of se.inera.intyg.common.support.model.common.internal.Vardenhet in project webcert by sklintyg.
the class IntygConverterUtil method buildVardenhet.
private static Vardenhet buildVardenhet(WebCertUser user) {
Vardenhet vardenhet = new Vardenhet();
SelectableVardenhet sourceVardenhet = user.getValdVardenhet();
if (sourceVardenhet != null && sourceVardenhet instanceof AbstractVardenhet) {
AbstractVardenhet valdVardenhet = (AbstractVardenhet) sourceVardenhet;
vardenhet.setArbetsplatsKod(valdVardenhet.getArbetsplatskod());
vardenhet.setEnhetsid(valdVardenhet.getId());
vardenhet.setEnhetsnamn(valdVardenhet.getNamn());
vardenhet.setEpost(valdVardenhet.getEpost());
vardenhet.setPostadress(valdVardenhet.getPostadress());
vardenhet.setPostnummer(valdVardenhet.getPostnummer());
vardenhet.setPostort(valdVardenhet.getPostort());
vardenhet.setTelefonnummer(valdVardenhet.getTelefonnummer());
}
vardenhet.setVardgivare(buildVardgivare(user.getValdVardgivare()));
return vardenhet;
}
use of se.inera.intyg.common.support.model.common.internal.Vardenhet in project webcert by sklintyg.
the class CreateDraftCertificateResponderImpl method addVardenhetToRegistry.
private void addVardenhetToRegistry(CreateNewDraftRequest utkastsRequest) {
Vardenhet vardenhet = utkastsRequest.getHosPerson().getVardenhet();
Vardgivare vardgivare = vardenhet.getVardgivare();
IntegreradEnhetEntry integreradEnhet = new IntegreradEnhetEntry(vardenhet.getEnhetsid(), vardenhet.getEnhetsnamn(), vardgivare.getVardgivarid(), vardgivare.getVardgivarnamn());
integreradeEnheterRegistry.putIntegreradEnhet(integreradEnhet, false, true);
}
Aggregations